-
Notifications
You must be signed in to change notification settings - Fork 0
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
154f8ed
commit 40d6cc2
Showing
2 changed files
with
67 additions
and
71 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 |
---|---|---|
@@ -1,73 +1,4 @@ | ||
#!/usr/bin/env node | ||
import minimist from 'minimist'; | ||
import { create, CreateOptions } from './create'; | ||
import { run } from './index'; | ||
|
||
async function run(): Promise<void> { | ||
try { | ||
const argvs: CreateOptions = minimist(process.argv.slice(2), { | ||
alias: { | ||
output: 'o', | ||
force: 'f', | ||
path: 'p', | ||
example: 'e', | ||
}, | ||
default: { | ||
path: 'https://kktjs.github.io/zip/', | ||
output: '.', | ||
force: false, | ||
example: 'basic', | ||
}, | ||
}); | ||
if (argvs.h || argvs.help) { | ||
console.log('\n Usage: create-kkt <app-name> [options] [--help|h]'); | ||
console.log('\n Options:'); | ||
console.log(' --version, -v', 'Show version number'); | ||
console.log(' --help, -h', 'Displays help information.'); | ||
console.log(' --output, -o', 'Output directory.'); | ||
console.log( | ||
' --example, -e', | ||
'Example from: \x1b[34mhttps://kktjs.github.io/zip/ \x1b[0m , default: "basic"', | ||
); | ||
console.log(' --force, -f', 'Overwrite target directory if it exists. default: false'); | ||
console.log( | ||
' --path, -p', | ||
'Specify the download target git address. default: "\x1b[34mhttps://kktjs.github.io/zip/ \x1b[0m"', | ||
); | ||
exampleHelp(); | ||
console.log('\n Copyright 2021'); | ||
console.log('\n'); | ||
return; | ||
} | ||
const { version } = require('../package.json'); | ||
if (argvs.v || argvs.version) { | ||
console.log(`\n create-kkt v${version}\n`); | ||
return; | ||
} | ||
argvs.appName = argvs._[0]; | ||
argvs.example = argvs.e = String(argvs.example).toLocaleLowerCase(); | ||
create(argvs, exampleHelp); | ||
} catch (error) { | ||
console.log(`\x1b[31m${error.message}\x1b[0m`); | ||
console.log(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
export function exampleHelp() { | ||
console.log('\n Example:'); | ||
console.log(' \x1b[35myarn\x1b[0m create kkt \x1b[33mappName\x1b[0m'); | ||
console.log(' \x1b[35mnpx\x1b[0m create-kkt \x1b[33mmy-app\x1b[0m'); | ||
console.log(' \x1b[35mnpm\x1b[0m create kkt \x1b[33mmy-app\x1b[0m'); | ||
console.log(' \x1b[35mnpm\x1b[0m create kkt \x1b[33mmy-app\x1b[0m -f'); | ||
console.log( | ||
' \x1b[35mnpm\x1b[0m create kkt \x1b[33mmy-app\x1b[0m -p \x1b[34mhttps://kktjs.github.io/zip/\x1b[0m', | ||
); | ||
} | ||
|
||
try { | ||
run(); | ||
} catch (error) { | ||
console.log(`\x1b[31m${error.message}\x1b[0m`); | ||
console.log(error); | ||
process.exit(1); | ||
} | ||
run(); |
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 |
---|---|---|
@@ -1 +1,66 @@ | ||
import minimist from 'minimist'; | ||
|
||
import { create, CreateOptions } from './create'; | ||
export * from './create'; | ||
|
||
export async function run(): Promise<void> { | ||
try { | ||
const argvs: CreateOptions = minimist(process.argv.slice(2), { | ||
alias: { | ||
output: 'o', | ||
force: 'f', | ||
path: 'p', | ||
example: 'e', | ||
}, | ||
default: { | ||
path: 'https://kktjs.github.io/zip/', | ||
output: '.', | ||
force: false, | ||
example: 'basic', | ||
}, | ||
}); | ||
if (argvs.h || argvs.help) { | ||
console.log('\n Usage: create-kkt <app-name> [options] [--help|h]'); | ||
console.log('\n Options:'); | ||
console.log(' --version, -v', 'Show version number'); | ||
console.log(' --help, -h', 'Displays help information.'); | ||
console.log(' --output, -o', 'Output directory.'); | ||
console.log( | ||
' --example, -e', | ||
'Example from: \x1b[34mhttps://kktjs.github.io/zip/ \x1b[0m , default: "basic"', | ||
); | ||
console.log(' --force, -f', 'Overwrite target directory if it exists. default: false'); | ||
console.log( | ||
' --path, -p', | ||
'Specify the download target git address. default: "\x1b[34mhttps://kktjs.github.io/zip/ \x1b[0m"', | ||
); | ||
exampleHelp(); | ||
console.log('\n Copyright 2021'); | ||
console.log('\n'); | ||
return; | ||
} | ||
const { version } = require('../package.json'); | ||
if (argvs.v || argvs.version) { | ||
console.log(`\n create-kkt v${version}\n`); | ||
return; | ||
} | ||
argvs.appName = argvs._[0]; | ||
argvs.example = argvs.e = String(argvs.example).toLocaleLowerCase(); | ||
await create(argvs, exampleHelp); | ||
} catch (error) { | ||
console.log(`\x1b[31m${error.message}\x1b[0m`); | ||
console.log(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
export function exampleHelp() { | ||
console.log('\n Example:'); | ||
console.log(' \x1b[35myarn\x1b[0m create kkt \x1b[33mappName\x1b[0m'); | ||
console.log(' \x1b[35mnpx\x1b[0m create-kkt \x1b[33mmy-app\x1b[0m'); | ||
console.log(' \x1b[35mnpm\x1b[0m create kkt \x1b[33mmy-app\x1b[0m'); | ||
console.log(' \x1b[35mnpm\x1b[0m create kkt \x1b[33mmy-app\x1b[0m -f'); | ||
console.log( | ||
' \x1b[35mnpm\x1b[0m create kkt \x1b[33mmy-app\x1b[0m -p \x1b[34mhttps://kktjs.github.io/zip/\x1b[0m', | ||
); | ||
} |