piral-cli 0.14.0-unstable.3096 → 0.14.1-beta.3244
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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { PiletSchemaVersion, LogLevels, SharedDependency, PiletBuildHandler } from '../types';
|
|
2
|
+
import { setStandardEnvs } from '../common';
|
|
3
|
+
|
|
4
|
+
let handler: PiletBuildHandler;
|
|
5
|
+
|
|
6
|
+
function run(
|
|
7
|
+
root: string,
|
|
8
|
+
piral: string,
|
|
9
|
+
sourceMaps: boolean,
|
|
10
|
+
contentHash: boolean,
|
|
11
|
+
minify: boolean,
|
|
12
|
+
externals: Array<string>,
|
|
13
|
+
importmap: Array<SharedDependency>,
|
|
14
|
+
targetDir: string,
|
|
15
|
+
outDir: string,
|
|
16
|
+
outFile: string,
|
|
17
|
+
entryModule: string,
|
|
18
|
+
version: PiletSchemaVersion,
|
|
19
|
+
logLevel: LogLevels,
|
|
20
|
+
args: any,
|
|
21
|
+
) {
|
|
22
|
+
setStandardEnvs({
|
|
23
|
+
production: true,
|
|
24
|
+
piral,
|
|
25
|
+
root,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return handler.create({
|
|
29
|
+
root,
|
|
30
|
+
piral,
|
|
31
|
+
entryModule,
|
|
32
|
+
targetDir,
|
|
33
|
+
outDir,
|
|
34
|
+
outFile,
|
|
35
|
+
externals,
|
|
36
|
+
importmap,
|
|
37
|
+
version,
|
|
38
|
+
develop: false,
|
|
39
|
+
sourceMaps,
|
|
40
|
+
contentHash,
|
|
41
|
+
minify,
|
|
42
|
+
logLevel,
|
|
43
|
+
watch: false,
|
|
44
|
+
args,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
process.on('message', async (msg) => {
|
|
49
|
+
try {
|
|
50
|
+
switch (msg.type) {
|
|
51
|
+
case 'init':
|
|
52
|
+
handler = require(msg.path);
|
|
53
|
+
break;
|
|
54
|
+
case 'start':
|
|
55
|
+
const bundler = await run(
|
|
56
|
+
process.cwd(),
|
|
57
|
+
msg.piral,
|
|
58
|
+
msg.sourceMaps,
|
|
59
|
+
msg.contentHash,
|
|
60
|
+
msg.minify,
|
|
61
|
+
msg.externals,
|
|
62
|
+
msg.importmap,
|
|
63
|
+
msg.targetDir,
|
|
64
|
+
msg.outDir,
|
|
65
|
+
msg.outFile,
|
|
66
|
+
msg.entryModule,
|
|
67
|
+
msg.version,
|
|
68
|
+
msg.logLevel,
|
|
69
|
+
msg,
|
|
70
|
+
);
|
|
71
|
+
const result = await bundler.bundle();
|
|
72
|
+
|
|
73
|
+
if (result) {
|
|
74
|
+
process.send({
|
|
75
|
+
type: 'done',
|
|
76
|
+
outDir: result.outDir,
|
|
77
|
+
outFile: result.outFile,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
process.send({
|
|
85
|
+
type: 'fail',
|
|
86
|
+
error: error?.message,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { PiralBuildHandler, LogLevels } from '../types';
|
|
2
|
+
import { setStandardEnvs } from '../common';
|
|
3
|
+
|
|
4
|
+
let handler: PiralBuildHandler;
|
|
5
|
+
|
|
6
|
+
function run(
|
|
7
|
+
root: string,
|
|
8
|
+
piral: string,
|
|
9
|
+
emulator: boolean,
|
|
10
|
+
sourceMaps: boolean,
|
|
11
|
+
contentHash: boolean,
|
|
12
|
+
minify: boolean,
|
|
13
|
+
externals: Array<string>,
|
|
14
|
+
publicUrl: string,
|
|
15
|
+
outFile: string,
|
|
16
|
+
outDir: string,
|
|
17
|
+
entryFiles: string,
|
|
18
|
+
logLevel: LogLevels,
|
|
19
|
+
args: any,
|
|
20
|
+
) {
|
|
21
|
+
setStandardEnvs({
|
|
22
|
+
production: !emulator,
|
|
23
|
+
root,
|
|
24
|
+
debugPiral: emulator,
|
|
25
|
+
debugPilet: emulator,
|
|
26
|
+
piral,
|
|
27
|
+
dependencies: externals,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return handler.create({
|
|
31
|
+
root,
|
|
32
|
+
entryFiles,
|
|
33
|
+
outFile,
|
|
34
|
+
outDir,
|
|
35
|
+
externals,
|
|
36
|
+
emulator,
|
|
37
|
+
sourceMaps,
|
|
38
|
+
contentHash,
|
|
39
|
+
minify,
|
|
40
|
+
publicUrl,
|
|
41
|
+
hmr: false,
|
|
42
|
+
logLevel,
|
|
43
|
+
watch: false,
|
|
44
|
+
args,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
process.on('message', async (msg) => {
|
|
49
|
+
try {
|
|
50
|
+
switch (msg.type) {
|
|
51
|
+
case 'init':
|
|
52
|
+
handler = require(msg.path);
|
|
53
|
+
break;
|
|
54
|
+
case 'start':
|
|
55
|
+
const bundler = await run(
|
|
56
|
+
process.cwd(),
|
|
57
|
+
msg.piral,
|
|
58
|
+
msg.emulator,
|
|
59
|
+
msg.sourceMaps,
|
|
60
|
+
msg.contentHash,
|
|
61
|
+
msg.minify,
|
|
62
|
+
msg.externals,
|
|
63
|
+
msg.publicUrl,
|
|
64
|
+
msg.outFile,
|
|
65
|
+
msg.outDir,
|
|
66
|
+
msg.entryFiles,
|
|
67
|
+
msg.logLevel,
|
|
68
|
+
msg,
|
|
69
|
+
);
|
|
70
|
+
const result = await bundler.bundle();
|
|
71
|
+
|
|
72
|
+
if (result) {
|
|
73
|
+
process.send({
|
|
74
|
+
type: 'done',
|
|
75
|
+
outDir: result.outDir,
|
|
76
|
+
outFile: result.outFile,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
} catch (error) {
|
|
83
|
+
process.send({
|
|
84
|
+
type: 'fail',
|
|
85
|
+
error: error?.message,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
@@ -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,23 +6,37 @@ import {
|
|
|
6
6
|
callPiralDebug,
|
|
7
7
|
callDebugPiralFromMonoRepo,
|
|
8
8
|
} from './bundler';
|
|
9
|
+
import { callDynamic, callStatic } from './build/bundler-calls';
|
|
9
10
|
import * as common from './common';
|
|
10
11
|
|
|
11
|
-
|
|
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
|
}
|
|
@@ -60,11 +74,11 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
60
74
|
|
|
61
75
|
it('setting the bundler can resolve it properly for call pilet build', async () => {
|
|
62
76
|
const actions = {
|
|
63
|
-
buildPilet: {
|
|
64
|
-
debugPilet: {
|
|
65
|
-
buildPiral: {
|
|
66
|
-
debugPiral: {
|
|
67
|
-
watchPiral: {
|
|
77
|
+
buildPilet: { path: '1' },
|
|
78
|
+
debugPilet: { path: '2' },
|
|
79
|
+
buildPiral: { path: '3' },
|
|
80
|
+
debugPiral: { path: '4' },
|
|
81
|
+
watchPiral: { path: '5' },
|
|
68
82
|
};
|
|
69
83
|
|
|
70
84
|
setBundler({
|
|
@@ -72,17 +86,18 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
72
86
|
actions: actions as any,
|
|
73
87
|
});
|
|
74
88
|
|
|
75
|
-
|
|
76
|
-
|
|
89
|
+
const args = { root: undefined };
|
|
90
|
+
await callPiletBuild(args as any, 'foo1');
|
|
91
|
+
expect(callStatic).toHaveBeenCalledWith('build-pilet', '1', args);
|
|
77
92
|
});
|
|
78
93
|
|
|
79
94
|
it('setting the bundler with optimize modules calls optimize modules', async () => {
|
|
80
95
|
const actions = {
|
|
81
|
-
buildPilet: {
|
|
82
|
-
debugPilet: {
|
|
83
|
-
buildPiral: {
|
|
84
|
-
debugPiral: {
|
|
85
|
-
watchPiral: {
|
|
96
|
+
buildPilet: { path: '' },
|
|
97
|
+
debugPilet: { path: '' },
|
|
98
|
+
buildPiral: { path: '' },
|
|
99
|
+
debugPiral: { path: '' },
|
|
100
|
+
watchPiral: { path: '' },
|
|
86
101
|
};
|
|
87
102
|
|
|
88
103
|
setBundler({
|
|
@@ -101,11 +116,11 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
101
116
|
|
|
102
117
|
it('setting the bundler can resolve it properly for call piral build', async () => {
|
|
103
118
|
const actions = {
|
|
104
|
-
buildPilet: {
|
|
105
|
-
debugPilet: {
|
|
106
|
-
buildPiral: {
|
|
107
|
-
debugPiral: {
|
|
108
|
-
watchPiral: {
|
|
119
|
+
buildPilet: { path: '1' },
|
|
120
|
+
debugPilet: { path: '2' },
|
|
121
|
+
buildPiral: { path: '3' },
|
|
122
|
+
debugPiral: { path: '4' },
|
|
123
|
+
watchPiral: { path: '5' },
|
|
109
124
|
};
|
|
110
125
|
|
|
111
126
|
setBundler({
|
|
@@ -113,17 +128,18 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
113
128
|
actions: actions as any,
|
|
114
129
|
});
|
|
115
130
|
|
|
116
|
-
|
|
117
|
-
|
|
131
|
+
const args = { root: undefined };
|
|
132
|
+
await callPiralBuild(args as any, 'foo2');
|
|
133
|
+
expect(callStatic).toHaveBeenCalledWith('build-piral', '3', args);
|
|
118
134
|
});
|
|
119
135
|
|
|
120
136
|
it('setting the bundler can resolve it properly for call pilet debug', async () => {
|
|
121
137
|
const actions = {
|
|
122
|
-
buildPilet: {
|
|
123
|
-
debugPilet: {
|
|
124
|
-
buildPiral: {
|
|
125
|
-
debugPiral: {
|
|
126
|
-
watchPiral: {
|
|
138
|
+
buildPilet: { path: '0' },
|
|
139
|
+
debugPilet: { path: '1' },
|
|
140
|
+
buildPiral: { path: '2' },
|
|
141
|
+
debugPiral: { path: '3' },
|
|
142
|
+
watchPiral: { path: '4' },
|
|
127
143
|
};
|
|
128
144
|
|
|
129
145
|
setBundler({
|
|
@@ -131,17 +147,18 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
131
147
|
actions: actions as any,
|
|
132
148
|
});
|
|
133
149
|
|
|
134
|
-
|
|
135
|
-
|
|
150
|
+
const args = { root: undefined };
|
|
151
|
+
await callPiletDebug(args as any, 'foo3');
|
|
152
|
+
expect(callDynamic).toHaveBeenCalledWith('debug-pilet', '1', args);
|
|
136
153
|
});
|
|
137
154
|
|
|
138
155
|
it('setting the bundler can resolve it properly for call piral debug', async () => {
|
|
139
156
|
const actions = {
|
|
140
|
-
buildPilet: {
|
|
141
|
-
debugPilet: {
|
|
142
|
-
buildPiral: {
|
|
143
|
-
debugPiral: {
|
|
144
|
-
watchPiral: {
|
|
157
|
+
buildPilet: { path: '7' },
|
|
158
|
+
debugPilet: { path: '8' },
|
|
159
|
+
buildPiral: { path: '9' },
|
|
160
|
+
debugPiral: { path: '10' },
|
|
161
|
+
watchPiral: { path: '11' },
|
|
145
162
|
};
|
|
146
163
|
|
|
147
164
|
setBundler({
|
|
@@ -149,17 +166,18 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
149
166
|
actions: actions as any,
|
|
150
167
|
});
|
|
151
168
|
|
|
152
|
-
|
|
153
|
-
|
|
169
|
+
const args = { root: undefined };
|
|
170
|
+
await callPiralDebug(args as any, 'foo4');
|
|
171
|
+
expect(callDynamic).toHaveBeenCalledWith('debug-piral', '10', args);
|
|
154
172
|
});
|
|
155
173
|
|
|
156
174
|
it('setting the bundler can resolve it properly for call piral watch', async () => {
|
|
157
175
|
const actions = {
|
|
158
|
-
buildPilet: {
|
|
159
|
-
debugPilet: {
|
|
160
|
-
buildPiral: {
|
|
161
|
-
debugPiral: {
|
|
162
|
-
watchPiral: {
|
|
176
|
+
buildPilet: { path: '3' },
|
|
177
|
+
debugPilet: { path: '4' },
|
|
178
|
+
buildPiral: { path: '5' },
|
|
179
|
+
debugPiral: { path: '6' },
|
|
180
|
+
watchPiral: { path: '7' },
|
|
163
181
|
};
|
|
164
182
|
|
|
165
183
|
setBundler({
|
|
@@ -167,8 +185,9 @@ describe('Piral CLI Bundler Module', () => {
|
|
|
167
185
|
actions: actions as any,
|
|
168
186
|
});
|
|
169
187
|
|
|
170
|
-
|
|
171
|
-
|
|
188
|
+
const args = { root: undefined };
|
|
189
|
+
await callDebugPiralFromMonoRepo(args as any, 'foo5');
|
|
190
|
+
expect(callStatic).toHaveBeenCalledWith('debug-mono-piral', '7', args);
|
|
172
191
|
});
|
|
173
192
|
|
|
174
193
|
it('using a non-available bundler should fail', () => {
|