@capacitor/create-app
Advanced tools
Comparing version 0.0.2 to 0.0.3
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const help = ` | ||
Usage: npm init @capacitor/app | ||
Usage: npm init @capacitor/app [<path>] [options] | ||
@@ -10,3 +10,2 @@ Options: | ||
--package-id <id> ......... Unique app ID in reverse-DNS notation | ||
--dir <path> .............. Path of new app's directory | ||
@@ -13,0 +12,0 @@ -h, --help ................ Print help, then quit |
@@ -7,3 +7,4 @@ "use strict"; | ||
const debug = debug_1.default('@capacitor/create-app:options'); | ||
exports.OPTIONS = ['name', 'package-id', 'dir']; | ||
exports.CLI_ARGS = ['dir']; | ||
exports.CLI_OPTIONS = ['name', 'package-id']; | ||
exports.VALIDATORS = { | ||
@@ -21,13 +22,27 @@ name: value => typeof value !== 'string' || value.trim().length === 0 | ||
dir: value => typeof value !== 'string' || value.trim().length === 0 | ||
? `Must provide a directory, e.g. "my-dir"` | ||
: true, | ||
? `Must provide a directory, e.g. "my-app"` | ||
: /^\-/.test(value) | ||
? 'Directories should not start with a hyphen.' | ||
: true, | ||
}; | ||
exports.getOptions = () => exports.OPTIONS.reduce((opts, option) => { | ||
const value = cli_1.getOptionValue(process.argv, `--${option}`); | ||
const validatorResult = exports.VALIDATORS[option](value); | ||
if (typeof validatorResult === 'string') { | ||
debug(`invalid option: --%s %O: %s`, option, value, validatorResult); | ||
} | ||
opts[option] = validatorResult === true ? value : undefined; | ||
return opts; | ||
}, {}); | ||
exports.getOptions = () => { | ||
const argValues = exports.CLI_ARGS.reduce((opts, option, i) => { | ||
const value = process.argv[i + 2]; | ||
const validatorResult = exports.VALIDATORS[option](value); | ||
if (typeof validatorResult === 'string') { | ||
debug(`invalid positional arg: %s %O: %s`, option, value, validatorResult); | ||
} | ||
opts[option] = validatorResult === true ? value : undefined; | ||
return opts; | ||
}, {}); | ||
const optionValues = exports.CLI_OPTIONS.reduce((opts, option) => { | ||
const value = cli_1.getOptionValue(process.argv, `--${option}`); | ||
const validatorResult = exports.VALIDATORS[option](value); | ||
if (typeof validatorResult === 'string') { | ||
debug(`invalid option: --%s %O: %s`, option, value, validatorResult); | ||
} | ||
opts[option] = validatorResult === true ? value : undefined; | ||
return opts; | ||
}, {}); | ||
return { ...argValues, ...optionValues }; | ||
}; |
@@ -21,2 +21,10 @@ "use strict"; | ||
type: 'text', | ||
name: 'dir', | ||
message: `What directory should be used for your app?\n`, | ||
initial: 'my-app', | ||
validate: options_1.VALIDATORS.dir, | ||
format: value => value.trim(), | ||
}, | ||
{ | ||
type: 'text', | ||
name: 'package-id', | ||
@@ -31,10 +39,2 @@ message: `What should be the Package ID for your app?\n\n` + | ||
}, | ||
{ | ||
type: 'text', | ||
name: 'dir', | ||
message: `What directory should be used for your app?\n`, | ||
initial: 'my-app', | ||
validate: options_1.VALIDATORS.dir, | ||
format: value => value.trim(), | ||
}, | ||
], { | ||
@@ -41,0 +41,0 @@ onCancel: async () => { |
{ | ||
"name": "@capacitor/create-app", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Create a new Capacitor project", | ||
@@ -63,2 +63,3 @@ "author": "Ionic Team <hi@ionicframework.com>", | ||
"@types/tar": "^4.0.3", | ||
"husky": "^4.2.5", | ||
"prettier": "^2.0.5", | ||
@@ -65,0 +66,0 @@ "rimraf": "^3.0.2", |
@@ -5,6 +5,10 @@ # Create Capacitor App | ||
> ### :rotating_light: This tool is for Capacitor 3, which is in active development :rotating_light: | ||
> | ||
> To create minimal Capacitor 2 apps, use `npx @capacitor/cli create`. Follow Capacitor 3 development in [this issue](https://github.com/ionic-team/capacitor/issues/3133). | ||
## Usage | ||
``` | ||
npm init @capacitor/app | ||
npm init @capacitor/app [<path>] [options] | ||
``` | ||
@@ -22,8 +26,5 @@ | ||
Separate npm options with a `--` separator, e.g. `npm init @capacitor/app -- [options]`. | ||
``` | ||
--name <name> ............. Human-friendly app name | ||
--package-id <id> ......... Unique app ID in reverse-DNS notation | ||
--dir <path> .............. Path of new app's directory | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16170
228
29
9