piral-cli 0.14.0-unstable.3105 → 0.14.1-beta.3246
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/README.md +5 -2
- package/lib/apps/build-pilet.d.ts +11 -0
- package/lib/apps/build-pilet.js +8 -1
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/build-piral.d.ts +13 -0
- package/lib/apps/build-piral.js +16 -5
- package/lib/apps/build-piral.js.map +1 -1
- package/lib/apps/debug-pilet.d.ts +11 -0
- package/lib/apps/debug-pilet.js +15 -3
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.d.ts +11 -0
- package/lib/apps/debug-piral.js +11 -1
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/new-pilet.d.ts +1 -1
- package/lib/apps/new-pilet.js +11 -7
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.d.ts +1 -1
- package/lib/apps/new-piral.js +4 -3
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/pack-pilet.js +1 -1
- package/lib/apps/publish-pilet.d.ts +1 -1
- package/lib/apps/publish-pilet.js +1 -1
- package/lib/apps/upgrade-pilet.d.ts +6 -2
- package/lib/apps/upgrade-pilet.js +9 -6
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/apps/upgrade-piral.d.ts +2 -2
- package/lib/apps/upgrade-piral.js +1 -1
- package/lib/build/bundler-calls.d.ts +3 -0
- package/lib/build/bundler-calls.js +107 -0
- package/lib/build/bundler-calls.js.map +1 -0
- package/lib/build/run-build-pilet.d.ts +1 -0
- package/lib/build/run-build-pilet.js +65 -0
- package/lib/build/run-build-pilet.js.map +1 -0
- package/lib/build/run-build-piral.d.ts +1 -0
- package/lib/build/run-build-piral.js +66 -0
- package/lib/build/run-build-piral.js.map +1 -0
- package/lib/build/run-debug-mono-piral.d.ts +1 -0
- package/lib/build/run-debug-mono-piral.js +71 -0
- package/lib/build/run-debug-mono-piral.js.map +1 -0
- package/lib/build/run-debug-pilet.d.ts +1 -0
- package/lib/build/run-debug-pilet.js +90 -0
- package/lib/build/run-debug-pilet.js.map +1 -0
- package/lib/build/run-debug-piral.d.ts +1 -0
- package/lib/build/run-debug-piral.js +86 -0
- package/lib/build/run-debug-piral.js.map +1 -0
- package/lib/bundler.js +50 -13
- package/lib/bundler.js.map +1 -1
- package/lib/commands.js +12 -8
- package/lib/commands.js.map +1 -1
- package/lib/common/clients/npm.js +10 -10
- package/lib/common/constants.d.ts +1 -1
- package/lib/common/constants.js +2 -2
- package/lib/common/constants.js.map +1 -1
- package/lib/common/emulator.js +5 -2
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/log.js +7 -4
- package/lib/common/log.js.map +1 -1
- package/lib/common/npm.d.ts +3 -1
- package/lib/common/npm.js +31 -11
- package/lib/common/npm.js.map +1 -1
- package/lib/common/package.d.ts +5 -5
- package/lib/common/package.js +43 -24
- package/lib/common/package.js.map +1 -1
- package/lib/common/scaffold.d.ts +14 -2
- package/lib/common/scaffold.js +19 -7
- package/lib/common/scaffold.js.map +1 -1
- package/lib/common/template.d.ts +1 -0
- package/lib/common/template.js +29 -2
- package/lib/common/template.js.map +1 -1
- package/lib/external/index.js +119 -155
- package/lib/helpers.js +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/injectors/piral.d.ts +4 -2
- package/lib/injectors/piral.js +16 -1
- package/lib/injectors/piral.js.map +1 -1
- package/lib/messages.d.ts +25 -21
- package/lib/messages.js +30 -22
- package/lib/messages.js.map +1 -1
- package/lib/types/common.d.ts +1 -0
- package/lib/types/public.d.ts +63 -11
- package/package.json +3 -3
- package/src/apps/build-pilet.ts +22 -0
- package/src/apps/build-piral.ts +38 -4
- package/src/apps/debug-pilet.ts +29 -6
- package/src/apps/debug-piral.ts +24 -0
- package/src/apps/new-pilet.ts +13 -8
- package/src/apps/new-piral.ts +7 -5
- package/src/apps/pack-pilet.test.ts +2 -2
- package/src/apps/pack-pilet.ts +1 -1
- package/src/apps/publish-pilet.ts +2 -2
- package/src/apps/upgrade-pilet.ts +18 -7
- package/src/apps/upgrade-piral.ts +3 -3
- package/src/build/bundler-calls.ts +121 -0
- package/src/build/run-build-pilet.ts +89 -0
- package/src/build/run-build-piral.ts +88 -0
- package/src/build/run-debug-mono-piral.ts +87 -0
- package/src/build/run-debug-pilet.ts +114 -0
- package/src/build/run-debug-piral.ts +106 -0
- package/src/bundler.test.ts +65 -46
- package/src/bundler.ts +53 -13
- package/src/commands.ts +20 -10
- package/src/common/clients/npm.ts +10 -10
- package/src/common/constants.ts +1 -1
- package/src/common/emulator.ts +5 -2
- package/src/common/log.ts +9 -4
- package/src/common/npm.test.ts +18 -18
- package/src/common/npm.ts +27 -8
- package/src/common/package.ts +53 -17
- package/src/common/scaffold.ts +36 -20
- package/src/common/template.ts +24 -1
- package/src/helpers.ts +1 -1
- package/src/injectors/piral.test.ts +6 -5
- package/src/injectors/piral.ts +21 -2
- package/src/messages.ts +43 -35
- package/src/types/common.ts +1 -0
- package/src/types/public.ts +68 -20
package/src/bundler.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { callDynamic, callStatic } from './build/bundler-calls';
|
|
1
2
|
import { availableBundlers } from './helpers';
|
|
2
3
|
import {
|
|
3
4
|
installPackage,
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
DebugPiletParameters,
|
|
21
22
|
BundlerDefinition,
|
|
22
23
|
BaseBundleParameters,
|
|
24
|
+
BaseBundlerDefinition,
|
|
23
25
|
} from './types';
|
|
24
26
|
|
|
25
27
|
export interface QualifiedBundler {
|
|
@@ -33,7 +35,7 @@ async function installDefaultBundler(root: string) {
|
|
|
33
35
|
const selectedBundler = config.bundler || 'webpack';
|
|
34
36
|
log('generalDebug_0003', `Installation of default bundler for "${selectedBundler}".`);
|
|
35
37
|
const selectedPackage = `piral-cli-${selectedBundler}`;
|
|
36
|
-
log('generalDebug_0003', `Determining
|
|
38
|
+
log('generalDebug_0003', `Determining npm client at "${root}" ...`);
|
|
37
39
|
const client = await determineNpmClient(root);
|
|
38
40
|
log('generalDebug_0003', `Prepare to install ${selectedPackage}@${cliVersion} using "${client}" into "${root}".`);
|
|
39
41
|
progress(`Installing ${selectedPackage} ...`);
|
|
@@ -76,12 +78,18 @@ async function findBundler(root: string, bundlerName?: string) {
|
|
|
76
78
|
return defaultBundler;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
async function
|
|
81
|
+
async function prepareArgs<T extends BaseBundleParameters>(bundler: BaseBundlerDefinition<T>, args: T): Promise<T> {
|
|
80
82
|
if (args.optimizeModules) {
|
|
81
83
|
progress('Preparing modules ...');
|
|
82
84
|
await patchModules(args.root, args.ignored);
|
|
83
85
|
logReset();
|
|
84
86
|
}
|
|
87
|
+
|
|
88
|
+
if (bundler.prepare) {
|
|
89
|
+
return await bundler.prepare(args);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return args;
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
export function setBundler(bundler: QualifiedBundler) {
|
|
@@ -94,26 +102,52 @@ export function setBundler(bundler: QualifiedBundler) {
|
|
|
94
102
|
|
|
95
103
|
export async function callPiralDebug(args: DebugPiralParameters, bundlerName?: string): Promise<Bundler> {
|
|
96
104
|
const bundler = await findBundler(args.root, bundlerName);
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
const action = bundler.actions.debugPiral;
|
|
108
|
+
const params = await prepareArgs(action, args);
|
|
109
|
+
return await callDynamic('debug-piral', action.path, params);
|
|
110
|
+
} catch (err) {
|
|
111
|
+
fail('bundlingFailed_0174', err);
|
|
112
|
+
}
|
|
99
113
|
}
|
|
100
114
|
|
|
101
115
|
export async function callPiletDebug(args: DebugPiletParameters, bundlerName?: string): Promise<Bundler> {
|
|
102
116
|
const bundler = await findBundler(args.root, bundlerName);
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
const action = bundler.actions.debugPilet;
|
|
120
|
+
const params = await prepareArgs(action, args);
|
|
121
|
+
return await callDynamic('debug-pilet', action.path, params);
|
|
122
|
+
} catch (err) {
|
|
123
|
+
fail('bundlingFailed_0174', err);
|
|
124
|
+
}
|
|
105
125
|
}
|
|
106
126
|
|
|
107
127
|
export async function callPiralBuild(args: BuildPiralParameters, bundlerName?: string): Promise<BundleDetails> {
|
|
108
128
|
const bundler = await findBundler(args.root, bundlerName);
|
|
109
|
-
|
|
110
|
-
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
const action = bundler.actions.buildPiral;
|
|
132
|
+
const params = await prepareArgs(action, args);
|
|
133
|
+
const instance = await callStatic('build-piral', action.path, params);
|
|
134
|
+
return instance.bundle;
|
|
135
|
+
} catch (err) {
|
|
136
|
+
fail('bundlingFailed_0174', err);
|
|
137
|
+
}
|
|
111
138
|
}
|
|
112
139
|
|
|
113
140
|
export async function callPiletBuild(args: BuildPiletParameters, bundlerName?: string): Promise<BundleDetails> {
|
|
114
141
|
const bundler = await findBundler(args.root, bundlerName);
|
|
115
|
-
|
|
116
|
-
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
const action = bundler.actions.buildPilet;
|
|
145
|
+
const params = await prepareArgs(action, args);
|
|
146
|
+
const instance = await callStatic('build-pilet', action.path, params);
|
|
147
|
+
return instance.bundle;
|
|
148
|
+
} catch (err) {
|
|
149
|
+
fail('bundlingFailed_0174', err);
|
|
150
|
+
}
|
|
117
151
|
}
|
|
118
152
|
|
|
119
153
|
export async function callDebugPiralFromMonoRepo(
|
|
@@ -121,7 +155,13 @@ export async function callDebugPiralFromMonoRepo(
|
|
|
121
155
|
bundlerName?: string,
|
|
122
156
|
): Promise<BundleDetails> {
|
|
123
157
|
const bundler = await findBundler(args.root, bundlerName);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
const action = bundler.actions.watchPiral;
|
|
161
|
+
const params = await prepareArgs(action, args);
|
|
162
|
+
const instance = await callStatic('debug-mono-piral', action.path, params);
|
|
163
|
+
return instance.bundle;
|
|
164
|
+
} catch (err) {
|
|
165
|
+
fail('bundlingFailed_0174', err);
|
|
166
|
+
}
|
|
127
167
|
}
|
package/src/commands.ts
CHANGED
|
@@ -132,7 +132,10 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
132
132
|
.describe('source-maps', 'Create associated source maps for the bundles.')
|
|
133
133
|
.default('source-maps', apps.buildPiralDefaults.sourceMaps)
|
|
134
134
|
.boolean('subdir')
|
|
135
|
-
.describe(
|
|
135
|
+
.describe(
|
|
136
|
+
'subdir',
|
|
137
|
+
`Places the build's output in an appropriate subdirectory (e.g., "emulator"). Ignored for "--all".`,
|
|
138
|
+
)
|
|
136
139
|
.default('subdir', apps.buildPiralDefaults.subdir)
|
|
137
140
|
.boolean('content-hash')
|
|
138
141
|
.describe('content-hash', 'Appends the hash to the side-bundle files.')
|
|
@@ -260,7 +263,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
260
263
|
.describe('framework', 'Sets the framework/library level to use.')
|
|
261
264
|
.default('framework', apps.newPiralDefaults.framework)
|
|
262
265
|
.boolean('install')
|
|
263
|
-
.describe('install', 'Already performs the installation of its
|
|
266
|
+
.describe('install', 'Already performs the installation of its npm dependencies.')
|
|
264
267
|
.default('install', apps.newPiralDefaults.install)
|
|
265
268
|
.string('registry')
|
|
266
269
|
.describe('registry', 'Sets the package registry to use for resolving the dependencies.')
|
|
@@ -269,7 +272,10 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
269
272
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
270
273
|
.default('log-level', apps.newPiralDefaults.logLevel)
|
|
271
274
|
.string('tag')
|
|
272
|
-
.describe(
|
|
275
|
+
.describe(
|
|
276
|
+
'tag',
|
|
277
|
+
'Sets the tag or version of the package to install. By default, this uses the version of the CLI.',
|
|
278
|
+
)
|
|
273
279
|
.default('tag', apps.newPiralDefaults.version)
|
|
274
280
|
.choices('force-overwrite', forceOverwriteKeys)
|
|
275
281
|
.describe('force-overwrite', 'Determines if files should be overwritten by the installation.')
|
|
@@ -281,7 +287,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
281
287
|
.describe('template', 'Sets the boilerplate template package to be used when scaffolding.')
|
|
282
288
|
.default('template', apps.newPiralDefaults.template)
|
|
283
289
|
.choices('npm-client', clientTypeKeys)
|
|
284
|
-
.describe('npm-client', 'Sets the
|
|
290
|
+
.describe('npm-client', 'Sets the npm client to be used when scaffolding.')
|
|
285
291
|
.default('npm-client', apps.newPiralDefaults.npmClient)
|
|
286
292
|
.choices('bundler', bundlerKeys)
|
|
287
293
|
.describe('bundler', 'Sets the default bundler to install.')
|
|
@@ -330,10 +336,10 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
330
336
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
331
337
|
.default('log-level', apps.upgradePiralDefaults.logLevel)
|
|
332
338
|
.boolean('install')
|
|
333
|
-
.describe('install', 'Already performs the update of its
|
|
339
|
+
.describe('install', 'Already performs the update of its npm dependencies.')
|
|
334
340
|
.default('install', apps.upgradePiralDefaults.install)
|
|
335
341
|
.choices('npm-client', clientTypeKeys)
|
|
336
|
-
.describe('npm-client', 'Sets the
|
|
342
|
+
.describe('npm-client', 'Sets the npm client to be used when upgrading.')
|
|
337
343
|
.default('npm-client', apps.upgradePiralDefaults.npmClient)
|
|
338
344
|
.string('base')
|
|
339
345
|
.default('base', process.cwd())
|
|
@@ -606,7 +612,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
606
612
|
.describe('registry', 'Sets the package registry to use for resolving the specified Piral app.')
|
|
607
613
|
.default('registry', apps.newPiletDefaults.registry)
|
|
608
614
|
.boolean('install')
|
|
609
|
-
.describe('install', 'Already performs the installation of its
|
|
615
|
+
.describe('install', 'Already performs the installation of its npm dependencies.')
|
|
610
616
|
.default('install', apps.newPiletDefaults.install)
|
|
611
617
|
.choices('force-overwrite', forceOverwriteKeys)
|
|
612
618
|
.describe('force-overwrite', 'Determines if files should be overwritten by the scaffolding.')
|
|
@@ -621,7 +627,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
621
627
|
.describe('template', 'Sets the boilerplate template package to be used when scaffolding.')
|
|
622
628
|
.default('template', apps.newPiletDefaults.template)
|
|
623
629
|
.choices('npm-client', clientTypeKeys)
|
|
624
|
-
.describe('npm-client', 'Sets the
|
|
630
|
+
.describe('npm-client', 'Sets the npm client to be used when scaffolding.')
|
|
625
631
|
.default('npm-client', apps.newPiletDefaults.npmClient)
|
|
626
632
|
.choices('bundler', bundlerKeys)
|
|
627
633
|
.describe('bundler', 'Sets the default bundler to install.')
|
|
@@ -668,14 +674,17 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
668
674
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
669
675
|
.default('log-level', apps.upgradePiletDefaults.logLevel)
|
|
670
676
|
.boolean('install')
|
|
671
|
-
.describe('install', 'Already performs the update of its
|
|
677
|
+
.describe('install', 'Already performs the update of its npm dependencies.')
|
|
672
678
|
.default('install', apps.upgradePiletDefaults.install)
|
|
673
679
|
.choices('force-overwrite', forceOverwriteKeys)
|
|
674
680
|
.describe('force-overwrite', 'Determines if files should be overwritten by the upgrading process.')
|
|
675
681
|
.default('force-overwrite', keyOfForceOverwrite(apps.upgradePiletDefaults.forceOverwrite))
|
|
676
682
|
.choices('npm-client', clientTypeKeys)
|
|
677
|
-
.describe('npm-client', 'Sets the
|
|
683
|
+
.describe('npm-client', 'Sets the npm client to be used when upgrading.')
|
|
678
684
|
.default('npm-client', apps.upgradePiletDefaults.npmClient)
|
|
685
|
+
.option('vars', undefined)
|
|
686
|
+
.describe('vars', 'Sets additional variables to be used when scaffolding.')
|
|
687
|
+
.default('vars', apps.upgradePiletDefaults.variables)
|
|
679
688
|
.string('base')
|
|
680
689
|
.default('base', process.cwd())
|
|
681
690
|
.describe('base', 'Sets the base directory. By default the current directory is used.');
|
|
@@ -688,6 +697,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
688
697
|
forceOverwrite: valueOfForceOverwrite(args['force-overwrite'] as string),
|
|
689
698
|
install: args.install as boolean,
|
|
690
699
|
npmClient: args['npm-client'] as NpmClientType,
|
|
700
|
+
variables: args.vars as Record<string, string>,
|
|
691
701
|
});
|
|
692
702
|
},
|
|
693
703
|
},
|
|
@@ -4,7 +4,7 @@ import { runCommand } from '../scripts';
|
|
|
4
4
|
import { MemoryStream } from '../MemoryStream';
|
|
5
5
|
|
|
6
6
|
function runNpmProcess(args: Array<string>, target: string, output?: NodeJS.WritableStream) {
|
|
7
|
-
log('generalDebug_0003', 'Starting the
|
|
7
|
+
log('generalDebug_0003', 'Starting the npm process ...');
|
|
8
8
|
const cwd = resolve(process.cwd(), target);
|
|
9
9
|
return runCommand('npm', args, cwd, output);
|
|
10
10
|
}
|
|
@@ -12,49 +12,49 @@ function runNpmProcess(args: Array<string>, target: string, output?: NodeJS.Writ
|
|
|
12
12
|
export async function installDependencies(target = '.', ...flags: Array<string>) {
|
|
13
13
|
const ms = new MemoryStream();
|
|
14
14
|
await runNpmProcess(['install', '--legacy-peer-deps', ...flags], target, ms);
|
|
15
|
-
log('generalDebug_0003', `
|
|
15
|
+
log('generalDebug_0003', `npm install dependencies result: ${ms.value}`);
|
|
16
16
|
return ms.value;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export async function unpackPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
20
20
|
const ms = new MemoryStream();
|
|
21
21
|
await runNpmProcess(['pack', packageRef, ...flags], target, ms);
|
|
22
|
-
log('generalDebug_0003', `
|
|
22
|
+
log('generalDebug_0003', `npm (un)pack result: ${ms.value}`);
|
|
23
23
|
return ms.value;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
27
27
|
const ms = new MemoryStream();
|
|
28
28
|
await runNpmProcess(['install', packageRef, '--legacy-peer-deps', ...flags], target, ms);
|
|
29
|
-
log('generalDebug_0003', `
|
|
29
|
+
log('generalDebug_0003', `npm install package result: ${ms.value}`);
|
|
30
30
|
return ms.value;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export async function createPackage(target = '.', ...flags: Array<string>) {
|
|
34
34
|
const ms = new MemoryStream();
|
|
35
35
|
await runNpmProcess(['pack', ...flags], target, ms);
|
|
36
|
-
log('generalDebug_0003', `
|
|
36
|
+
log('generalDebug_0003', `npm pack result: ${ms.value}`);
|
|
37
37
|
return ms.value;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export async function publishPackage(target = '.', file = '*.tgz', ...flags: Array<string>) {
|
|
41
41
|
const ms = new MemoryStream();
|
|
42
42
|
await runNpmProcess(['publish', file, ...flags], target, ms);
|
|
43
|
-
log('generalDebug_0003', `
|
|
43
|
+
log('generalDebug_0003', `npm publish result: ${ms.value}`);
|
|
44
44
|
return ms.value;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export async function findSpecificVersion(packageName: string, version: string) {
|
|
48
48
|
const ms = new MemoryStream();
|
|
49
49
|
await runNpmProcess(['show', packageName, 'version', '--tag', version], '.', ms);
|
|
50
|
-
log('generalDebug_0003', `
|
|
50
|
+
log('generalDebug_0003', `npm show result: ${ms.value}`);
|
|
51
51
|
return ms.value;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export async function findTarball(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
55
55
|
const ms = new MemoryStream();
|
|
56
56
|
await runNpmProcess(['view', packageRef, 'dist.tarball', ...flags], target, ms);
|
|
57
|
-
log('generalDebug_0003', `
|
|
57
|
+
log('generalDebug_0003', `npm view packageRef result: ${ms.value}`);
|
|
58
58
|
return ms.value;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -64,9 +64,9 @@ export async function listPackage(packageRef: string, target = '.', ...flags: Ar
|
|
|
64
64
|
try {
|
|
65
65
|
await runNpmProcess(['ls', packageRef, '--json', '--depth', '0', ...flags], target, ms);
|
|
66
66
|
} catch (e) {
|
|
67
|
-
log('generalDebug_0003', `
|
|
67
|
+
log('generalDebug_0003', `npm ls packageRef error: ${e}`);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
log('generalDebug_0003', `
|
|
70
|
+
log('generalDebug_0003', `npm ls packageRef result: ${ms.value}`);
|
|
71
71
|
return JSON.parse(ms.value);
|
|
72
72
|
}
|
package/src/common/constants.ts
CHANGED
|
@@ -4,7 +4,7 @@ export const filesOnceTar = 'files_once';
|
|
|
4
4
|
export const piralBaseRoot = 'piral-base/lib/types';
|
|
5
5
|
export const entryModuleExtensions = ['.ts', '.tsx', '.js', '.jsx'];
|
|
6
6
|
export const declarationEntryExtensions = ['.html', '.pug', ...entryModuleExtensions];
|
|
7
|
-
export const
|
|
7
|
+
export const legacyCoreExternals = [
|
|
8
8
|
'@dbeining/react-atom',
|
|
9
9
|
'@libre/atom',
|
|
10
10
|
'history',
|
package/src/common/emulator.ts
CHANGED
|
@@ -46,11 +46,13 @@ export async function createEmulatorSources(
|
|
|
46
46
|
const filesOnceDir = resolve(rootDir, filesOnceTar);
|
|
47
47
|
|
|
48
48
|
const filesMap = files
|
|
49
|
+
.filter((file) => file && (typeof file === 'string' || typeof file === 'object'))
|
|
49
50
|
.map((file) => (typeof file === 'string' ? { from: file, to: file } : file))
|
|
51
|
+
.filter((file) => typeof file.to === 'string' && typeof file.from === 'string')
|
|
50
52
|
.map((file) => ({
|
|
51
53
|
...file,
|
|
52
54
|
to: file.to.replace(/\\/g, '/'),
|
|
53
|
-
from: join('files', file.
|
|
55
|
+
from: join('files', file.to).replace(/\\/g, '/'),
|
|
54
56
|
}));
|
|
55
57
|
|
|
56
58
|
// do not modify an existing JSON
|
|
@@ -81,6 +83,7 @@ export async function createEmulatorSources(
|
|
|
81
83
|
...piralPkg.dependencies,
|
|
82
84
|
...externalDependencies,
|
|
83
85
|
},
|
|
86
|
+
sharedDependencies: allExternals,
|
|
84
87
|
repository: piralPkg.repository,
|
|
85
88
|
bugs: piralPkg.bugs,
|
|
86
89
|
author: piralPkg.author,
|
|
@@ -118,7 +121,7 @@ export async function createEmulatorSources(
|
|
|
118
121
|
// generate the associated index.d.ts
|
|
119
122
|
await createPiralDeclaration(sourceDir, piralPkg.app ?? `./src/index.html`, targetDir, ForceOverwrite.yes, logLevel);
|
|
120
123
|
|
|
121
|
-
// since things like .gitignore are not properly treated by
|
|
124
|
+
// since things like .gitignore are not properly treated by npm we pack the files (for standard and once only)
|
|
122
125
|
await Promise.all([
|
|
123
126
|
createTarball(filesDir, rootDir, `${filesTar}.tar`),
|
|
124
127
|
createTarball(filesOnceDir, rootDir, `${filesOnceTar}.tar`),
|
package/src/common/log.ts
CHANGED
|
@@ -11,10 +11,15 @@ type MessageTypes = keyof Messages;
|
|
|
11
11
|
|
|
12
12
|
const logger = (() => {
|
|
13
13
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const logger = require('@parcel/logger');
|
|
15
|
+
|
|
16
|
+
// check to see if this is really right
|
|
17
|
+
if (typeof logger.verbose === 'function') {
|
|
18
|
+
return logger;
|
|
19
|
+
}
|
|
20
|
+
} catch {}
|
|
21
|
+
|
|
22
|
+
return require('../external').logger;
|
|
18
23
|
})();
|
|
19
24
|
|
|
20
25
|
// unfortunately, Parcel's support for verbose logging on Windows is broken
|
package/src/common/npm.test.ts
CHANGED
|
@@ -81,7 +81,7 @@ jest.mock('fs', () => ({
|
|
|
81
81
|
},
|
|
82
82
|
}));
|
|
83
83
|
|
|
84
|
-
describe('
|
|
84
|
+
describe('npm Module', () => {
|
|
85
85
|
it('dissects a fully qualified name with latest correctly', async () => {
|
|
86
86
|
wrongCase = false;
|
|
87
87
|
const [name, version, hadVersion, type] = await dissectPackageName(process.cwd(), 'foo@latest');
|
|
@@ -172,14 +172,14 @@ describe('NPM Module', () => {
|
|
|
172
172
|
expect(type).toBe('registry');
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
it('installs a package using the
|
|
175
|
+
it('installs a package using the npm command line tool without a target', async () => {
|
|
176
176
|
wrongCase = false;
|
|
177
177
|
await installPackage('npm', 'foo', 'latest').then((result) => expect(result).toEqual(jsonValueString));
|
|
178
178
|
wrongCase = true;
|
|
179
179
|
await installPackage('npm', 'foo', 'latest').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
-
it('installs a package using the
|
|
182
|
+
it('installs a package using the npm command line tool without a version', async () => {
|
|
183
183
|
wrongCase = false;
|
|
184
184
|
await installPackage('npm', 'foo').then((result) => expect(result).toEqual(jsonValueString));
|
|
185
185
|
wrongCase = true;
|
|
@@ -200,7 +200,7 @@ describe('NPM Module', () => {
|
|
|
200
200
|
await installPackage('pnpm', 'foo').then((result) => expect(result).not.toEqual(jsonValueString));
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
it('installs a package using the
|
|
203
|
+
it('installs a package using the npm command line tool with some flag', async () => {
|
|
204
204
|
wrongCase = false;
|
|
205
205
|
await installPackage('npm', 'foo', '1.3', '.', '--a=b').then((result) => expect(result).toEqual(jsonValueString));
|
|
206
206
|
wrongCase = true;
|
|
@@ -409,30 +409,30 @@ describe('NPM Module', () => {
|
|
|
409
409
|
it('makeExternals without externals returns coreExternals', () => {
|
|
410
410
|
const externals = makeExternals();
|
|
411
411
|
expect(externals).toEqual([
|
|
412
|
-
'@dbeining/react-atom',
|
|
413
|
-
'@libre/atom',
|
|
414
|
-
'history',
|
|
415
412
|
'react',
|
|
416
413
|
'react-dom',
|
|
417
414
|
'react-router',
|
|
418
415
|
'react-router-dom',
|
|
416
|
+
'history',
|
|
419
417
|
'tslib',
|
|
420
418
|
'path-to-regexp',
|
|
419
|
+
'@libre/atom',
|
|
420
|
+
'@dbeining/react-atom',
|
|
421
421
|
]);
|
|
422
422
|
});
|
|
423
423
|
|
|
424
424
|
it('makeExternals with no externals returns coreExternals', () => {
|
|
425
425
|
const externals = makeExternals([]);
|
|
426
426
|
expect(externals).toEqual([
|
|
427
|
-
'@dbeining/react-atom',
|
|
428
|
-
'@libre/atom',
|
|
429
|
-
'history',
|
|
430
427
|
'react',
|
|
431
428
|
'react-dom',
|
|
432
429
|
'react-router',
|
|
433
430
|
'react-router-dom',
|
|
431
|
+
'history',
|
|
434
432
|
'tslib',
|
|
435
433
|
'path-to-regexp',
|
|
434
|
+
'@libre/atom',
|
|
435
|
+
'@dbeining/react-atom',
|
|
436
436
|
]);
|
|
437
437
|
});
|
|
438
438
|
|
|
@@ -446,15 +446,15 @@ describe('NPM Module', () => {
|
|
|
446
446
|
expect(externals).toEqual([
|
|
447
447
|
'foo',
|
|
448
448
|
'bar',
|
|
449
|
-
'@dbeining/react-atom',
|
|
450
|
-
'@libre/atom',
|
|
451
|
-
'history',
|
|
452
449
|
'react',
|
|
453
450
|
'react-dom',
|
|
454
451
|
'react-router',
|
|
455
452
|
'react-router-dom',
|
|
453
|
+
'history',
|
|
456
454
|
'tslib',
|
|
457
455
|
'path-to-regexp',
|
|
456
|
+
'@libre/atom',
|
|
457
|
+
'@dbeining/react-atom',
|
|
458
458
|
]);
|
|
459
459
|
});
|
|
460
460
|
|
|
@@ -463,14 +463,14 @@ describe('NPM Module', () => {
|
|
|
463
463
|
expect(externals).toEqual([
|
|
464
464
|
'react',
|
|
465
465
|
'foo',
|
|
466
|
-
'@dbeining/react-atom',
|
|
467
|
-
'@libre/atom',
|
|
468
|
-
'history',
|
|
469
466
|
'react-dom',
|
|
470
467
|
'react-router',
|
|
471
468
|
'react-router-dom',
|
|
469
|
+
'history',
|
|
472
470
|
'tslib',
|
|
473
471
|
'path-to-regexp',
|
|
472
|
+
'@libre/atom',
|
|
473
|
+
'@dbeining/react-atom',
|
|
474
474
|
]);
|
|
475
475
|
});
|
|
476
476
|
|
|
@@ -479,13 +479,13 @@ describe('NPM Module', () => {
|
|
|
479
479
|
expect(externals).toEqual([
|
|
480
480
|
'react',
|
|
481
481
|
'react-calendar',
|
|
482
|
-
'@dbeining/react-atom',
|
|
483
|
-
'@libre/atom',
|
|
484
482
|
'react-dom',
|
|
485
483
|
'react-router',
|
|
486
484
|
'react-router-dom',
|
|
487
485
|
'tslib',
|
|
488
486
|
'path-to-regexp',
|
|
487
|
+
'@libre/atom',
|
|
488
|
+
'@dbeining/react-atom',
|
|
489
489
|
]);
|
|
490
490
|
});
|
|
491
491
|
|
package/src/common/npm.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { resolve, relative } from 'path';
|
|
|
2
2
|
import { createReadStream, existsSync, access, constants } from 'fs';
|
|
3
3
|
import { log, fail } from './log';
|
|
4
4
|
import { config } from './config';
|
|
5
|
+
import { legacyCoreExternals } from './constants';
|
|
5
6
|
import { inspectPackage } from './inspect';
|
|
6
|
-
import { coreExternals } from './constants';
|
|
7
7
|
import { readJson, checkExists, findFile } from './io';
|
|
8
8
|
import { clientTypeKeys } from '../helpers';
|
|
9
9
|
import { PackageType, NpmClientType } from '../types';
|
|
@@ -69,27 +69,27 @@ export async function getLernaNpmClient(root: string): Promise<NpmClientType> {
|
|
|
69
69
|
*/
|
|
70
70
|
export async function determineNpmClient(root: string, selected?: NpmClientType): Promise<NpmClientType> {
|
|
71
71
|
if (!selected || !clientTypeKeys.includes(selected)) {
|
|
72
|
-
log('generalDebug_0003', 'No
|
|
72
|
+
log('generalDebug_0003', 'No npm client selected. Checking for lock files ...');
|
|
73
73
|
const [hasNpm, hasYarn, hasPnpm] = await Promise.all([detectNpm(root), detectYarn(root), detectPnpm(root)]);
|
|
74
74
|
const found = +hasNpm + +hasYarn + +hasPnpm;
|
|
75
|
-
log('generalDebug_0003', `Results of the lock file check:
|
|
75
|
+
log('generalDebug_0003', `Results of the lock file check: npm = ${hasNpm}, Yarn = ${hasYarn}, Pnpm = ${hasPnpm}`);
|
|
76
76
|
const defaultClient = config.npmClient;
|
|
77
77
|
|
|
78
78
|
if (found !== 1) {
|
|
79
79
|
const lernaClient = await getLernaNpmClient(root);
|
|
80
80
|
|
|
81
81
|
if (clientTypeKeys.includes(lernaClient)) {
|
|
82
|
-
log('generalDebug_0003', `Found valid
|
|
82
|
+
log('generalDebug_0003', `Found valid npm client via Lerna: ${lernaClient}.`);
|
|
83
83
|
return lernaClient;
|
|
84
84
|
}
|
|
85
85
|
} else if (hasNpm) {
|
|
86
|
-
log('generalDebug_0003', `Found valid
|
|
86
|
+
log('generalDebug_0003', `Found valid npm client via lockfile.`);
|
|
87
87
|
return 'npm';
|
|
88
88
|
} else if (hasYarn) {
|
|
89
89
|
log('generalDebug_0003', `Found valid Yarn client via lockfile.`);
|
|
90
90
|
return 'yarn';
|
|
91
91
|
} else if (hasPnpm) {
|
|
92
|
-
log('generalDebug_0003', `Found valid
|
|
92
|
+
log('generalDebug_0003', `Found valid pnpm client via lockfile.`);
|
|
93
93
|
return 'pnpm';
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -98,7 +98,7 @@ export async function determineNpmClient(root: string, selected?: NpmClientType)
|
|
|
98
98
|
return defaultClient;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
log('generalDebug_0003', 'Using the default
|
|
101
|
+
log('generalDebug_0003', 'Using the default npm client.');
|
|
102
102
|
return 'npm';
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -388,7 +388,26 @@ export function getPackageVersion(
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
export function
|
|
391
|
+
export function getCoreExternals(): Array<string> {
|
|
392
|
+
try {
|
|
393
|
+
return require('piral-core/package.json').sharedDependencies || [];
|
|
394
|
+
} catch {
|
|
395
|
+
return [];
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export function makePiletExternals(externals: Array<string>, fromEmulator: boolean, piralInfo: any) {
|
|
400
|
+
if (fromEmulator) {
|
|
401
|
+
const { sharedDependencies = makeExternals(externals, true) } = piralInfo;
|
|
402
|
+
return sharedDependencies;
|
|
403
|
+
} else {
|
|
404
|
+
return makeExternals(externals);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export function makeExternals(externals?: Array<string>, legacy = false) {
|
|
409
|
+
const coreExternals = legacy ? legacyCoreExternals : getCoreExternals();
|
|
410
|
+
|
|
392
411
|
if (externals && Array.isArray(externals)) {
|
|
393
412
|
const [include, exclude] = externals.reduce<[Array<string>, Array<string>]>(
|
|
394
413
|
(prev, curr) => {
|