piral-cli 0.13.8 → 0.14.0-beta.3156
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/api.js +23 -23
- package/lib/api.js.map +1 -1
- package/lib/apps/build-pilet.js +18 -16
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/build-piral.js +35 -34
- package/lib/apps/build-piral.js.map +1 -1
- package/lib/apps/debug-pilet.js +28 -27
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js +15 -14
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/declaration-piral.js +5 -3
- package/lib/apps/declaration-piral.js.map +1 -1
- package/lib/apps/new-pilet.js +43 -39
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.js +21 -20
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/pack-pilet.js +6 -4
- package/lib/apps/pack-pilet.js.map +1 -1
- package/lib/apps/publish-pilet.js +48 -47
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/apps/publish-piral.js +23 -22
- package/lib/apps/publish-piral.js.map +1 -1
- package/lib/apps/upgrade-pilet.js +34 -33
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/apps/upgrade-piral.js +20 -19
- package/lib/apps/upgrade-piral.js.map +1 -1
- package/lib/apps/validate-pilet.js +13 -11
- package/lib/apps/validate-pilet.js.map +1 -1
- package/lib/apps/validate-piral.js +12 -10
- package/lib/apps/validate-piral.js.map +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 +62 -25
- package/lib/bundler.js.map +1 -1
- package/lib/cli.js +2 -2
- package/lib/cli.js.map +1 -1
- package/lib/commands.js +12 -12
- package/lib/commands.js.map +1 -1
- package/lib/common/archive.js +8 -8
- package/lib/common/archive.js.map +1 -1
- package/lib/common/browser.js +2 -2
- package/lib/common/browser.js.map +1 -1
- package/lib/common/clients/lerna.js +4 -4
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.js +12 -12
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnpm.js +5 -5
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/yarn.js +5 -5
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/compatibility.js +9 -9
- package/lib/common/compatibility.js.map +1 -1
- package/lib/common/config.d.ts +5 -1
- package/lib/common/config.js +2 -1
- package/lib/common/config.js.map +1 -1
- 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/declaration.js +19 -19
- package/lib/common/declaration.js.map +1 -1
- package/lib/common/emulator.js +24 -23
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/envs.js +3 -3
- package/lib/common/envs.js.map +1 -1
- package/lib/common/hash.d.ts +1 -0
- package/lib/common/hash.js +8 -3
- package/lib/common/hash.js.map +1 -1
- package/lib/common/http.d.ts +1 -0
- package/lib/common/http.js +28 -14
- package/lib/common/http.js.map +1 -1
- package/lib/common/injectors.js +4 -4
- package/lib/common/injectors.js.map +1 -1
- package/lib/common/inspect.js +4 -4
- package/lib/common/inspect.js.map +1 -1
- package/lib/common/io.js +77 -73
- package/lib/common/io.js.map +1 -1
- package/lib/common/language.js +2 -2
- package/lib/common/language.js.map +1 -1
- package/lib/common/log.js +8 -8
- package/lib/common/log.js.map +1 -1
- package/lib/common/npm.d.ts +3 -1
- package/lib/common/npm.js +68 -48
- package/lib/common/npm.js.map +1 -1
- package/lib/common/pack.js +18 -18
- package/lib/common/pack.js.map +1 -1
- package/lib/common/package.d.ts +4 -2
- package/lib/common/package.js +182 -81
- package/lib/common/package.js.map +1 -1
- package/lib/common/patcher.js +20 -20
- package/lib/common/patcher.js.map +1 -1
- package/lib/common/port.js +3 -3
- package/lib/common/port.js.map +1 -1
- package/lib/common/rules.js +4 -4
- package/lib/common/rules.js.map +1 -1
- package/lib/common/scaffold.js +15 -15
- package/lib/common/scaffold.js.map +1 -1
- package/lib/common/scripts.js +5 -5
- package/lib/common/scripts.js.map +1 -1
- package/lib/common/template.js +4 -4
- package/lib/common/template.js.map +1 -1
- package/lib/external/index.js +1369 -611
- package/lib/helpers.js +2 -2
- package/lib/helpers.js.map +1 -1
- package/lib/inject.js +2 -2
- package/lib/inject.js.map +1 -1
- package/lib/injectors/pilet.d.ts +1 -10
- package/lib/injectors/pilet.js +74 -27
- package/lib/injectors/pilet.js.map +1 -1
- package/lib/injectors/piral.d.ts +4 -2
- package/lib/injectors/piral.js +20 -5
- package/lib/injectors/piral.js.map +1 -1
- package/lib/messages.d.ts +11 -3
- package/lib/messages.js +11 -3
- package/lib/messages.js.map +1 -1
- package/lib/pb-cli.js +1 -1
- package/lib/pb-cli.js.map +1 -1
- package/lib/pilet-cli.js +1 -1
- package/lib/pilet-cli.js.map +1 -1
- package/lib/piral-cli.js +1 -1
- package/lib/piral-cli.js.map +1 -1
- package/lib/plugin.js +10 -10
- package/lib/plugin.js.map +1 -1
- package/lib/release.js +3 -3
- package/lib/release.js.map +1 -1
- package/lib/resolvers.js +13 -13
- package/lib/resolvers.js.map +1 -1
- package/lib/rules/index.js +7 -7
- package/lib/rules/index.js.map +1 -1
- package/lib/rules/pilet-has-externals-as-peers.js +3 -3
- package/lib/rules/pilet-has-externals-as-peers.js.map +1 -1
- package/lib/rules/pilet-has-no-self-reference.js +1 -1
- package/lib/rules/pilet-has-no-self-reference.js.map +1 -1
- package/lib/rules/pilet-stays-small.js +3 -3
- package/lib/rules/pilet-stays-small.js.map +1 -1
- package/lib/rules/pilet-uses-latest-piral.js +1 -1
- package/lib/rules/pilet-uses-latest-piral.js.map +1 -1
- package/lib/rules/piral-entry-ends-with-html.js +1 -1
- package/lib/rules/piral-entry-ends-with-html.js.map +1 -1
- package/lib/rules/piral-has-valid-files.js +5 -5
- package/lib/rules/piral-has-valid-files.js.map +1 -1
- package/lib/runner.js +1 -1
- package/lib/runner.js.map +1 -1
- package/lib/select.js +6 -6
- package/lib/select.js.map +1 -1
- package/lib/types/common.d.ts +8 -0
- package/lib/types/public.d.ts +66 -12
- package/package.json +3 -3
- package/src/apps/build-pilet.ts +7 -4
- package/src/apps/build-piral.ts +6 -5
- package/src/apps/debug-pilet.ts +3 -2
- package/src/apps/debug-piral.ts +2 -1
- package/src/apps/declaration-piral.ts +3 -1
- package/src/apps/new-pilet.ts +7 -3
- package/src/apps/new-piral.ts +2 -1
- package/src/apps/pack-pilet.ts +3 -1
- package/src/apps/publish-pilet.ts +6 -5
- package/src/apps/publish-piral.ts +3 -2
- package/src/apps/upgrade-pilet.ts +5 -4
- package/src/apps/upgrade-piral.ts +2 -1
- package/src/apps/validate-pilet.ts +5 -2
- package/src/apps/validate-piral.ts +3 -1
- 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 +83 -68
- package/src/bundler.ts +52 -12
- package/src/common/config.ts +6 -1
- package/src/common/constants.ts +1 -1
- package/src/common/emulator.ts +1 -0
- package/src/common/hash.ts +5 -0
- package/src/common/http.ts +18 -4
- package/src/common/io.ts +4 -0
- package/src/common/npm.test.ts +14 -14
- package/src/common/npm.ts +21 -2
- package/src/common/package.ts +120 -9
- package/src/helpers.ts +2 -2
- package/src/injectors/pilet.ts +82 -22
- package/src/injectors/piral.test.ts +6 -5
- package/src/injectors/piral.ts +21 -2
- package/src/messages.ts +23 -15
- package/src/types/common.ts +9 -0
- package/src/types/public.ts +71 -20
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { LogLevels, PiralBuildHandler } from '../types';
|
|
2
|
+
import { setStandardEnvs, progress, logReset } from '../common';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
|
|
5
|
+
let handler: PiralBuildHandler;
|
|
6
|
+
|
|
7
|
+
function run(
|
|
8
|
+
root: string,
|
|
9
|
+
outFile: string,
|
|
10
|
+
outDir: string,
|
|
11
|
+
piral: string,
|
|
12
|
+
hmr: boolean,
|
|
13
|
+
externals: Array<string>,
|
|
14
|
+
entryFiles: string,
|
|
15
|
+
logLevel: LogLevels,
|
|
16
|
+
args: any,
|
|
17
|
+
) {
|
|
18
|
+
progress(`Preparing supplied Piral instance ...`);
|
|
19
|
+
|
|
20
|
+
setStandardEnvs({
|
|
21
|
+
piral,
|
|
22
|
+
dependencies: externals,
|
|
23
|
+
production: false,
|
|
24
|
+
debugPiral: true,
|
|
25
|
+
debugPilet: true,
|
|
26
|
+
root,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return handler.create({
|
|
30
|
+
root,
|
|
31
|
+
entryFiles,
|
|
32
|
+
outFile,
|
|
33
|
+
outDir,
|
|
34
|
+
externals,
|
|
35
|
+
emulator: true,
|
|
36
|
+
sourceMaps: true,
|
|
37
|
+
contentHash: false,
|
|
38
|
+
minify: false,
|
|
39
|
+
publicUrl: undefined,
|
|
40
|
+
hmr,
|
|
41
|
+
logLevel,
|
|
42
|
+
watch: true,
|
|
43
|
+
args,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
process.on('message', async (msg) => {
|
|
48
|
+
try {
|
|
49
|
+
switch (msg.type) {
|
|
50
|
+
case 'init':
|
|
51
|
+
handler = require(msg.path);
|
|
52
|
+
break;
|
|
53
|
+
case 'start':
|
|
54
|
+
const root = process.cwd();
|
|
55
|
+
const outDir = resolve(root, 'dist', 'app');
|
|
56
|
+
const bundler = await run(
|
|
57
|
+
root,
|
|
58
|
+
msg.outFile,
|
|
59
|
+
outDir,
|
|
60
|
+
msg.piral,
|
|
61
|
+
true,
|
|
62
|
+
msg.externals,
|
|
63
|
+
msg.entryFiles,
|
|
64
|
+
msg.logLevel,
|
|
65
|
+
msg,
|
|
66
|
+
);
|
|
67
|
+
const result = await bundler.bundle();
|
|
68
|
+
|
|
69
|
+
logReset();
|
|
70
|
+
|
|
71
|
+
if (result) {
|
|
72
|
+
process.send({
|
|
73
|
+
type: 'done',
|
|
74
|
+
outDir: result.outDir,
|
|
75
|
+
outFile: result.outFile,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
process.send({
|
|
83
|
+
type: 'fail',
|
|
84
|
+
error: error?.message,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PiletSchemaVersion,
|
|
3
|
+
LogLevels,
|
|
4
|
+
SharedDependency,
|
|
5
|
+
BundleHandlerResponse,
|
|
6
|
+
PiletBuildHandler,
|
|
7
|
+
} from '../types';
|
|
8
|
+
import { setStandardEnvs } from '../common';
|
|
9
|
+
import { resolve } from 'path';
|
|
10
|
+
|
|
11
|
+
let handler: PiletBuildHandler;
|
|
12
|
+
let bundler: BundleHandlerResponse;
|
|
13
|
+
|
|
14
|
+
function run(
|
|
15
|
+
root: string,
|
|
16
|
+
targetDir: string,
|
|
17
|
+
outDir: string,
|
|
18
|
+
piral: string,
|
|
19
|
+
externals: Array<string>,
|
|
20
|
+
importmap: Array<SharedDependency>,
|
|
21
|
+
entryModule: string,
|
|
22
|
+
version: PiletSchemaVersion,
|
|
23
|
+
logLevel: LogLevels,
|
|
24
|
+
args: any,
|
|
25
|
+
) {
|
|
26
|
+
setStandardEnvs({
|
|
27
|
+
piral,
|
|
28
|
+
root,
|
|
29
|
+
});
|
|
30
|
+
return handler.create({
|
|
31
|
+
root,
|
|
32
|
+
piral,
|
|
33
|
+
entryModule,
|
|
34
|
+
targetDir,
|
|
35
|
+
outDir,
|
|
36
|
+
outFile: 'index.js',
|
|
37
|
+
externals,
|
|
38
|
+
importmap,
|
|
39
|
+
version,
|
|
40
|
+
develop: true,
|
|
41
|
+
sourceMaps: true,
|
|
42
|
+
contentHash: true,
|
|
43
|
+
minify: false,
|
|
44
|
+
logLevel,
|
|
45
|
+
watch: true,
|
|
46
|
+
args,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
process.on('message', async (msg) => {
|
|
51
|
+
const root = process.cwd();
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
switch (msg.type) {
|
|
55
|
+
case 'init':
|
|
56
|
+
handler = require(msg.path);
|
|
57
|
+
break;
|
|
58
|
+
case 'bundle':
|
|
59
|
+
if (bundler) {
|
|
60
|
+
await bundler.bundle();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
break;
|
|
64
|
+
case 'start':
|
|
65
|
+
const dist = resolve(root, 'dist');
|
|
66
|
+
bundler = await run(
|
|
67
|
+
root,
|
|
68
|
+
msg.targetDir,
|
|
69
|
+
dist,
|
|
70
|
+
msg.piral,
|
|
71
|
+
msg.externals,
|
|
72
|
+
msg.importmap,
|
|
73
|
+
msg.entryModule,
|
|
74
|
+
msg.version,
|
|
75
|
+
msg.logLevel,
|
|
76
|
+
msg,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
if (bundler) {
|
|
80
|
+
bundler.onStart(() => {
|
|
81
|
+
process.send({
|
|
82
|
+
type: 'pending',
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
bundler.onEnd((result) => {
|
|
86
|
+
if (msg.hmr) {
|
|
87
|
+
process.send({
|
|
88
|
+
type: 'update',
|
|
89
|
+
outHash: result.hash,
|
|
90
|
+
outName: result.name,
|
|
91
|
+
args: {
|
|
92
|
+
requireRef: result.requireRef,
|
|
93
|
+
version: msg.version,
|
|
94
|
+
root,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
process.send({
|
|
101
|
+
type: 'done',
|
|
102
|
+
outDir: dist,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
process.send({
|
|
110
|
+
type: 'fail',
|
|
111
|
+
error: error?.message,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { BundleHandlerResponse, LogLevels, PiralBuildHandler } from '../types';
|
|
2
|
+
import { setStandardEnvs } from '../common';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
|
|
5
|
+
let handler: PiralBuildHandler;
|
|
6
|
+
let bundler: BundleHandlerResponse;
|
|
7
|
+
|
|
8
|
+
function run(
|
|
9
|
+
root: string,
|
|
10
|
+
outFile: string,
|
|
11
|
+
outDir: string,
|
|
12
|
+
piral: string,
|
|
13
|
+
hmr: boolean,
|
|
14
|
+
externals: Array<string>,
|
|
15
|
+
publicUrl: string,
|
|
16
|
+
entryFiles: string,
|
|
17
|
+
logLevel: LogLevels,
|
|
18
|
+
args: any,
|
|
19
|
+
) {
|
|
20
|
+
setStandardEnvs({
|
|
21
|
+
root,
|
|
22
|
+
debugPiral: true,
|
|
23
|
+
dependencies: externals,
|
|
24
|
+
piral,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return handler.create({
|
|
28
|
+
root,
|
|
29
|
+
entryFiles,
|
|
30
|
+
outFile,
|
|
31
|
+
outDir,
|
|
32
|
+
externals,
|
|
33
|
+
emulator: true,
|
|
34
|
+
sourceMaps: true,
|
|
35
|
+
contentHash: false,
|
|
36
|
+
minify: false,
|
|
37
|
+
publicUrl,
|
|
38
|
+
hmr,
|
|
39
|
+
logLevel,
|
|
40
|
+
watch: true,
|
|
41
|
+
args,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
process.on('message', async (msg) => {
|
|
46
|
+
const root = process.cwd();
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
switch (msg.type) {
|
|
50
|
+
case 'init':
|
|
51
|
+
handler = require(msg.path);
|
|
52
|
+
break;
|
|
53
|
+
case 'bundle':
|
|
54
|
+
if (bundler) {
|
|
55
|
+
await bundler.bundle();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
break;
|
|
59
|
+
case 'start':
|
|
60
|
+
const dist = resolve(root, 'dist');
|
|
61
|
+
bundler = await run(
|
|
62
|
+
root,
|
|
63
|
+
msg.outFile,
|
|
64
|
+
dist,
|
|
65
|
+
msg.piral,
|
|
66
|
+
msg.hmr,
|
|
67
|
+
msg.externals,
|
|
68
|
+
msg.publicUrl,
|
|
69
|
+
msg.entryFiles,
|
|
70
|
+
msg.logLevel,
|
|
71
|
+
msg,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (bundler) {
|
|
75
|
+
bundler.onStart(() => {
|
|
76
|
+
process.send({
|
|
77
|
+
type: 'pending',
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
bundler.onEnd((result) => {
|
|
82
|
+
process.send({
|
|
83
|
+
type: 'update',
|
|
84
|
+
outHash: result.hash,
|
|
85
|
+
outName: 'index.html',
|
|
86
|
+
args: {
|
|
87
|
+
root,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
process.send({
|
|
93
|
+
type: 'done',
|
|
94
|
+
outDir: dist,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
} catch (error) {
|
|
101
|
+
process.send({
|
|
102
|
+
type: 'fail',
|
|
103
|
+
error: error?.message,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
});
|
package/src/bundler.test.ts
CHANGED
|
@@ -6,50 +6,60 @@ import {
|
|
|
6
6
|
callPiralDebug,
|
|
7
7
|
callDebugPiralFromMonoRepo,
|
|
8
8
|
} from './bundler';
|
|
9
|
+
import { callDynamic, callStatic } from './build/bundler-calls';
|
|
10
|
+
import * as common from './common';
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
let defaults = {
|
|
12
|
+
const defaults = {
|
|
12
13
|
bundler: false,
|
|
13
14
|
};
|
|
14
15
|
|
|
16
|
+
jest.mock('./build/bundler-calls.ts', () => ({
|
|
17
|
+
callDynamic: jest.fn(() =>
|
|
18
|
+
Promise.resolve({
|
|
19
|
+
bundle: {},
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
callStatic: jest.fn(() =>
|
|
23
|
+
Promise.resolve({
|
|
24
|
+
bundle: {},
|
|
25
|
+
}),
|
|
26
|
+
),
|
|
27
|
+
}));
|
|
28
|
+
|
|
15
29
|
jest.mock('./inject', () => ({
|
|
16
30
|
inject() {
|
|
17
31
|
if (defaults.bundler) {
|
|
18
32
|
setBundler({
|
|
19
33
|
name: 'default',
|
|
20
34
|
actions: {
|
|
21
|
-
buildPilet: {
|
|
22
|
-
debugPilet: {
|
|
23
|
-
buildPiral: {
|
|
24
|
-
debugPiral: {
|
|
25
|
-
watchPiral: {
|
|
35
|
+
buildPilet: { path: '' },
|
|
36
|
+
debugPilet: { path: '' },
|
|
37
|
+
buildPiral: { path: '' },
|
|
38
|
+
debugPiral: { path: '' },
|
|
39
|
+
watchPiral: { path: '' },
|
|
26
40
|
} as any,
|
|
27
41
|
});
|
|
28
42
|
}
|
|
29
43
|
},
|
|
30
44
|
}));
|
|
31
45
|
|
|
32
|
-
jest.mock(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
patchModules: jest.fn(),
|
|
50
|
-
logReset() {},
|
|
51
|
-
}),
|
|
52
|
-
);
|
|
46
|
+
jest.mock('./common', () => ({
|
|
47
|
+
config: {
|
|
48
|
+
bundler: 'parcel',
|
|
49
|
+
},
|
|
50
|
+
cliVersion: '1.0.0',
|
|
51
|
+
installPackage: jest.fn(),
|
|
52
|
+
fail(msg) {
|
|
53
|
+
throw new Error(msg);
|
|
54
|
+
},
|
|
55
|
+
progress() {},
|
|
56
|
+
log() {},
|
|
57
|
+
determineNpmClient() {
|
|
58
|
+
return 'npm';
|
|
59
|
+
},
|
|
60
|
+
patchModules: jest.fn(),
|
|
61
|
+
logReset() {},
|
|
62
|
+
}));
|
|
53
63
|
|
|
54
64
|
describe('Piral CLI Bundler Module', () => {
|
|
55
65
|
it('fails if no default bundler can be installed, but required', async () => {
|
|
@@ -64,11 +74,11 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
64
74
|
|
|
65
75
|
it('setting the bundler can resolve it properly for call pilet build', async () => {
|
|
66
76
|
const actions = {
|
|
67
|
-
buildPilet: {
|
|
68
|
-
debugPilet: {
|
|
69
|
-
buildPiral: {
|
|
70
|
-
debugPiral: {
|
|
71
|
-
watchPiral: {
|
|
77
|
+
buildPilet: { path: '1' },
|
|
78
|
+
debugPilet: { path: '2' },
|
|
79
|
+
buildPiral: { path: '3' },
|
|
80
|
+
debugPiral: { path: '4' },
|
|
81
|
+
watchPiral: { path: '5' },
|
|
72
82
|
};
|
|
73
83
|
|
|
74
84
|
setBundler({
|
|
@@ -76,17 +86,18 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
76
86
|
actions: actions as any,
|
|
77
87
|
});
|
|
78
88
|
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
const args = { root: undefined };
|
|
90
|
+
await callPiletBuild(args as any, 'foo1');
|
|
91
|
+
expect(callStatic).toHaveBeenCalledWith('build-pilet', '1', args);
|
|
81
92
|
});
|
|
82
93
|
|
|
83
94
|
it('setting the bundler with optimize modules calls optimize modules', async () => {
|
|
84
95
|
const actions = {
|
|
85
|
-
buildPilet: {
|
|
86
|
-
debugPilet: {
|
|
87
|
-
buildPiral: {
|
|
88
|
-
debugPiral: {
|
|
89
|
-
watchPiral: {
|
|
96
|
+
buildPilet: { path: '' },
|
|
97
|
+
debugPilet: { path: '' },
|
|
98
|
+
buildPiral: { path: '' },
|
|
99
|
+
debugPiral: { path: '' },
|
|
100
|
+
watchPiral: { path: '' },
|
|
90
101
|
};
|
|
91
102
|
|
|
92
103
|
setBundler({
|
|
@@ -105,11 +116,11 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
105
116
|
|
|
106
117
|
it('setting the bundler can resolve it properly for call piral build', async () => {
|
|
107
118
|
const actions = {
|
|
108
|
-
buildPilet: {
|
|
109
|
-
debugPilet: {
|
|
110
|
-
buildPiral: {
|
|
111
|
-
debugPiral: {
|
|
112
|
-
watchPiral: {
|
|
119
|
+
buildPilet: { path: '1' },
|
|
120
|
+
debugPilet: { path: '2' },
|
|
121
|
+
buildPiral: { path: '3' },
|
|
122
|
+
debugPiral: { path: '4' },
|
|
123
|
+
watchPiral: { path: '5' },
|
|
113
124
|
};
|
|
114
125
|
|
|
115
126
|
setBundler({
|
|
@@ -117,17 +128,18 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
117
128
|
actions: actions as any,
|
|
118
129
|
});
|
|
119
130
|
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
const args = { root: undefined };
|
|
132
|
+
await callPiralBuild(args as any, 'foo2');
|
|
133
|
+
expect(callStatic).toHaveBeenCalledWith('build-piral', '3', args);
|
|
122
134
|
});
|
|
123
135
|
|
|
124
136
|
it('setting the bundler can resolve it properly for call pilet debug', async () => {
|
|
125
137
|
const actions = {
|
|
126
|
-
buildPilet: {
|
|
127
|
-
debugPilet: {
|
|
128
|
-
buildPiral: {
|
|
129
|
-
debugPiral: {
|
|
130
|
-
watchPiral: {
|
|
138
|
+
buildPilet: { path: '0' },
|
|
139
|
+
debugPilet: { path: '1' },
|
|
140
|
+
buildPiral: { path: '2' },
|
|
141
|
+
debugPiral: { path: '3' },
|
|
142
|
+
watchPiral: { path: '4' },
|
|
131
143
|
};
|
|
132
144
|
|
|
133
145
|
setBundler({
|
|
@@ -135,17 +147,18 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
135
147
|
actions: actions as any,
|
|
136
148
|
});
|
|
137
149
|
|
|
138
|
-
|
|
139
|
-
|
|
150
|
+
const args = { root: undefined };
|
|
151
|
+
await callPiletDebug(args as any, 'foo3');
|
|
152
|
+
expect(callDynamic).toHaveBeenCalledWith('debug-pilet', '1', args);
|
|
140
153
|
});
|
|
141
154
|
|
|
142
155
|
it('setting the bundler can resolve it properly for call piral debug', async () => {
|
|
143
156
|
const actions = {
|
|
144
|
-
buildPilet: {
|
|
145
|
-
debugPilet: {
|
|
146
|
-
buildPiral: {
|
|
147
|
-
debugPiral: {
|
|
148
|
-
watchPiral: {
|
|
157
|
+
buildPilet: { path: '7' },
|
|
158
|
+
debugPilet: { path: '8' },
|
|
159
|
+
buildPiral: { path: '9' },
|
|
160
|
+
debugPiral: { path: '10' },
|
|
161
|
+
watchPiral: { path: '11' },
|
|
149
162
|
};
|
|
150
163
|
|
|
151
164
|
setBundler({
|
|
@@ -153,17 +166,18 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
153
166
|
actions: actions as any,
|
|
154
167
|
});
|
|
155
168
|
|
|
156
|
-
|
|
157
|
-
|
|
169
|
+
const args = { root: undefined };
|
|
170
|
+
await callPiralDebug(args as any, 'foo4');
|
|
171
|
+
expect(callDynamic).toHaveBeenCalledWith('debug-piral', '10', args);
|
|
158
172
|
});
|
|
159
173
|
|
|
160
174
|
it('setting the bundler can resolve it properly for call piral watch', async () => {
|
|
161
175
|
const actions = {
|
|
162
|
-
buildPilet: {
|
|
163
|
-
debugPilet: {
|
|
164
|
-
buildPiral: {
|
|
165
|
-
debugPiral: {
|
|
166
|
-
watchPiral: {
|
|
176
|
+
buildPilet: { path: '3' },
|
|
177
|
+
debugPilet: { path: '4' },
|
|
178
|
+
buildPiral: { path: '5' },
|
|
179
|
+
debugPiral: { path: '6' },
|
|
180
|
+
watchPiral: { path: '7' },
|
|
167
181
|
};
|
|
168
182
|
|
|
169
183
|
setBundler({
|
|
@@ -171,8 +185,9 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
171
185
|
actions: actions as any,
|
|
172
186
|
});
|
|
173
187
|
|
|
174
|
-
|
|
175
|
-
|
|
188
|
+
const args = { root: undefined };
|
|
189
|
+
await callDebugPiralFromMonoRepo(args as any, 'foo5');
|
|
190
|
+
expect(callStatic).toHaveBeenCalledWith('debug-mono-piral', '7', args);
|
|
176
191
|
});
|
|
177
192
|
|
|
178
193
|
it('using a non-available bundler should fail', () => {
|
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 {
|
|
@@ -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/common/config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { rc } from '../external';
|
|
2
|
-
import { NpmClientType } from '../types';
|
|
2
|
+
import { NpmClientType, PiletSchemaVersion } from '../types';
|
|
3
3
|
|
|
4
4
|
export interface PiralCliConfig {
|
|
5
5
|
/**
|
|
@@ -37,6 +37,10 @@ export interface PiralCliConfig {
|
|
|
37
37
|
* Sets the validators configuration for a Piral instance.
|
|
38
38
|
*/
|
|
39
39
|
validators?: Record<string, any>;
|
|
40
|
+
/**
|
|
41
|
+
* Sets the schema version to be used for pilets.
|
|
42
|
+
*/
|
|
43
|
+
schemaVersion?: PiletSchemaVersion;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
export const config: PiralCliConfig = rc('piral', {
|
|
@@ -48,4 +52,5 @@ export const config: PiralCliConfig = rc('piral', {
|
|
|
48
52
|
bundler: 'webpack',
|
|
49
53
|
piletApi: '/$pilet-api',
|
|
50
54
|
validators: {},
|
|
55
|
+
schemaVersion: 'v2',
|
|
51
56
|
});
|
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',
|