-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65ff08e
commit 87008df
Showing
4 changed files
with
704 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env node | ||
const fetch = require('node-fetch') | ||
const path = require('path') | ||
const fs = require('fs') | ||
const download = require('download-git-repo') | ||
const args = process.argv.slice(2) | ||
const exit = (text: string): void => { | ||
console.log(text) | ||
process.exit(1) | ||
} | ||
|
||
// check args | ||
if (!args || !args.length) exit('you need to specify the project name.') | ||
const to = path.join(process.cwd(), args[0]) | ||
|
||
// check project name | ||
if (fs.existsSync(to)) exit(`${args[0]} already exists, abort.`) | ||
|
||
const install = async(): Promise<void> => { | ||
const response = await fetch('https://raw.githubusercontent.com/just-fine/vue-coffee/master/package.json') | ||
const pkg = await response.text() | ||
const { version } = JSON.parse(pkg) | ||
const url = `https://github.com/DhyanaChina/koa-custom-response/archive/v${version}.zip` | ||
console.log('install...') | ||
download(url, to, { clone: false }, (err: any) => { | ||
if (err) return exit(`${err}. abort.`) | ||
console.log('installed successfully.') | ||
}) | ||
} | ||
|
||
install().then().catch(e => console.log(e)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "cli", | ||
"version": "0.1.0", | ||
"main": "./dist/bin/koa2-ts.js", | ||
"bin": { | ||
"koa2-ts": "./dist/bin/koa2-ts.js" | ||
}, | ||
"scripts": { | ||
"start": "tsc -w --skipLibCheck -p ./", | ||
"build": "tsc -p ./" | ||
}, | ||
"author": "WittBulter ([email protected])", | ||
"license": "MIT", | ||
"dependencies": { | ||
"download-git-repo": "^1.1.0", | ||
"node-fetch": "^2.3.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^11.9.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compileOnSave": false, | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
"sourceMap": false, | ||
"outDir": "./dist", | ||
"lib": ["es7"], | ||
"rootDir": "./" | ||
}, | ||
"include": [ | ||
"./bin/*" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
Oops, something went wrong.