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/lib/common/npm.js
CHANGED
|
@@ -9,70 +9,59 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.makeExternals = exports.getPackageVersion = exports.getGitPackageVersion = exports.getFilePackageVersion = exports.getPackageName = exports.combinePackageRef = exports.isLinkedPackage = exports.
|
|
12
|
+
exports.makeExternals = exports.mergeExternals = exports.makePiletExternals = exports.getPackageVersion = exports.getGitPackageVersion = exports.getFilePackageVersion = exports.getPackageName = exports.combinePackageRef = exports.isLinkedPackage = exports.findPackageRoot = exports.tryResolvePackage = exports.getCurrentPackageDetails = exports.dissectPackageName = exports.makeFilePath = exports.makeGitUrl = exports.isGitPackage = exports.makeNpmAlias = exports.isNpmPackage = exports.isLocalPackage = exports.findLatestVersion = exports.findSpecificVersion = exports.findNpmTarball = exports.createNpmPackage = exports.publishNpmPackage = exports.initNpmProject = exports.installNpmPackage = exports.uninstallNpmPackage = exports.installNpmPackageFromOptionalRegistry = exports.installNpmDependencies = exports.isMonorepoPackageRef = exports.determineNpmClient = void 0;
|
|
13
13
|
const path_1 = require("path");
|
|
14
14
|
const fs_1 = require("fs");
|
|
15
15
|
const log_1 = require("./log");
|
|
16
|
+
const clients_1 = require("./clients");
|
|
16
17
|
const config_1 = require("./config");
|
|
17
|
-
const inspect_1 = require("./inspect");
|
|
18
18
|
const constants_1 = require("./constants");
|
|
19
|
+
const inspect_1 = require("./inspect");
|
|
19
20
|
const io_1 = require("./io");
|
|
20
21
|
const helpers_1 = require("../helpers");
|
|
22
|
+
const external_1 = require("../external");
|
|
21
23
|
const gitPrefix = 'git+';
|
|
22
24
|
const filePrefix = 'file:';
|
|
25
|
+
const npmPrefix = 'npm:';
|
|
26
|
+
const pathPrefixes = ['/', './', '../', '.\\', '..\\', '~/', '~\\', filePrefix];
|
|
23
27
|
function isProjectReference(name) {
|
|
24
|
-
const target = path_1.resolve(name,
|
|
25
|
-
return io_1.checkExists(target);
|
|
26
|
-
}
|
|
27
|
-
function detectPnpm(root) {
|
|
28
|
-
return new Promise((res) => {
|
|
29
|
-
fs_1.access(path_1.resolve(root, 'pnpm-lock.yaml'), fs_1.constants.F_OK, (noPnpmLock) => {
|
|
30
|
-
res(!noPnpmLock);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
28
|
+
const target = (0, path_1.resolve)(name, constants_1.packageJson);
|
|
29
|
+
return (0, io_1.checkExists)(target);
|
|
33
30
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
res(!noPackageLock);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
exports.detectNpm = detectNpm;
|
|
43
|
-
function detectYarn(root) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
return !!(yield io_1.findFile(root, 'yarn.lock'));
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
exports.detectYarn = detectYarn;
|
|
49
|
-
function getLernaConfigPath(root) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
log_1.log('generalDebug_0003', 'Trying to get the configuration file for Lerna ...');
|
|
52
|
-
const file = yield io_1.findFile(root, 'lerna.json');
|
|
53
|
-
if (file) {
|
|
54
|
-
log_1.log('generalDebug_0003', `Found Lerna config in "${file}".`);
|
|
55
|
-
return file;
|
|
56
|
-
}
|
|
57
|
-
return undefined;
|
|
58
|
-
});
|
|
31
|
+
function resolveAbsPath(basePath, fullName) {
|
|
32
|
+
const prefixed = fullName.startsWith(filePrefix);
|
|
33
|
+
const relPath = !prefixed ? fullName : fullName.replace(filePrefix, '');
|
|
34
|
+
return (0, path_1.resolve)(basePath, relPath);
|
|
59
35
|
}
|
|
60
|
-
|
|
61
|
-
function getLernaNpmClient(root) {
|
|
36
|
+
function detectMonorepoRoot(root) {
|
|
62
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return
|
|
38
|
+
let previous = root;
|
|
39
|
+
do {
|
|
40
|
+
if (yield (0, io_1.checkExists)((0, path_1.resolve)(root, 'lerna.json'))) {
|
|
41
|
+
return [root, 'lerna'];
|
|
67
42
|
}
|
|
68
|
-
|
|
69
|
-
|
|
43
|
+
if (yield (0, io_1.checkExists)((0, path_1.resolve)(root, 'rush.json'))) {
|
|
44
|
+
return [root, 'rush'];
|
|
70
45
|
}
|
|
71
|
-
|
|
72
|
-
|
|
46
|
+
if (yield (0, io_1.checkExists)((0, path_1.resolve)(root, 'pnpm-workspace.yaml'))) {
|
|
47
|
+
return [root, 'pnpm'];
|
|
48
|
+
}
|
|
49
|
+
const pj = yield (0, io_1.readJson)(root, constants_1.packageJson);
|
|
50
|
+
if (Array.isArray(pj === null || pj === void 0 ? void 0 : pj.workspaces)) {
|
|
51
|
+
if (yield (0, io_1.checkExists)((0, path_1.resolve)(root, '.pnp.cjs'))) {
|
|
52
|
+
return [root, 'pnp'];
|
|
53
|
+
}
|
|
54
|
+
if (yield (0, io_1.checkExists)((0, path_1.resolve)(root, 'yarn.lock'))) {
|
|
55
|
+
return [root, 'yarn'];
|
|
56
|
+
}
|
|
57
|
+
return [root, 'npm'];
|
|
58
|
+
}
|
|
59
|
+
previous = root;
|
|
60
|
+
root = (0, path_1.dirname)(root);
|
|
61
|
+
} while (root !== previous);
|
|
62
|
+
return [];
|
|
73
63
|
});
|
|
74
64
|
}
|
|
75
|
-
exports.getLernaNpmClient = getLernaNpmClient;
|
|
76
65
|
/**
|
|
77
66
|
* For details about how this works consult issue
|
|
78
67
|
* https://github.com/smapiot/piral/issues/203
|
|
@@ -81,35 +70,32 @@ exports.getLernaNpmClient = getLernaNpmClient;
|
|
|
81
70
|
function determineNpmClient(root, selected) {
|
|
82
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
72
|
if (!selected || !helpers_1.clientTypeKeys.includes(selected)) {
|
|
84
|
-
log_1.log('generalDebug_0003', 'No
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
log_1.log('generalDebug_0003', `Results of the lock file check:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
log_1.log('generalDebug_0003', `Found valid
|
|
93
|
-
return lernaClient;
|
|
73
|
+
(0, log_1.log)('generalDebug_0003', 'No npm client selected. Checking for lock or config files ...');
|
|
74
|
+
const searchedClients = yield (0, clients_1.detectClients)(root);
|
|
75
|
+
const foundClients = searchedClients.filter((m) => m.result);
|
|
76
|
+
(0, log_1.log)('generalDebug_0003', `Results of the lock file check: ${searchedClients.map((m) => `${m.client}=${m.result}`).join(', ')}`);
|
|
77
|
+
if (foundClients.length > 1) {
|
|
78
|
+
const wrapperClient = foundClients.find((m) => (0, clients_1.isWrapperClient)(m.client));
|
|
79
|
+
if (wrapperClient) {
|
|
80
|
+
const { client } = wrapperClient;
|
|
81
|
+
(0, log_1.log)('generalDebug_0003', `Found valid wrapper client via lock or config file: "${client}".`);
|
|
94
82
|
}
|
|
95
83
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
else if (hasPnpm) {
|
|
105
|
-
log_1.log('generalDebug_0003', `Found valid Pnpm client via lockfile.`);
|
|
106
|
-
return 'pnpm';
|
|
84
|
+
if (foundClients.length > 0) {
|
|
85
|
+
const { client } = foundClients[0];
|
|
86
|
+
if (foundClients.length > 1) {
|
|
87
|
+
const clientStr = `"${foundClients.map((m) => m.client).join('", "')}"`;
|
|
88
|
+
(0, log_1.log)('generalWarning_0001', `Found multiple clients via their lock or config files: ${clientStr}.`);
|
|
89
|
+
}
|
|
90
|
+
(0, log_1.log)('generalDebug_0003', `Found valid direct client via lock or config file: "${client}".`);
|
|
91
|
+
return client;
|
|
107
92
|
}
|
|
93
|
+
const defaultClient = config_1.config.npmClient;
|
|
108
94
|
if (helpers_1.clientTypeKeys.includes(defaultClient)) {
|
|
109
|
-
log_1.log('generalDebug_0003', `
|
|
95
|
+
(0, log_1.log)('generalDebug_0003', `Using the default client: "${defaultClient}".`);
|
|
110
96
|
return defaultClient;
|
|
111
97
|
}
|
|
112
|
-
log_1.log('generalDebug_0003', 'Using the
|
|
98
|
+
(0, log_1.log)('generalDebug_0003', 'Using the fallback "npm" client.');
|
|
113
99
|
return 'npm';
|
|
114
100
|
}
|
|
115
101
|
return selected;
|
|
@@ -117,78 +103,107 @@ function determineNpmClient(root, selected) {
|
|
|
117
103
|
}
|
|
118
104
|
exports.determineNpmClient = determineNpmClient;
|
|
119
105
|
function isMonorepoPackageRef(refName, root) {
|
|
120
|
-
var _a, _b, _c;
|
|
121
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
107
|
+
const [monorepoRoot, client] = yield detectMonorepoRoot(root);
|
|
108
|
+
if (monorepoRoot) {
|
|
109
|
+
const c = clients_1.clients[client];
|
|
110
|
+
return yield c.isProject(monorepoRoot, refName);
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
125
113
|
});
|
|
126
114
|
}
|
|
127
115
|
exports.isMonorepoPackageRef = isMonorepoPackageRef;
|
|
128
|
-
function
|
|
116
|
+
function installNpmDependencies(client, target = '.') {
|
|
117
|
+
const { installDependencies } = clients_1.clients[client];
|
|
118
|
+
return installDependencies(target);
|
|
119
|
+
}
|
|
120
|
+
exports.installNpmDependencies = installNpmDependencies;
|
|
121
|
+
function installNpmPackageFromOptionalRegistry(packageRef, target = '.', registry) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
try {
|
|
124
|
+
yield installNpmPackage('npm', packageRef, target, '--registry', registry);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
if (registry === constants_1.defaultRegistry) {
|
|
128
|
+
throw e;
|
|
129
|
+
}
|
|
130
|
+
yield installNpmPackage('npm', packageRef, target, '--registry', constants_1.defaultRegistry);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
exports.installNpmPackageFromOptionalRegistry = installNpmPackageFromOptionalRegistry;
|
|
135
|
+
function uninstallNpmPackage(client, packageRef, target = '.', ...flags) {
|
|
129
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return
|
|
137
|
+
try {
|
|
138
|
+
const { uninstallPackage } = clients_1.clients[client];
|
|
139
|
+
return yield uninstallPackage(packageRef, target, ...flags);
|
|
140
|
+
}
|
|
141
|
+
catch (ex) {
|
|
142
|
+
(0, log_1.log)('generalError_0002', `Could not uninstall the package "${packageRef}" using ${client}. Make sure ${client} is correctly installed and accessible: ${ex}`);
|
|
143
|
+
throw ex;
|
|
133
144
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
exports.uninstallNpmPackage = uninstallNpmPackage;
|
|
148
|
+
function installNpmPackage(client, packageRef, target = '.', ...flags) {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
try {
|
|
151
|
+
const { installPackage } = clients_1.clients[client];
|
|
152
|
+
return yield installPackage(packageRef, target, ...flags);
|
|
153
|
+
}
|
|
154
|
+
catch (ex) {
|
|
155
|
+
(0, log_1.log)('generalError_0002', `Could not install the package "${packageRef}" using ${client}. Make sure ${client} is correctly installed and accessible: ${ex}`);
|
|
156
|
+
throw ex;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
exports.installNpmPackage = installNpmPackage;
|
|
161
|
+
function initNpmProject(client, projectName, target) {
|
|
162
|
+
const { initProject } = clients_1.clients[client];
|
|
163
|
+
return initProject(projectName, target);
|
|
164
|
+
}
|
|
165
|
+
exports.initNpmProject = initNpmProject;
|
|
166
|
+
function publishNpmPackage(target = '.', file = '*.tgz', flags = [], interactive = false) {
|
|
167
|
+
const { publishPackage, loginUser } = clients_1.clients.npm;
|
|
168
|
+
return publishPackage(target, file, ...flags).catch(err => {
|
|
169
|
+
if (!interactive) {
|
|
170
|
+
throw err;
|
|
137
171
|
}
|
|
138
|
-
return
|
|
172
|
+
return loginUser().then(() => publishNpmPackage(target, file, flags, false));
|
|
139
173
|
});
|
|
140
174
|
}
|
|
141
|
-
exports.
|
|
142
|
-
function
|
|
143
|
-
const
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
exports.
|
|
147
|
-
function
|
|
148
|
-
const
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
exports.
|
|
152
|
-
function installPackage(client, packageRef, target = '.', ...flags) {
|
|
153
|
-
const c = require(`./clients/${client}`);
|
|
154
|
-
return c.installPackage(packageRef, target, ...flags);
|
|
155
|
-
}
|
|
156
|
-
exports.installPackage = installPackage;
|
|
157
|
-
function publishPackage(target = '.', file = '*.tgz', flags = []) {
|
|
158
|
-
const c = require(`./clients/npm`);
|
|
159
|
-
return c.publishPackage(target, file, ...flags);
|
|
160
|
-
}
|
|
161
|
-
exports.publishPackage = publishPackage;
|
|
162
|
-
function createPackage(target = '.') {
|
|
163
|
-
const c = require(`./clients/npm`);
|
|
164
|
-
return c.createPackage(target);
|
|
165
|
-
}
|
|
166
|
-
exports.createPackage = createPackage;
|
|
167
|
-
function findTarball(packageRef) {
|
|
168
|
-
const c = require(`./clients/npm`);
|
|
169
|
-
return c.findTarball(packageRef);
|
|
170
|
-
}
|
|
171
|
-
exports.findTarball = findTarball;
|
|
175
|
+
exports.publishNpmPackage = publishNpmPackage;
|
|
176
|
+
function createNpmPackage(target = '.') {
|
|
177
|
+
const { createPackage } = clients_1.clients.npm;
|
|
178
|
+
return createPackage(target);
|
|
179
|
+
}
|
|
180
|
+
exports.createNpmPackage = createNpmPackage;
|
|
181
|
+
function findNpmTarball(packageRef) {
|
|
182
|
+
const { findTarball } = clients_1.clients.npm;
|
|
183
|
+
return findTarball(packageRef);
|
|
184
|
+
}
|
|
185
|
+
exports.findNpmTarball = findNpmTarball;
|
|
172
186
|
function findSpecificVersion(packageName, version) {
|
|
173
|
-
const
|
|
174
|
-
return
|
|
187
|
+
const { findSpecificVersion } = clients_1.clients.npm;
|
|
188
|
+
return findSpecificVersion(packageName, version);
|
|
175
189
|
}
|
|
176
190
|
exports.findSpecificVersion = findSpecificVersion;
|
|
177
191
|
function findLatestVersion(packageName) {
|
|
192
|
+
const { findSpecificVersion } = clients_1.clients.npm;
|
|
178
193
|
return findSpecificVersion(packageName, 'latest');
|
|
179
194
|
}
|
|
180
195
|
exports.findLatestVersion = findLatestVersion;
|
|
181
196
|
function isLocalPackage(baseDir, fullName) {
|
|
182
|
-
log_1.log('generalDebug_0003', 'Checking if its a local package ...');
|
|
197
|
+
(0, log_1.log)('generalDebug_0003', 'Checking if its a local package ...');
|
|
183
198
|
if (fullName) {
|
|
184
|
-
if (
|
|
185
|
-
log_1.log('generalDebug_0003', 'Found a local package by name.');
|
|
199
|
+
if (pathPrefixes.some((prefix) => fullName.startsWith(prefix))) {
|
|
200
|
+
(0, log_1.log)('generalDebug_0003', 'Found a local package by name.');
|
|
186
201
|
return true;
|
|
187
202
|
}
|
|
188
203
|
else if (fullName.endsWith('.tgz')) {
|
|
189
|
-
log_1.log('generalDebug_0003', ' Verifying if local path exists ...');
|
|
190
|
-
if (fs_1.existsSync(path_1.resolve(baseDir, fullName))) {
|
|
191
|
-
log_1.log('generalDebug_0003', 'Found a potential local package by path.');
|
|
204
|
+
(0, log_1.log)('generalDebug_0003', ' Verifying if local path exists ...');
|
|
205
|
+
if ((0, fs_1.existsSync)((0, path_1.resolve)(baseDir, fullName))) {
|
|
206
|
+
(0, log_1.log)('generalDebug_0003', 'Found a potential local package by path.');
|
|
192
207
|
return true;
|
|
193
208
|
}
|
|
194
209
|
}
|
|
@@ -197,12 +212,28 @@ function isLocalPackage(baseDir, fullName) {
|
|
|
197
212
|
return false;
|
|
198
213
|
}
|
|
199
214
|
exports.isLocalPackage = isLocalPackage;
|
|
215
|
+
function isNpmPackage(fullName) {
|
|
216
|
+
(0, log_1.log)('generalDebug_0003', 'Checking if its an npm alias ...');
|
|
217
|
+
if (fullName) {
|
|
218
|
+
const npmed = fullName.startsWith(npmPrefix);
|
|
219
|
+
if (npmed && fullName.substring(npmPrefix.length + 1).indexOf('@') !== -1) {
|
|
220
|
+
(0, log_1.log)('generalDebug_0003', 'Found an npm package alias by name.');
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
exports.isNpmPackage = isNpmPackage;
|
|
227
|
+
function makeNpmAlias(name, version) {
|
|
228
|
+
return `${npmPrefix}${name}@${version}`;
|
|
229
|
+
}
|
|
230
|
+
exports.makeNpmAlias = makeNpmAlias;
|
|
200
231
|
function isGitPackage(fullName) {
|
|
201
|
-
log_1.log('generalDebug_0003', 'Checking if its a Git package ...');
|
|
232
|
+
(0, log_1.log)('generalDebug_0003', 'Checking if its a Git package ...');
|
|
202
233
|
if (fullName) {
|
|
203
234
|
const gitted = fullName.startsWith(gitPrefix);
|
|
204
235
|
if (gitted || /^(https?|ssh):\/\/.*\.git$/.test(fullName)) {
|
|
205
|
-
log_1.log('generalDebug_0003', 'Found a Git package by name.');
|
|
236
|
+
(0, log_1.log)('generalDebug_0003', 'Found a Git package by name.');
|
|
206
237
|
return true;
|
|
207
238
|
}
|
|
208
239
|
}
|
|
@@ -215,9 +246,7 @@ function makeGitUrl(fullName) {
|
|
|
215
246
|
}
|
|
216
247
|
exports.makeGitUrl = makeGitUrl;
|
|
217
248
|
function makeFilePath(basePath, fullName) {
|
|
218
|
-
const
|
|
219
|
-
const relPath = !prefixed ? fullName : fullName.replace(filePrefix, '');
|
|
220
|
-
const absPath = path_1.resolve(basePath, relPath);
|
|
249
|
+
const absPath = resolveAbsPath(basePath, fullName);
|
|
221
250
|
return `${filePrefix}${absPath}`;
|
|
222
251
|
}
|
|
223
252
|
exports.makeFilePath = makeFilePath;
|
|
@@ -240,14 +269,14 @@ function dissectPackageName(baseDir, fullName) {
|
|
|
240
269
|
return [gitUrl, 'latest', false, 'git'];
|
|
241
270
|
}
|
|
242
271
|
else if (isLocalPackage(baseDir, fullName)) {
|
|
243
|
-
const fullPath =
|
|
244
|
-
const exists = yield io_1.checkExists(fullPath);
|
|
272
|
+
const fullPath = resolveAbsPath(baseDir, fullName);
|
|
273
|
+
const exists = yield (0, io_1.checkExists)(fullPath);
|
|
245
274
|
if (!exists) {
|
|
246
|
-
log_1.fail('scaffoldPathDoesNotExist_0030', fullPath);
|
|
275
|
+
(0, log_1.fail)('scaffoldPathDoesNotExist_0030', fullPath);
|
|
247
276
|
}
|
|
248
277
|
const isReference = yield isProjectReference(fullPath);
|
|
249
278
|
if (isReference) {
|
|
250
|
-
log_1.fail('projectReferenceNotSupported_0032', fullPath);
|
|
279
|
+
(0, log_1.fail)('projectReferenceNotSupported_0032', fullPath);
|
|
251
280
|
}
|
|
252
281
|
return [fullPath, 'latest', false, 'file'];
|
|
253
282
|
}
|
|
@@ -255,7 +284,7 @@ function dissectPackageName(baseDir, fullName) {
|
|
|
255
284
|
const index = fullName.indexOf('@', 1);
|
|
256
285
|
const type = 'registry';
|
|
257
286
|
if (index !== -1) {
|
|
258
|
-
return [fullName.
|
|
287
|
+
return [fullName.substring(0, index), fullName.substring(index + 1), true, type];
|
|
259
288
|
}
|
|
260
289
|
return [fullName, 'latest', false, type];
|
|
261
290
|
}
|
|
@@ -276,16 +305,16 @@ exports.dissectPackageName = dissectPackageName;
|
|
|
276
305
|
*/
|
|
277
306
|
function getCurrentPackageDetails(baseDir, sourceName, sourceVersion, desired, root) {
|
|
278
307
|
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
-
log_1.log('generalDebug_0003', `Checking package details in "${baseDir}" ...`);
|
|
308
|
+
(0, log_1.log)('generalDebug_0003', `Checking package details in "${baseDir}" ...`);
|
|
280
309
|
if (isLocalPackage(baseDir, desired)) {
|
|
281
|
-
const fullPath = path_1.resolve(baseDir, desired);
|
|
282
|
-
const exists = yield io_1.checkExists(fullPath);
|
|
310
|
+
const fullPath = (0, path_1.resolve)(baseDir, desired);
|
|
311
|
+
const exists = yield (0, io_1.checkExists)(fullPath);
|
|
283
312
|
if (!exists) {
|
|
284
|
-
log_1.fail('upgradePathDoesNotExist_0031', fullPath);
|
|
313
|
+
(0, log_1.fail)('upgradePathDoesNotExist_0031', fullPath);
|
|
285
314
|
}
|
|
286
315
|
const isReference = yield isProjectReference(fullPath);
|
|
287
316
|
if (isReference) {
|
|
288
|
-
log_1.fail('projectReferenceNotSupported_0032', fullPath);
|
|
317
|
+
(0, log_1.fail)('projectReferenceNotSupported_0032', fullPath);
|
|
289
318
|
}
|
|
290
319
|
return [fullPath, getFilePackageVersion(fullPath, root)];
|
|
291
320
|
}
|
|
@@ -294,7 +323,7 @@ function getCurrentPackageDetails(baseDir, sourceName, sourceVersion, desired, r
|
|
|
294
323
|
return [gitUrl, getGitPackageVersion(gitUrl)];
|
|
295
324
|
}
|
|
296
325
|
else if (sourceVersion && sourceVersion.startsWith('file:')) {
|
|
297
|
-
log_1.log('localeFileForUpgradeMissing_0050');
|
|
326
|
+
(0, log_1.log)('localeFileForUpgradeMissing_0050');
|
|
298
327
|
}
|
|
299
328
|
else if (sourceVersion && sourceVersion.startsWith('git+')) {
|
|
300
329
|
if (desired === 'latest') {
|
|
@@ -302,27 +331,49 @@ function getCurrentPackageDetails(baseDir, sourceName, sourceVersion, desired, r
|
|
|
302
331
|
return [gitUrl, getGitPackageVersion(gitUrl)];
|
|
303
332
|
}
|
|
304
333
|
else {
|
|
305
|
-
log_1.log('gitLatestForUpgradeMissing_0051');
|
|
334
|
+
(0, log_1.log)('gitLatestForUpgradeMissing_0051');
|
|
306
335
|
}
|
|
307
336
|
}
|
|
308
337
|
return [combinePackageRef(sourceName, desired, 'registry'), desired];
|
|
309
338
|
});
|
|
310
339
|
}
|
|
311
340
|
exports.getCurrentPackageDetails = getCurrentPackageDetails;
|
|
312
|
-
function
|
|
341
|
+
function tryResolve(packageName, baseDir = process.cwd()) {
|
|
342
|
+
try {
|
|
343
|
+
return (0, external_1.getModulePath)(baseDir, packageName);
|
|
344
|
+
}
|
|
345
|
+
catch (_a) {
|
|
346
|
+
return undefined;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
function tryResolvePackage(name, baseDir = undefined) {
|
|
350
|
+
const path = baseDir ? tryResolve(name, baseDir) : tryResolve(name);
|
|
351
|
+
const root = baseDir || process.cwd();
|
|
352
|
+
if (!path) {
|
|
353
|
+
(0, log_1.log)('generalDebug_0003', `Could not resolve the package "${name}" in "${root}".`);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
(0, log_1.log)('generalVerbose_0004', `Resolved the package "${name}" (from "${root}") to be "${path}".`);
|
|
357
|
+
}
|
|
358
|
+
return path;
|
|
359
|
+
}
|
|
360
|
+
exports.tryResolvePackage = tryResolvePackage;
|
|
361
|
+
function findPackageRoot(pck, baseDir) {
|
|
362
|
+
return tryResolvePackage(`${pck}/${constants_1.packageJson}`, baseDir);
|
|
363
|
+
}
|
|
364
|
+
exports.findPackageRoot = findPackageRoot;
|
|
365
|
+
function isLinkedPackage(name, type, hadVersion, target) {
|
|
313
366
|
if (type === 'registry' && !hadVersion) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return true;
|
|
317
|
-
}
|
|
318
|
-
catch (_a) { }
|
|
367
|
+
const root = findPackageRoot(name, target);
|
|
368
|
+
return typeof root === 'string';
|
|
319
369
|
}
|
|
320
370
|
return false;
|
|
321
371
|
}
|
|
322
372
|
exports.isLinkedPackage = isLinkedPackage;
|
|
323
373
|
function combinePackageRef(name, version, type) {
|
|
324
374
|
if (type === 'registry') {
|
|
325
|
-
|
|
375
|
+
const tag = version || 'latest';
|
|
376
|
+
return `${name}@${tag}`;
|
|
326
377
|
}
|
|
327
378
|
return name;
|
|
328
379
|
}
|
|
@@ -331,16 +382,22 @@ function getPackageName(root, name, type) {
|
|
|
331
382
|
return __awaiter(this, void 0, void 0, function* () {
|
|
332
383
|
switch (type) {
|
|
333
384
|
case 'file':
|
|
334
|
-
const originalPackageJson = yield io_1.readJson(name,
|
|
385
|
+
const originalPackageJson = yield (0, io_1.readJson)(name, constants_1.packageJson);
|
|
335
386
|
if (!originalPackageJson.name) {
|
|
336
|
-
const p = path_1.resolve(process.cwd(), name);
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
387
|
+
const p = (0, path_1.resolve)(process.cwd(), name);
|
|
388
|
+
try {
|
|
389
|
+
const s = (0, fs_1.createReadStream)(p);
|
|
390
|
+
const i = yield (0, inspect_1.inspectPackage)(s);
|
|
391
|
+
return i.name;
|
|
392
|
+
}
|
|
393
|
+
catch (err) {
|
|
394
|
+
(0, log_1.log)('generalError_0002', `Could not open package tarball at "${p}": "${err}`);
|
|
395
|
+
return undefined;
|
|
396
|
+
}
|
|
340
397
|
}
|
|
341
398
|
return originalPackageJson.name;
|
|
342
399
|
case 'git':
|
|
343
|
-
const pj = yield io_1.readJson(root,
|
|
400
|
+
const pj = yield (0, io_1.readJson)(root, constants_1.packageJson);
|
|
344
401
|
const dd = pj.devDependencies || {};
|
|
345
402
|
return Object.keys(dd).filter((dep) => dd[dep] === name)[0];
|
|
346
403
|
case 'registry':
|
|
@@ -350,7 +407,7 @@ function getPackageName(root, name, type) {
|
|
|
350
407
|
}
|
|
351
408
|
exports.getPackageName = getPackageName;
|
|
352
409
|
function getFilePackageVersion(sourceName, root) {
|
|
353
|
-
const path = path_1.relative(root, sourceName);
|
|
410
|
+
const path = (0, path_1.relative)(root, sourceName);
|
|
354
411
|
return `${filePrefix}${path}`;
|
|
355
412
|
}
|
|
356
413
|
exports.getFilePackageVersion = getFilePackageVersion;
|
|
@@ -369,12 +426,52 @@ function getPackageVersion(hadVersion, sourceName, sourceVersion, type, root) {
|
|
|
369
426
|
}
|
|
370
427
|
}
|
|
371
428
|
exports.getPackageVersion = getPackageVersion;
|
|
372
|
-
function
|
|
373
|
-
|
|
374
|
-
|
|
429
|
+
function getExternalsFrom(root, packageName) {
|
|
430
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
431
|
+
try {
|
|
432
|
+
const target = (0, external_1.getModulePath)(root, `${packageName}/${constants_1.packageJson}`);
|
|
433
|
+
const dir = (0, path_1.dirname)(target);
|
|
434
|
+
const { sharedDependencies } = yield (0, io_1.readJson)(dir, constants_1.packageJson);
|
|
435
|
+
return sharedDependencies;
|
|
436
|
+
}
|
|
437
|
+
catch (err) {
|
|
438
|
+
(0, log_1.log)('generalError_0002', `Could not get externals from "${packageName}": "${err}`);
|
|
439
|
+
return undefined;
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
function getCoreExternals(root, dependencies) {
|
|
444
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
445
|
+
for (const frameworkLib of constants_1.frameworkLibs) {
|
|
446
|
+
if (dependencies[frameworkLib]) {
|
|
447
|
+
const deps = yield getExternalsFrom(root, frameworkLib);
|
|
448
|
+
if (deps) {
|
|
449
|
+
return deps;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
(0, log_1.log)('frameworkLibMissing_0078', constants_1.frameworkLibs);
|
|
454
|
+
return [];
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
function makePiletExternals(root, dependencies, fromEmulator, piralInfo) {
|
|
458
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
459
|
+
if (fromEmulator) {
|
|
460
|
+
const { sharedDependencies = constants_1.legacyCoreExternals } = piralInfo;
|
|
461
|
+
return sharedDependencies;
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
return yield getCoreExternals(root, dependencies);
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
exports.makePiletExternals = makePiletExternals;
|
|
469
|
+
function mergeExternals(customExternals, coreExternals = []) {
|
|
470
|
+
if (customExternals && Array.isArray(customExternals)) {
|
|
471
|
+
const [include, exclude] = customExternals.reduce((prev, curr) => {
|
|
375
472
|
if (typeof curr === 'string') {
|
|
376
473
|
if (curr.startsWith('!')) {
|
|
377
|
-
prev[1].push(curr.
|
|
474
|
+
prev[1].push(curr.substring(1));
|
|
378
475
|
}
|
|
379
476
|
else {
|
|
380
477
|
prev[0].push(curr);
|
|
@@ -382,10 +479,17 @@ function makeExternals(externals) {
|
|
|
382
479
|
}
|
|
383
480
|
return prev;
|
|
384
481
|
}, [[], []]);
|
|
385
|
-
const all = exclude.includes('*') ? include : [...include, ...
|
|
482
|
+
const all = exclude.includes('*') ? include : [...include, ...coreExternals];
|
|
386
483
|
return all.filter((m, i, arr) => !exclude.includes(m) && arr.indexOf(m) === i);
|
|
387
484
|
}
|
|
388
|
-
return
|
|
485
|
+
return coreExternals;
|
|
486
|
+
}
|
|
487
|
+
exports.mergeExternals = mergeExternals;
|
|
488
|
+
function makeExternals(root, dependencies, externals) {
|
|
489
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
490
|
+
const coreExternals = yield getCoreExternals(root, dependencies);
|
|
491
|
+
return mergeExternals(externals, coreExternals);
|
|
492
|
+
});
|
|
389
493
|
}
|
|
390
494
|
exports.makeExternals = makeExternals;
|
|
391
495
|
//# sourceMappingURL=npm.js.map
|