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/debug-piral.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { dirname, join, resolve } from 'path';
|
|
2
|
-
import { readKrasConfig, krasrc, buildKrasWithCli, defaultConfig } from 'kras';
|
|
3
2
|
import { callPiralDebug } from '../bundler';
|
|
4
3
|
import { LogLevels } from '../types';
|
|
5
4
|
import {
|
|
6
5
|
retrievePiletsInfo,
|
|
7
6
|
retrievePiralRoot,
|
|
8
|
-
openBrowser,
|
|
9
7
|
checkCliCompatibility,
|
|
10
|
-
reorderInjectors,
|
|
11
|
-
notifyServerOnline,
|
|
12
8
|
setLogLevel,
|
|
13
9
|
progress,
|
|
14
|
-
|
|
10
|
+
config,
|
|
11
|
+
normalizePublicUrl,
|
|
12
|
+
configurePlatform,
|
|
13
|
+
logDone,
|
|
14
|
+
getDestination,
|
|
15
|
+
watcherTask,
|
|
16
|
+
validateSharedDependencies,
|
|
17
|
+
piralJson,
|
|
18
|
+
packageJson,
|
|
15
19
|
} from '../common';
|
|
16
20
|
|
|
17
21
|
export interface DebugPiralOptions {
|
|
@@ -20,6 +24,11 @@ export interface DebugPiralOptions {
|
|
|
20
24
|
*/
|
|
21
25
|
entry?: string;
|
|
22
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Sets the target directory where the output of the bundling should be placed.
|
|
29
|
+
*/
|
|
30
|
+
target?: string;
|
|
31
|
+
|
|
23
32
|
/**
|
|
24
33
|
* Sets the port to use for the debug server.
|
|
25
34
|
*/
|
|
@@ -51,101 +60,145 @@ export interface DebugPiralOptions {
|
|
|
51
60
|
*/
|
|
52
61
|
bundlerName?: string;
|
|
53
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Sets the relative path to the krasrc, if any.
|
|
65
|
+
*/
|
|
66
|
+
krasrc?: string;
|
|
67
|
+
|
|
54
68
|
/**
|
|
55
69
|
* States if the node modules should be included for target transpilation
|
|
56
70
|
*/
|
|
57
71
|
optimizeModules?: boolean;
|
|
58
72
|
|
|
73
|
+
/**
|
|
74
|
+
* The URL of a pilet feed(s) used to include locally missing pilets.
|
|
75
|
+
*/
|
|
76
|
+
feed?: string | Array<string>;
|
|
77
|
+
|
|
59
78
|
/**
|
|
60
79
|
* Additional arguments for a specific bundler.
|
|
61
80
|
*/
|
|
62
81
|
_?: Record<string, any>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Hooks to be triggered at various stages.
|
|
85
|
+
*/
|
|
86
|
+
hooks?: {
|
|
87
|
+
onBegin?(e: any): Promise<void>;
|
|
88
|
+
beforeBuild?(e: any): Promise<void>;
|
|
89
|
+
afterBuild?(e: any): Promise<void>;
|
|
90
|
+
beforeOnline?(e: any): Promise<void>;
|
|
91
|
+
afterOnline?(e: any): Promise<void>;
|
|
92
|
+
onEnd?(e: any): Promise<void>;
|
|
93
|
+
};
|
|
63
94
|
}
|
|
64
95
|
|
|
65
96
|
export const debugPiralDefaults: DebugPiralOptions = {
|
|
66
97
|
entry: './',
|
|
67
|
-
|
|
98
|
+
target: './dist',
|
|
99
|
+
port: config.port,
|
|
68
100
|
publicUrl: '/',
|
|
69
101
|
logLevel: LogLevels.info,
|
|
70
|
-
open:
|
|
102
|
+
open: config.openBrowser,
|
|
71
103
|
hmr: true,
|
|
104
|
+
krasrc: undefined,
|
|
72
105
|
optimizeModules: false,
|
|
73
106
|
};
|
|
74
107
|
|
|
75
|
-
const injectorName = resolve(__dirname, '../injectors/piral.js');
|
|
76
|
-
|
|
77
108
|
export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOptions = {}) {
|
|
78
109
|
const {
|
|
79
110
|
entry = debugPiralDefaults.entry,
|
|
80
|
-
|
|
111
|
+
target = debugPiralDefaults.target,
|
|
81
112
|
open = debugPiralDefaults.open,
|
|
82
113
|
hmr = debugPiralDefaults.hmr,
|
|
83
|
-
|
|
114
|
+
port: originalPort = debugPiralDefaults.port,
|
|
115
|
+
publicUrl: originalPublicUrl = debugPiralDefaults.publicUrl,
|
|
84
116
|
logLevel = debugPiralDefaults.logLevel,
|
|
117
|
+
krasrc: customkrasrc = debugPiralDefaults.krasrc,
|
|
85
118
|
optimizeModules = debugPiralDefaults.optimizeModules,
|
|
119
|
+
feed,
|
|
86
120
|
_ = {},
|
|
121
|
+
hooks = {},
|
|
87
122
|
bundlerName,
|
|
88
123
|
} = options;
|
|
124
|
+
const publicUrl = normalizePublicUrl(originalPublicUrl);
|
|
125
|
+
const fullBase = resolve(process.cwd(), baseDir);
|
|
89
126
|
setLogLevel(logLevel);
|
|
90
|
-
progress('Reading configuration ...');
|
|
91
|
-
const entryFiles = await retrievePiralRoot(baseDir, entry);
|
|
92
|
-
const { externals, name, root, ignored } = await retrievePiletsInfo(entryFiles);
|
|
93
|
-
const krasConfig = readKrasConfig({ port }, krasrc);
|
|
94
127
|
|
|
95
|
-
await
|
|
128
|
+
await hooks.onBegin?.({ options, fullBase });
|
|
96
129
|
|
|
97
|
-
|
|
98
|
-
krasConfig.directory = join(dirname(entryFiles), 'mocks');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (krasConfig.ssl === undefined) {
|
|
102
|
-
krasConfig.ssl = undefined;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (krasConfig.map === undefined) {
|
|
106
|
-
krasConfig.map = {};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (krasConfig.api === undefined) {
|
|
110
|
-
krasConfig.api = '/manage-mock-server';
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (krasConfig.injectors === undefined) {
|
|
114
|
-
krasConfig.injectors = defaultConfig.injectors;
|
|
115
|
-
}
|
|
130
|
+
progress('Reading configuration ...');
|
|
116
131
|
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
132
|
+
const buildRef = await watcherTask(async (watcherContext) => {
|
|
133
|
+
const entryFiles = await retrievePiralRoot(fullBase, entry);
|
|
134
|
+
const { externals, name, root, ignored } = await retrievePiletsInfo(entryFiles);
|
|
135
|
+
const piralInstances = [name];
|
|
136
|
+
const dest = getDestination(entryFiles, resolve(fullBase, target));
|
|
137
|
+
|
|
138
|
+
await checkCliCompatibility(root);
|
|
139
|
+
|
|
140
|
+
validateSharedDependencies(externals);
|
|
141
|
+
|
|
142
|
+
await hooks.beforeBuild?.({ root, publicUrl, externals, entryFiles, piralInstances });
|
|
143
|
+
|
|
144
|
+
watcherContext.watch(join(root, packageJson));
|
|
145
|
+
watcherContext.watch(join(root, piralJson));
|
|
146
|
+
|
|
147
|
+
const bundler = await callPiralDebug(
|
|
148
|
+
{
|
|
149
|
+
root,
|
|
150
|
+
piralInstances,
|
|
151
|
+
optimizeModules,
|
|
152
|
+
hmr,
|
|
153
|
+
externals: externals.map((m) => m.name),
|
|
154
|
+
publicUrl,
|
|
155
|
+
entryFiles,
|
|
156
|
+
logLevel,
|
|
157
|
+
ignored,
|
|
158
|
+
...dest,
|
|
159
|
+
_,
|
|
160
|
+
},
|
|
161
|
+
bundlerName,
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
bundler.ready().then(() => logDone(`Ready!`));
|
|
165
|
+
|
|
166
|
+
bundler.on((args) => {
|
|
167
|
+
hooks.afterBuild?.({ ...args, root, publicUrl, externals, entryFiles, piralInstances, bundler, ...dest });
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
bundler.start();
|
|
171
|
+
return { bundler, entryFiles, root };
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const platform = configurePlatform();
|
|
175
|
+
|
|
176
|
+
const serverRef = await watcherTask(async (watcherContext) => {
|
|
177
|
+
watcherContext.dependOn(buildRef);
|
|
178
|
+
const { bundler, entryFiles, root } = buildRef.data;
|
|
179
|
+
const targetDir = dirname(entryFiles);
|
|
180
|
+
|
|
181
|
+
await platform.startShell({
|
|
182
|
+
bundler,
|
|
183
|
+
customkrasrc,
|
|
184
|
+
feed,
|
|
185
|
+
fullBase,
|
|
186
|
+
hooks,
|
|
187
|
+
open,
|
|
188
|
+
originalPort,
|
|
124
189
|
publicUrl,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
krasConfig.map['/'] = '';
|
|
140
|
-
krasConfig.injectors = reorderInjectors(injectorName, injectorConfig, krasConfig.injectors);
|
|
141
|
-
|
|
142
|
-
log('generalVerbose_0004', `Using kras with configuration: ${JSON.stringify(krasConfig, undefined, 2)}`);
|
|
143
|
-
|
|
144
|
-
const krasServer = buildKrasWithCli(krasConfig);
|
|
145
|
-
krasServer.removeAllListeners('open');
|
|
146
|
-
krasServer.on('open', notifyServerOnline([bundler], krasConfig.api));
|
|
147
|
-
|
|
148
|
-
await krasServer.start();
|
|
149
|
-
openBrowser(open, port);
|
|
150
|
-
await new Promise((resolve) => krasServer.on('close', resolve));
|
|
190
|
+
root,
|
|
191
|
+
targetDir,
|
|
192
|
+
registerEnd(cb) {
|
|
193
|
+
return watcherContext.onClean(cb);
|
|
194
|
+
},
|
|
195
|
+
registerWatcher(file) {
|
|
196
|
+
return watcherContext.watch(file);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
await Promise.all([buildRef.end, serverRef.end]);
|
|
202
|
+
|
|
203
|
+
await hooks.onEnd?.({});
|
|
151
204
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { setLogLevel, logDone, createPiralDeclaration, ForceOverwrite } from '../common';
|
|
2
3
|
import { LogLevels } from '../types';
|
|
3
4
|
|
|
4
5
|
export interface DeclarationPiralOptions {
|
|
@@ -37,7 +38,8 @@ export async function declarationPiral(baseDir = process.cwd(), options: Declara
|
|
|
37
38
|
forceOverwrite = declarationPiralDefaults.forceOverwrite,
|
|
38
39
|
logLevel = declarationPiralDefaults.logLevel,
|
|
39
40
|
} = options;
|
|
41
|
+
const fullBase = resolve(process.cwd(), baseDir);
|
|
40
42
|
setLogLevel(logLevel);
|
|
41
|
-
await
|
|
43
|
+
await createPiralDeclaration(fullBase, entry, target, forceOverwrite, logLevel);
|
|
42
44
|
logDone(`Declaration created successfully in "${target}"!`);
|
|
43
45
|
}
|
package/src/apps/index.ts
CHANGED
|
@@ -7,6 +7,9 @@ export * from './publish-piral';
|
|
|
7
7
|
export * from './validate-piral';
|
|
8
8
|
export * from './new-pilet';
|
|
9
9
|
export * from './upgrade-pilet';
|
|
10
|
+
export * from './add-piral-instance-pilet';
|
|
11
|
+
export * from './remove-piral-instance-pilet';
|
|
12
|
+
export * from './run-emulator-piral';
|
|
10
13
|
export * from './debug-pilet';
|
|
11
14
|
export * from './build-pilet';
|
|
12
15
|
export * from './pack-pilet';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { mkdtempSync, existsSync } from 'fs';
|
|
1
|
+
import { mkdtempSync, existsSync, readFileSync } from 'fs';
|
|
2
2
|
import { tmpdir } from 'os';
|
|
3
3
|
import { join, resolve } from 'path';
|
|
4
4
|
import { newPilet } from './new-pilet';
|
|
5
|
-
import { SourceLanguage } from '../common';
|
|
6
5
|
|
|
7
6
|
function createTempDir() {
|
|
8
7
|
return mkdtempSync(join(tmpdir(), 'piral-tests-new-pilet-'));
|
|
@@ -14,18 +13,21 @@ jest.mock('../common/clients/npm', () => {
|
|
|
14
13
|
return {
|
|
15
14
|
...original,
|
|
16
15
|
installPackage: (...args) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
return original.installPackage(
|
|
17
|
+
...args,
|
|
18
|
+
'--legacy-peer-deps',
|
|
19
|
+
'--no-package-lock',
|
|
20
|
+
'--no-save',
|
|
21
|
+
'--registry=https://registry.npmjs.org/',
|
|
22
|
+
);
|
|
22
23
|
},
|
|
23
24
|
};
|
|
24
25
|
});
|
|
25
26
|
|
|
27
|
+
jest.setTimeout(90000);
|
|
28
|
+
|
|
26
29
|
describe('New Pilet Command', () => {
|
|
27
30
|
it('scaffolding in an empty directory works', async () => {
|
|
28
|
-
jest.setTimeout(60000);
|
|
29
31
|
const dir = createTempDir();
|
|
30
32
|
await newPilet(dir, {
|
|
31
33
|
install: false,
|
|
@@ -56,7 +58,6 @@ describe('New Pilet Command', () => {
|
|
|
56
58
|
});
|
|
57
59
|
|
|
58
60
|
it('should scaffold without creating npmrc file', async () => {
|
|
59
|
-
jest.setTimeout(60000);
|
|
60
61
|
const dir = createTempDir();
|
|
61
62
|
await newPilet(dir, {
|
|
62
63
|
install: false,
|
|
@@ -70,10 +71,9 @@ describe('New Pilet Command', () => {
|
|
|
70
71
|
});
|
|
71
72
|
|
|
72
73
|
it('scaffolding with language JS works', async () => {
|
|
73
|
-
jest.setTimeout(60000);
|
|
74
74
|
const dir = createTempDir();
|
|
75
75
|
await newPilet(dir, {
|
|
76
|
-
language:
|
|
76
|
+
language: 'js',
|
|
77
77
|
install: false,
|
|
78
78
|
source: 'piral@latest',
|
|
79
79
|
});
|
|
@@ -83,4 +83,21 @@ describe('New Pilet Command', () => {
|
|
|
83
83
|
expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeTruthy();
|
|
84
84
|
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
85
85
|
});
|
|
86
|
+
|
|
87
|
+
it('should set pilet name if passed as argument', async () => {
|
|
88
|
+
const dir = createTempDir();
|
|
89
|
+
await newPilet(dir, {
|
|
90
|
+
install: false,
|
|
91
|
+
source: 'piral@latest',
|
|
92
|
+
name: 'testpiralname',
|
|
93
|
+
});
|
|
94
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
95
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
96
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
97
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
98
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
99
|
+
|
|
100
|
+
const packageContent = await JSON.parse(readFileSync(`${dir}/package.json`, 'utf8'));
|
|
101
|
+
expect(packageContent.name).toBe('testpiralname');
|
|
102
|
+
});
|
|
86
103
|
});
|
package/src/apps/new-pilet.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { resolve, basename } from 'path';
|
|
2
|
-
import { LogLevels, NpmClientType } from '../types';
|
|
2
|
+
import { SourceLanguage, LogLevels, NpmClientType } from '../types';
|
|
3
3
|
import {
|
|
4
4
|
ForceOverwrite,
|
|
5
|
-
SourceLanguage,
|
|
6
5
|
createDirectory,
|
|
7
6
|
createFileIfNotExists,
|
|
8
|
-
defaultRegistry,
|
|
9
|
-
installPackage,
|
|
10
|
-
dissectPackageName,
|
|
11
7
|
copyPiralFiles,
|
|
12
8
|
patchPiletPackage,
|
|
13
9
|
scaffoldPiletSourceFiles,
|
|
14
|
-
|
|
15
|
-
combinePackageRef,
|
|
16
|
-
getPackageName,
|
|
17
|
-
getPackageVersion,
|
|
10
|
+
installNpmDependencies,
|
|
18
11
|
readPiralPackage,
|
|
19
12
|
getPiletsInfo,
|
|
20
13
|
runScript,
|
|
@@ -25,11 +18,15 @@ import {
|
|
|
25
18
|
log,
|
|
26
19
|
logDone,
|
|
27
20
|
determineNpmClient,
|
|
28
|
-
isLinkedPackage,
|
|
29
21
|
copyScaffoldingFiles,
|
|
30
22
|
getPiralPath,
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
getPiletScaffoldData,
|
|
24
|
+
config,
|
|
25
|
+
initNpmProject,
|
|
26
|
+
cliVersion,
|
|
27
|
+
installPiralInstance,
|
|
28
|
+
piletJson,
|
|
29
|
+
defaultSchemaVersion,
|
|
33
30
|
} from '../common';
|
|
34
31
|
|
|
35
32
|
export interface NewPiletOptions {
|
|
@@ -76,7 +73,7 @@ export interface NewPiletOptions {
|
|
|
76
73
|
logLevel?: LogLevels;
|
|
77
74
|
|
|
78
75
|
/**
|
|
79
|
-
* The
|
|
76
|
+
* The npm client to be used when scaffolding.
|
|
80
77
|
* @example 'yarn'
|
|
81
78
|
*/
|
|
82
79
|
npmClient?: NpmClientType;
|
|
@@ -91,20 +88,26 @@ export interface NewPiletOptions {
|
|
|
91
88
|
* Places additional variables that should used when scaffolding.
|
|
92
89
|
*/
|
|
93
90
|
variables?: Record<string, string>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Sets Pilet's name
|
|
94
|
+
*/
|
|
95
|
+
name?: string;
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
export const newPiletDefaults: NewPiletOptions = {
|
|
97
99
|
target: '.',
|
|
98
|
-
registry:
|
|
99
|
-
source:
|
|
100
|
+
registry: config.registry,
|
|
101
|
+
source: undefined,
|
|
100
102
|
forceOverwrite: ForceOverwrite.no,
|
|
101
|
-
language:
|
|
103
|
+
language: config.language,
|
|
102
104
|
install: true,
|
|
103
|
-
template:
|
|
105
|
+
template: undefined,
|
|
104
106
|
logLevel: LogLevels.info,
|
|
105
107
|
npmClient: undefined,
|
|
106
108
|
bundlerName: 'none',
|
|
107
109
|
variables: {},
|
|
110
|
+
name: undefined,
|
|
108
111
|
};
|
|
109
112
|
|
|
110
113
|
export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions = {}) {
|
|
@@ -119,15 +122,18 @@ export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions
|
|
|
119
122
|
logLevel = newPiletDefaults.logLevel,
|
|
120
123
|
bundlerName = newPiletDefaults.bundlerName,
|
|
121
124
|
variables = newPiletDefaults.variables,
|
|
125
|
+
npmClient: defaultNpmClient = newPiletDefaults.npmClient,
|
|
126
|
+
name = newPiletDefaults.name,
|
|
122
127
|
} = options;
|
|
128
|
+
const fullBase = resolve(process.cwd(), baseDir);
|
|
129
|
+
const root = resolve(fullBase, target);
|
|
123
130
|
setLogLevel(logLevel);
|
|
124
131
|
progress('Preparing source and target ...');
|
|
125
|
-
const root = resolve(baseDir, target);
|
|
126
|
-
const [sourceName, sourceVersion, hadVersion, type] = await dissectPackageName(baseDir, source);
|
|
127
132
|
const success = await createDirectory(root);
|
|
128
133
|
|
|
129
134
|
if (success) {
|
|
130
|
-
const npmClient = await determineNpmClient(root,
|
|
135
|
+
const npmClient = await determineNpmClient(root, defaultNpmClient);
|
|
136
|
+
const projectName = name || basename(root);
|
|
131
137
|
|
|
132
138
|
progress(`Scaffolding new pilet in %s ...`, root);
|
|
133
139
|
|
|
@@ -136,7 +142,7 @@ export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions
|
|
|
136
142
|
'package.json',
|
|
137
143
|
JSON.stringify(
|
|
138
144
|
{
|
|
139
|
-
name:
|
|
145
|
+
name: projectName,
|
|
140
146
|
version: '1.0.0',
|
|
141
147
|
description: '',
|
|
142
148
|
keywords: ['pilet'],
|
|
@@ -152,8 +158,10 @@ export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions
|
|
|
152
158
|
),
|
|
153
159
|
);
|
|
154
160
|
|
|
161
|
+
await initNpmProject(npmClient, projectName, root);
|
|
162
|
+
|
|
155
163
|
if (registry !== newPiletDefaults.registry) {
|
|
156
|
-
progress(`Setting up
|
|
164
|
+
progress(`Setting up npm registry (%s) ...`, registry);
|
|
157
165
|
|
|
158
166
|
await createFileIfNotExists(
|
|
159
167
|
root,
|
|
@@ -164,25 +172,29 @@ always-auth=true`,
|
|
|
164
172
|
);
|
|
165
173
|
}
|
|
166
174
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
await createFileIfNotExists(
|
|
176
|
+
root,
|
|
177
|
+
piletJson,
|
|
178
|
+
JSON.stringify(
|
|
179
|
+
{
|
|
180
|
+
schemaVersion: defaultSchemaVersion,
|
|
181
|
+
},
|
|
182
|
+
undefined,
|
|
183
|
+
2,
|
|
184
|
+
),
|
|
185
|
+
);
|
|
178
186
|
|
|
179
|
-
const packageName = await
|
|
180
|
-
|
|
187
|
+
const [packageName, packageVersion] = await installPiralInstance(
|
|
188
|
+
source || `empty-piral@${cliVersion}`,
|
|
189
|
+
fullBase,
|
|
190
|
+
root,
|
|
191
|
+
npmClient,
|
|
192
|
+
);
|
|
181
193
|
const piralInfo = await readPiralPackage(root, packageName);
|
|
182
194
|
|
|
183
195
|
const isEmulator = checkAppShellPackage(piralInfo);
|
|
184
196
|
|
|
185
|
-
const { preScaffold, postScaffold, files } = getPiletsInfo(piralInfo);
|
|
197
|
+
const { preScaffold, postScaffold, files, template: preSelectedTemplate } = getPiletsInfo(piralInfo);
|
|
186
198
|
|
|
187
199
|
if (preScaffold) {
|
|
188
200
|
progress(`Running preScaffold script ...`);
|
|
@@ -192,29 +204,29 @@ always-auth=true`,
|
|
|
192
204
|
|
|
193
205
|
progress(`Taking care of templating ...`);
|
|
194
206
|
|
|
195
|
-
|
|
207
|
+
const data = getPiletScaffoldData(language, root, packageName, variables);
|
|
208
|
+
|
|
209
|
+
await patchPiletPackage(root, packageName, packageVersion, piralInfo, isEmulator, {
|
|
210
|
+
language,
|
|
211
|
+
bundler: bundlerName,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const chosenTemplate = template || preSelectedTemplate || 'default';
|
|
215
|
+
await scaffoldPiletSourceFiles(chosenTemplate, registry, data, forceOverwrite);
|
|
196
216
|
|
|
197
217
|
if (isEmulator) {
|
|
198
218
|
// in the emulator case we get the files (and files_once) from the contained tarballs
|
|
199
|
-
await copyPiralFiles(root, packageName, piralInfo, ForceOverwrite.yes);
|
|
219
|
+
await copyPiralFiles(root, packageName, piralInfo, ForceOverwrite.yes, data);
|
|
200
220
|
} else {
|
|
201
221
|
// otherwise, we perform the same action as in the emulator creation
|
|
202
222
|
// just with a different target; not a created directory, but the root
|
|
203
223
|
const packageRoot = getPiralPath(root, packageName);
|
|
204
|
-
await copyScaffoldingFiles(packageRoot, root, files, piralInfo);
|
|
224
|
+
await copyScaffoldingFiles(packageRoot, root, files, piralInfo, data);
|
|
205
225
|
}
|
|
206
226
|
|
|
207
|
-
await patchPiletPackage(root, packageName, packageVersion, piralInfo, { language, bundler: bundlerName });
|
|
208
|
-
|
|
209
227
|
if (install) {
|
|
210
228
|
progress(`Installing dependencies ...`);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (monorepoKind === 'lerna') {
|
|
214
|
-
await bootstrapMonorepo(root);
|
|
215
|
-
} else {
|
|
216
|
-
await installDependencies(npmClient, root);
|
|
217
|
-
}
|
|
229
|
+
await installNpmDependencies(npmClient, root);
|
|
218
230
|
}
|
|
219
231
|
|
|
220
232
|
if (postScaffold) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { mkdtempSync, existsSync } from 'fs';
|
|
1
|
+
import { mkdtempSync, existsSync, readFileSync } from 'fs';
|
|
2
2
|
import { tmpdir } from 'os';
|
|
3
3
|
import { join, resolve } from 'path';
|
|
4
4
|
import { newPiral } from './new-piral';
|
|
5
|
-
import { SourceLanguage } from '../common';
|
|
6
5
|
|
|
7
6
|
function createTempDir() {
|
|
8
7
|
return mkdtempSync(join(tmpdir(), 'piral-tests-new-piral-'));
|
|
@@ -14,18 +13,15 @@ jest.mock('../common/clients/npm', () => {
|
|
|
14
13
|
return {
|
|
15
14
|
...original,
|
|
16
15
|
installPackage: (...args) => {
|
|
17
|
-
|
|
18
|
-
return Promise.resolve();
|
|
19
|
-
} else {
|
|
20
|
-
return original.installPackage(...args);
|
|
21
|
-
}
|
|
16
|
+
return original.installPackage(...args, '--legacy-peer-deps', '--no-package-lock', '--no-save');
|
|
22
17
|
},
|
|
23
18
|
};
|
|
24
19
|
});
|
|
25
20
|
|
|
21
|
+
jest.setTimeout(90000);
|
|
22
|
+
|
|
26
23
|
describe('New Piral Command', () => {
|
|
27
24
|
it('scaffolding in an empty directory works', async () => {
|
|
28
|
-
jest.setTimeout(60000);
|
|
29
25
|
const dir = createTempDir();
|
|
30
26
|
await newPiral(dir, { install: false });
|
|
31
27
|
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
@@ -38,10 +34,9 @@ describe('New Piral Command', () => {
|
|
|
38
34
|
});
|
|
39
35
|
|
|
40
36
|
it('scaffolding with language JS works', async () => {
|
|
41
|
-
jest.setTimeout(60000);
|
|
42
37
|
const dir = createTempDir();
|
|
43
38
|
await newPiral(dir, {
|
|
44
|
-
language:
|
|
39
|
+
language: 'js',
|
|
45
40
|
install: false,
|
|
46
41
|
});
|
|
47
42
|
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
@@ -53,8 +48,26 @@ describe('New Piral Command', () => {
|
|
|
53
48
|
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
54
49
|
});
|
|
55
50
|
|
|
51
|
+
it('scaffolding with custom app name works', async () => {
|
|
52
|
+
const dir = createTempDir();
|
|
53
|
+
await newPiral(dir, {
|
|
54
|
+
name: 'test-name',
|
|
55
|
+
install: false,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
expect(existsSync(resolve(dir, 'node_modules/piral/package.json'))).toBeTruthy();
|
|
59
|
+
expect(existsSync(resolve(dir, 'package.json'))).toBeTruthy();
|
|
60
|
+
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
61
|
+
expect(existsSync(resolve(dir, 'src/index.tsx'))).toBeTruthy();
|
|
62
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
63
|
+
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
64
|
+
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
65
|
+
|
|
66
|
+
const packageContent = await JSON.parse(readFileSync(`${dir}/package.json`, 'utf8'));
|
|
67
|
+
expect(packageContent.name).toBe('test-name');
|
|
68
|
+
});
|
|
69
|
+
|
|
56
70
|
it('scaffolding for piral-core works', async () => {
|
|
57
|
-
jest.setTimeout(60000);
|
|
58
71
|
const dir = createTempDir();
|
|
59
72
|
await newPiral(dir, {
|
|
60
73
|
framework: 'piral-core',
|
|
@@ -72,7 +85,6 @@ describe('New Piral Command', () => {
|
|
|
72
85
|
});
|
|
73
86
|
|
|
74
87
|
it('scaffolding for piral-base works', async () => {
|
|
75
|
-
jest.setTimeout(60000);
|
|
76
88
|
const dir = createTempDir();
|
|
77
89
|
await newPiral(dir, {
|
|
78
90
|
framework: 'piral-base',
|
|
@@ -85,7 +97,7 @@ describe('New Piral Command', () => {
|
|
|
85
97
|
expect(existsSync(resolve(dir, 'tsconfig.json'))).toBeTruthy();
|
|
86
98
|
expect(existsSync(resolve(dir, 'src/index.jsx'))).toBeFalsy();
|
|
87
99
|
expect(existsSync(resolve(dir, 'src/index.ts'))).toBeTruthy();
|
|
88
|
-
expect(existsSync(resolve(dir, 'src/index.html'))).
|
|
100
|
+
expect(existsSync(resolve(dir, 'src/index.html'))).toBeTruthy();
|
|
89
101
|
expect(existsSync(resolve(dir, 'src/mocks/backend.js'))).toBeTruthy();
|
|
90
102
|
expect(existsSync(resolve(dir, '.npmrc'))).toBeFalsy();
|
|
91
103
|
});
|