piral-cli 1.0.0-pre.2296 → 1.0.1-beta.5640
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/debug-pilet.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import { join, dirname, resolve } from 'path';
|
|
2
|
-
import { readKrasConfig, krasrc, buildKrasWithCli, defaultConfig } from 'kras';
|
|
1
|
+
import { join, dirname, resolve, relative, basename } from 'path';
|
|
3
2
|
import { callDebugPiralFromMonoRepo, callPiletDebug } from '../bundler';
|
|
4
|
-
import { LogLevels, PiletSchemaVersion } from '../types';
|
|
3
|
+
import { AppDefinition, LogLevels, PiletSchemaVersion } from '../types';
|
|
5
4
|
import {
|
|
6
5
|
checkExistingDirectory,
|
|
7
6
|
retrievePiletData,
|
|
7
|
+
retrievePiletsInfo,
|
|
8
8
|
config,
|
|
9
|
-
openBrowser,
|
|
10
|
-
reorderInjectors,
|
|
11
|
-
notifyServerOnline,
|
|
12
|
-
findEntryModule,
|
|
13
9
|
setLogLevel,
|
|
14
10
|
progress,
|
|
15
|
-
|
|
11
|
+
matchAnyPilet,
|
|
16
12
|
fail,
|
|
17
13
|
log,
|
|
14
|
+
logDone,
|
|
15
|
+
cpuCount,
|
|
16
|
+
concurrentWorkers,
|
|
17
|
+
normalizePublicUrl,
|
|
18
|
+
combinePiletExternals,
|
|
19
|
+
watcherTask,
|
|
20
|
+
flattenExternals,
|
|
21
|
+
validateSharedDependencies,
|
|
22
|
+
configurePlatform,
|
|
23
|
+
packageJson,
|
|
24
|
+
piletJson,
|
|
25
|
+
defaultSchemaVersion,
|
|
18
26
|
} from '../common';
|
|
19
27
|
|
|
20
28
|
export interface DebugPiletOptions {
|
|
@@ -28,12 +36,24 @@ export interface DebugPiletOptions {
|
|
|
28
36
|
*/
|
|
29
37
|
entry?: string | Array<string>;
|
|
30
38
|
|
|
39
|
+
/**
|
|
40
|
+
* The target file of bundling.
|
|
41
|
+
* @example './dist/index.js'
|
|
42
|
+
*/
|
|
43
|
+
target?: string;
|
|
44
|
+
|
|
31
45
|
/**
|
|
32
46
|
* Overrides the name of the app shell to use.
|
|
33
47
|
* By default the app is inferred from the package.json.
|
|
34
48
|
*/
|
|
35
49
|
app?: string;
|
|
36
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Overrides the directory of the app to serve when
|
|
53
|
+
* debugging.
|
|
54
|
+
*/
|
|
55
|
+
appInstanceDir?: string;
|
|
56
|
+
|
|
37
57
|
/**
|
|
38
58
|
* Sets if the (system default) browser should be auto-opened.
|
|
39
59
|
*/
|
|
@@ -44,6 +64,17 @@ export interface DebugPiletOptions {
|
|
|
44
64
|
*/
|
|
45
65
|
port?: number;
|
|
46
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Sets the publicUrl to use.
|
|
69
|
+
* By default, the server is assumed to be at root "/".
|
|
70
|
+
*/
|
|
71
|
+
publicUrl?: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Sets the maximum number of parallel build processes.
|
|
75
|
+
*/
|
|
76
|
+
concurrency?: number;
|
|
77
|
+
|
|
47
78
|
/**
|
|
48
79
|
* Defines if hot module reloading (HMR) should be integrated for faster debugging.
|
|
49
80
|
*/
|
|
@@ -54,6 +85,11 @@ export interface DebugPiletOptions {
|
|
|
54
85
|
*/
|
|
55
86
|
bundlerName?: string;
|
|
56
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Sets the relative path to the krasrc, if any.
|
|
90
|
+
*/
|
|
91
|
+
krasrc?: string;
|
|
92
|
+
|
|
57
93
|
/**
|
|
58
94
|
* States if the node modules should be included for target transpilation
|
|
59
95
|
*/
|
|
@@ -66,65 +102,104 @@ export interface DebugPiletOptions {
|
|
|
66
102
|
schemaVersion?: PiletSchemaVersion;
|
|
67
103
|
|
|
68
104
|
/**
|
|
69
|
-
* The URL of a pilet feed used to include locally missing pilets.
|
|
105
|
+
* The URL of a pilet feed(s) used to include locally missing pilets.
|
|
70
106
|
*/
|
|
71
|
-
feed?: string
|
|
107
|
+
feed?: string | Array<string>;
|
|
72
108
|
|
|
73
109
|
/**
|
|
74
110
|
* Additional arguments for a specific bundler.
|
|
75
111
|
*/
|
|
76
112
|
_?: Record<string, any>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Hooks to be triggered at various stages.
|
|
116
|
+
*/
|
|
117
|
+
hooks?: {
|
|
118
|
+
onBegin?(e: any): Promise<void>;
|
|
119
|
+
beforeBuild?(e: any): Promise<void>;
|
|
120
|
+
afterBuild?(e: any): Promise<void>;
|
|
121
|
+
beforeApp?(e: any): Promise<void>;
|
|
122
|
+
afterApp?(e: any): Promise<void>;
|
|
123
|
+
beforeOnline?(e: any): Promise<void>;
|
|
124
|
+
afterOnline?(e: any): Promise<void>;
|
|
125
|
+
onEnd?(e: any): Promise<void>;
|
|
126
|
+
};
|
|
77
127
|
}
|
|
78
128
|
|
|
79
129
|
export const debugPiletDefaults: DebugPiletOptions = {
|
|
80
130
|
logLevel: LogLevels.info,
|
|
131
|
+
target: './dist/index.js',
|
|
81
132
|
entry: './src/index',
|
|
82
|
-
open:
|
|
83
|
-
port:
|
|
133
|
+
open: config.openBrowser,
|
|
134
|
+
port: config.port,
|
|
135
|
+
publicUrl: '/',
|
|
84
136
|
hmr: true,
|
|
137
|
+
krasrc: undefined,
|
|
85
138
|
optimizeModules: false,
|
|
86
|
-
schemaVersion:
|
|
139
|
+
schemaVersion: undefined,
|
|
140
|
+
concurrency: cpuCount,
|
|
87
141
|
};
|
|
88
142
|
|
|
89
|
-
const injectorName = resolve(__dirname, '../injectors/pilet.js');
|
|
90
|
-
|
|
91
143
|
interface AppInfo {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
144
|
+
apps: Array<AppDefinition>;
|
|
145
|
+
root: string;
|
|
146
|
+
mocks: string;
|
|
147
|
+
publicUrl: string;
|
|
95
148
|
externals: Array<string>;
|
|
96
|
-
piral: string;
|
|
97
149
|
}
|
|
98
150
|
|
|
99
|
-
|
|
100
|
-
if (!emulator) {
|
|
101
|
-
const packageJson = require.resolve(`${piral}/package.json`);
|
|
102
|
-
const cwd = resolve(packageJson, '..');
|
|
103
|
-
const { dir } = await callDebugPiralFromMonoRepo({
|
|
104
|
-
root: cwd,
|
|
105
|
-
optimizeModules: false,
|
|
106
|
-
ignored: [],
|
|
107
|
-
externals,
|
|
108
|
-
piral,
|
|
109
|
-
entryFiles: appFile,
|
|
110
|
-
logLevel,
|
|
111
|
-
_: {},
|
|
112
|
-
});
|
|
113
|
-
return dir;
|
|
114
|
-
}
|
|
151
|
+
type PiralInstanceInfo = [appDir: string, appPort: number];
|
|
115
152
|
|
|
116
|
-
|
|
153
|
+
function byPort(a: PiralInstanceInfo, b: PiralInstanceInfo) {
|
|
154
|
+
return a[1] - b[1];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function getOrMakeApps({ apps, publicUrl }: AppInfo, logLevel: LogLevels) {
|
|
158
|
+
return Promise.all(
|
|
159
|
+
apps.map(async ({ emulator, appFile, appPackage, appPort }): Promise<PiralInstanceInfo> => {
|
|
160
|
+
if (!emulator) {
|
|
161
|
+
const piralInstances = [appPackage.name];
|
|
162
|
+
const { externals, root, ignored } = await retrievePiletsInfo(appFile);
|
|
163
|
+
const { dir } = await callDebugPiralFromMonoRepo({
|
|
164
|
+
root,
|
|
165
|
+
optimizeModules: false,
|
|
166
|
+
publicUrl,
|
|
167
|
+
ignored,
|
|
168
|
+
externals: flattenExternals(externals),
|
|
169
|
+
piralInstances,
|
|
170
|
+
entryFiles: appFile,
|
|
171
|
+
logLevel,
|
|
172
|
+
_: {},
|
|
173
|
+
});
|
|
174
|
+
return [dir, appPort];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return [dirname(appFile), appPort];
|
|
178
|
+
}),
|
|
179
|
+
);
|
|
117
180
|
}
|
|
118
181
|
|
|
119
182
|
function checkSanity(pilets: Array<AppInfo>) {
|
|
120
183
|
for (let i = 1; i < pilets.length; i++) {
|
|
121
184
|
const previous = pilets[i - 1];
|
|
122
185
|
const current = pilets[i];
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
186
|
+
const previousInstances = previous.apps;
|
|
187
|
+
const currentInstances = current.apps;
|
|
188
|
+
const previousInstancesNames = previousInstances
|
|
189
|
+
.map((m) => m.appPackage.name)
|
|
190
|
+
.sort()
|
|
191
|
+
.join(', ');
|
|
192
|
+
const currentInstancesNames = currentInstances
|
|
193
|
+
.map((m) => m.appPackage.name)
|
|
194
|
+
.sort()
|
|
195
|
+
.join(', ');
|
|
196
|
+
const previousInstancesVersions = previousInstances.map((m) => m.appPackage.version).join(', ');
|
|
197
|
+
const currentInstancesVersions = currentInstances.map((m) => m.appPackage.version).join(', ');
|
|
198
|
+
|
|
199
|
+
if (previousInstancesNames !== currentInstancesNames) {
|
|
200
|
+
return log('piletMultiDebugAppShellDifferent_0301', previousInstancesNames, currentInstancesNames);
|
|
201
|
+
} else if (previousInstancesVersions !== currentInstancesVersions) {
|
|
202
|
+
return log('piletMultiDebugAppShellVersions_0302', previousInstancesVersions, currentInstancesVersions);
|
|
128
203
|
} else if (previous.externals.length !== current.externals.length) {
|
|
129
204
|
return log('piletMultiDebugExternalsDifferent_0303', previous.externals, current.externals);
|
|
130
205
|
} else if (previous.externals.some((m) => !current.externals.includes(m))) {
|
|
@@ -136,65 +211,84 @@ function checkSanity(pilets: Array<AppInfo>) {
|
|
|
136
211
|
export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOptions = {}) {
|
|
137
212
|
const {
|
|
138
213
|
entry = debugPiletDefaults.entry,
|
|
139
|
-
|
|
214
|
+
target = debugPiletDefaults.target,
|
|
140
215
|
open = debugPiletDefaults.open,
|
|
141
216
|
hmr = debugPiletDefaults.hmr,
|
|
217
|
+
port: originalPort = debugPiletDefaults.port,
|
|
218
|
+
publicUrl: originalPublicUrl = debugPiletDefaults.publicUrl,
|
|
142
219
|
logLevel = debugPiletDefaults.logLevel,
|
|
220
|
+
concurrency = debugPiletDefaults.concurrency,
|
|
221
|
+
krasrc: customkrasrc = debugPiletDefaults.krasrc,
|
|
143
222
|
optimizeModules = debugPiletDefaults.optimizeModules,
|
|
144
|
-
schemaVersion = debugPiletDefaults.schemaVersion,
|
|
223
|
+
schemaVersion: originalSchemaVersion = debugPiletDefaults.schemaVersion,
|
|
145
224
|
_ = {},
|
|
225
|
+
hooks = {},
|
|
146
226
|
bundlerName,
|
|
147
227
|
app,
|
|
228
|
+
appInstanceDir,
|
|
148
229
|
feed,
|
|
149
230
|
} = options;
|
|
231
|
+
const publicUrl = normalizePublicUrl(originalPublicUrl);
|
|
232
|
+
const fullBase = resolve(process.cwd(), baseDir);
|
|
150
233
|
setLogLevel(logLevel);
|
|
151
|
-
progress('Reading configuration ...');
|
|
152
|
-
const krasConfig = readKrasConfig({ port }, krasrc);
|
|
153
|
-
const api = config.piletApi;
|
|
154
|
-
const entryList = Array.isArray(entry) ? entry : [entry];
|
|
155
|
-
const multi = entryList.length > 1 || entryList[0].indexOf('*') !== -1;
|
|
156
|
-
log('generalDebug_0003', `Looking for (${multi ? 'multi' : 'single'}) "${entryList.join('", "')}" in "${baseDir}".`);
|
|
157
|
-
const allEntries = multi ? await matchAny(baseDir, entryList) : entryList;
|
|
158
|
-
log('generalDebug_0003', `Found the following entries: ${allEntries.join(', ')}`);
|
|
159
|
-
|
|
160
|
-
if (krasConfig.sources === undefined) {
|
|
161
|
-
krasConfig.sources = [];
|
|
162
|
-
}
|
|
163
234
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
235
|
+
await hooks.onBegin?.({ options, fullBase });
|
|
236
|
+
|
|
237
|
+
const watcherRef = await watcherTask(async (watcherContext) => {
|
|
238
|
+
progress('Reading configuration ...');
|
|
239
|
+
const entryList = Array.isArray(entry) ? entry : [entry];
|
|
240
|
+
const multi = entryList.length > 1 || entryList[0].indexOf('*') !== -1;
|
|
241
|
+
log(
|
|
242
|
+
'generalDebug_0003',
|
|
243
|
+
`Looking for (${multi ? 'multi' : 'single'}) "${entryList.join('", "')}" in "${fullBase}".`,
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
const allEntries = await matchAnyPilet(fullBase, entryList);
|
|
247
|
+
const maxListeners = Math.max(2 + allEntries.length * 2, 16);
|
|
248
|
+
log('generalDebug_0003', `Found the following entries: ${allEntries.join(', ')}`);
|
|
249
|
+
|
|
250
|
+
if (allEntries.length === 0) {
|
|
251
|
+
fail('entryFileMissing_0077');
|
|
252
|
+
}
|
|
167
253
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const
|
|
254
|
+
process.stderr?.setMaxListeners(maxListeners);
|
|
255
|
+
process.stdout?.setMaxListeners(maxListeners);
|
|
256
|
+
process.stdin?.setMaxListeners(maxListeners);
|
|
257
|
+
|
|
258
|
+
const pilets = await concurrentWorkers(allEntries, concurrency, async (entryModule) => {
|
|
259
|
+
const targetDir = dirname(entryModule);
|
|
260
|
+
const { peerDependencies, peerModules, root, apps, ignored, importmap, schema } = await retrievePiletData(
|
|
174
261
|
targetDir,
|
|
175
262
|
app,
|
|
176
263
|
);
|
|
177
|
-
const
|
|
264
|
+
const schemaVersion = originalSchemaVersion || schema || config.schemaVersion || defaultSchemaVersion;
|
|
265
|
+
const piralInstances = apps.map((m) => m.appPackage.name);
|
|
266
|
+
const externals = combinePiletExternals(piralInstances, peerDependencies, peerModules, importmap);
|
|
178
267
|
const mocks = join(targetDir, 'mocks');
|
|
179
|
-
const
|
|
268
|
+
const dest = resolve(root, target);
|
|
269
|
+
const outDir = dirname(dest);
|
|
270
|
+
const outFile = basename(dest);
|
|
271
|
+
const mocksExists = await checkExistingDirectory(mocks);
|
|
180
272
|
|
|
181
|
-
|
|
182
|
-
if (krasConfig.directory === undefined) {
|
|
183
|
-
krasConfig.directory = mocks;
|
|
184
|
-
}
|
|
273
|
+
validateSharedDependencies(importmap);
|
|
185
274
|
|
|
186
|
-
|
|
187
|
-
|
|
275
|
+
await hooks.beforeBuild?.({ root, publicUrl, importmap, entryModule, schemaVersion });
|
|
276
|
+
|
|
277
|
+
watcherContext.watch(join(root, packageJson));
|
|
278
|
+
watcherContext.watch(join(root, piletJson));
|
|
188
279
|
|
|
189
280
|
const bundler = await callPiletDebug(
|
|
190
281
|
{
|
|
191
282
|
root,
|
|
192
|
-
|
|
283
|
+
piralInstances,
|
|
193
284
|
optimizeModules,
|
|
194
285
|
hmr,
|
|
195
286
|
externals,
|
|
196
287
|
targetDir,
|
|
197
|
-
|
|
288
|
+
importmap,
|
|
289
|
+
outFile,
|
|
290
|
+
outDir,
|
|
291
|
+
entryModule: `./${relative(root, entryModule)}`,
|
|
198
292
|
logLevel,
|
|
199
293
|
version: schemaVersion,
|
|
200
294
|
ignored,
|
|
@@ -203,65 +297,77 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
|
|
|
203
297
|
bundlerName,
|
|
204
298
|
);
|
|
205
299
|
|
|
300
|
+
bundler.on((args) => {
|
|
301
|
+
hooks.afterBuild?.({
|
|
302
|
+
...args,
|
|
303
|
+
root,
|
|
304
|
+
publicUrl,
|
|
305
|
+
importmap,
|
|
306
|
+
entryModule,
|
|
307
|
+
schemaVersion,
|
|
308
|
+
bundler,
|
|
309
|
+
outFile,
|
|
310
|
+
outDir,
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
|
|
206
314
|
return {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
appVersion: appPackage.version,
|
|
315
|
+
apps,
|
|
316
|
+
publicUrl,
|
|
210
317
|
externals,
|
|
211
|
-
piral: appPackage.name,
|
|
212
318
|
bundler,
|
|
319
|
+
mocks: mocksExists ? mocks : undefined,
|
|
213
320
|
root,
|
|
214
321
|
};
|
|
215
|
-
})
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
// sanity check see #250
|
|
219
|
-
checkSanity(pilets);
|
|
220
|
-
|
|
221
|
-
const appDir = await getOrMakeAppDir(pilets[0], logLevel);
|
|
222
|
-
|
|
223
|
-
if (krasConfig.ssl === undefined) {
|
|
224
|
-
krasConfig.ssl = undefined;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (krasConfig.map === undefined) {
|
|
228
|
-
krasConfig.map = {};
|
|
229
|
-
}
|
|
322
|
+
});
|
|
230
323
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
324
|
+
// sanity check see #250
|
|
325
|
+
checkSanity(pilets);
|
|
234
326
|
|
|
235
|
-
|
|
236
|
-
krasConfig.injectors = defaultConfig.injectors;
|
|
237
|
-
}
|
|
327
|
+
await hooks.beforeApp?.({ appInstanceDir, pilets });
|
|
238
328
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
app: appDir,
|
|
243
|
-
handle: ['/', api],
|
|
244
|
-
api,
|
|
245
|
-
feed,
|
|
246
|
-
};
|
|
329
|
+
const appInstances: Array<PiralInstanceInfo> = appInstanceDir
|
|
330
|
+
? [[appInstanceDir, 0]]
|
|
331
|
+
: await getOrMakeApps(pilets[0], logLevel);
|
|
247
332
|
|
|
248
|
-
|
|
249
|
-
krasConfig.map[api] = '';
|
|
250
|
-
krasConfig.injectors = reorderInjectors(injectorName, injectorConfig, krasConfig.injectors);
|
|
333
|
+
Promise.all(pilets.map((p) => p.bundler.ready())).then(() => logDone(`Ready!`));
|
|
251
334
|
|
|
252
|
-
|
|
335
|
+
pilets.forEach((p) => p.bundler.start());
|
|
253
336
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
'open',
|
|
258
|
-
notifyServerOnline(
|
|
259
|
-
pilets.map((p) => p.bundler),
|
|
260
|
-
krasConfig.api,
|
|
261
|
-
),
|
|
262
|
-
);
|
|
337
|
+
if (appInstances.length === 0) {
|
|
338
|
+
appInstances.push([undefined, originalPort]);
|
|
339
|
+
}
|
|
263
340
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
341
|
+
await Promise.all(
|
|
342
|
+
appInstances.sort(byPort).map(async ([appDir, appPort], i) => {
|
|
343
|
+
const platform = configurePlatform();
|
|
344
|
+
const suggestedPort = appPort || originalPort + i;
|
|
345
|
+
|
|
346
|
+
await platform.startModule({
|
|
347
|
+
appDir,
|
|
348
|
+
pilets,
|
|
349
|
+
customkrasrc,
|
|
350
|
+
feed,
|
|
351
|
+
fullBase,
|
|
352
|
+
hooks,
|
|
353
|
+
open,
|
|
354
|
+
originalPort: suggestedPort,
|
|
355
|
+
publicUrl,
|
|
356
|
+
maxListeners,
|
|
357
|
+
registerEnd(cb) {
|
|
358
|
+
return watcherContext.onClean(cb);
|
|
359
|
+
},
|
|
360
|
+
registerWatcher(file) {
|
|
361
|
+
return watcherContext.watch(file);
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
}),
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
await hooks.afterApp?.({ appInstanceDir, pilets });
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
await Promise.all([watcherRef.end]);
|
|
371
|
+
|
|
372
|
+
await hooks.onEnd?.({});
|
|
267
373
|
}
|