piral-cli 1.0.0-pre.2217 → 1.0.0
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/LICENSE +1 -1
- package/README.md +30 -7
- package/lib/api.js +23 -23
- package/lib/api.js.map +1 -1
- package/lib/apps/add-piral-instance-pilet.d.ts +26 -0
- package/lib/apps/add-piral-instance-pilet.js +53 -0
- package/lib/apps/add-piral-instance-pilet.js.map +1 -0
- package/lib/apps/build-pilet.d.ts +33 -2
- package/lib/apps/build-pilet.js +159 -32
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/build-piral.d.ts +18 -1
- package/lib/apps/build-piral.js +68 -52
- package/lib/apps/build-piral.js.map +1 -1
- package/lib/apps/debug-pilet.d.ts +38 -2
- package/lib/apps/debug-pilet.js +150 -108
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.d.ts +23 -0
- package/lib/apps/debug-piral.js +63 -52
- 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/index.d.ts +3 -0
- package/lib/apps/index.js +8 -1
- package/lib/apps/index.js.map +1 -1
- package/lib/apps/new-pilet.d.ts +7 -3
- package/lib/apps/new-pilet.js +47 -52
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.d.ts +7 -3
- package/lib/apps/new-piral.js +33 -23
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/pack-pilet.d.ts +9 -0
- package/lib/apps/pack-pilet.js +6 -13
- package/lib/apps/pack-pilet.js.map +1 -1
- package/lib/apps/publish-pilet.d.ts +23 -3
- package/lib/apps/publish-pilet.js +112 -62
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/apps/publish-piral.d.ts +6 -2
- package/lib/apps/publish-piral.js +30 -26
- package/lib/apps/publish-piral.js.map +1 -1
- package/lib/apps/remove-piral-instance-pilet.d.ts +22 -0
- package/lib/apps/remove-piral-instance-pilet.js +52 -0
- package/lib/apps/remove-piral-instance-pilet.js.map +1 -0
- package/lib/apps/run-emulator-piral.d.ts +34 -0
- package/lib/apps/run-emulator-piral.js +91 -0
- package/lib/apps/run-emulator-piral.js.map +1 -0
- package/lib/apps/upgrade-pilet.d.ts +6 -2
- package/lib/apps/upgrade-pilet.js +41 -43
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/apps/upgrade-piral.d.ts +2 -2
- package/lib/apps/upgrade-piral.js +21 -20
- package/lib/apps/upgrade-piral.js.map +1 -1
- package/lib/apps/validate-pilet.js +30 -36
- package/lib/apps/validate-pilet.js.map +1 -1
- package/lib/apps/validate-piral.js +13 -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 +117 -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 +67 -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 +70 -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 +89 -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 +85 -0
- package/lib/build/run-debug-piral.js.map +1 -0
- package/lib/bundler.js +75 -26
- package/lib/bundler.js.map +1 -1
- package/lib/cli.js +7 -4
- package/lib/cli.js.map +1 -1
- package/lib/commands.js +266 -46
- package/lib/commands.js.map +1 -1
- package/lib/common/archive.d.ts +4 -0
- package/lib/common/archive.js +31 -10
- package/lib/common/archive.js.map +1 -1
- package/lib/common/browser.d.ts +2 -1
- package/lib/common/browser.js +17 -8
- package/lib/common/browser.js.map +1 -1
- package/lib/common/clients/index.d.ts +21 -0
- package/lib/common/clients/index.js +48 -0
- package/lib/common/clients/index.js.map +1 -0
- package/lib/common/clients/lerna.d.ts +7 -1
- package/lib/common/clients/lerna.js +93 -7
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.d.ts +6 -1
- package/lib/common/clients/npm.js +66 -18
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnp.d.ts +7 -0
- package/lib/common/clients/pnp.js +104 -0
- package/lib/common/clients/pnp.js.map +1 -0
- package/lib/common/clients/pnpm.d.ts +5 -0
- package/lib/common/clients/pnpm.js +55 -6
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/rush.d.ts +7 -0
- package/lib/common/clients/rush.js +127 -0
- package/lib/common/clients/rush.js.map +1 -0
- package/lib/common/clients/yarn.d.ts +5 -0
- package/lib/common/clients/yarn.js +57 -6
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/compatibility.js +14 -9
- package/lib/common/compatibility.js.map +1 -1
- package/lib/common/config.d.ts +52 -1
- package/lib/common/config.js +10 -30
- package/lib/common/config.js.map +1 -1
- package/lib/common/constants.d.ts +10 -2
- package/lib/common/constants.js +22 -4
- package/lib/common/constants.js.map +1 -1
- package/lib/common/declaration.d.ts +2 -1
- package/lib/common/declaration.js +113 -56
- package/lib/common/declaration.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/emulator.d.ts +2 -2
- package/lib/common/emulator.js +45 -32
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/enums.d.ts +0 -4
- package/lib/common/enums.js +1 -6
- package/lib/common/enums.js.map +1 -1
- package/lib/common/envs.js +16 -5
- 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 +5 -2
- package/lib/common/http.js +65 -23
- package/lib/common/http.js.map +1 -1
- package/lib/common/importmap.d.ts +2 -0
- package/lib/common/importmap.js +202 -0
- package/lib/common/importmap.js.map +1 -0
- package/lib/common/index.d.ts +10 -0
- package/lib/common/index.js +15 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/info.d.ts +5 -0
- package/lib/common/info.js +9 -2
- package/lib/common/info.js.map +1 -1
- package/lib/common/injectors.d.ts +36 -8
- package/lib/common/injectors.js +46 -19
- package/lib/common/injectors.js.map +1 -1
- package/lib/common/inspect.d.ts +5 -3
- package/lib/common/inspect.js +15 -15
- package/lib/common/inspect.js.map +1 -1
- package/lib/common/interactive.d.ts +9 -0
- package/lib/common/interactive.js +60 -1
- package/lib/common/interactive.js.map +1 -1
- package/lib/common/io.d.ts +9 -3
- package/lib/common/io.js +219 -116
- package/lib/common/io.js.map +1 -1
- package/lib/common/language.d.ts +9 -6
- package/lib/common/language.js +68 -12
- package/lib/common/language.js.map +1 -1
- package/lib/common/log.d.ts +5 -3
- package/lib/common/log.js +34 -48
- package/lib/common/log.js.map +1 -1
- package/lib/common/npm.d.ts +17 -16
- package/lib/common/npm.js +262 -158
- package/lib/common/npm.js.map +1 -1
- package/lib/common/pack.js +47 -26
- package/lib/common/pack.js.map +1 -1
- package/lib/common/package.d.ts +43 -20
- package/lib/common/package.js +377 -213
- package/lib/common/package.js.map +1 -1
- package/lib/common/parallel.d.ts +1 -0
- package/lib/common/parallel.js +29 -0
- package/lib/common/parallel.js.map +1 -0
- package/lib/common/patcher.js +20 -20
- package/lib/common/patcher.js.map +1 -1
- package/lib/common/platform.d.ts +13 -0
- package/lib/common/platform.js +29 -0
- package/lib/common/platform.js.map +1 -0
- package/lib/common/port.d.ts +1 -0
- package/lib/common/port.js +14 -4
- 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.d.ts +18 -4
- package/lib/common/scaffold.js +59 -36
- package/lib/common/scaffold.js.map +1 -1
- package/lib/common/scripts.js +8 -8
- package/lib/common/scripts.js.map +1 -1
- package/lib/common/shell.d.ts +2 -0
- package/lib/common/shell.js +33 -0
- package/lib/common/shell.js.map +1 -0
- package/lib/common/spec.d.ts +29 -0
- package/lib/common/spec.js +69 -0
- package/lib/common/spec.js.map +1 -0
- package/lib/common/template.d.ts +1 -2
- package/lib/common/template.js +23 -22
- package/lib/common/template.js.map +1 -1
- package/lib/common/url.d.ts +1 -0
- package/lib/common/url.js +17 -0
- package/lib/common/url.js.map +1 -0
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.js +8 -0
- package/lib/common/utils.js.map +1 -0
- package/lib/common/version.d.ts +2 -0
- package/lib/common/version.js +130 -0
- package/lib/common/version.js.map +1 -0
- package/lib/common/watcher.d.ts +13 -0
- package/lib/common/watcher.js +78 -0
- package/lib/common/watcher.js.map +1 -0
- package/lib/external/index.js +59413 -57862
- package/lib/helpers.d.ts +6 -6
- package/lib/helpers.js +10 -25
- package/lib/helpers.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/inject.js +2 -2
- package/lib/inject.js.map +1 -1
- package/lib/injectors/pilet-injector.d.ts +75 -0
- package/lib/injectors/pilet-injector.js +246 -0
- package/lib/injectors/pilet-injector.js.map +1 -0
- package/lib/injectors/{piral.d.ts → piral-injector.d.ts} +10 -2
- package/lib/injectors/piral-injector.js +97 -0
- package/lib/injectors/piral-injector.js.map +1 -0
- package/lib/messages.d.ts +567 -47
- package/lib/messages.js +638 -51
- 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/platforms/node.d.ts +8 -0
- package/lib/platforms/node.js +30 -0
- package/lib/platforms/node.js.map +1 -0
- package/lib/platforms/web.d.ts +8 -0
- package/lib/platforms/web.js +120 -0
- package/lib/platforms/web.js.map +1 -0
- package/lib/plugin.js +36 -11
- package/lib/plugin.js.map +1 -1
- package/lib/questionnaire.d.ts +1 -1
- package/lib/questionnaire.js +9 -4
- package/lib/questionnaire.js.map +1 -1
- package/lib/release.d.ts +1 -1
- package/lib/release.js +38 -6
- 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 +8 -8
- package/lib/rules/index.js.map +1 -1
- package/lib/rules/pilet-has-externals-as-peers.d.ts +1 -1
- package/lib/rules/pilet-has-externals-as-peers.js +9 -7
- package/lib/rules/pilet-has-externals-as-peers.js.map +1 -1
- package/lib/rules/pilet-has-no-self-reference.d.ts +1 -1
- package/lib/rules/pilet-has-no-self-reference.js +2 -2
- package/lib/rules/pilet-has-no-self-reference.js.map +1 -1
- package/lib/rules/pilet-has-no-third-party-dependency.d.ts +1 -1
- package/lib/rules/pilet-stays-small.d.ts +1 -1
- package/lib/rules/pilet-stays-small.js +4 -4
- package/lib/rules/pilet-stays-small.js.map +1 -1
- package/lib/rules/pilet-uses-latest-piral.d.ts +1 -1
- package/lib/rules/pilet-uses-latest-piral.js +18 -9
- package/lib/rules/pilet-uses-latest-piral.js.map +1 -1
- package/lib/rules/piral-depends-on-piral.d.ts +1 -1
- package/lib/rules/piral-entry-ends-with-html.d.ts +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-devDependencies.d.ts +1 -1
- package/lib/rules/piral-has-valid-externals.d.ts +1 -1
- package/lib/rules/piral-has-valid-externals.js +10 -24
- package/lib/rules/piral-has-valid-externals.js.map +1 -1
- package/lib/rules/piral-has-valid-files.d.ts +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/rules/piral-has-valid-scripts.d.ts +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 +88 -8
- package/lib/types/common.js.map +1 -1
- package/lib/types/index.js +5 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/internal.d.ts +12 -13
- package/lib/types/public.d.ts +89 -23
- package/package.json +19 -16
- package/src/apps/add-piral-instance-pilet.ts +98 -0
- package/src/apps/build-pilet.ts +286 -38
- package/src/apps/build-piral.test.ts +20 -7
- package/src/apps/build-piral.ts +90 -39
- package/src/apps/debug-pilet.ts +229 -123
- package/src/apps/debug-piral.ts +121 -68
- package/src/apps/declaration-piral.ts +4 -2
- package/src/apps/index.ts +3 -0
- package/src/apps/new-pilet.test.ts +28 -11
- package/src/apps/new-pilet.ts +60 -48
- package/src/apps/new-piral.test.ts +25 -13
- package/src/apps/new-piral.ts +43 -19
- package/src/apps/pack-pilet.test.ts +2 -2
- package/src/apps/pack-pilet.ts +12 -10
- package/src/apps/publish-pilet.ts +148 -43
- package/src/apps/publish-piral.ts +38 -11
- package/src/apps/remove-piral-instance-pilet.ts +92 -0
- package/src/apps/run-emulator-piral.ts +154 -0
- package/src/apps/upgrade-pilet.ts +37 -31
- package/src/apps/upgrade-piral.ts +9 -7
- package/src/apps/validate-pilet.ts +30 -22
- package/src/apps/validate-piral.ts +5 -2
- package/src/build/bundler-calls.ts +133 -0
- package/src/build/run-build-pilet.ts +91 -0
- package/src/build/run-build-piral.ts +93 -0
- package/src/build/run-debug-mono-piral.ts +86 -0
- package/src/build/run-debug-pilet.ts +116 -0
- package/src/build/run-debug-piral.ts +105 -0
- package/src/bundler.test.ts +86 -68
- package/src/bundler.ts +74 -19
- package/src/cli.ts +6 -2
- package/src/commands.ts +273 -44
- package/src/common/archive.test.ts +51 -45
- package/src/common/archive.ts +28 -1
- package/src/common/browser.test.ts +20 -10
- package/src/common/browser.ts +13 -6
- package/src/common/clients/index.ts +41 -0
- package/src/common/clients/lerna.ts +85 -1
- package/src/common/clients/npm.ts +56 -14
- package/src/common/clients/pnp.ts +84 -0
- package/src/common/clients/pnpm.ts +45 -1
- package/src/common/clients/rush.ts +118 -0
- package/src/common/clients/yarn.ts +49 -3
- package/src/common/compatibility.ts +8 -1
- package/src/common/config.ts +57 -22
- package/src/common/constants.ts +21 -3
- package/src/common/declaration.ts +124 -50
- package/src/common/emoji.ts +9 -0
- package/src/common/emulator.ts +43 -23
- package/src/common/enums.ts +0 -5
- package/src/common/envs.ts +15 -3
- package/src/common/hash.ts +5 -0
- package/src/common/http.test.ts +76 -64
- package/src/common/http.ts +88 -24
- package/src/common/importmap.ts +242 -0
- package/src/common/index.ts +10 -0
- package/src/common/info.ts +9 -1
- package/src/common/injectors.ts +49 -22
- package/src/common/inspect.ts +13 -14
- package/src/common/interactive.test.ts +6 -0
- package/src/common/interactive.ts +69 -1
- package/src/common/io.ts +199 -82
- package/src/common/language.ts +87 -10
- package/src/common/log.ts +32 -46
- package/src/common/npm.test.ts +187 -166
- package/src/common/npm.ts +263 -119
- package/src/common/pack.test.ts +11 -13
- package/src/common/pack.ts +60 -21
- package/src/common/package.test.ts +59 -49
- package/src/common/package.ts +406 -167
- package/src/common/parallel.test.ts +28 -0
- package/src/common/parallel.ts +21 -0
- package/src/common/platform.ts +31 -0
- package/src/common/port.test.ts +4 -1
- package/src/common/port.ts +10 -0
- package/src/common/rules.test.ts +3 -3
- package/src/common/scaffold.ts +69 -41
- package/src/common/scripts.ts +5 -4
- package/src/common/shell.ts +34 -0
- package/src/common/spec.ts +69 -0
- package/src/common/template.ts +20 -18
- package/src/common/url.test.ts +28 -0
- package/src/common/url.ts +15 -0
- package/src/common/utils.ts +3 -0
- package/src/common/version.test.ts +233 -0
- package/src/common/version.ts +142 -0
- package/src/common/watcher.ts +89 -0
- package/src/external/index.test.ts +2 -2
- package/src/external/index.ts +7 -3
- package/src/external/resolve.ts +29 -0
- package/src/helpers.test.ts +2 -22
- package/src/helpers.ts +21 -30
- package/src/injectors/{pilet.test.ts → pilet-injector.test.ts} +13 -4
- package/src/injectors/pilet-injector.ts +346 -0
- package/src/injectors/{piral.test.ts → piral-injector.test.ts} +14 -5
- package/src/injectors/piral-injector.ts +130 -0
- package/src/messages.ts +649 -63
- package/src/platforms/node.ts +16 -0
- package/src/platforms/web.ts +148 -0
- package/src/plugin.ts +34 -5
- package/src/questionnaire.ts +17 -3
- package/src/release.ts +47 -5
- package/src/rules/index.ts +1 -1
- package/src/rules/pilet-has-externals-as-peers.test.ts +3 -2
- package/src/rules/pilet-has-externals-as-peers.ts +9 -7
- package/src/rules/pilet-has-no-self-reference.ts +1 -1
- package/src/rules/pilet-stays-small.ts +1 -1
- package/src/rules/pilet-uses-latest-piral.ts +22 -12
- package/src/rules/piral-has-valid-externals.ts +10 -29
- package/src/types/common.ts +99 -9
- package/src/types/internal.ts +14 -14
- package/src/types/public.ts +93 -27
- package/lib/external/child.js +0 -144
- package/lib/external/classes.trie +0 -0
- package/lib/external/xdg-open +0 -1066
- package/lib/injectors/pilet.d.ts +0 -47
- package/lib/injectors/pilet.js +0 -187
- package/lib/injectors/pilet.js.map +0 -1
- package/lib/injectors/piral.js +0 -62
- package/lib/injectors/piral.js.map +0 -1
- package/src/injectors/pilet.ts +0 -219
- package/src/injectors/piral.ts +0 -76
- package/templates/piral-index.js.ejs +0 -16
package/src/apps/build-pilet.ts
CHANGED
|
@@ -1,16 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LogLevels, PiletSchemaVersion } from '../types';
|
|
3
|
-
import { callPiletBuild } from '../bundler';
|
|
1
|
+
import { dirname, basename, resolve, relative } from 'path';
|
|
2
|
+
import { LogLevels, PiletBuildType, PiletSchemaVersion } from '../types';
|
|
3
|
+
import { callPiletBuild, callPiralBuild } from '../bundler';
|
|
4
4
|
import {
|
|
5
5
|
removeDirectory,
|
|
6
|
-
findEntryModule,
|
|
7
6
|
retrievePiletData,
|
|
8
7
|
setLogLevel,
|
|
9
8
|
progress,
|
|
10
9
|
logDone,
|
|
11
10
|
logInfo,
|
|
11
|
+
createPiletDeclaration,
|
|
12
|
+
ForceOverwrite,
|
|
13
|
+
matchAnyPilet,
|
|
14
|
+
fail,
|
|
15
|
+
config,
|
|
16
|
+
log,
|
|
17
|
+
writeJson,
|
|
18
|
+
getPiletSpecMeta,
|
|
19
|
+
getFileNames,
|
|
20
|
+
copy,
|
|
21
|
+
checkAppShellPackage,
|
|
22
|
+
cpuCount,
|
|
23
|
+
concurrentWorkers,
|
|
24
|
+
normalizePublicUrl,
|
|
25
|
+
combinePiletExternals,
|
|
26
|
+
retrievePiletsInfo,
|
|
27
|
+
validateSharedDependencies,
|
|
28
|
+
defaultSchemaVersion,
|
|
12
29
|
} from '../common';
|
|
13
30
|
|
|
31
|
+
interface PiletData {
|
|
32
|
+
id: string;
|
|
33
|
+
package: any;
|
|
34
|
+
path: string;
|
|
35
|
+
outFile: string;
|
|
36
|
+
outDir: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function createMetadata(outDir: string, outFile: string, pilets: Array<PiletData>, publicPath: string) {
|
|
40
|
+
return writeJson(
|
|
41
|
+
outDir,
|
|
42
|
+
outFile,
|
|
43
|
+
pilets.map((p) => ({
|
|
44
|
+
name: p.package.name,
|
|
45
|
+
version: p.package.version,
|
|
46
|
+
link: `${publicPath}${p.id}/${p.outFile}`,
|
|
47
|
+
...getPiletSpecMeta(p.path, `${publicPath}${p.id}/`),
|
|
48
|
+
})),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function copyPilets(outDir: string, pilets: Array<PiletData>) {
|
|
53
|
+
return Promise.all(
|
|
54
|
+
pilets.map(async (p) => {
|
|
55
|
+
const files = await getFileNames(p.outDir);
|
|
56
|
+
|
|
57
|
+
for (const file of files) {
|
|
58
|
+
await copy(resolve(p.outDir, file), resolve(outDir, p.id, file), ForceOverwrite.yes);
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
14
64
|
export interface BuildPiletOptions {
|
|
15
65
|
/**
|
|
16
66
|
* Sets the name of the Piral instance.
|
|
@@ -21,7 +71,7 @@ export interface BuildPiletOptions {
|
|
|
21
71
|
* The source index file (e.g. index.tsx) for collecting all the information
|
|
22
72
|
* @example './src/index'
|
|
23
73
|
*/
|
|
24
|
-
entry?: string
|
|
74
|
+
entry?: string | Array<string>;
|
|
25
75
|
|
|
26
76
|
/**
|
|
27
77
|
* The target file of bundling.
|
|
@@ -29,11 +79,26 @@ export interface BuildPiletOptions {
|
|
|
29
79
|
*/
|
|
30
80
|
target?: string;
|
|
31
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Sets the public URL (path) of the bundle. Only for release output.
|
|
84
|
+
*/
|
|
85
|
+
publicUrl?: string;
|
|
86
|
+
|
|
32
87
|
/**
|
|
33
88
|
* States if minifaction or other post-bundle transformations should be performed.
|
|
34
89
|
*/
|
|
35
90
|
minify?: boolean;
|
|
36
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Indicates if a declaration file should be generated.
|
|
94
|
+
*/
|
|
95
|
+
declaration?: boolean;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Sets the maximum number of parallel build processes.
|
|
99
|
+
*/
|
|
100
|
+
concurrency?: number;
|
|
101
|
+
|
|
37
102
|
/**
|
|
38
103
|
* Sets the log level to use (1-5).
|
|
39
104
|
*/
|
|
@@ -49,6 +114,11 @@ export interface BuildPiletOptions {
|
|
|
49
114
|
*/
|
|
50
115
|
sourceMaps?: boolean;
|
|
51
116
|
|
|
117
|
+
/**
|
|
118
|
+
* States if the build should run continuously and re-build when files change.
|
|
119
|
+
*/
|
|
120
|
+
watch?: boolean;
|
|
121
|
+
|
|
52
122
|
/**
|
|
53
123
|
* Sets the bundler to use for building, if any specific.
|
|
54
124
|
*/
|
|
@@ -59,6 +129,11 @@ export interface BuildPiletOptions {
|
|
|
59
129
|
*/
|
|
60
130
|
contentHash?: boolean;
|
|
61
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Selects the target type of the build (e.g. 'release'). "all" builds all target types.
|
|
134
|
+
*/
|
|
135
|
+
type?: PiletBuildType;
|
|
136
|
+
|
|
62
137
|
/**
|
|
63
138
|
* States if the node modules should be included for target transpilation
|
|
64
139
|
*/
|
|
@@ -74,71 +149,244 @@ export interface BuildPiletOptions {
|
|
|
74
149
|
* Additional arguments for a specific bundler.
|
|
75
150
|
*/
|
|
76
151
|
_?: Record<string, any>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Hooks to be triggered at various stages.
|
|
155
|
+
*/
|
|
156
|
+
hooks?: {
|
|
157
|
+
onBegin?(e: any): Promise<void>;
|
|
158
|
+
beforeBuild?(e: any): Promise<void>;
|
|
159
|
+
afterBuild?(e: any): Promise<void>;
|
|
160
|
+
beforeDeclaration?(e: any): Promise<void>;
|
|
161
|
+
afterDeclaration?(e: any): Promise<void>;
|
|
162
|
+
onEnd?(e: any): Promise<void>;
|
|
163
|
+
};
|
|
77
164
|
}
|
|
78
165
|
|
|
79
166
|
export const buildPiletDefaults: BuildPiletOptions = {
|
|
80
167
|
entry: './src/index',
|
|
81
168
|
target: './dist/index.js',
|
|
169
|
+
publicUrl: '/',
|
|
82
170
|
minify: true,
|
|
83
171
|
logLevel: LogLevels.info,
|
|
172
|
+
type: 'default',
|
|
84
173
|
fresh: false,
|
|
85
174
|
sourceMaps: true,
|
|
175
|
+
watch: false,
|
|
86
176
|
contentHash: true,
|
|
87
177
|
optimizeModules: false,
|
|
88
|
-
schemaVersion:
|
|
178
|
+
schemaVersion: undefined,
|
|
179
|
+
concurrency: cpuCount,
|
|
180
|
+
declaration: true,
|
|
89
181
|
};
|
|
90
182
|
|
|
91
183
|
export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOptions = {}) {
|
|
92
184
|
const {
|
|
93
185
|
entry = buildPiletDefaults.entry,
|
|
94
186
|
target = buildPiletDefaults.target,
|
|
187
|
+
publicUrl: originalPublicUrl = buildPiletDefaults.publicUrl,
|
|
188
|
+
logLevel = buildPiletDefaults.logLevel,
|
|
95
189
|
minify = buildPiletDefaults.minify,
|
|
96
190
|
sourceMaps = buildPiletDefaults.sourceMaps,
|
|
191
|
+
watch = buildPiletDefaults.watch,
|
|
97
192
|
contentHash = buildPiletDefaults.contentHash,
|
|
98
|
-
logLevel = buildPiletDefaults.logLevel,
|
|
99
193
|
fresh = buildPiletDefaults.fresh,
|
|
194
|
+
concurrency = buildPiletDefaults.concurrency,
|
|
100
195
|
optimizeModules = buildPiletDefaults.optimizeModules,
|
|
101
|
-
schemaVersion = buildPiletDefaults.schemaVersion,
|
|
196
|
+
schemaVersion: originalSchemaVersion = buildPiletDefaults.schemaVersion,
|
|
197
|
+
declaration = buildPiletDefaults.declaration,
|
|
198
|
+
type = buildPiletDefaults.type,
|
|
102
199
|
_ = {},
|
|
200
|
+
hooks = {},
|
|
103
201
|
bundlerName,
|
|
104
202
|
app,
|
|
105
203
|
} = options;
|
|
204
|
+
const publicUrl = normalizePublicUrl(originalPublicUrl);
|
|
205
|
+
const fullBase = resolve(process.cwd(), baseDir);
|
|
206
|
+
const entryList = Array.isArray(entry) ? entry : [entry];
|
|
106
207
|
setLogLevel(logLevel);
|
|
208
|
+
|
|
209
|
+
await hooks.onBegin?.({ options, fullBase });
|
|
107
210
|
progress('Reading configuration ...');
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const outDir = dirname(resolve(baseDir, target));
|
|
114
|
-
|
|
115
|
-
if (fresh) {
|
|
116
|
-
progress('Removing output directory ...');
|
|
117
|
-
await removeDirectory(outDir);
|
|
211
|
+
const allEntries = await matchAnyPilet(fullBase, entryList);
|
|
212
|
+
log('generalDebug_0003', `Found the following entries: ${allEntries.join(', ')}`);
|
|
213
|
+
|
|
214
|
+
if (allEntries.length === 0) {
|
|
215
|
+
fail('entryFileMissing_0077');
|
|
118
216
|
}
|
|
119
217
|
|
|
120
|
-
|
|
218
|
+
const pilets = await concurrentWorkers(allEntries, concurrency, async (entryModule) => {
|
|
219
|
+
const targetDir = dirname(entryModule);
|
|
220
|
+
const { peerDependencies, peerModules, root, apps, piletPackage, ignored, importmap, schema } = await retrievePiletData(
|
|
221
|
+
targetDir,
|
|
222
|
+
app,
|
|
223
|
+
);
|
|
224
|
+
const schemaVersion = originalSchemaVersion || schema || config.schemaVersion || defaultSchemaVersion;
|
|
225
|
+
const piralInstances = apps.map(m => m.appPackage.name);
|
|
226
|
+
const externals = combinePiletExternals(piralInstances, peerDependencies, peerModules, importmap);
|
|
227
|
+
const dest = resolve(root, target);
|
|
228
|
+
const outDir = dirname(dest);
|
|
229
|
+
const outFile = basename(dest);
|
|
230
|
+
|
|
231
|
+
validateSharedDependencies(importmap);
|
|
232
|
+
|
|
233
|
+
if (fresh) {
|
|
234
|
+
progress('Removing output directory ...');
|
|
235
|
+
await removeDirectory(outDir);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
logInfo('Bundle pilet ...');
|
|
239
|
+
|
|
240
|
+
await hooks.beforeBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
|
|
241
|
+
|
|
242
|
+
await callPiletBuild(
|
|
243
|
+
{
|
|
244
|
+
root,
|
|
245
|
+
piralInstances,
|
|
246
|
+
optimizeModules,
|
|
247
|
+
sourceMaps,
|
|
248
|
+
watch,
|
|
249
|
+
contentHash,
|
|
250
|
+
minify,
|
|
251
|
+
externals,
|
|
252
|
+
targetDir,
|
|
253
|
+
importmap,
|
|
254
|
+
outFile,
|
|
255
|
+
outDir,
|
|
256
|
+
entryModule: `./${relative(root, entryModule)}`,
|
|
257
|
+
logLevel,
|
|
258
|
+
version: schemaVersion,
|
|
259
|
+
ignored,
|
|
260
|
+
_,
|
|
261
|
+
},
|
|
262
|
+
bundlerName,
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
await hooks.afterBuild?.({ root, outDir, importmap, entryModule, schemaVersion, piletPackage });
|
|
266
|
+
|
|
267
|
+
if (declaration) {
|
|
268
|
+
await hooks.beforeDeclaration?.({ root, outDir, entryModule, piletPackage });
|
|
269
|
+
await createPiletDeclaration(
|
|
270
|
+
piletPackage.name,
|
|
271
|
+
root,
|
|
272
|
+
entryModule,
|
|
273
|
+
externals,
|
|
274
|
+
outDir,
|
|
275
|
+
ForceOverwrite.yes,
|
|
276
|
+
logLevel,
|
|
277
|
+
);
|
|
278
|
+
await hooks.afterDeclaration?.({ root, outDir, entryModule, piletPackage });
|
|
279
|
+
}
|
|
121
280
|
|
|
122
|
-
|
|
123
|
-
|
|
281
|
+
logDone(`Pilet "${piletPackage.name}" built successfully!`);
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
id: piletPackage.name.replace(/[^a-zA-Z0-9\-]/gi, ''),
|
|
124
285
|
root,
|
|
125
|
-
|
|
126
|
-
optimizeModules,
|
|
127
|
-
sourceMaps,
|
|
128
|
-
contentHash,
|
|
129
|
-
minify,
|
|
130
|
-
externals,
|
|
131
|
-
targetDir,
|
|
132
|
-
outFile: basename(target),
|
|
286
|
+
apps,
|
|
133
287
|
outDir,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
288
|
+
outFile,
|
|
289
|
+
path: dest,
|
|
290
|
+
package: piletPackage,
|
|
291
|
+
};
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
if (type === 'standalone') {
|
|
295
|
+
const distDir = dirname(resolve(fullBase, target));
|
|
296
|
+
const outDir = resolve(distDir, 'standalone');
|
|
297
|
+
const { apps, root } = pilets[0];
|
|
298
|
+
|
|
299
|
+
if (apps.length === 0) {
|
|
300
|
+
fail('appInstancesNotGiven_0012');
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const { appPackage, appFile } = apps[0];
|
|
304
|
+
const piralInstances = [appPackage.name];
|
|
305
|
+
const isEmulator = checkAppShellPackage(appPackage);
|
|
306
|
+
|
|
307
|
+
logInfo('Building standalone solution ...');
|
|
308
|
+
|
|
309
|
+
await removeDirectory(outDir);
|
|
310
|
+
|
|
311
|
+
progress('Copying files ...');
|
|
312
|
+
|
|
313
|
+
await copyPilets(outDir, pilets);
|
|
314
|
+
|
|
315
|
+
await createMetadata(outDir, '$pilet-api', pilets, publicUrl);
|
|
316
|
+
|
|
317
|
+
if (isEmulator) {
|
|
318
|
+
// in case of an emulator assets are not "seen" by the bundler, so we
|
|
319
|
+
// just copy overthing over - this should work in most cases.
|
|
320
|
+
await copy(dirname(appFile), outDir, ForceOverwrite.yes);
|
|
321
|
+
progress('Optimizing app shell ...');
|
|
322
|
+
|
|
323
|
+
// we don't need to care about externals or other things that are already
|
|
324
|
+
// part of the emulator
|
|
325
|
+
await callPiralBuild(
|
|
326
|
+
{
|
|
327
|
+
root,
|
|
328
|
+
piralInstances,
|
|
329
|
+
emulator: false,
|
|
330
|
+
standalone: true,
|
|
331
|
+
optimizeModules: false,
|
|
332
|
+
sourceMaps,
|
|
333
|
+
watch: false,
|
|
334
|
+
contentHash,
|
|
335
|
+
minify,
|
|
336
|
+
externals: [],
|
|
337
|
+
publicUrl,
|
|
338
|
+
outFile: 'index.html',
|
|
339
|
+
outDir,
|
|
340
|
+
entryFiles: appFile,
|
|
341
|
+
logLevel,
|
|
342
|
+
ignored: [],
|
|
343
|
+
_,
|
|
344
|
+
},
|
|
345
|
+
bundlerName,
|
|
346
|
+
);
|
|
347
|
+
} else {
|
|
348
|
+
// in this case we can just do the same steps as if
|
|
349
|
+
const { ignored, externals } = await retrievePiletsInfo(appFile);
|
|
350
|
+
|
|
351
|
+
await callPiralBuild(
|
|
352
|
+
{
|
|
353
|
+
root,
|
|
354
|
+
piralInstances,
|
|
355
|
+
emulator: false,
|
|
356
|
+
standalone: true,
|
|
357
|
+
optimizeModules: false,
|
|
358
|
+
sourceMaps,
|
|
359
|
+
watch: false,
|
|
360
|
+
contentHash,
|
|
361
|
+
minify,
|
|
362
|
+
externals: externals.map(m => m.name),
|
|
363
|
+
publicUrl,
|
|
364
|
+
outFile: 'index.html',
|
|
365
|
+
outDir,
|
|
366
|
+
entryFiles: appFile,
|
|
367
|
+
logLevel,
|
|
368
|
+
ignored,
|
|
369
|
+
_,
|
|
370
|
+
},
|
|
371
|
+
bundlerName,
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
logDone(`Standalone app available at "${outDir}"!`);
|
|
376
|
+
} else if (type === 'manifest') {
|
|
377
|
+
const manifest = 'pilets.json';
|
|
378
|
+
const outDir = dirname(resolve(fullBase, target));
|
|
379
|
+
|
|
380
|
+
logInfo('Building pilet manifest ...');
|
|
381
|
+
|
|
382
|
+
progress('Copying files ...');
|
|
383
|
+
|
|
384
|
+
await copyPilets(outDir, pilets);
|
|
385
|
+
|
|
386
|
+
await createMetadata(outDir, manifest, pilets, publicUrl);
|
|
387
|
+
|
|
388
|
+
logDone(`Manifest available at "${outDir}/${manifest}"!`);
|
|
389
|
+
}
|
|
142
390
|
|
|
143
|
-
|
|
391
|
+
await hooks.onEnd?.({});
|
|
144
392
|
}
|
|
@@ -16,16 +16,21 @@ const defaultPackageJson = (files: Array<any>) => `
|
|
|
16
16
|
"piral"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"piral-base": "*",
|
|
20
|
+
"piral-core": "*",
|
|
19
21
|
"piral": "*"
|
|
20
22
|
},
|
|
21
23
|
"scripts": {
|
|
22
24
|
"start": "piral debug",
|
|
23
25
|
"build": "piral build"
|
|
24
26
|
},
|
|
27
|
+
"importmap": {
|
|
28
|
+
"imports": {},
|
|
29
|
+
"inherit": ["piral-base", "piral-core"]
|
|
30
|
+
},
|
|
25
31
|
"app": "./src/index.html",
|
|
26
32
|
"pilets": {
|
|
27
33
|
"files": ${JSON.stringify(files)},
|
|
28
|
-
"externals": [],
|
|
29
34
|
"scripts": {
|
|
30
35
|
"build": "npm run build-pilet",
|
|
31
36
|
"start": "npm run debug-pilet"
|
|
@@ -43,7 +48,6 @@ const defaultPackageJson = (files: Array<any>) => `
|
|
|
43
48
|
"@types/react-dom": "latest",
|
|
44
49
|
"@types/react-router": "latest",
|
|
45
50
|
"@types/react-router-dom": "latest",
|
|
46
|
-
"piral-cli": "*",
|
|
47
51
|
"typescript": "latest"
|
|
48
52
|
}
|
|
49
53
|
}
|
|
@@ -60,13 +64,17 @@ const defaultIndexHtml = `
|
|
|
60
64
|
`;
|
|
61
65
|
|
|
62
66
|
const defaultIndexTsx = `
|
|
63
|
-
import
|
|
67
|
+
import * as React from 'react';
|
|
68
|
+
import { render } from 'react-dom';
|
|
69
|
+
import { createInstance, Piral } from 'piral';
|
|
64
70
|
|
|
65
|
-
|
|
71
|
+
const instance = createInstance({
|
|
66
72
|
requestPilets() {
|
|
67
73
|
return Promise.resolve([]);
|
|
68
74
|
},
|
|
69
75
|
});
|
|
76
|
+
|
|
77
|
+
render(<Piral instance={instance} />, document.querySelector('#app'));
|
|
70
78
|
`;
|
|
71
79
|
|
|
72
80
|
const tsConfigJson = `
|
|
@@ -107,7 +115,7 @@ function scaffoldNewPiralInstance(files: Array<any> = []) {
|
|
|
107
115
|
writeFileSync(resolve(dir, 'src/index.html'), defaultIndexHtml, 'utf8');
|
|
108
116
|
writeFileSync(resolve(dir, 'src/index.tsx'), defaultIndexTsx, 'utf8');
|
|
109
117
|
|
|
110
|
-
execSync('npm i', {
|
|
118
|
+
execSync('npm i --legacy-peer-deps', {
|
|
111
119
|
cwd: dir,
|
|
112
120
|
});
|
|
113
121
|
|
|
@@ -116,12 +124,17 @@ function scaffoldNewPiralInstance(files: Array<any> = []) {
|
|
|
116
124
|
|
|
117
125
|
describe('Build Piral Command', () => {
|
|
118
126
|
beforeEach(() => {
|
|
127
|
+
process.env.NODE_ENV = undefined;
|
|
119
128
|
setBundler({
|
|
120
|
-
name: '
|
|
121
|
-
actions: require(resolve(__dirname, '../../../piral-cli-
|
|
129
|
+
name: 'webpack5',
|
|
130
|
+
actions: require(resolve(__dirname, '../../../piral-cli-webpack5/lib/actions')),
|
|
122
131
|
});
|
|
123
132
|
});
|
|
124
133
|
|
|
134
|
+
afterEach(() => {
|
|
135
|
+
process.env.NODE_ENV = 'test';
|
|
136
|
+
});
|
|
137
|
+
|
|
125
138
|
it('missing source should result in an error', async () => {
|
|
126
139
|
const dir = createTempDir();
|
|
127
140
|
let error = false;
|