projen 0.71.38 → 0.71.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +3 -3
- package/lib/awscdk/auto-discover.js +5 -5
- package/lib/awscdk/awscdk-app-java.js +1 -1
- package/lib/awscdk/awscdk-app-py.js +1 -1
- package/lib/awscdk/awscdk-app-ts.js +1 -1
- package/lib/awscdk/awscdk-construct.js +2 -2
- package/lib/awscdk/awscdk-deps-java.js +1 -1
- package/lib/awscdk/awscdk-deps-js.js +1 -1
- package/lib/awscdk/awscdk-deps-py.js +1 -1
- package/lib/awscdk/awscdk-deps.js +1 -1
- package/lib/awscdk/cdk-config.js +1 -1
- package/lib/awscdk/cdk-tasks.js +1 -1
- package/lib/awscdk/integration-test.js +1 -1
- package/lib/awscdk/lambda-extension.js +1 -1
- package/lib/awscdk/lambda-function.js +2 -2
- package/lib/build/build-workflow.js +1 -1
- package/lib/cdk/auto-discover-base.js +2 -2
- package/lib/cdk/construct-lib.js +1 -1
- package/lib/cdk/integration-test-base.js +1 -1
- package/lib/cdk/jsii-docgen.js +1 -1
- package/lib/cdk/jsii-project.js +1 -1
- package/lib/cdk8s/auto-discover.js +2 -2
- package/lib/cdk8s/cdk8s-app-py.js +1 -1
- package/lib/cdk8s/cdk8s-app-ts.js +1 -1
- package/lib/cdk8s/cdk8s-construct.js +1 -1
- package/lib/cdk8s/cdk8s-deps-py.js +1 -1
- package/lib/cdk8s/cdk8s-deps.js +1 -1
- package/lib/cdk8s/integration-test.js +1 -1
- package/lib/cdktf/cdktf-construct.js +1 -1
- package/lib/circleci/circleci.js +1 -1
- package/lib/cli/cmds/new.js +27 -19
- package/lib/cli/index.js +2 -2
- package/lib/cli/util.d.ts +3 -0
- package/lib/cli/util.js +9 -2
- package/lib/component.js +1 -1
- package/lib/dependencies.js +1 -1
- package/lib/dev-env.js +1 -1
- package/lib/docker-compose/docker-compose-service.js +1 -1
- package/lib/docker-compose/docker-compose.js +1 -1
- package/lib/file.js +1 -1
- package/lib/gitattributes.js +1 -1
- package/lib/github/actions-provider.js +1 -1
- package/lib/github/auto-approve.js +1 -1
- package/lib/github/auto-merge.js +1 -1
- package/lib/github/dependabot.js +1 -1
- package/lib/github/github-credentials.js +1 -1
- package/lib/github/github-project.js +1 -1
- package/lib/github/github.js +1 -1
- package/lib/github/mergify.js +1 -1
- package/lib/github/pr-template.js +1 -1
- package/lib/github/pull-request-lint.js +1 -1
- package/lib/github/stale.js +1 -1
- package/lib/github/task-workflow.js +1 -1
- package/lib/github/workflow-actions.js +1 -1
- package/lib/github/workflow-jobs.js +1 -1
- package/lib/github/workflows.js +1 -1
- package/lib/gitlab/configuration.js +1 -1
- package/lib/gitlab/gitlab-configuration.js +1 -1
- package/lib/gitlab/nested-configuration.js +1 -1
- package/lib/gitpod.js +1 -1
- package/lib/ignore-file.js +1 -1
- package/lib/ini.js +1 -1
- package/lib/java/java-project.js +1 -1
- package/lib/java/junit.js +1 -1
- package/lib/java/maven-compile.js +1 -1
- package/lib/java/maven-packaging.js +1 -1
- package/lib/java/maven-sample.js +1 -1
- package/lib/java/pom.js +1 -1
- package/lib/java/projenrc.js +1 -1
- package/lib/javascript/bundler.js +1 -1
- package/lib/javascript/eslint.js +1 -1
- package/lib/javascript/jest.js +4 -4
- package/lib/javascript/node-package.js +1 -1
- package/lib/javascript/node-project.js +1 -1
- package/lib/javascript/npm-config.js +1 -1
- package/lib/javascript/prettier.js +1 -1
- package/lib/javascript/projenrc.js +1 -1
- package/lib/javascript/typescript-config.js +2 -2
- package/lib/javascript/upgrade-dependencies.js +2 -2
- package/lib/json-patch.js +1 -1
- package/lib/json.js +1 -1
- package/lib/license.js +1 -1
- package/lib/logger.js +1 -1
- package/lib/makefile.js +1 -1
- package/lib/object-file.js +1 -1
- package/lib/project-build.js +1 -1
- package/lib/project.js +1 -1
- package/lib/projects.js +1 -1
- package/lib/projenrc-json.js +2 -2
- package/lib/projenrc.js +1 -1
- package/lib/python/pip.js +1 -1
- package/lib/python/poetry.js +2 -2
- package/lib/python/projenrc.js +1 -1
- package/lib/python/pytest-sample.js +1 -1
- package/lib/python/pytest.js +1 -1
- package/lib/python/python-project.js +1 -1
- package/lib/python/python-sample.js +1 -1
- package/lib/python/requirements-file.js +1 -1
- package/lib/python/setuppy.js +1 -1
- package/lib/python/setuptools.js +1 -1
- package/lib/python/venv.js +1 -1
- package/lib/readme.js +1 -1
- package/lib/release/publisher.js +1 -1
- package/lib/release/release-trigger.js +1 -1
- package/lib/release/release.js +1 -1
- package/lib/renovatebot.js +1 -1
- package/lib/sample-file.js +2 -2
- package/lib/semver.js +1 -1
- package/lib/source-code.js +1 -1
- package/lib/task-runtime.js +1 -1
- package/lib/task.js +1 -1
- package/lib/tasks.js +1 -1
- package/lib/testing.js +1 -1
- package/lib/textfile.js +1 -1
- package/lib/toml.js +1 -1
- package/lib/typescript/projenrc-ts.js +1 -1
- package/lib/typescript/projenrc.js +1 -1
- package/lib/typescript/typescript-typedoc.js +1 -1
- package/lib/typescript/typescript.js +3 -3
- package/lib/version.js +1 -1
- package/lib/vscode/devcontainer.js +1 -1
- package/lib/vscode/extensions.js +1 -1
- package/lib/vscode/launch-config.js +1 -1
- package/lib/vscode/settings.js +1 -1
- package/lib/vscode/vscode.js +1 -1
- package/lib/web/next.js +3 -3
- package/lib/web/postcss.js +1 -1
- package/lib/web/react.js +4 -4
- package/lib/web/tailwind.js +1 -1
- package/lib/xmlfile.js +1 -1
- package/lib/yaml.js +1 -1
- package/node_modules/cliui/CHANGELOG.md +18 -0
- package/node_modules/cliui/build/index.d.cts +43 -0
- package/node_modules/cliui/package.json +6 -6
- package/node_modules/yargs/README.md +8 -6
- package/node_modules/yargs/browser.d.ts +5 -0
- package/node_modules/yargs/browser.mjs +2 -2
- package/node_modules/yargs/build/index.cjs +1 -2920
- package/node_modules/yargs/build/lib/command.js +277 -210
- package/node_modules/yargs/build/lib/completion-templates.js +5 -4
- package/node_modules/yargs/build/lib/completion.js +201 -86
- package/node_modules/yargs/build/lib/middleware.js +51 -16
- package/node_modules/yargs/build/lib/usage.js +88 -52
- package/node_modules/yargs/build/lib/utils/levenshtein.js +9 -1
- package/node_modules/yargs/build/lib/utils/maybe-async-result.js +17 -0
- package/node_modules/yargs/build/lib/validation.js +51 -54
- package/node_modules/yargs/build/lib/yargs-factory.js +1253 -884
- package/node_modules/yargs/build/lib/yerror.js +3 -1
- package/node_modules/yargs/index.cjs +22 -8
- package/node_modules/yargs/index.mjs +2 -2
- package/node_modules/yargs/lib/platform-shims/browser.mjs +3 -0
- package/node_modules/yargs/lib/platform-shims/esm.mjs +9 -3
- package/node_modules/yargs/locales/cs.json +51 -0
- package/node_modules/yargs/locales/en.json +4 -0
- package/node_modules/yargs/locales/fi.json +1 -1
- package/node_modules/yargs/locales/ko.json +25 -25
- package/node_modules/yargs/locales/ru.json +6 -1
- package/node_modules/yargs/locales/uk_UA.json +51 -0
- package/node_modules/yargs/locales/uz.json +52 -0
- package/node_modules/yargs/locales/zh_TW.json +50 -46
- package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/CHANGELOG.md +45 -0
- package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/build/index.cjs +25 -17
- package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/build/lib/index.js +8 -5
- package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/build/lib/yargs-parser.js +20 -12
- package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/package.json +14 -9
- package/node_modules/yargs/package.json +25 -24
- package/node_modules/yargs/yargs.mjs +10 -0
- package/package.json +2 -2
- package/node_modules/yargs/CHANGELOG.md +0 -88
- /package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/LICENSE.txt +0 -0
- /package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/README.md +0 -0
- /package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/browser.js +0 -0
- /package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/build/lib/string-utils.js +0 -0
- /package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/build/lib/tokenize-arg-string.js +0 -0
- /package/node_modules/{yargs-parser → yargs/node_modules/yargs-parser}/build/lib/yargs-parser-types.js +0 -0
|
@@ -1,31 +1,43 @@
|
|
|
1
|
-
import { assertNotStrictEqual, } from './typings/common-types.js';
|
|
2
1
|
import { objFilter } from './utils/obj-filter.js';
|
|
3
2
|
import { YError } from './yerror.js';
|
|
4
3
|
import setBlocking from './utils/set-blocking.js';
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
function isBoolean(fail) {
|
|
5
|
+
return typeof fail === 'boolean';
|
|
6
|
+
}
|
|
7
|
+
export function usage(yargs, shim) {
|
|
8
|
+
const __ = shim.y18n.__;
|
|
7
9
|
const self = {};
|
|
8
10
|
const fails = [];
|
|
9
11
|
self.failFn = function failFn(f) {
|
|
10
12
|
fails.push(f);
|
|
11
13
|
};
|
|
12
14
|
let failMessage = null;
|
|
15
|
+
let globalFailMessage = null;
|
|
13
16
|
let showHelpOnFail = true;
|
|
14
17
|
self.showHelpOnFail = function showHelpOnFailFn(arg1 = true, arg2) {
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const [enabled, message] = typeof arg1 === 'string' ? [true, arg1] : [arg1, arg2];
|
|
19
|
+
if (yargs.getInternalMethods().isGlobalContext()) {
|
|
20
|
+
globalFailMessage = message;
|
|
17
21
|
}
|
|
18
|
-
const [enabled, message] = parseFunctionArgs();
|
|
19
22
|
failMessage = message;
|
|
20
23
|
showHelpOnFail = enabled;
|
|
21
24
|
return self;
|
|
22
25
|
};
|
|
23
26
|
let failureOutput = false;
|
|
24
27
|
self.fail = function fail(msg, err) {
|
|
25
|
-
const logger = yargs.
|
|
28
|
+
const logger = yargs.getInternalMethods().getLoggerInstance();
|
|
26
29
|
if (fails.length) {
|
|
27
30
|
for (let i = fails.length - 1; i >= 0; --i) {
|
|
28
|
-
fails[i]
|
|
31
|
+
const fail = fails[i];
|
|
32
|
+
if (isBoolean(fail)) {
|
|
33
|
+
if (err)
|
|
34
|
+
throw err;
|
|
35
|
+
else if (msg)
|
|
36
|
+
throw Error(msg);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
fail(msg, err, self);
|
|
40
|
+
}
|
|
29
41
|
}
|
|
30
42
|
}
|
|
31
43
|
else {
|
|
@@ -39,17 +51,18 @@ export function usage(yargs, y18n, shim) {
|
|
|
39
51
|
}
|
|
40
52
|
if (msg || err)
|
|
41
53
|
logger.error(msg || err);
|
|
42
|
-
|
|
54
|
+
const globalOrCommandFailMessage = failMessage || globalFailMessage;
|
|
55
|
+
if (globalOrCommandFailMessage) {
|
|
43
56
|
if (msg || err)
|
|
44
57
|
logger.error('');
|
|
45
|
-
logger.error(
|
|
58
|
+
logger.error(globalOrCommandFailMessage);
|
|
46
59
|
}
|
|
47
60
|
}
|
|
48
61
|
err = err || new YError(msg);
|
|
49
62
|
if (yargs.getExitProcess()) {
|
|
50
63
|
return yargs.exit(1);
|
|
51
64
|
}
|
|
52
|
-
else if (yargs.
|
|
65
|
+
else if (yargs.getInternalMethods().hasParseCallback()) {
|
|
53
66
|
return yargs.exit(1, err);
|
|
54
67
|
}
|
|
55
68
|
else {
|
|
@@ -120,13 +133,16 @@ export function usage(yargs, y18n, shim) {
|
|
|
120
133
|
wrapSet = true;
|
|
121
134
|
wrap = cols;
|
|
122
135
|
};
|
|
123
|
-
|
|
136
|
+
self.getWrap = () => {
|
|
137
|
+
if (shim.getEnv('YARGS_DISABLE_WRAP')) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
124
140
|
if (!wrapSet) {
|
|
125
141
|
wrap = windowWidth();
|
|
126
142
|
wrapSet = true;
|
|
127
143
|
}
|
|
128
144
|
return wrap;
|
|
129
|
-
}
|
|
145
|
+
};
|
|
130
146
|
const deferY18nLookupPrefix = '__yargsString__:';
|
|
131
147
|
self.deferY18nLookup = str => deferY18nLookupPrefix + str;
|
|
132
148
|
self.help = function help() {
|
|
@@ -152,7 +168,7 @@ export function usage(yargs, y18n, shim) {
|
|
|
152
168
|
acc[key] = true;
|
|
153
169
|
return acc;
|
|
154
170
|
}, {}));
|
|
155
|
-
const theWrap = getWrap();
|
|
171
|
+
const theWrap = self.getWrap();
|
|
156
172
|
const ui = shim.cliui({
|
|
157
173
|
width: theWrap,
|
|
158
174
|
wrap: !!theWrap,
|
|
@@ -160,7 +176,7 @@ export function usage(yargs, y18n, shim) {
|
|
|
160
176
|
if (!usageDisabled) {
|
|
161
177
|
if (usages.length) {
|
|
162
178
|
usages.forEach(usage => {
|
|
163
|
-
ui.div(`${usage[0].replace(/\$0/g, base$0)}`);
|
|
179
|
+
ui.div({ text: `${usage[0].replace(/\$0/g, base$0)}` });
|
|
164
180
|
if (usage[1]) {
|
|
165
181
|
ui.div({ text: `${usage[1]}`, padding: [1, 0, 0, 0] });
|
|
166
182
|
}
|
|
@@ -178,17 +194,19 @@ export function usage(yargs, y18n, shim) {
|
|
|
178
194
|
ui.div(`${u}`);
|
|
179
195
|
}
|
|
180
196
|
}
|
|
181
|
-
if (commands.length) {
|
|
197
|
+
if (commands.length > 1 || (commands.length === 1 && !commands[0][2])) {
|
|
182
198
|
ui.div(__('Commands:'));
|
|
183
|
-
const context = yargs.getContext();
|
|
199
|
+
const context = yargs.getInternalMethods().getContext();
|
|
184
200
|
const parentCommands = context.commands.length
|
|
185
201
|
? `${context.commands.join(' ')} `
|
|
186
202
|
: '';
|
|
187
|
-
if (yargs.getParserConfiguration()['sort-commands'] ===
|
|
203
|
+
if (yargs.getInternalMethods().getParserConfiguration()['sort-commands'] ===
|
|
204
|
+
true) {
|
|
188
205
|
commands = commands.sort((a, b) => a[0].localeCompare(b[0]));
|
|
189
206
|
}
|
|
207
|
+
const prefix = base$0 ? `${base$0} ` : '';
|
|
190
208
|
commands.forEach(command => {
|
|
191
|
-
const commandString = `${
|
|
209
|
+
const commandString = `${prefix}${parentCommands}${command[0].replace(/^\$0 ?/, '')}`;
|
|
192
210
|
ui.span({
|
|
193
211
|
text: commandString,
|
|
194
212
|
padding: [0, 2, 0, 2],
|
|
@@ -235,10 +253,10 @@ export function usage(yargs, y18n, shim) {
|
|
|
235
253
|
const normalizedKeys = groups[groupName]
|
|
236
254
|
.filter(filterHiddenOptions)
|
|
237
255
|
.map(key => {
|
|
238
|
-
if (
|
|
256
|
+
if (aliasKeys.includes(key))
|
|
239
257
|
return key;
|
|
240
258
|
for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) {
|
|
241
|
-
if (
|
|
259
|
+
if ((options.alias[aliasKey] || []).includes(key))
|
|
242
260
|
return aliasKey;
|
|
243
261
|
}
|
|
244
262
|
return key;
|
|
@@ -255,7 +273,7 @@ export function usage(yargs, y18n, shim) {
|
|
|
255
273
|
return sw;
|
|
256
274
|
else {
|
|
257
275
|
return ((/^[0-9]$/.test(sw)
|
|
258
|
-
?
|
|
276
|
+
? options.boolean.includes(key)
|
|
259
277
|
? '-'
|
|
260
278
|
: '--'
|
|
261
279
|
: sw.length > 1
|
|
@@ -293,19 +311,19 @@ export function usage(yargs, y18n, shim) {
|
|
|
293
311
|
const kswitch = switches[key];
|
|
294
312
|
let desc = descriptions[key] || '';
|
|
295
313
|
let type = null;
|
|
296
|
-
if (
|
|
314
|
+
if (desc.includes(deferY18nLookupPrefix))
|
|
297
315
|
desc = __(desc.substring(deferY18nLookupPrefix.length));
|
|
298
|
-
if (
|
|
316
|
+
if (options.boolean.includes(key))
|
|
299
317
|
type = `[${__('boolean')}]`;
|
|
300
|
-
if (
|
|
318
|
+
if (options.count.includes(key))
|
|
301
319
|
type = `[${__('count')}]`;
|
|
302
|
-
if (
|
|
320
|
+
if (options.string.includes(key))
|
|
303
321
|
type = `[${__('string')}]`;
|
|
304
|
-
if (
|
|
322
|
+
if (options.normalize.includes(key))
|
|
305
323
|
type = `[${__('string')}]`;
|
|
306
|
-
if (
|
|
324
|
+
if (options.array.includes(key))
|
|
307
325
|
type = `[${__('array')}]`;
|
|
308
|
-
if (
|
|
326
|
+
if (options.number.includes(key))
|
|
309
327
|
type = `[${__('number')}]`;
|
|
310
328
|
const deprecatedExtra = (deprecated) => typeof deprecated === 'string'
|
|
311
329
|
? `[${__('deprecated: %s', deprecated)}]`
|
|
@@ -328,7 +346,9 @@ export function usage(yargs, y18n, shim) {
|
|
|
328
346
|
padding: [0, 2, 0, 2 + getIndentation(kswitch)],
|
|
329
347
|
width: maxWidth(switches, theWrap) + 4,
|
|
330
348
|
}, desc);
|
|
331
|
-
|
|
349
|
+
const shouldHideOptionExtras = yargs.getInternalMethods().getUsageConfiguration()['hide-types'] ===
|
|
350
|
+
true;
|
|
351
|
+
if (extra && !shouldHideOptionExtras)
|
|
332
352
|
ui.div({ text: extra, padding: [0, 0, 0, 2], align: 'right' });
|
|
333
353
|
else
|
|
334
354
|
ui.div();
|
|
@@ -388,17 +408,17 @@ export function usage(yargs, y18n, shim) {
|
|
|
388
408
|
self.describe(key, descriptions[alias]);
|
|
389
409
|
if (alias in demandedOptions)
|
|
390
410
|
yargs.demandOption(key, demandedOptions[alias]);
|
|
391
|
-
if (
|
|
411
|
+
if (options.boolean.includes(alias))
|
|
392
412
|
yargs.boolean(key);
|
|
393
|
-
if (
|
|
413
|
+
if (options.count.includes(alias))
|
|
394
414
|
yargs.count(key);
|
|
395
|
-
if (
|
|
415
|
+
if (options.string.includes(alias))
|
|
396
416
|
yargs.string(key);
|
|
397
|
-
if (
|
|
417
|
+
if (options.normalize.includes(alias))
|
|
398
418
|
yargs.normalize(key);
|
|
399
|
-
if (
|
|
419
|
+
if (options.array.includes(alias))
|
|
400
420
|
yargs.array(key);
|
|
401
|
-
if (
|
|
421
|
+
if (options.number.includes(alias))
|
|
402
422
|
yargs.number(key);
|
|
403
423
|
});
|
|
404
424
|
});
|
|
@@ -410,6 +430,9 @@ export function usage(yargs, y18n, shim) {
|
|
|
410
430
|
self.clearCachedHelpMessage = function () {
|
|
411
431
|
cachedHelpMessage = undefined;
|
|
412
432
|
};
|
|
433
|
+
self.hasCachedHelpMessage = function () {
|
|
434
|
+
return !!cachedHelpMessage;
|
|
435
|
+
};
|
|
413
436
|
function addUngroupedKeys(keys, aliases, groups, defaultGroup) {
|
|
414
437
|
let groupedKeys = [];
|
|
415
438
|
let toCheck = null;
|
|
@@ -429,7 +452,7 @@ export function usage(yargs, y18n, shim) {
|
|
|
429
452
|
yargs.parsed.argv[yargs.getOptions().showHiddenOpt]);
|
|
430
453
|
}
|
|
431
454
|
self.showHelp = (level) => {
|
|
432
|
-
const logger = yargs.
|
|
455
|
+
const logger = yargs.getInternalMethods().getLoggerInstance();
|
|
433
456
|
if (!level)
|
|
434
457
|
level = 'error';
|
|
435
458
|
const emit = typeof level === 'function' ? level : logger[level];
|
|
@@ -488,9 +511,12 @@ export function usage(yargs, y18n, shim) {
|
|
|
488
511
|
self.version = ver => {
|
|
489
512
|
version = ver;
|
|
490
513
|
};
|
|
491
|
-
self.showVersion =
|
|
492
|
-
const logger = yargs.
|
|
493
|
-
|
|
514
|
+
self.showVersion = level => {
|
|
515
|
+
const logger = yargs.getInternalMethods().getLoggerInstance();
|
|
516
|
+
if (!level)
|
|
517
|
+
level = 'error';
|
|
518
|
+
const emit = typeof level === 'function' ? level : logger[level];
|
|
519
|
+
emit(version);
|
|
494
520
|
};
|
|
495
521
|
self.reset = function reset(localLookup) {
|
|
496
522
|
failMessage = null;
|
|
@@ -516,19 +542,29 @@ export function usage(yargs, y18n, shim) {
|
|
|
516
542
|
descriptions,
|
|
517
543
|
});
|
|
518
544
|
};
|
|
519
|
-
self.unfreeze = function unfreeze() {
|
|
545
|
+
self.unfreeze = function unfreeze(defaultCommand = false) {
|
|
520
546
|
const frozen = frozens.pop();
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
547
|
+
if (!frozen)
|
|
548
|
+
return;
|
|
549
|
+
if (defaultCommand) {
|
|
550
|
+
descriptions = { ...frozen.descriptions, ...descriptions };
|
|
551
|
+
commands = [...frozen.commands, ...commands];
|
|
552
|
+
usages = [...frozen.usages, ...usages];
|
|
553
|
+
examples = [...frozen.examples, ...examples];
|
|
554
|
+
epilogs = [...frozen.epilogs, ...epilogs];
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
({
|
|
558
|
+
failMessage,
|
|
559
|
+
failureOutput,
|
|
560
|
+
usages,
|
|
561
|
+
usageDisabled,
|
|
562
|
+
epilogs,
|
|
563
|
+
examples,
|
|
564
|
+
commands,
|
|
565
|
+
descriptions,
|
|
566
|
+
} = frozen);
|
|
567
|
+
}
|
|
532
568
|
};
|
|
533
569
|
return self;
|
|
534
570
|
}
|
|
@@ -18,7 +18,15 @@ export function levenshtein(a, b) {
|
|
|
18
18
|
matrix[i][j] = matrix[i - 1][j - 1];
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
|
|
21
|
+
if (i > 1 &&
|
|
22
|
+
j > 1 &&
|
|
23
|
+
b.charAt(i - 2) === a.charAt(j - 1) &&
|
|
24
|
+
b.charAt(i - 1) === a.charAt(j - 2)) {
|
|
25
|
+
matrix[i][j] = matrix[i - 2][j - 2] + 1;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
|
|
29
|
+
}
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isPromise } from './is-promise.js';
|
|
2
|
+
export function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => {
|
|
3
|
+
throw err;
|
|
4
|
+
}) {
|
|
5
|
+
try {
|
|
6
|
+
const result = isFunction(getResult) ? getResult() : getResult;
|
|
7
|
+
return isPromise(result)
|
|
8
|
+
? result.then((result) => resultHandler(result))
|
|
9
|
+
: resultHandler(result);
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
return errorHandler(err);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function isFunction(arg) {
|
|
16
|
+
return typeof arg === 'function';
|
|
17
|
+
}
|
|
@@ -3,14 +3,14 @@ import { assertNotStrictEqual, } from './typings/common-types.js';
|
|
|
3
3
|
import { levenshtein as distance } from './utils/levenshtein.js';
|
|
4
4
|
import { objFilter } from './utils/obj-filter.js';
|
|
5
5
|
const specialKeys = ['$0', '--', '_'];
|
|
6
|
-
export function validation(yargs, usage,
|
|
7
|
-
const __ = y18n.__;
|
|
8
|
-
const __n = y18n.__n;
|
|
6
|
+
export function validation(yargs, usage, shim) {
|
|
7
|
+
const __ = shim.y18n.__;
|
|
8
|
+
const __n = shim.y18n.__n;
|
|
9
9
|
const self = {};
|
|
10
10
|
self.nonOptionCount = function nonOptionCount(argv) {
|
|
11
11
|
const demandedCommands = yargs.getDemandedCommands();
|
|
12
12
|
const positionalCount = argv._.length + (argv['--'] ? argv['--'].length : 0);
|
|
13
|
-
const _s = positionalCount - yargs.getContext().commands.length;
|
|
13
|
+
const _s = positionalCount - yargs.getInternalMethods().getContext().commands.length;
|
|
14
14
|
if (demandedCommands._ &&
|
|
15
15
|
(_s < demandedCommands._.min || _s > demandedCommands._.max)) {
|
|
16
16
|
if (_s < demandedCommands._.min) {
|
|
@@ -44,8 +44,7 @@ export function validation(yargs, usage, y18n, shim) {
|
|
|
44
44
|
usage.fail(__n('Not enough non-option arguments: got %s, need at least %s', 'Not enough non-option arguments: got %s, need at least %s', observed, observed + '', required + ''));
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
self.requiredArguments = function requiredArguments(argv) {
|
|
48
|
-
const demandedOptions = yargs.getDemandedOptions();
|
|
47
|
+
self.requiredArguments = function requiredArguments(argv, demandedOptions) {
|
|
49
48
|
let missing = null;
|
|
50
49
|
for (const key of Object.keys(demandedOptions)) {
|
|
51
50
|
if (!Object.prototype.hasOwnProperty.call(argv, key) ||
|
|
@@ -67,13 +66,17 @@ export function validation(yargs, usage, y18n, shim) {
|
|
|
67
66
|
}
|
|
68
67
|
};
|
|
69
68
|
self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
|
|
70
|
-
|
|
69
|
+
var _a;
|
|
70
|
+
const commandKeys = yargs
|
|
71
|
+
.getInternalMethods()
|
|
72
|
+
.getCommandInstance()
|
|
73
|
+
.getCommands();
|
|
71
74
|
const unknown = [];
|
|
72
|
-
const currentContext = yargs.getContext();
|
|
75
|
+
const currentContext = yargs.getInternalMethods().getContext();
|
|
73
76
|
Object.keys(argv).forEach(key => {
|
|
74
|
-
if (specialKeys.
|
|
77
|
+
if (!specialKeys.includes(key) &&
|
|
75
78
|
!Object.prototype.hasOwnProperty.call(positionalMap, key) &&
|
|
76
|
-
!Object.prototype.hasOwnProperty.call(yargs.
|
|
79
|
+
!Object.prototype.hasOwnProperty.call(yargs.getInternalMethods().getParseContext(), key) &&
|
|
77
80
|
!self.isValidAndSomeAliasIsNotNew(key, aliases)) {
|
|
78
81
|
unknown.push(key);
|
|
79
82
|
}
|
|
@@ -83,22 +86,39 @@ export function validation(yargs, usage, y18n, shim) {
|
|
|
83
86
|
commandKeys.length > 0 ||
|
|
84
87
|
isDefaultCommand)) {
|
|
85
88
|
argv._.slice(currentContext.commands.length).forEach(key => {
|
|
86
|
-
if (commandKeys.
|
|
89
|
+
if (!commandKeys.includes('' + key)) {
|
|
87
90
|
unknown.push('' + key);
|
|
88
91
|
}
|
|
89
92
|
});
|
|
90
93
|
}
|
|
91
|
-
if (
|
|
92
|
-
|
|
94
|
+
if (checkPositionals) {
|
|
95
|
+
const demandedCommands = yargs.getDemandedCommands();
|
|
96
|
+
const maxNonOptDemanded = ((_a = demandedCommands._) === null || _a === void 0 ? void 0 : _a.max) || 0;
|
|
97
|
+
const expected = currentContext.commands.length + maxNonOptDemanded;
|
|
98
|
+
if (expected < argv._.length) {
|
|
99
|
+
argv._.slice(expected).forEach(key => {
|
|
100
|
+
key = String(key);
|
|
101
|
+
if (!currentContext.commands.includes(key) &&
|
|
102
|
+
!unknown.includes(key)) {
|
|
103
|
+
unknown.push(key);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (unknown.length) {
|
|
109
|
+
usage.fail(__n('Unknown argument: %s', 'Unknown arguments: %s', unknown.length, unknown.map(s => (s.trim() ? s : `"${s}"`)).join(', ')));
|
|
93
110
|
}
|
|
94
111
|
};
|
|
95
112
|
self.unknownCommands = function unknownCommands(argv) {
|
|
96
|
-
const commandKeys = yargs
|
|
113
|
+
const commandKeys = yargs
|
|
114
|
+
.getInternalMethods()
|
|
115
|
+
.getCommandInstance()
|
|
116
|
+
.getCommands();
|
|
97
117
|
const unknown = [];
|
|
98
|
-
const currentContext = yargs.getContext();
|
|
118
|
+
const currentContext = yargs.getInternalMethods().getContext();
|
|
99
119
|
if (currentContext.commands.length > 0 || commandKeys.length > 0) {
|
|
100
120
|
argv._.slice(currentContext.commands.length).forEach(key => {
|
|
101
|
-
if (commandKeys.
|
|
121
|
+
if (!commandKeys.includes('' + key)) {
|
|
102
122
|
unknown.push('' + key);
|
|
103
123
|
}
|
|
104
124
|
});
|
|
@@ -116,13 +136,7 @@ export function validation(yargs, usage, y18n, shim) {
|
|
|
116
136
|
return false;
|
|
117
137
|
}
|
|
118
138
|
const newAliases = yargs.parsed.newAliases;
|
|
119
|
-
|
|
120
|
-
if (!Object.prototype.hasOwnProperty.call(newAliases, a) ||
|
|
121
|
-
!newAliases[key]) {
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return false;
|
|
139
|
+
return [key, ...aliases[key]].some(a => !Object.prototype.hasOwnProperty.call(newAliases, a) || !newAliases[key]);
|
|
126
140
|
};
|
|
127
141
|
self.limitedChoices = function limitedChoices(argv) {
|
|
128
142
|
const options = yargs.getOptions();
|
|
@@ -149,32 +163,6 @@ export function validation(yargs, usage, y18n, shim) {
|
|
|
149
163
|
});
|
|
150
164
|
usage.fail(msg);
|
|
151
165
|
};
|
|
152
|
-
let checks = [];
|
|
153
|
-
self.check = function check(f, global) {
|
|
154
|
-
checks.push({
|
|
155
|
-
func: f,
|
|
156
|
-
global,
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
self.customChecks = function customChecks(argv, aliases) {
|
|
160
|
-
for (let i = 0, f; (f = checks[i]) !== undefined; i++) {
|
|
161
|
-
const func = f.func;
|
|
162
|
-
let result = null;
|
|
163
|
-
try {
|
|
164
|
-
result = func(argv, aliases);
|
|
165
|
-
}
|
|
166
|
-
catch (err) {
|
|
167
|
-
usage.fail(err.message ? err.message : err, err);
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (!result) {
|
|
171
|
-
usage.fail(__('Argument check failed: %s', func.toString()));
|
|
172
|
-
}
|
|
173
|
-
else if (typeof result === 'string' || result instanceof Error) {
|
|
174
|
-
usage.fail(result.toString(), result);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
166
|
let implied = {};
|
|
179
167
|
self.implies = function implies(key, value) {
|
|
180
168
|
argsert('<string|object> [array|number|string]', [key, value], arguments.length);
|
|
@@ -208,10 +196,10 @@ export function validation(yargs, usage, y18n, shim) {
|
|
|
208
196
|
}
|
|
209
197
|
else if (val.match(/^--no-.+/)) {
|
|
210
198
|
val = val.match(/^--no-(.+)/)[1];
|
|
211
|
-
val = !argv
|
|
199
|
+
val = !Object.prototype.hasOwnProperty.call(argv, val);
|
|
212
200
|
}
|
|
213
201
|
else {
|
|
214
|
-
val = argv
|
|
202
|
+
val = Object.prototype.hasOwnProperty.call(argv, val);
|
|
215
203
|
}
|
|
216
204
|
return val;
|
|
217
205
|
}
|
|
@@ -269,6 +257,17 @@ export function validation(yargs, usage, y18n, shim) {
|
|
|
269
257
|
});
|
|
270
258
|
}
|
|
271
259
|
});
|
|
260
|
+
if (yargs.getInternalMethods().getParserConfiguration()['strip-dashed']) {
|
|
261
|
+
Object.keys(conflicting).forEach(key => {
|
|
262
|
+
conflicting[key].forEach(value => {
|
|
263
|
+
if (value &&
|
|
264
|
+
argv[shim.Parser.camelCase(key)] !== undefined &&
|
|
265
|
+
argv[shim.Parser.camelCase(value)] !== undefined) {
|
|
266
|
+
usage.fail(__('Arguments %s and %s are mutually exclusive', key, value));
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
}
|
|
272
271
|
};
|
|
273
272
|
self.recommendCommands = function recommendCommands(cmd, potentialCommands) {
|
|
274
273
|
const threshold = 3;
|
|
@@ -288,21 +287,19 @@ export function validation(yargs, usage, y18n, shim) {
|
|
|
288
287
|
self.reset = function reset(localLookup) {
|
|
289
288
|
implied = objFilter(implied, k => !localLookup[k]);
|
|
290
289
|
conflicting = objFilter(conflicting, k => !localLookup[k]);
|
|
291
|
-
checks = checks.filter(c => c.global);
|
|
292
290
|
return self;
|
|
293
291
|
};
|
|
294
292
|
const frozens = [];
|
|
295
293
|
self.freeze = function freeze() {
|
|
296
294
|
frozens.push({
|
|
297
295
|
implied,
|
|
298
|
-
checks,
|
|
299
296
|
conflicting,
|
|
300
297
|
});
|
|
301
298
|
};
|
|
302
299
|
self.unfreeze = function unfreeze() {
|
|
303
300
|
const frozen = frozens.pop();
|
|
304
301
|
assertNotStrictEqual(frozen, undefined, shim);
|
|
305
|
-
({ implied,
|
|
302
|
+
({ implied, conflicting } = frozen);
|
|
306
303
|
};
|
|
307
304
|
return self;
|
|
308
305
|
}
|