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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/common/interactive.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/common/interactive.ts"],"names":[],"mappings":"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"}
|
package/lib/common/io.d.ts
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ForceOverwrite } from './enums';
|
|
3
|
+
export interface Destination {
|
|
4
|
+
outDir: string;
|
|
5
|
+
outFile: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function getDestination(entryFiles: string, target: string): Destination;
|
|
3
8
|
export declare function removeAny(target: string): Promise<void>;
|
|
4
9
|
export declare function removeDirectory(targetDir: string): Promise<void>;
|
|
5
10
|
export declare function createDirectory(targetDir: string): Promise<boolean>;
|
|
6
11
|
export declare function getEntryFiles(content: string, basePath: string): Promise<string[]>;
|
|
12
|
+
export declare function makeTempDir(prefix: string): Promise<string>;
|
|
7
13
|
export declare function checkExists(target: string): Promise<boolean>;
|
|
8
14
|
export declare function checkExistingDirectory(target: string): Promise<boolean>;
|
|
9
15
|
export declare function checkIsDirectory(target: string): Promise<boolean>;
|
|
10
16
|
export declare function getFileNames(target: string): Promise<string[]>;
|
|
11
|
-
export declare function findFile(topDir: string, fileName: string): Promise<string>;
|
|
12
|
-
export declare function
|
|
17
|
+
export declare function findFile(topDir: string, fileName: string | Array<string>, stopDir?: string): Promise<string>;
|
|
18
|
+
export declare function matchAnyPilet(baseDir: string, patterns: Array<string>): Promise<string[]>;
|
|
13
19
|
export declare function matchFiles(baseDir: string, pattern: string): Promise<string[]>;
|
|
14
20
|
export declare function createFileIfNotExists(targetDir: string, fileName: string, content: Buffer | string, forceOverwrite?: ForceOverwrite): Promise<void>;
|
|
15
21
|
export declare function updateExistingFile(targetDir: string, fileName: string, content: string): Promise<void>;
|
|
16
22
|
export declare function getHash(targetFile: string): Promise<string>;
|
|
17
23
|
export declare function mergeWithJson<T>(targetDir: string, fileName: string, newContent: T): Promise<any>;
|
|
18
|
-
export declare function readJson<T = any>(targetDir: string, fileName: string): Promise<T>;
|
|
24
|
+
export declare function readJson<T = any>(targetDir: string, fileName: string, defaultValue?: {}): Promise<T>;
|
|
19
25
|
export declare function readBinary(targetDir: string, fileName: string): Promise<Buffer>;
|
|
20
26
|
export declare function readText(targetDir: string, fileName: string): Promise<string>;
|
|
21
27
|
export declare function writeJson<T = any>(targetDir: string, fileName: string, data: T, beautify?: boolean): Promise<void>;
|
package/lib/common/io.js
CHANGED
|
@@ -9,52 +9,43 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getSourceFiles = exports.move = exports.removeFile = exports.remove = exports.copy = exports.updateExistingJson = exports.writeBinary = exports.writeText = exports.writeJson = exports.readText = exports.readBinary = exports.readJson = exports.mergeWithJson = exports.getHash = exports.updateExistingFile = exports.createFileIfNotExists = exports.matchFiles = exports.
|
|
12
|
+
exports.getSourceFiles = exports.move = exports.removeFile = exports.remove = exports.copy = exports.updateExistingJson = exports.writeBinary = exports.writeText = exports.writeJson = exports.readText = exports.readBinary = exports.readJson = exports.mergeWithJson = exports.getHash = exports.updateExistingFile = exports.createFileIfNotExists = exports.matchFiles = exports.matchAnyPilet = exports.findFile = exports.getFileNames = exports.checkIsDirectory = exports.checkExistingDirectory = exports.checkExists = exports.makeTempDir = exports.getEntryFiles = exports.createDirectory = exports.removeDirectory = exports.removeAny = exports.getDestination = void 0;
|
|
13
13
|
const rimraf = require("rimraf");
|
|
14
14
|
const typescript_1 = require("typescript");
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
17
|
const fs_2 = require("fs");
|
|
18
|
+
const fs_3 = require("fs");
|
|
19
|
+
const constants_1 = require("./constants");
|
|
18
20
|
const log_1 = require("./log");
|
|
19
21
|
const merge_1 = require("./merge");
|
|
20
|
-
const info_1 = require("./info");
|
|
21
22
|
const hash_1 = require("./hash");
|
|
22
23
|
const enums_1 = require("./enums");
|
|
23
24
|
const interactive_1 = require("./interactive");
|
|
24
25
|
const external_1 = require("../external");
|
|
25
26
|
function promptOverwrite(file) {
|
|
26
27
|
const message = `The file ${file} exists already. Do you want to overwrite it?`;
|
|
27
|
-
return interactive_1.promptConfirm(message, false);
|
|
28
|
-
}
|
|
29
|
-
function createDirectoryLegacy(targetDir) {
|
|
30
|
-
const initDir = path_1.isAbsolute(targetDir) ? path_1.sep : '';
|
|
31
|
-
return targetDir.split(path_1.sep).reduce((parentDir, childDir) => {
|
|
32
|
-
const curDir = path_1.resolve(parentDir, childDir);
|
|
33
|
-
try {
|
|
34
|
-
fs_1.mkdirSync(curDir);
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
if (err.code === 'EEXIST') {
|
|
38
|
-
return curDir;
|
|
39
|
-
}
|
|
40
|
-
if (err.code === 'ENOENT') {
|
|
41
|
-
throw new Error(`EACCES: permission denied, mkdir '${parentDir}'`);
|
|
42
|
-
}
|
|
43
|
-
const caughtErr = ['EACCES', 'EPERM', 'EISDIR'].indexOf(err.code) > -1;
|
|
44
|
-
if (!caughtErr || (caughtErr && curDir === path_1.resolve(targetDir))) {
|
|
45
|
-
throw err;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return curDir;
|
|
49
|
-
}, initDir);
|
|
28
|
+
return (0, interactive_1.promptConfirm)(message, false);
|
|
50
29
|
}
|
|
51
30
|
function isFile(file) {
|
|
52
|
-
return fs_1.statSync(file).isFile();
|
|
31
|
+
return (0, fs_1.statSync)(file).isFile();
|
|
53
32
|
}
|
|
54
|
-
function
|
|
55
|
-
const
|
|
56
|
-
|
|
33
|
+
function getDestination(entryFiles, target) {
|
|
34
|
+
const isdir = (0, path_1.extname)(target) !== '.html';
|
|
35
|
+
if (isdir) {
|
|
36
|
+
return {
|
|
37
|
+
outDir: target,
|
|
38
|
+
outFile: (0, path_1.basename)(entryFiles),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return {
|
|
43
|
+
outDir: (0, path_1.dirname)(target),
|
|
44
|
+
outFile: (0, path_1.basename)(target),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
57
47
|
}
|
|
48
|
+
exports.getDestination = getDestination;
|
|
58
49
|
function removeAny(target) {
|
|
59
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
51
|
const isDir = yield checkIsDirectory(target);
|
|
@@ -68,34 +59,22 @@ function removeAny(target) {
|
|
|
68
59
|
}
|
|
69
60
|
exports.removeAny = removeAny;
|
|
70
61
|
function removeDirectory(targetDir) {
|
|
71
|
-
log_1.log('generalDebug_0003', `Removing the directory "${targetDir}" ...`);
|
|
62
|
+
(0, log_1.log)('generalDebug_0003', `Removing the directory "${targetDir}" ...`);
|
|
72
63
|
return new Promise((resolve, reject) => rimraf(targetDir, (err) => (err ? reject(err) : resolve())));
|
|
73
64
|
}
|
|
74
65
|
exports.removeDirectory = removeDirectory;
|
|
75
66
|
function createDirectory(targetDir) {
|
|
76
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
if (isLegacy()) {
|
|
78
|
-
try {
|
|
79
|
-
log_1.log('generalDebug_0003', `Trying to create "${targetDir}" in legacy mode ...`);
|
|
80
|
-
createDirectoryLegacy(targetDir);
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
catch (e) {
|
|
84
|
-
log_1.log('cannotCreateDirectory_0044');
|
|
85
|
-
log_1.log('generalDebug_0003', `Error while creating ${targetDir}: ${e}`);
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
68
|
try {
|
|
90
|
-
log_1.log('generalDebug_0003', `Trying to create "${targetDir}"
|
|
69
|
+
(0, log_1.log)('generalDebug_0003', `Trying to create "${targetDir}" ...`);
|
|
91
70
|
yield new Promise((resolve, reject) => {
|
|
92
|
-
|
|
71
|
+
(0, fs_2.mkdir)(targetDir, { recursive: true }, (err) => (err ? reject(err) : resolve()));
|
|
93
72
|
});
|
|
94
73
|
return true;
|
|
95
74
|
}
|
|
96
75
|
catch (e) {
|
|
97
|
-
log_1.log('cannotCreateDirectory_0044');
|
|
98
|
-
log_1.log('generalDebug_0003', `Error while creating ${targetDir}: ${e}`);
|
|
76
|
+
(0, log_1.log)('cannotCreateDirectory_0044');
|
|
77
|
+
(0, log_1.log)('generalDebug_0003', `Error while creating ${targetDir}: ${e}`);
|
|
99
78
|
return false;
|
|
100
79
|
}
|
|
101
80
|
});
|
|
@@ -103,14 +82,14 @@ function createDirectory(targetDir) {
|
|
|
103
82
|
exports.createDirectory = createDirectory;
|
|
104
83
|
function getEntryFiles(content, basePath) {
|
|
105
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
log_1.log('generalDebug_0003', `Extract entry files from "${basePath}".`);
|
|
85
|
+
(0, log_1.log)('generalDebug_0003', `Extract entry files from "${basePath}".`);
|
|
107
86
|
const matcher = /<script\s.*?src=(?:"(.*?)"|'(.*?)'|([^\s>]*)).*?>/gi;
|
|
108
87
|
const results = [];
|
|
109
88
|
let result = undefined;
|
|
110
89
|
while ((result = matcher.exec(content))) {
|
|
111
90
|
const src = result[1] || result[2] || result[3];
|
|
112
|
-
log_1.log('generalDebug_0003', `Found potential entry file "${src}".`);
|
|
113
|
-
const filePath = path_1.resolve(basePath, src);
|
|
91
|
+
(0, log_1.log)('generalDebug_0003', `Found potential entry file "${src}".`);
|
|
92
|
+
const filePath = (0, path_1.resolve)(basePath, src);
|
|
114
93
|
const exists = yield checkExists(filePath);
|
|
115
94
|
if (exists) {
|
|
116
95
|
results.push(filePath);
|
|
@@ -120,10 +99,21 @@ function getEntryFiles(content, basePath) {
|
|
|
120
99
|
});
|
|
121
100
|
}
|
|
122
101
|
exports.getEntryFiles = getEntryFiles;
|
|
102
|
+
function makeTempDir(prefix) {
|
|
103
|
+
return new Promise((resolve, reject) => (0, fs_2.mkdtemp)(prefix, (err, folder) => {
|
|
104
|
+
if (err) {
|
|
105
|
+
reject(err);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
resolve(folder);
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
exports.makeTempDir = makeTempDir;
|
|
123
113
|
function checkExists(target) {
|
|
124
114
|
return new Promise((resolve) => {
|
|
125
115
|
if (target !== undefined) {
|
|
126
|
-
fs_1.exists(target, resolve);
|
|
116
|
+
(0, fs_1.exists)(target, resolve);
|
|
127
117
|
}
|
|
128
118
|
else {
|
|
129
119
|
resolve(false);
|
|
@@ -133,9 +123,9 @@ function checkExists(target) {
|
|
|
133
123
|
exports.checkExists = checkExists;
|
|
134
124
|
function checkExistingDirectory(target) {
|
|
135
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
log_1.log('generalDebug_0003', `Checking directory "${target}" ...`);
|
|
126
|
+
(0, log_1.log)('generalDebug_0003', `Checking directory "${target}" ...`);
|
|
137
127
|
if (yield checkExists(target)) {
|
|
138
|
-
log_1.log('generalDebug_0003', `Target exists, but not yet clear if directory.`);
|
|
128
|
+
(0, log_1.log)('generalDebug_0003', `Target exists, but not yet clear if directory.`);
|
|
139
129
|
return yield checkIsDirectory(target);
|
|
140
130
|
}
|
|
141
131
|
return false;
|
|
@@ -144,9 +134,9 @@ function checkExistingDirectory(target) {
|
|
|
144
134
|
exports.checkExistingDirectory = checkExistingDirectory;
|
|
145
135
|
function checkIsDirectory(target) {
|
|
146
136
|
return new Promise((resolve) => {
|
|
147
|
-
fs_1.lstat(target, (err, stats) => {
|
|
137
|
+
(0, fs_1.lstat)(target, (err, stats) => {
|
|
148
138
|
if (err) {
|
|
149
|
-
resolve(path_1.extname(target) === '');
|
|
139
|
+
resolve((0, path_1.extname)(target) === '');
|
|
150
140
|
}
|
|
151
141
|
else {
|
|
152
142
|
resolve(stats.isDirectory());
|
|
@@ -157,48 +147,145 @@ function checkIsDirectory(target) {
|
|
|
157
147
|
exports.checkIsDirectory = checkIsDirectory;
|
|
158
148
|
function getFileNames(target) {
|
|
159
149
|
return new Promise((resolve, reject) => {
|
|
160
|
-
|
|
150
|
+
(0, fs_3.readdir)(target, (err, files) => (err ? reject(err) : resolve(files)));
|
|
161
151
|
});
|
|
162
152
|
}
|
|
163
153
|
exports.getFileNames = getFileNames;
|
|
164
|
-
function findFile(topDir, fileName) {
|
|
154
|
+
function findFile(topDir, fileName, stopDir = (0, path_1.resolve)(topDir, '/')) {
|
|
165
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
return
|
|
156
|
+
const fileNames = Array.isArray(fileName) ? fileName : [fileName];
|
|
157
|
+
for (const fn of fileNames) {
|
|
158
|
+
const path = (0, path_1.join)(topDir, fn);
|
|
159
|
+
const exists = yield checkExists(path);
|
|
160
|
+
if (exists) {
|
|
161
|
+
return path;
|
|
172
162
|
}
|
|
173
|
-
return undefined;
|
|
174
163
|
}
|
|
175
|
-
|
|
164
|
+
if (topDir !== stopDir) {
|
|
165
|
+
const parentDir = (0, path_1.resolve)(topDir, '..');
|
|
166
|
+
return yield findFile(parentDir, fileNames, stopDir);
|
|
167
|
+
}
|
|
168
|
+
return undefined;
|
|
176
169
|
});
|
|
177
170
|
}
|
|
178
171
|
exports.findFile = findFile;
|
|
179
|
-
function
|
|
172
|
+
function matchPattern(baseDir, pattern) {
|
|
173
|
+
return new Promise((resolve, reject) => {
|
|
174
|
+
(0, external_1.glob)(pattern, {
|
|
175
|
+
cwd: baseDir,
|
|
176
|
+
nodir: true,
|
|
177
|
+
absolute: true,
|
|
178
|
+
}, (err, files) => {
|
|
179
|
+
if (err) {
|
|
180
|
+
reject(err);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
resolve(files);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function matchAnyPattern(baseDir, pattern) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
const matches = yield Promise.all(pattern.patterns.map((pattern) => matchPattern(baseDir, pattern)));
|
|
191
|
+
return {
|
|
192
|
+
pattern: pattern.original,
|
|
193
|
+
results: matches.reduce((agg, curr) => [...agg, ...curr], []),
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const preferences = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs', '.esm', '.es', '.es6', '.html'];
|
|
198
|
+
function matchAnyPilet(baseDir, patterns) {
|
|
180
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
200
|
const matches = [];
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
201
|
+
const pilets = [];
|
|
202
|
+
const matched = (name, path) => {
|
|
203
|
+
pilets.push(name);
|
|
204
|
+
matches.push(path);
|
|
205
|
+
};
|
|
206
|
+
const exts = preferences.map((s) => s.substring(1)).join(',');
|
|
207
|
+
const allPatterns = patterns.reduce((agg, curr) => {
|
|
208
|
+
const patterns = [];
|
|
209
|
+
if (/[a-zA-Z0-9\-\*]$/.test(curr) && !preferences.find((ext) => curr.endsWith(ext))) {
|
|
210
|
+
patterns.push(curr, `${curr}.{${exts}}`, `${curr}/${constants_1.packageJson}`, `${curr}/${constants_1.piletJson}`);
|
|
211
|
+
}
|
|
212
|
+
else if (curr.endsWith('/')) {
|
|
213
|
+
patterns.push(`${curr}index.{${exts}}`, `${curr}${constants_1.packageJson}`, `${curr}${constants_1.piletJson}`);
|
|
214
|
+
}
|
|
215
|
+
else if (curr === '.' || curr === '..') {
|
|
216
|
+
patterns.push(`${curr}/index.{${exts}}`, `${curr}/${constants_1.packageJson}`, `${curr}/${constants_1.piletJson}`);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
patterns.push(curr);
|
|
220
|
+
}
|
|
221
|
+
agg.push({ original: curr, patterns });
|
|
222
|
+
return agg;
|
|
223
|
+
}, []);
|
|
224
|
+
yield Promise.all(allPatterns.map((patterns) => matchAnyPattern(baseDir, patterns).then(({ results, pattern }) => __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
if (!results.length) {
|
|
226
|
+
(0, log_1.log)('generalDebug_0003', `Found no potential entry points using "${pattern}".`);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
//TODO -> shouldn't take the first one,
|
|
230
|
+
// should be the first one, yes, but, PER pilet
|
|
231
|
+
// so that multiple pilets can be considered, too
|
|
232
|
+
(0, log_1.log)('generalDebug_0003', `Found ${results.length} potential entry points in "${pattern}".`);
|
|
233
|
+
for (const result of results) {
|
|
234
|
+
const fileName = (0, path_1.basename)(result);
|
|
235
|
+
if (fileName === constants_1.packageJson) {
|
|
236
|
+
(0, log_1.log)('generalDebug_0003', `Entry point is a "${constants_1.packageJson}" and needs further inspection.`);
|
|
237
|
+
const targetDir = (0, path_1.dirname)(result);
|
|
238
|
+
const { source, name } = yield readJson(targetDir, fileName);
|
|
239
|
+
if (!pilets.includes(name)) {
|
|
240
|
+
if (typeof source === 'string') {
|
|
241
|
+
(0, log_1.log)('generalDebug_0003', `Found a "source" field with value "${source}".`);
|
|
242
|
+
const target = (0, path_1.resolve)(targetDir, source);
|
|
243
|
+
const exists = yield checkExists(target);
|
|
244
|
+
if (exists) {
|
|
245
|
+
(0, log_1.log)('generalDebug_0003', `Taking existing target as "${target}".`);
|
|
246
|
+
matched(name, target);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
(0, log_1.log)('generalDebug_0003', `Source target "${target}" does not exist. Skipped.`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
(0, log_1.log)('generalDebug_0003', `No "source" field found. Trying combinations in "src".`);
|
|
254
|
+
const files = yield matchPattern(targetDir, `src/index.{${exts}}`);
|
|
255
|
+
if (files.length > 0) {
|
|
256
|
+
(0, log_1.log)('generalDebug_0003', `Found a result; taking "${files[0]}".`);
|
|
257
|
+
matched(name, files[0]);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
(0, log_1.log)('generalDebug_0003', `Found no results in "src". Skipped.`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
const packageJsonPath = yield findFile(result, constants_1.packageJson);
|
|
267
|
+
if (packageJsonPath) {
|
|
268
|
+
const targetDir = (0, path_1.dirname)(packageJsonPath);
|
|
269
|
+
const { name } = yield readJson(targetDir, constants_1.packageJson);
|
|
270
|
+
if (!pilets.includes(name)) {
|
|
271
|
+
(0, log_1.log)('generalDebug_0003', `Entry point result is "${result}".`);
|
|
272
|
+
matched(name, result);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
(0, log_1.log)('generalDebug_0003', `Could not find "${constants_1.packageJson}" for entry "${result}". Skipping.`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
192
279
|
}
|
|
193
|
-
}
|
|
194
|
-
})));
|
|
280
|
+
}
|
|
281
|
+
}))));
|
|
195
282
|
return matches;
|
|
196
283
|
});
|
|
197
284
|
}
|
|
198
|
-
exports.
|
|
285
|
+
exports.matchAnyPilet = matchAnyPilet;
|
|
199
286
|
function matchFiles(baseDir, pattern) {
|
|
200
287
|
return new Promise((resolve, reject) => {
|
|
201
|
-
external_1.glob(pattern, {
|
|
288
|
+
(0, external_1.glob)(pattern, {
|
|
202
289
|
cwd: baseDir,
|
|
203
290
|
absolute: true,
|
|
204
291
|
dot: true,
|
|
@@ -215,14 +302,14 @@ function matchFiles(baseDir, pattern) {
|
|
|
215
302
|
exports.matchFiles = matchFiles;
|
|
216
303
|
function createFileIfNotExists(targetDir, fileName, content, forceOverwrite = enums_1.ForceOverwrite.no) {
|
|
217
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
218
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
219
|
-
log_1.log('generalDebug_0003', `Checking if file "${targetFile}" exists ...`);
|
|
305
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
306
|
+
(0, log_1.log)('generalDebug_0003', `Checking if file "${targetFile}" exists ...`);
|
|
220
307
|
const exists = yield checkExists(targetFile);
|
|
221
308
|
if (!exists ||
|
|
222
309
|
forceOverwrite === enums_1.ForceOverwrite.yes ||
|
|
223
310
|
(forceOverwrite === enums_1.ForceOverwrite.prompt && (yield promptOverwrite(targetFile)))) {
|
|
224
|
-
yield createDirectory(path_1.dirname(targetFile));
|
|
225
|
-
log_1.log('generalDebug_0003', `Creating file "${targetFile}" ...`);
|
|
311
|
+
yield createDirectory((0, path_1.dirname)(targetFile));
|
|
312
|
+
(0, log_1.log)('generalDebug_0003', `Creating file "${targetFile}" ...`);
|
|
226
313
|
if (typeof content === 'string') {
|
|
227
314
|
yield writeText(targetDir, fileName, content);
|
|
228
315
|
}
|
|
@@ -235,13 +322,13 @@ function createFileIfNotExists(targetDir, fileName, content, forceOverwrite = en
|
|
|
235
322
|
exports.createFileIfNotExists = createFileIfNotExists;
|
|
236
323
|
function updateExistingFile(targetDir, fileName, content) {
|
|
237
324
|
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
239
|
-
log_1.log('generalDebug_0003', `Checking if file "${targetFile}" exists ...`);
|
|
325
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
326
|
+
(0, log_1.log)('generalDebug_0003', `Checking if file "${targetFile}" exists ...`);
|
|
240
327
|
const exists = yield checkExists(targetFile);
|
|
241
328
|
if (exists) {
|
|
242
|
-
log_1.log('generalDebug_0003', `Updating file "${targetFile}" ...`);
|
|
329
|
+
(0, log_1.log)('generalDebug_0003', `Updating file "${targetFile}" ...`);
|
|
243
330
|
yield new Promise((resolve, reject) => {
|
|
244
|
-
|
|
331
|
+
(0, fs_3.writeFile)(targetFile, content, 'utf8', (err) => (err ? reject(err) : resolve()));
|
|
245
332
|
});
|
|
246
333
|
}
|
|
247
334
|
});
|
|
@@ -250,43 +337,51 @@ exports.updateExistingFile = updateExistingFile;
|
|
|
250
337
|
function getHash(targetFile) {
|
|
251
338
|
return __awaiter(this, void 0, void 0, function* () {
|
|
252
339
|
return new Promise((resolve) => {
|
|
253
|
-
|
|
340
|
+
(0, fs_3.readFile)(targetFile, (err, c) => (err ? resolve(undefined) : resolve((0, hash_1.computeHash)(c))));
|
|
254
341
|
});
|
|
255
342
|
});
|
|
256
343
|
}
|
|
257
344
|
exports.getHash = getHash;
|
|
258
345
|
function mergeWithJson(targetDir, fileName, newContent) {
|
|
259
346
|
return __awaiter(this, void 0, void 0, function* () {
|
|
260
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
261
|
-
const content = yield new Promise((resolve
|
|
262
|
-
|
|
347
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
348
|
+
const content = yield new Promise((resolve) => {
|
|
349
|
+
(0, fs_3.readFile)(targetFile, 'utf8', (err, c) => (err ? resolve('{}') : resolve(c)));
|
|
263
350
|
});
|
|
264
351
|
const originalContent = JSON.parse(content);
|
|
265
|
-
return merge_1.deepMerge(originalContent, newContent);
|
|
352
|
+
return (0, merge_1.deepMerge)(originalContent, newContent);
|
|
266
353
|
});
|
|
267
354
|
}
|
|
268
355
|
exports.mergeWithJson = mergeWithJson;
|
|
269
|
-
function readJson(targetDir, fileName) {
|
|
356
|
+
function readJson(targetDir, fileName, defaultValue = {}) {
|
|
270
357
|
return __awaiter(this, void 0, void 0, function* () {
|
|
271
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
358
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
272
359
|
const content = yield new Promise((resolve) => {
|
|
273
|
-
|
|
360
|
+
(0, fs_3.readFile)(targetFile, 'utf8', (err, c) => (err ? resolve('') : resolve(c)));
|
|
274
361
|
});
|
|
275
|
-
|
|
362
|
+
if (content) {
|
|
363
|
+
try {
|
|
364
|
+
return JSON.parse(content);
|
|
365
|
+
}
|
|
366
|
+
catch (ex) {
|
|
367
|
+
(0, log_1.log)('generalError_0002', `Invalid JSON found in file "${fileName}" at "${targetDir}".`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return defaultValue;
|
|
276
371
|
});
|
|
277
372
|
}
|
|
278
373
|
exports.readJson = readJson;
|
|
279
374
|
function readBinary(targetDir, fileName) {
|
|
280
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
375
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
281
376
|
return new Promise((resolve) => {
|
|
282
|
-
|
|
377
|
+
(0, fs_3.readFile)(targetFile, (err, c) => (err ? resolve(undefined) : resolve(c)));
|
|
283
378
|
});
|
|
284
379
|
}
|
|
285
380
|
exports.readBinary = readBinary;
|
|
286
381
|
function readText(targetDir, fileName) {
|
|
287
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
382
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
288
383
|
return new Promise((resolve) => {
|
|
289
|
-
|
|
384
|
+
(0, fs_3.readFile)(targetFile, 'utf8', (err, c) => (err ? resolve(undefined) : resolve(c)));
|
|
290
385
|
});
|
|
291
386
|
}
|
|
292
387
|
exports.readText = readText;
|
|
@@ -301,9 +396,9 @@ function writeText(targetDir, fileName, content) {
|
|
|
301
396
|
}
|
|
302
397
|
exports.writeText = writeText;
|
|
303
398
|
function writeBinary(targetDir, fileName, data) {
|
|
304
|
-
const targetFile = path_1.join(targetDir, fileName);
|
|
399
|
+
const targetFile = (0, path_1.join)(targetDir, fileName);
|
|
305
400
|
return new Promise((resolve, reject) => {
|
|
306
|
-
|
|
401
|
+
(0, fs_3.writeFile)(targetFile, data, (err) => (err ? reject(err) : resolve()));
|
|
307
402
|
});
|
|
308
403
|
}
|
|
309
404
|
exports.writeBinary = writeBinary;
|
|
@@ -316,13 +411,21 @@ function updateExistingJson(targetDir, fileName, newContent) {
|
|
|
316
411
|
exports.updateExistingJson = updateExistingJson;
|
|
317
412
|
function copy(source, target, forceOverwrite = enums_1.ForceOverwrite.no) {
|
|
318
413
|
return __awaiter(this, void 0, void 0, function* () {
|
|
319
|
-
yield createDirectory(path_1.dirname(target));
|
|
414
|
+
yield createDirectory((0, path_1.dirname)(target));
|
|
320
415
|
try {
|
|
321
416
|
const flag = forceOverwrite === enums_1.ForceOverwrite.yes ? 0 : fs_2.constants.COPYFILE_EXCL;
|
|
322
|
-
yield
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
417
|
+
const isDir = yield checkIsDirectory(source);
|
|
418
|
+
if (isDir) {
|
|
419
|
+
const files = yield getFileNames(source);
|
|
420
|
+
const results = yield Promise.all(files.map((file) => copy((0, path_1.resolve)(source, file), (0, path_1.resolve)(target, file), forceOverwrite)));
|
|
421
|
+
return results.every(Boolean);
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
yield new Promise((resolve, reject) => {
|
|
425
|
+
(0, fs_3.copyFile)(source, target, flag, (err) => (err ? reject(err) : resolve()));
|
|
426
|
+
});
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
326
429
|
}
|
|
327
430
|
catch (e) {
|
|
328
431
|
if (forceOverwrite === enums_1.ForceOverwrite.prompt) {
|
|
@@ -332,7 +435,7 @@ function copy(source, target, forceOverwrite = enums_1.ForceOverwrite.no) {
|
|
|
332
435
|
}
|
|
333
436
|
}
|
|
334
437
|
else {
|
|
335
|
-
log_1.log('didNotOverWriteFile_0045', target);
|
|
438
|
+
(0, log_1.log)('didNotOverWriteFile_0045', target);
|
|
336
439
|
}
|
|
337
440
|
}
|
|
338
441
|
return false;
|
|
@@ -348,7 +451,7 @@ function remove(target) {
|
|
|
348
451
|
exports.remove = remove;
|
|
349
452
|
function removeFile(target) {
|
|
350
453
|
return new Promise((resolve, reject) => {
|
|
351
|
-
fs_1.unlink(target, (err) => {
|
|
454
|
+
(0, fs_1.unlink)(target, (err) => {
|
|
352
455
|
if (err) {
|
|
353
456
|
reject(err);
|
|
354
457
|
}
|
|
@@ -363,8 +466,8 @@ function move(source, target, forceOverwrite = enums_1.ForceOverwrite.no) {
|
|
|
363
466
|
return __awaiter(this, void 0, void 0, function* () {
|
|
364
467
|
const dir = yield checkIsDirectory(target);
|
|
365
468
|
if (dir) {
|
|
366
|
-
const file = path_1.basename(source);
|
|
367
|
-
target = path_1.resolve(target, file);
|
|
469
|
+
const file = (0, path_1.basename)(source);
|
|
470
|
+
target = (0, path_1.resolve)(target, file);
|
|
368
471
|
}
|
|
369
472
|
const success = yield copy(source, target, forceOverwrite);
|
|
370
473
|
if (success) {
|
|
@@ -377,12 +480,12 @@ function move(source, target, forceOverwrite = enums_1.ForceOverwrite.no) {
|
|
|
377
480
|
exports.move = move;
|
|
378
481
|
function getSourceFiles(entry) {
|
|
379
482
|
return __awaiter(this, void 0, void 0, function* () {
|
|
380
|
-
const dir = path_1.dirname(entry);
|
|
381
|
-
log_1.log('generalDebug_0003', `Trying to get source files from "${dir}" ...`);
|
|
483
|
+
const dir = (0, path_1.dirname)(entry);
|
|
484
|
+
(0, log_1.log)('generalDebug_0003', `Trying to get source files from "${dir}" ...`);
|
|
382
485
|
const files = yield matchFiles(dir, '**/*.?(jsx|tsx|js|ts)');
|
|
383
486
|
return files.map((path) => {
|
|
384
|
-
const directory = path_1.dirname(path);
|
|
385
|
-
const name = path_1.basename(path);
|
|
487
|
+
const directory = (0, path_1.dirname)(path);
|
|
488
|
+
const name = (0, path_1.basename)(path);
|
|
386
489
|
return {
|
|
387
490
|
path,
|
|
388
491
|
directory,
|
|
@@ -391,7 +494,7 @@ function getSourceFiles(entry) {
|
|
|
391
494
|
return __awaiter(this, void 0, void 0, function* () {
|
|
392
495
|
const content = yield readText(directory, name);
|
|
393
496
|
if (name.endsWith('.ts') || name.endsWith('.tsx')) {
|
|
394
|
-
return typescript_1.transpileModule(content, {
|
|
497
|
+
return (0, typescript_1.transpileModule)(content, {
|
|
395
498
|
fileName: path,
|
|
396
499
|
moduleName: name,
|
|
397
500
|
compilerOptions: {
|