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
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { satisfies, validate } from './version';
|
|
2
|
+
|
|
3
|
+
describe('semver check module', () => {
|
|
4
|
+
it('specific publish version is valid', () => {
|
|
5
|
+
const result = validate('1.2.3');
|
|
6
|
+
expect(result).toBeTruthy();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('shortened publish version is valid', () => {
|
|
10
|
+
const result = validate('1.2');
|
|
11
|
+
expect(result).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('some hash is invalid', () => {
|
|
15
|
+
const result = validate('fabcde');
|
|
16
|
+
expect(result).toBeFalsy();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('some longer hash is invalid', () => {
|
|
20
|
+
const result = validate('123fabdef0012');
|
|
21
|
+
expect(result).toBeFalsy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('major publish version is valid', () => {
|
|
25
|
+
const result = validate('1');
|
|
26
|
+
expect(result).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('any publish version is valid', () => {
|
|
30
|
+
const result = validate('1.2.x');
|
|
31
|
+
expect(result).toBeTruthy();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('specific preview version is valid', () => {
|
|
35
|
+
const result = validate('1.2.3-pre.123');
|
|
36
|
+
expect(result).toBeTruthy();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('caret version is specifier valid', () => {
|
|
40
|
+
const result = validate('^1.2.3');
|
|
41
|
+
expect(result).toBeTruthy();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('tilde version is specifier valid', () => {
|
|
45
|
+
const result = validate('~1.2.3');
|
|
46
|
+
expect(result).toBeTruthy();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('greater version is specifier valid', () => {
|
|
50
|
+
const result = validate('>1.2.3');
|
|
51
|
+
expect(result).toBeTruthy();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('greater equals version is specifier valid', () => {
|
|
55
|
+
const result = validate('>=1.2.3');
|
|
56
|
+
expect(result).toBeTruthy();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('greater equals with x version is specifier valid', () => {
|
|
60
|
+
const result = validate('>=1.x');
|
|
61
|
+
expect(result).toBeTruthy();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('satisfies exact version match', () => {
|
|
65
|
+
const result = satisfies('1.2.3', '1.2.3');
|
|
66
|
+
expect(result).toBeTruthy();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('does not satisfy exact version mismatch greater', () => {
|
|
70
|
+
const result = satisfies('1.2.3', '1.2.4');
|
|
71
|
+
expect(result).toBeFalsy();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('does not satisfy exact version mismatch smaller', () => {
|
|
75
|
+
const result = satisfies('1.2.3', '1.2.2');
|
|
76
|
+
expect(result).toBeFalsy();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('satisfies constraint with caret patch', () => {
|
|
80
|
+
const result = satisfies('1.2.3', '^1.2.0');
|
|
81
|
+
expect(result).toBeTruthy();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('satisfies constraint with caret minor', () => {
|
|
85
|
+
const result = satisfies('1.3.0', '^1.2.0');
|
|
86
|
+
expect(result).toBeTruthy();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('satisfies constraint with caret exact', () => {
|
|
90
|
+
const result = satisfies('1.3.0', '^1.3.0');
|
|
91
|
+
expect(result).toBeTruthy();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('satisfies constraint with caret exact with dropped number', () => {
|
|
95
|
+
const result = satisfies('1.3.0', '^1.3');
|
|
96
|
+
expect(result).toBeTruthy();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('satisfies constraint with caret exact with dropped numbers', () => {
|
|
100
|
+
const result = satisfies('1', '^1');
|
|
101
|
+
expect(result).toBeTruthy();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('does not satisfy constraint with caret major', () => {
|
|
105
|
+
const result = satisfies('2.0.0', '^1.2.0');
|
|
106
|
+
expect(result).toBeFalsy();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('satisfies constraint with tilde patch', () => {
|
|
110
|
+
const result = satisfies('1.2.3', '~1.2.0');
|
|
111
|
+
expect(result).toBeTruthy();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('does not satisfy constraint with tilde minor', () => {
|
|
115
|
+
const result = satisfies('1.3.0', '~1.2.0');
|
|
116
|
+
expect(result).toBeFalsy();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('does not satisfy constraint with tilde patch greater', () => {
|
|
120
|
+
const result = satisfies('1.3.0', '~1.3.2');
|
|
121
|
+
expect(result).toBeFalsy();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('satisfies constraint with tilde patch lighter', () => {
|
|
125
|
+
const result = satisfies('1.3.3', '~1.3.2');
|
|
126
|
+
expect(result).toBeTruthy();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('satisfies constraint with x patch', () => {
|
|
130
|
+
const result = satisfies('1.2.3', '1.x.3');
|
|
131
|
+
expect(result).toBeTruthy();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('does not satisfy constraint x minor', () => {
|
|
135
|
+
const result = satisfies('1.3.0', '1.2.x');
|
|
136
|
+
expect(result).toBeFalsy();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('satsfies greater than matching', () => {
|
|
140
|
+
const result = satisfies('1.3.0', '>=1.2.0');
|
|
141
|
+
expect(result).toBeTruthy();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('satsfies less than matching', () => {
|
|
145
|
+
const result = satisfies('1.3.0', '<=1.3.0');
|
|
146
|
+
expect(result).toBeTruthy();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('does not satisfy only greater than non-matching', () => {
|
|
150
|
+
const result = satisfies('1.3.0', '>1.3.0');
|
|
151
|
+
expect(result).toBeFalsy();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('does not satisfy greater than non-matching', () => {
|
|
155
|
+
const result = satisfies('1.3.0', '>=1.3.1');
|
|
156
|
+
expect(result).toBeFalsy();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('does not satisfy less than non-matching', () => {
|
|
160
|
+
const result = satisfies('1.3.0', '<=1.2.0');
|
|
161
|
+
expect(result).toBeFalsy();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('does not satisfy less than non-matching', () => {
|
|
165
|
+
const result = satisfies('1.3.0', '<1.3.0');
|
|
166
|
+
expect(result).toBeFalsy();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('does not satisfy less than non-matching', () => {
|
|
170
|
+
const result = satisfies('1.3.0', '<=1.2.0');
|
|
171
|
+
expect(result).toBeFalsy();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('satisfies exact version match with previews', () => {
|
|
175
|
+
const result = satisfies('1.2.3-pre.5', '1.2.3-pre.5');
|
|
176
|
+
expect(result).toBeTruthy();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('satisfies exact version match with dropped number', () => {
|
|
180
|
+
const result = satisfies('1.0', '1');
|
|
181
|
+
expect(result).toBeTruthy();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('satisfies exact version match with dropped numbers', () => {
|
|
185
|
+
const result = satisfies('1', '1.0.0');
|
|
186
|
+
expect(result).toBeTruthy();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('does not satisfy exact version mismatch preview', () => {
|
|
190
|
+
const result = satisfies('1.2.4-pre.5', '1.2.4-pre.6');
|
|
191
|
+
expect(result).toBeFalsy();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('does not satisfy exact version mismatch preview version offered', () => {
|
|
195
|
+
const result = satisfies('1.2.4-beta', '1.2.4-beta.5');
|
|
196
|
+
expect(result).toBeFalsy();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('does not satisfy exact version mismatch preview version demanded', () => {
|
|
200
|
+
const result = satisfies('1.2.4-beta.5', '1.2.4-beta');
|
|
201
|
+
expect(result).toBeFalsy();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('does not satisfy exact version mismatch preview higher', () => {
|
|
205
|
+
const result = satisfies('1.2.4-gamma', '1.2.4-beta');
|
|
206
|
+
expect(result).toBeFalsy();
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('does not satisfy exact version mismatch preview smaller', () => {
|
|
210
|
+
const result = satisfies('1.2.4-alpha', '1.2.4-beta');
|
|
211
|
+
expect(result).toBeFalsy();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('does not satisfy exact and preview mismatch', () => {
|
|
215
|
+
const result = satisfies('1.2.4-pre.5', '1.2.4');
|
|
216
|
+
expect(result).toBeFalsy();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('satisfies just an x', () => {
|
|
220
|
+
const result = satisfies('1.2.3', 'x');
|
|
221
|
+
expect(result).toBeTruthy();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('satisfies just a *', () => {
|
|
225
|
+
const result = satisfies('1.2.3', '*');
|
|
226
|
+
expect(result).toBeTruthy();
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('satisfies just a >=0', () => {
|
|
230
|
+
const result = satisfies('1.2.3', '>=0');
|
|
231
|
+
expect(result).toBeTruthy();
|
|
232
|
+
});
|
|
233
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
const semver =
|
|
2
|
+
/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
|
|
3
|
+
|
|
4
|
+
const acceptsAll = ['*', 'x', '>=0'];
|
|
5
|
+
|
|
6
|
+
const operatorResMap: Record<string, [number, number?]> = {
|
|
7
|
+
'>': [1],
|
|
8
|
+
'>=': [0, 1],
|
|
9
|
+
'=': [0],
|
|
10
|
+
'<=': [-1, 0],
|
|
11
|
+
'<': [-1],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function indexOrEnd(str: string, q: string) {
|
|
15
|
+
return str.indexOf(q) === -1 ? str.length : str.indexOf(q);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function splitVersion(v: string) {
|
|
19
|
+
const c = v.replace(/^v/, '').replace(/\+.*$/, '');
|
|
20
|
+
const patchIndex = indexOrEnd(c, '-');
|
|
21
|
+
const arr = c.substring(0, patchIndex).split('.');
|
|
22
|
+
arr.push(c.substring(patchIndex + 1));
|
|
23
|
+
return arr;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function parseSegment(v: string) {
|
|
27
|
+
const n = parseInt(v, 10);
|
|
28
|
+
return isNaN(n) ? v : n;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function validateAndParse(v: string) {
|
|
32
|
+
const match = v.match(semver);
|
|
33
|
+
match.shift();
|
|
34
|
+
return match;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function compareStrings(a: string, b: string) {
|
|
38
|
+
const ap = parseSegment(a);
|
|
39
|
+
const bp = parseSegment(b);
|
|
40
|
+
|
|
41
|
+
if (ap > bp) {
|
|
42
|
+
return 1;
|
|
43
|
+
} else if (ap < bp) {
|
|
44
|
+
return -1;
|
|
45
|
+
} else {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function compareSegments(a: [string, string], b: [string, string]) {
|
|
51
|
+
for (let i = 0; i < 2; i++) {
|
|
52
|
+
const r = compareStrings(a[i] || '0', b[i] || '0');
|
|
53
|
+
|
|
54
|
+
if (r !== 0) {
|
|
55
|
+
return r;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function compareVersions(v1: string, v2: string) {
|
|
63
|
+
const s1 = splitVersion(v1);
|
|
64
|
+
const s2 = splitVersion(v2);
|
|
65
|
+
const len = Math.max(s1.length - 1, s2.length - 1);
|
|
66
|
+
|
|
67
|
+
for (let i = 0; i < len; i++) {
|
|
68
|
+
const n1 = parseInt(s1[i] || '0', 10);
|
|
69
|
+
const n2 = parseInt(s2[i] || '0', 10);
|
|
70
|
+
|
|
71
|
+
if (n1 > n2) {
|
|
72
|
+
return 1;
|
|
73
|
+
} else if (n2 > n1) {
|
|
74
|
+
return -1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const sp1 = s1[s1.length - 1];
|
|
79
|
+
const sp2 = s2[s2.length - 1];
|
|
80
|
+
|
|
81
|
+
if (sp1 && sp2) {
|
|
82
|
+
const p1 = sp1.split('.').map(parseSegment);
|
|
83
|
+
const p2 = sp2.split('.').map(parseSegment);
|
|
84
|
+
const len = Math.max(p1.length, p2.length);
|
|
85
|
+
|
|
86
|
+
for (let i = 0; i < len; i++) {
|
|
87
|
+
if (p1[i] === undefined || (typeof p2[i] === 'string' && typeof p1[i] === 'number')) {
|
|
88
|
+
return -1;
|
|
89
|
+
} else if (p2[i] === undefined || (typeof p1[i] === 'string' && typeof p2[i] === 'number')) {
|
|
90
|
+
return 1;
|
|
91
|
+
} else if (p1[i] > p2[i]) {
|
|
92
|
+
return 1;
|
|
93
|
+
} else if (p2[i] > p1[i]) {
|
|
94
|
+
return -1;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} else if (sp1 || sp2) {
|
|
98
|
+
return sp1 ? -1 : 1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function compare(v1: string, v2: string, operator: string) {
|
|
105
|
+
// since result of compareVersions can only be -1 or 0 or 1
|
|
106
|
+
// a simple map can be used to replace switch
|
|
107
|
+
const res = compareVersions(v1, v2);
|
|
108
|
+
return operatorResMap[operator].indexOf(res) > -1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function validate(version: string) {
|
|
112
|
+
return acceptsAll.includes(version) || semver.test(version);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function satisfies(v: string, r: string) {
|
|
116
|
+
if (!acceptsAll.includes(r)) {
|
|
117
|
+
// if no range operator then "="
|
|
118
|
+
const match = r.match(/^([<>=~^]+)/);
|
|
119
|
+
const op = match ? match[1] : '=';
|
|
120
|
+
|
|
121
|
+
// if gt/lt/eq then operator compare
|
|
122
|
+
if (op !== '^' && op !== '~') {
|
|
123
|
+
return compare(v, r, op);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// else range of either "~" or "^" is assumed
|
|
127
|
+
const [v1, v2, v3] = validateAndParse(v);
|
|
128
|
+
const [m1, m2, m3] = validateAndParse(r);
|
|
129
|
+
|
|
130
|
+
if (compareStrings(v1, m1) !== 0) {
|
|
131
|
+
return false;
|
|
132
|
+
} else if (op === '^') {
|
|
133
|
+
return compareSegments([v2, v3], [m2, m3]) >= 0;
|
|
134
|
+
} else if (compareStrings(v2, m2) !== 0) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return compareStrings(v3, m3) >= 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { watch, existsSync } from 'fs';
|
|
2
|
+
|
|
3
|
+
export interface WatcherRef<T> {
|
|
4
|
+
end: Promise<void>;
|
|
5
|
+
data: T;
|
|
6
|
+
onTrigger(cb: () => void): void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface WatcherContext {
|
|
10
|
+
onClean(dispose: () => void): void;
|
|
11
|
+
watch(file: string): void;
|
|
12
|
+
dependOn<T>(ref: WatcherRef<T>): void;
|
|
13
|
+
close(): void;
|
|
14
|
+
status: 'initial' | 'reoccuring';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function watcherTask<T = void>(cb: (watcherContext: WatcherContext) => Promise<T>) {
|
|
18
|
+
let running = Promise.resolve();
|
|
19
|
+
let pending = false;
|
|
20
|
+
let notify = () => {};
|
|
21
|
+
|
|
22
|
+
const disposers: Array<() => void> = [];
|
|
23
|
+
const triggers: Array<() => void> = [];
|
|
24
|
+
const end = new Promise<void>(resolve => {
|
|
25
|
+
notify = resolve;
|
|
26
|
+
});
|
|
27
|
+
const ref: WatcherRef<T> = {
|
|
28
|
+
data: undefined,
|
|
29
|
+
onTrigger(cb) {
|
|
30
|
+
triggers.push(cb);
|
|
31
|
+
},
|
|
32
|
+
end,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const reRun = async () => {
|
|
36
|
+
if (!pending) {
|
|
37
|
+
pending = true;
|
|
38
|
+
await running;
|
|
39
|
+
disposers.splice(0, disposers.length).forEach((dispose) => {
|
|
40
|
+
dispose();
|
|
41
|
+
});
|
|
42
|
+
pending = false;
|
|
43
|
+
context.status = 'reoccuring';
|
|
44
|
+
await run();
|
|
45
|
+
|
|
46
|
+
triggers.splice(0, triggers.length).forEach((trigger) => {
|
|
47
|
+
trigger();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const context: WatcherContext = {
|
|
53
|
+
onClean(dispose) {
|
|
54
|
+
disposers.push(dispose);
|
|
55
|
+
},
|
|
56
|
+
watch(file) {
|
|
57
|
+
if (existsSync(file)) {
|
|
58
|
+
const watcher = watch(
|
|
59
|
+
file,
|
|
60
|
+
{
|
|
61
|
+
persistent: false,
|
|
62
|
+
},
|
|
63
|
+
reRun,
|
|
64
|
+
);
|
|
65
|
+
disposers.push(() => watcher.close());
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
dependOn(anotherRef) {
|
|
69
|
+
anotherRef.onTrigger(reRun);
|
|
70
|
+
},
|
|
71
|
+
close() {
|
|
72
|
+
cb = () => Promise.resolve(undefined);
|
|
73
|
+
reRun().then(notify);
|
|
74
|
+
},
|
|
75
|
+
status: 'initial',
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const run = async () => {
|
|
79
|
+
running = cb(context).then((data) => {
|
|
80
|
+
ref.data = data;
|
|
81
|
+
});
|
|
82
|
+
await running;
|
|
83
|
+
return ref;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return new Promise<WatcherRef<T>>((resolve, reject) => {
|
|
87
|
+
run().then(resolve, reject);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as externals from '
|
|
1
|
+
import * as externals from '../external';
|
|
2
2
|
|
|
3
3
|
describe('Externals module', () => {
|
|
4
4
|
it('exports the FormData class', () => {
|
|
@@ -27,7 +27,7 @@ describe('Externals module', () => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
it('exports the logger module', () => {
|
|
30
|
-
const logger = externals.
|
|
30
|
+
const logger = externals.ora;
|
|
31
31
|
expect(logger).not.toBeUndefined();
|
|
32
32
|
});
|
|
33
33
|
|
package/src/external/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import logger = require('@parcel/logger');
|
|
2
|
-
import stripAnsi = require('strip-ansi');
|
|
3
1
|
import inquirer = require('inquirer');
|
|
2
|
+
import jju = require('jju');
|
|
4
3
|
import glob = require('glob');
|
|
5
4
|
import tar = require('tar');
|
|
6
5
|
import FormData = require('form-data');
|
|
@@ -9,5 +8,10 @@ import axios = require('axios');
|
|
|
9
8
|
import mime = require('mime');
|
|
10
9
|
import getPort = require('get-port');
|
|
11
10
|
import open = require('open');
|
|
11
|
+
import chalk = require('chalk');
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
import isInteractive from 'is-interactive';
|
|
14
|
+
import ora from 'ora';
|
|
15
|
+
import { getModulePath } from './resolve';
|
|
16
|
+
|
|
17
|
+
export { chalk, inquirer, isInteractive, ora, glob, tar, FormData, rc, axios, mime, getPort, open, jju, getModulePath };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as fs from 'graceful-fs';
|
|
2
|
+
import { ResolverFactory, CachedInputFileSystem } from 'enhanced-resolve';
|
|
3
|
+
|
|
4
|
+
const nodeFileSystem = new CachedInputFileSystem(fs, 100);
|
|
5
|
+
|
|
6
|
+
const nodeContext = {
|
|
7
|
+
environments: ['node+es3+es5+process+native'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const enhancedResolve = ResolverFactory.createResolver({
|
|
11
|
+
aliasFields: ['browser'],
|
|
12
|
+
conditionNames: ['import', 'module', 'webpack', 'development', 'browser'],
|
|
13
|
+
extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.json'],
|
|
14
|
+
exportsFields: ['exports'],
|
|
15
|
+
importsFields: ['imports'],
|
|
16
|
+
mainFields: ['browser', 'module', 'main'],
|
|
17
|
+
useSyncFileSystemCalls: true,
|
|
18
|
+
fileSystem: nodeFileSystem,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export function getModulePath(root: string, moduleName: string) {
|
|
22
|
+
const res = enhancedResolve.resolveSync(nodeContext, root, moduleName);
|
|
23
|
+
|
|
24
|
+
if (!res) {
|
|
25
|
+
throw new Error(`Could not find module "${moduleName}".`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return res;
|
|
29
|
+
}
|
package/src/helpers.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { keyOfForceOverwrite,
|
|
2
|
-
import { ForceOverwrite
|
|
1
|
+
import { keyOfForceOverwrite, valueOfForceOverwrite } from './helpers';
|
|
2
|
+
import { ForceOverwrite } from './common/enums';
|
|
3
3
|
|
|
4
4
|
describe('Piral CLI Command Helpers Module', () => {
|
|
5
5
|
it('correct value of keyOfForceOverwrite results in same key', () => {
|
|
@@ -12,16 +12,6 @@ describe('Piral CLI Command Helpers Module', () => {
|
|
|
12
12
|
expect(result).toBe('no');
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it('correct value of keyOfPiletLanguage results in same key', () => {
|
|
16
|
-
const result = keyOfPiletLanguage(SourceLanguage.ts);
|
|
17
|
-
expect(result).toBe('ts');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('incorrect value of keyOfPiletLanguage results in key for TS', () => {
|
|
21
|
-
const result = keyOfPiletLanguage(5);
|
|
22
|
-
expect(result).toBe('ts');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
15
|
it('correct key of valueOfForceOverwrite results in same value', () => {
|
|
26
16
|
const result = valueOfForceOverwrite('prompt');
|
|
27
17
|
expect(result).toBe(ForceOverwrite.prompt);
|
|
@@ -31,14 +21,4 @@ describe('Piral CLI Command Helpers Module', () => {
|
|
|
31
21
|
const result = valueOfForceOverwrite('foo');
|
|
32
22
|
expect(result).toBe(ForceOverwrite.no);
|
|
33
23
|
});
|
|
34
|
-
|
|
35
|
-
it('correct key of valueOfPiletLanguage results in same value', () => {
|
|
36
|
-
const result = valueOfPiletLanguage('ts');
|
|
37
|
-
expect(result).toBe(SourceLanguage.ts);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('incorrect key of valueOfPiletLanguage results in value for TS', () => {
|
|
41
|
-
const result = valueOfPiletLanguage('foo');
|
|
42
|
-
expect(result).toBe(SourceLanguage.ts);
|
|
43
|
-
});
|
|
44
24
|
});
|
package/src/helpers.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import { ForceOverwrite
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ForceOverwrite } from './common/enums';
|
|
2
|
+
import { bundlerNames, frameworkLibs } from './common/constants';
|
|
3
|
+
import type {
|
|
4
|
+
Framework,
|
|
5
|
+
NpmClientType,
|
|
6
|
+
PiletSchemaVersion,
|
|
7
|
+
PiletPublishSource,
|
|
8
|
+
PiralBuildType,
|
|
9
|
+
PiletBuildType,
|
|
10
|
+
PiletPublishScheme,
|
|
11
|
+
SourceLanguage,
|
|
12
|
+
} from './types';
|
|
13
|
+
|
|
14
|
+
export const schemaKeys: Array<PiletSchemaVersion> = ['v0', 'v1', 'v2', 'none'];
|
|
15
|
+
export const publishModeKeys: Array<PiletPublishScheme> = ['none', 'basic', 'bearer', 'digest'];
|
|
5
16
|
export const fromKeys: Array<PiletPublishSource> = ['local', 'remote', 'npm'];
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
17
|
+
export const piralBuildTypeKeys: Array<PiralBuildType> = ['all', 'release', 'emulator', 'emulator-sources'];
|
|
18
|
+
export const piletBuildTypeKeys: Array<PiletBuildType> = ['default', 'standalone', 'manifest'];
|
|
19
|
+
export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'pnp', 'yarn', 'lerna', 'rush'];
|
|
20
|
+
export const sourceLanguageKeys: Array<SourceLanguage> = ['ts', 'js'];
|
|
21
|
+
export const bundlerKeys: Array<string> = ['none', ...bundlerNames];
|
|
9
22
|
export const availableBundlers: Array<string> = [];
|
|
10
23
|
export const availableReleaseProviders: Array<string> = [];
|
|
11
|
-
export const frameworkKeys: Array<Framework> = [
|
|
24
|
+
export const frameworkKeys: Array<Framework> = [...frameworkLibs];
|
|
12
25
|
export const forceOverwriteKeys = Object.keys(ForceOverwrite).filter((m) => typeof ForceOverwrite[m] === 'number');
|
|
13
26
|
|
|
14
27
|
export function valueOfForceOverwrite(key: string): ForceOverwrite {
|
|
@@ -30,25 +43,3 @@ export function keyOfForceOverwrite(value: ForceOverwrite) {
|
|
|
30
43
|
|
|
31
44
|
return forceOverwriteKeys[0];
|
|
32
45
|
}
|
|
33
|
-
|
|
34
|
-
export const piletLanguageKeys = Object.keys(SourceLanguage).filter((m) => typeof SourceLanguage[m] === 'number');
|
|
35
|
-
|
|
36
|
-
export function valueOfPiletLanguage(key: string): SourceLanguage {
|
|
37
|
-
for (const piletLanguageKey of piletLanguageKeys) {
|
|
38
|
-
if (piletLanguageKey === key) {
|
|
39
|
-
return SourceLanguage[piletLanguageKey];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return SourceLanguage.ts;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function keyOfPiletLanguage(value: SourceLanguage) {
|
|
47
|
-
for (const piletLanguageKey of piletLanguageKeys) {
|
|
48
|
-
if (SourceLanguage[piletLanguageKey] === value) {
|
|
49
|
-
return piletLanguageKey;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return piletLanguageKeys[0];
|
|
54
|
-
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { KrasRequest } from 'kras';
|
|
3
|
-
import PiletInjector from './pilet';
|
|
3
|
+
import PiletInjector from './pilet-injector';
|
|
4
4
|
|
|
5
5
|
const optionsMock = {
|
|
6
6
|
pilets: [],
|
|
7
|
+
publicUrl: '/',
|
|
7
8
|
api: '',
|
|
8
9
|
app: '',
|
|
9
10
|
active: true,
|
|
11
|
+
meta: '',
|
|
12
|
+
headers: {},
|
|
10
13
|
};
|
|
11
14
|
|
|
12
15
|
const configMock: any = {
|
|
13
16
|
port: 1234,
|
|
14
17
|
};
|
|
15
18
|
|
|
16
|
-
describe('Piral-CLI
|
|
19
|
+
describe('Piral-CLI pilet injector', () => {
|
|
17
20
|
it('PiletInjector is active when configured', () => {
|
|
18
21
|
const core = new EventEmitter();
|
|
19
22
|
const injector = new PiletInjector(optionsMock, configMock, core);
|
|
@@ -30,7 +33,7 @@ describe('Piral-CLI piral injector', () => {
|
|
|
30
33
|
injector.name;
|
|
31
34
|
injector.getOptions();
|
|
32
35
|
//injector.getMetaOf(0);
|
|
33
|
-
injector.
|
|
36
|
+
injector.getIndexMeta('http://localhost:9000');
|
|
34
37
|
|
|
35
38
|
// Assert
|
|
36
39
|
expect(injector.active).toBeFalsy();
|
|
@@ -73,7 +76,7 @@ describe('Piral-CLI piral injector', () => {
|
|
|
73
76
|
const injector = new PiletInjector(optionsMock, configMock, core);
|
|
74
77
|
|
|
75
78
|
// Act
|
|
76
|
-
const res = await injector.sendResponse('some/nice/invalid/path', 'localhost:1234');
|
|
79
|
+
const res = await injector.sendResponse('some/nice/invalid/path', 'localhost:1234', 'http://localhost:9000');
|
|
77
80
|
|
|
78
81
|
// Assert
|
|
79
82
|
expect(res).toBeUndefined();
|
|
@@ -85,6 +88,9 @@ describe('Piral-CLI piral injector', () => {
|
|
|
85
88
|
pilets: [],
|
|
86
89
|
api: 'http://someFakeApi:1234',
|
|
87
90
|
app: '',
|
|
91
|
+
publicUrl: '/',
|
|
92
|
+
meta: '',
|
|
93
|
+
headers: {},
|
|
88
94
|
active: true,
|
|
89
95
|
};
|
|
90
96
|
|
|
@@ -112,6 +118,9 @@ describe('Piral-CLI piral injector', () => {
|
|
|
112
118
|
pilets: [],
|
|
113
119
|
api: 'http://someFakeApi:1234',
|
|
114
120
|
app: '',
|
|
121
|
+
publicUrl: '/',
|
|
122
|
+
meta: '',
|
|
123
|
+
headers: {},
|
|
115
124
|
active: true,
|
|
116
125
|
};
|
|
117
126
|
const core = new EventEmitter();
|