piral-cli 0.15.0-alpha.4345 → 0.15.0-alpha.4399
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/lib/cli.js +3 -2
- package/lib/cli.js.map +1 -1
- package/lib/commands.js +8 -0
- package/lib/commands.js.map +1 -1
- package/lib/common/emoji.d.ts +8 -0
- package/lib/common/emoji.js +10 -1
- package/lib/common/emoji.js.map +1 -1
- package/lib/common/npm.d.ts +1 -0
- package/lib/common/npm.js +15 -1
- package/lib/common/npm.js.map +1 -1
- package/lib/common/scaffold.js +1 -1
- package/lib/common/scaffold.js.map +1 -1
- package/lib/external/index.js +160 -128
- package/lib/questionnaire.js +7 -4
- package/lib/questionnaire.js.map +1 -1
- package/package.json +2 -2
- package/src/cli.ts +3 -2
- package/src/commands.ts +8 -0
- package/src/common/emoji.ts +9 -0
- package/src/common/npm.ts +17 -1
- package/src/common/scaffold.ts +2 -2
- package/src/questionnaire.ts +15 -3
package/lib/questionnaire.js
CHANGED
|
@@ -6,13 +6,16 @@ const commands_1 = require("./commands");
|
|
|
6
6
|
function getCommandData(retrieve) {
|
|
7
7
|
const instructions = [];
|
|
8
8
|
const fn = {
|
|
9
|
+
alias(name, altName) {
|
|
10
|
+
return this.swap(name, (flag) => (Object.assign(Object.assign({}, flag), { alias: [...flag.alias, altName] })));
|
|
11
|
+
},
|
|
9
12
|
positional(name, info) {
|
|
10
|
-
instructions.push(Object.assign(Object.assign({}, info), { name }));
|
|
13
|
+
instructions.push(Object.assign(Object.assign({}, info), { alias: [], name }));
|
|
11
14
|
return this;
|
|
12
15
|
},
|
|
13
16
|
swap(name, swapper) {
|
|
14
17
|
const [flag] = instructions.filter((m) => m.name === name);
|
|
15
|
-
const newFlag = swapper(flag || { name });
|
|
18
|
+
const newFlag = swapper(flag || { name, alias: [] });
|
|
16
19
|
if (!flag) {
|
|
17
20
|
instructions.push(newFlag);
|
|
18
21
|
}
|
|
@@ -83,7 +86,7 @@ function runQuestionnaireFor(command, args, ignoredInstructions = ['base', 'log-
|
|
|
83
86
|
const questions = instructions
|
|
84
87
|
.filter((instruction) => !ignored.includes(instruction.name))
|
|
85
88
|
.filter((instruction) => !acceptAll || (instruction.default === undefined && instruction.required))
|
|
86
|
-
.filter((instruction) =>
|
|
89
|
+
.filter((instruction) => [...instruction.alias, instruction.name].every((m) => args[m] === undefined))
|
|
87
90
|
.filter((instruction) => instruction.type !== 'object')
|
|
88
91
|
.map((instruction) => ({
|
|
89
92
|
name: instruction.name,
|
|
@@ -98,7 +101,7 @@ function runQuestionnaireFor(command, args, ignoredInstructions = ['base', 'log-
|
|
|
98
101
|
const parameters = {};
|
|
99
102
|
for (const instruction of instructions) {
|
|
100
103
|
const name = instruction.name;
|
|
101
|
-
const value = (_b = (_a = answers[name]) !== null && _a !== void 0 ? _a : ignoredInstructions[name]) !== null && _b !== void 0 ? _b :
|
|
104
|
+
const value = (_b = (_a = answers[name]) !== null && _a !== void 0 ? _a : ignoredInstructions[name]) !== null && _b !== void 0 ? _b : [...instruction.alias, instruction.name].map((m) => args[m]).find((v) => v !== undefined);
|
|
102
105
|
parameters[name] = value !== undefined ? getValue(instruction.type, value) : instruction.default;
|
|
103
106
|
}
|
|
104
107
|
return command.run(parameters);
|
package/lib/questionnaire.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questionnaire.js","sourceRoot":"","sources":["../src/questionnaire.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,yCAAsC;
|
|
1
|
+
{"version":3,"file":"questionnaire.js","sourceRoot":"","sources":["../src/questionnaire.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,yCAAsC;AAetC,SAAS,cAAc,CAAC,QAAa;IACnC,MAAM,YAAY,GAAgB,EAAE,CAAC;IACrC,MAAM,EAAE,GAAG;QACT,KAAK,CAAC,IAAY,EAAE,OAAe;YACjC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,I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;YAC5F,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,KAAY,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC;SACzG;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC;AArCD,kDAqCC;AAED,SAAgB,gBAAgB,CAC9B,WAAmB,EACnB,sBAA2C,CAAC,MAAM,EAAE,WAAW,CAAC;IAEhE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,CAAC,OAAO,CAAC,GAAG,mBAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;IACrE,OAAO,mBAAmB,CAAC,OAAO,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC;AACjE,CAAC;AAPD,4CAOC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-cli",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.4399",
|
|
4
4
|
"description": "The standard CLI for creating and building a Piral instance or a Pilet.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"typescript": "^4.7.3",
|
|
79
79
|
"yargs": "^15.4.1"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "34be0cac6948a92981ab4994b01b34e44462e7a0"
|
|
82
82
|
}
|
package/src/cli.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as yargs from 'yargs';
|
|
2
2
|
import { detailed } from 'yargs-parser';
|
|
3
|
+
import { caterpillerIcon, zapIcon } from './common';
|
|
3
4
|
import { runQuestionnaireFor } from './questionnaire';
|
|
4
5
|
import { ToolCommand } from './types';
|
|
5
6
|
|
|
@@ -46,7 +47,7 @@ export function setupCli(commands: Array<ToolCommand<any>>) {
|
|
|
46
47
|
() => process.exit(0),
|
|
47
48
|
(err) => {
|
|
48
49
|
err && !err.logged && console.error(err.message);
|
|
49
|
-
console.log(
|
|
50
|
+
console.log(`${caterpillerIcon} Codes Reference: https://docs.piral.io/code/search`);
|
|
50
51
|
process.exit(1);
|
|
51
52
|
},
|
|
52
53
|
);
|
|
@@ -54,5 +55,5 @@ export function setupCli(commands: Array<ToolCommand<any>>) {
|
|
|
54
55
|
);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
argv.epilog(
|
|
58
|
+
argv.epilog(`${zapIcon} For more information, check out the documentation at https://docs.piral.io.`).help().strict().argv;
|
|
58
59
|
}
|
package/src/commands.ts
CHANGED
|
@@ -281,9 +281,11 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
281
281
|
.boolean('install')
|
|
282
282
|
.describe('install', 'Already performs the installation of its npm dependencies.')
|
|
283
283
|
.default('install', apps.newPiralDefaults.install)
|
|
284
|
+
.alias('install', 'package-install')
|
|
284
285
|
.string('registry')
|
|
285
286
|
.describe('registry', 'Sets the package registry to use for resolving the dependencies.')
|
|
286
287
|
.default('registry', apps.newPiralDefaults.registry)
|
|
288
|
+
.alias('registry', 'package-registry')
|
|
287
289
|
.number('log-level')
|
|
288
290
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
289
291
|
.default('log-level', apps.newPiralDefaults.logLevel)
|
|
@@ -293,6 +295,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
293
295
|
'Sets the tag or version of the package to install. By default, this uses the version of the CLI.',
|
|
294
296
|
)
|
|
295
297
|
.default('tag', apps.newPiralDefaults.version)
|
|
298
|
+
.alias('tag', 'piral-version')
|
|
296
299
|
.choices('force-overwrite', forceOverwriteKeys)
|
|
297
300
|
.describe('force-overwrite', 'Determines if files should be overwritten by the installation.')
|
|
298
301
|
.default('force-overwrite', keyOfForceOverwrite(apps.newPiralDefaults.forceOverwrite))
|
|
@@ -354,6 +357,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
354
357
|
.boolean('install')
|
|
355
358
|
.describe('install', 'Already performs the update of its npm dependencies.')
|
|
356
359
|
.default('install', apps.upgradePiralDefaults.install)
|
|
360
|
+
.alias('install', 'package-install')
|
|
357
361
|
.choices('npm-client', clientTypeKeys)
|
|
358
362
|
.describe('npm-client', 'Sets the npm client to be used when upgrading.')
|
|
359
363
|
.default('npm-client', apps.upgradePiralDefaults.npmClient)
|
|
@@ -614,6 +618,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
614
618
|
.choices('mode', publishModeKeys)
|
|
615
619
|
.describe('mode', 'Sets the authorization mode to use.')
|
|
616
620
|
.default('mode', apps.publishPiletDefaults.mode)
|
|
621
|
+
.alias('mode', 'auth-mode')
|
|
617
622
|
.choices('bundler', availableBundlers)
|
|
618
623
|
.describe('bundler', 'Sets the bundler to use.')
|
|
619
624
|
.default('bundler', availableBundlers[0])
|
|
@@ -672,9 +677,11 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
672
677
|
.string('registry')
|
|
673
678
|
.describe('registry', 'Sets the package registry to use for resolving the specified Piral app.')
|
|
674
679
|
.default('registry', apps.newPiletDefaults.registry)
|
|
680
|
+
.alias('registry', 'package-registry')
|
|
675
681
|
.boolean('install')
|
|
676
682
|
.describe('install', 'Already performs the installation of its npm dependencies.')
|
|
677
683
|
.default('install', apps.newPiletDefaults.install)
|
|
684
|
+
.alias('install', 'package-install')
|
|
678
685
|
.choices('force-overwrite', forceOverwriteKeys)
|
|
679
686
|
.describe('force-overwrite', 'Determines if files should be overwritten by the scaffolding.')
|
|
680
687
|
.default('force-overwrite', keyOfForceOverwrite(apps.newPiletDefaults.forceOverwrite))
|
|
@@ -737,6 +744,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
737
744
|
.boolean('install')
|
|
738
745
|
.describe('install', 'Already performs the update of its npm dependencies.')
|
|
739
746
|
.default('install', apps.upgradePiletDefaults.install)
|
|
747
|
+
.alias('install', 'package-install')
|
|
740
748
|
.choices('force-overwrite', forceOverwriteKeys)
|
|
741
749
|
.describe('force-overwrite', 'Determines if files should be overwritten by the upgrading process.')
|
|
742
750
|
.default('force-overwrite', keyOfForceOverwrite(apps.upgradePiletDefaults.forceOverwrite))
|
package/src/common/emoji.ts
CHANGED
|
@@ -2,5 +2,14 @@ import { isWindows } from './info';
|
|
|
2
2
|
|
|
3
3
|
const supportsEmoji = !isWindows || process.env.TERM === 'xterm-256color';
|
|
4
4
|
|
|
5
|
+
// see https://unicode.org/emoji/charts/full-emoji-list.html
|
|
5
6
|
export const liveIcon = supportsEmoji ? '🚀 ' : '>';
|
|
6
7
|
export const settingsIcon = supportsEmoji ? '🔧 ' : '>';
|
|
8
|
+
export const cactusIcon = supportsEmoji ? '👻' : '>';
|
|
9
|
+
export const clapIcon = supportsEmoji ? '👏' : '^';
|
|
10
|
+
export const sparklesIcon = supportsEmoji ? '✨' : '>';
|
|
11
|
+
export const unicornIcon = supportsEmoji ? '🦄' : '>';
|
|
12
|
+
export const caterpillerIcon = supportsEmoji ? '🐛' : '+';
|
|
13
|
+
export const butterflyIcon = supportsEmoji ? '🦋' : '+';
|
|
14
|
+
export const zapIcon = supportsEmoji ? '⚡' : '>';
|
|
15
|
+
export const rainbowIcon = supportsEmoji ? '🌈' : '~';
|
package/src/common/npm.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { createReadStream, existsSync } from 'fs';
|
|
|
3
3
|
import { log, fail } from './log';
|
|
4
4
|
import { clients, detectClients, isWrapperClient } from './clients';
|
|
5
5
|
import { config } from './config';
|
|
6
|
-
import { legacyCoreExternals, frameworkLibs } from './constants';
|
|
6
|
+
import { legacyCoreExternals, frameworkLibs, defaultRegistry } from './constants';
|
|
7
7
|
import { inspectPackage } from './inspect';
|
|
8
8
|
import { readJson, checkExists } from './io';
|
|
9
9
|
import { clientTypeKeys } from '../helpers';
|
|
@@ -129,6 +129,22 @@ export function installNpmDependencies(client: NpmClientType, target = '.'): Pro
|
|
|
129
129
|
return installDependencies(target);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
export async function installNpmPackageFromOptionalRegistry(
|
|
133
|
+
packageRef: string,
|
|
134
|
+
target = '.',
|
|
135
|
+
registry: string,
|
|
136
|
+
): Promise<void> {
|
|
137
|
+
try {
|
|
138
|
+
await installNpmPackage('npm', packageRef, target, '--registry', registry);
|
|
139
|
+
} catch (e) {
|
|
140
|
+
if (registry === defaultRegistry) {
|
|
141
|
+
throw e;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
await installNpmPackage('npm', packageRef, target, '--registry', defaultRegistry);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
132
148
|
export async function installNpmPackage(
|
|
133
149
|
client: NpmClientType,
|
|
134
150
|
packageRef: string,
|
package/src/common/scaffold.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join, dirname, resolve, basename, isAbsolute } from 'path';
|
|
2
|
-
import {
|
|
2
|
+
import { installNpmPackageFromOptionalRegistry } from './npm';
|
|
3
3
|
import { ForceOverwrite } from './enums';
|
|
4
4
|
import { createDirectory, createFileIfNotExists, updateExistingJson } from './io';
|
|
5
5
|
import { cliVersion, isWindows } from './info';
|
|
@@ -41,7 +41,7 @@ async function getTemplateFiles(
|
|
|
41
41
|
templatePackageName = `${templatePackageName}@latest`;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
await
|
|
44
|
+
await installNpmPackageFromOptionalRegistry(templatePackageName, __dirname, registry);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const templateRunner = getTemplatePackage(templatePackageName);
|
package/src/questionnaire.ts
CHANGED
|
@@ -7,6 +7,7 @@ type FlagType = 'string' | 'number' | 'boolean' | 'object';
|
|
|
7
7
|
interface Flag {
|
|
8
8
|
name: string;
|
|
9
9
|
type?: FlagType;
|
|
10
|
+
alias: Array<string>;
|
|
10
11
|
values?: Array<any>;
|
|
11
12
|
describe?: string;
|
|
12
13
|
default?: any;
|
|
@@ -16,16 +17,23 @@ interface Flag {
|
|
|
16
17
|
function getCommandData(retrieve: any) {
|
|
17
18
|
const instructions: Array<Flag> = [];
|
|
18
19
|
const fn = {
|
|
20
|
+
alias(name: string, altName: string) {
|
|
21
|
+
return this.swap(name, (flag) => ({
|
|
22
|
+
...flag,
|
|
23
|
+
alias: [...flag.alias, altName],
|
|
24
|
+
}));
|
|
25
|
+
},
|
|
19
26
|
positional(name: string, info: Flag) {
|
|
20
27
|
instructions.push({
|
|
21
28
|
...info,
|
|
29
|
+
alias: [],
|
|
22
30
|
name,
|
|
23
31
|
});
|
|
24
32
|
return this;
|
|
25
33
|
},
|
|
26
34
|
swap(name: string, swapper: (flag: Flag) => Flag) {
|
|
27
35
|
const [flag] = instructions.filter((m) => m.name === name);
|
|
28
|
-
const newFlag = swapper(flag || { name });
|
|
36
|
+
const newFlag = swapper(flag || { name, alias: [] });
|
|
29
37
|
|
|
30
38
|
if (!flag) {
|
|
31
39
|
instructions.push(newFlag);
|
|
@@ -135,7 +143,7 @@ export function runQuestionnaireFor(
|
|
|
135
143
|
const questions = instructions
|
|
136
144
|
.filter((instruction) => !ignored.includes(instruction.name))
|
|
137
145
|
.filter((instruction) => !acceptAll || (instruction.default === undefined && instruction.required))
|
|
138
|
-
.filter((instruction) =>
|
|
146
|
+
.filter((instruction) => [...instruction.alias, instruction.name].every((m) => args[m] === undefined))
|
|
139
147
|
.filter((instruction) => instruction.type !== 'object')
|
|
140
148
|
.map((instruction) => ({
|
|
141
149
|
name: instruction.name,
|
|
@@ -146,12 +154,16 @@ export function runQuestionnaireFor(
|
|
|
146
154
|
validate: instruction.type === 'number' ? (input: string) => !isNaN(+input) : () => true,
|
|
147
155
|
}));
|
|
148
156
|
|
|
157
|
+
|
|
149
158
|
return inquirer.prompt(questions).then((answers) => {
|
|
150
159
|
const parameters: any = {};
|
|
151
160
|
|
|
152
161
|
for (const instruction of instructions) {
|
|
153
162
|
const name = instruction.name;
|
|
154
|
-
const value =
|
|
163
|
+
const value =
|
|
164
|
+
answers[name] ??
|
|
165
|
+
ignoredInstructions[name] ??
|
|
166
|
+
[...instruction.alias, instruction.name].map((m) => args[m]).find((v) => v !== undefined);
|
|
155
167
|
parameters[name] = value !== undefined ? getValue(instruction.type, value as any) : instruction.default;
|
|
156
168
|
}
|
|
157
169
|
|