piral-cli 1.0.0-pre.2296 → 1.0.1-beta.5640
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +30 -7
- package/lib/api.js +23 -23
- package/lib/api.js.map +1 -1
- package/lib/apps/add-piral-instance-pilet.d.ts +26 -0
- package/lib/apps/add-piral-instance-pilet.js +53 -0
- package/lib/apps/add-piral-instance-pilet.js.map +1 -0
- package/lib/apps/build-pilet.d.ts +33 -2
- package/lib/apps/build-pilet.js +159 -32
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/build-piral.d.ts +18 -1
- package/lib/apps/build-piral.js +68 -52
- package/lib/apps/build-piral.js.map +1 -1
- package/lib/apps/debug-pilet.d.ts +38 -2
- package/lib/apps/debug-pilet.js +150 -108
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.d.ts +23 -0
- package/lib/apps/debug-piral.js +63 -52
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/declaration-piral.js +5 -3
- package/lib/apps/declaration-piral.js.map +1 -1
- package/lib/apps/index.d.ts +3 -0
- package/lib/apps/index.js +8 -1
- package/lib/apps/index.js.map +1 -1
- package/lib/apps/new-pilet.d.ts +7 -3
- package/lib/apps/new-pilet.js +47 -52
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.d.ts +7 -3
- package/lib/apps/new-piral.js +33 -23
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/pack-pilet.d.ts +9 -0
- package/lib/apps/pack-pilet.js +6 -13
- package/lib/apps/pack-pilet.js.map +1 -1
- package/lib/apps/publish-pilet.d.ts +23 -3
- package/lib/apps/publish-pilet.js +112 -62
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/apps/publish-piral.d.ts +6 -2
- package/lib/apps/publish-piral.js +30 -26
- package/lib/apps/publish-piral.js.map +1 -1
- package/lib/apps/remove-piral-instance-pilet.d.ts +22 -0
- package/lib/apps/remove-piral-instance-pilet.js +52 -0
- package/lib/apps/remove-piral-instance-pilet.js.map +1 -0
- package/lib/apps/run-emulator-piral.d.ts +34 -0
- package/lib/apps/run-emulator-piral.js +91 -0
- package/lib/apps/run-emulator-piral.js.map +1 -0
- package/lib/apps/upgrade-pilet.d.ts +6 -2
- package/lib/apps/upgrade-pilet.js +41 -43
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/apps/upgrade-piral.d.ts +2 -2
- package/lib/apps/upgrade-piral.js +21 -20
- package/lib/apps/upgrade-piral.js.map +1 -1
- package/lib/apps/validate-pilet.js +30 -36
- package/lib/apps/validate-pilet.js.map +1 -1
- package/lib/apps/validate-piral.js +13 -10
- package/lib/apps/validate-piral.js.map +1 -1
- package/lib/build/bundler-calls.d.ts +3 -0
- package/lib/build/bundler-calls.js +117 -0
- package/lib/build/bundler-calls.js.map +1 -0
- package/lib/build/run-build-pilet.d.ts +1 -0
- package/lib/build/run-build-pilet.js +65 -0
- package/lib/build/run-build-pilet.js.map +1 -0
- package/lib/build/run-build-piral.d.ts +1 -0
- package/lib/build/run-build-piral.js +67 -0
- package/lib/build/run-build-piral.js.map +1 -0
- package/lib/build/run-debug-mono-piral.d.ts +1 -0
- package/lib/build/run-debug-mono-piral.js +70 -0
- package/lib/build/run-debug-mono-piral.js.map +1 -0
- package/lib/build/run-debug-pilet.d.ts +1 -0
- package/lib/build/run-debug-pilet.js +89 -0
- package/lib/build/run-debug-pilet.js.map +1 -0
- package/lib/build/run-debug-piral.d.ts +1 -0
- package/lib/build/run-debug-piral.js +85 -0
- package/lib/build/run-debug-piral.js.map +1 -0
- package/lib/bundler.js +75 -26
- package/lib/bundler.js.map +1 -1
- package/lib/cli.js +7 -4
- package/lib/cli.js.map +1 -1
- package/lib/commands.js +266 -46
- package/lib/commands.js.map +1 -1
- package/lib/common/archive.d.ts +4 -0
- package/lib/common/archive.js +31 -10
- package/lib/common/archive.js.map +1 -1
- package/lib/common/browser.d.ts +2 -1
- package/lib/common/browser.js +17 -8
- package/lib/common/browser.js.map +1 -1
- package/lib/common/clients/index.d.ts +21 -0
- package/lib/common/clients/index.js +48 -0
- package/lib/common/clients/index.js.map +1 -0
- package/lib/common/clients/lerna.d.ts +7 -1
- package/lib/common/clients/lerna.js +93 -7
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.d.ts +6 -1
- package/lib/common/clients/npm.js +66 -18
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnp.d.ts +7 -0
- package/lib/common/clients/pnp.js +104 -0
- package/lib/common/clients/pnp.js.map +1 -0
- package/lib/common/clients/pnpm.d.ts +5 -0
- package/lib/common/clients/pnpm.js +55 -6
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/rush.d.ts +7 -0
- package/lib/common/clients/rush.js +127 -0
- package/lib/common/clients/rush.js.map +1 -0
- package/lib/common/clients/yarn.d.ts +5 -0
- package/lib/common/clients/yarn.js +57 -6
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/compatibility.js +14 -9
- package/lib/common/compatibility.js.map +1 -1
- package/lib/common/config.d.ts +52 -1
- package/lib/common/config.js +10 -30
- package/lib/common/config.js.map +1 -1
- package/lib/common/constants.d.ts +10 -2
- package/lib/common/constants.js +22 -4
- package/lib/common/constants.js.map +1 -1
- package/lib/common/declaration.d.ts +2 -1
- package/lib/common/declaration.js +113 -56
- package/lib/common/declaration.js.map +1 -1
- package/lib/common/emoji.d.ts +8 -0
- package/lib/common/emoji.js +10 -1
- package/lib/common/emoji.js.map +1 -1
- package/lib/common/emulator.d.ts +2 -2
- package/lib/common/emulator.js +45 -32
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/enums.d.ts +0 -4
- package/lib/common/enums.js +1 -6
- package/lib/common/enums.js.map +1 -1
- package/lib/common/envs.js +16 -5
- package/lib/common/envs.js.map +1 -1
- package/lib/common/hash.d.ts +1 -0
- package/lib/common/hash.js +8 -3
- package/lib/common/hash.js.map +1 -1
- package/lib/common/http.d.ts +5 -2
- package/lib/common/http.js +65 -23
- package/lib/common/http.js.map +1 -1
- package/lib/common/importmap.d.ts +2 -0
- package/lib/common/importmap.js +202 -0
- package/lib/common/importmap.js.map +1 -0
- package/lib/common/index.d.ts +10 -0
- package/lib/common/index.js +15 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/info.d.ts +5 -0
- package/lib/common/info.js +9 -2
- package/lib/common/info.js.map +1 -1
- package/lib/common/injectors.d.ts +36 -8
- package/lib/common/injectors.js +46 -19
- package/lib/common/injectors.js.map +1 -1
- package/lib/common/inspect.d.ts +5 -3
- package/lib/common/inspect.js +15 -15
- package/lib/common/inspect.js.map +1 -1
- package/lib/common/interactive.d.ts +9 -0
- package/lib/common/interactive.js +60 -1
- package/lib/common/interactive.js.map +1 -1
- package/lib/common/io.d.ts +9 -3
- package/lib/common/io.js +219 -116
- package/lib/common/io.js.map +1 -1
- package/lib/common/language.d.ts +9 -6
- package/lib/common/language.js +68 -12
- package/lib/common/language.js.map +1 -1
- package/lib/common/log.d.ts +5 -3
- package/lib/common/log.js +34 -48
- package/lib/common/log.js.map +1 -1
- package/lib/common/npm.d.ts +17 -16
- package/lib/common/npm.js +262 -158
- package/lib/common/npm.js.map +1 -1
- package/lib/common/pack.js +47 -26
- package/lib/common/pack.js.map +1 -1
- package/lib/common/package.d.ts +43 -20
- package/lib/common/package.js +377 -213
- package/lib/common/package.js.map +1 -1
- package/lib/common/parallel.d.ts +1 -0
- package/lib/common/parallel.js +29 -0
- package/lib/common/parallel.js.map +1 -0
- package/lib/common/patcher.js +20 -20
- package/lib/common/patcher.js.map +1 -1
- package/lib/common/platform.d.ts +13 -0
- package/lib/common/platform.js +29 -0
- package/lib/common/platform.js.map +1 -0
- package/lib/common/port.d.ts +1 -0
- package/lib/common/port.js +14 -4
- package/lib/common/port.js.map +1 -1
- package/lib/common/rules.js +4 -4
- package/lib/common/rules.js.map +1 -1
- package/lib/common/scaffold.d.ts +18 -4
- package/lib/common/scaffold.js +59 -36
- package/lib/common/scaffold.js.map +1 -1
- package/lib/common/scripts.js +8 -8
- package/lib/common/scripts.js.map +1 -1
- package/lib/common/shell.d.ts +2 -0
- package/lib/common/shell.js +33 -0
- package/lib/common/shell.js.map +1 -0
- package/lib/common/spec.d.ts +29 -0
- package/lib/common/spec.js +69 -0
- package/lib/common/spec.js.map +1 -0
- package/lib/common/template.d.ts +1 -2
- package/lib/common/template.js +23 -22
- package/lib/common/template.js.map +1 -1
- package/lib/common/url.d.ts +1 -0
- package/lib/common/url.js +17 -0
- package/lib/common/url.js.map +1 -0
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.js +8 -0
- package/lib/common/utils.js.map +1 -0
- package/lib/common/version.d.ts +2 -0
- package/lib/common/version.js +130 -0
- package/lib/common/version.js.map +1 -0
- package/lib/common/watcher.d.ts +13 -0
- package/lib/common/watcher.js +78 -0
- package/lib/common/watcher.js.map +1 -0
- package/lib/external/index.js +59413 -57862
- package/lib/helpers.d.ts +6 -6
- package/lib/helpers.js +10 -25
- package/lib/helpers.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/inject.js +2 -2
- package/lib/inject.js.map +1 -1
- package/lib/injectors/pilet-injector.d.ts +75 -0
- package/lib/injectors/pilet-injector.js +246 -0
- package/lib/injectors/pilet-injector.js.map +1 -0
- package/lib/injectors/{piral.d.ts → piral-injector.d.ts} +10 -2
- package/lib/injectors/piral-injector.js +97 -0
- package/lib/injectors/piral-injector.js.map +1 -0
- package/lib/messages.d.ts +567 -47
- package/lib/messages.js +638 -51
- package/lib/messages.js.map +1 -1
- package/lib/pb-cli.js +1 -1
- package/lib/pb-cli.js.map +1 -1
- package/lib/pilet-cli.js +1 -1
- package/lib/pilet-cli.js.map +1 -1
- package/lib/piral-cli.js +1 -1
- package/lib/piral-cli.js.map +1 -1
- package/lib/platforms/node.d.ts +8 -0
- package/lib/platforms/node.js +30 -0
- package/lib/platforms/node.js.map +1 -0
- package/lib/platforms/web.d.ts +8 -0
- package/lib/platforms/web.js +120 -0
- package/lib/platforms/web.js.map +1 -0
- package/lib/plugin.js +36 -11
- package/lib/plugin.js.map +1 -1
- package/lib/questionnaire.d.ts +1 -1
- package/lib/questionnaire.js +9 -4
- package/lib/questionnaire.js.map +1 -1
- package/lib/release.d.ts +1 -1
- package/lib/release.js +38 -6
- package/lib/release.js.map +1 -1
- package/lib/resolvers.js +13 -13
- package/lib/resolvers.js.map +1 -1
- package/lib/rules/index.js +8 -8
- package/lib/rules/index.js.map +1 -1
- package/lib/rules/pilet-has-externals-as-peers.d.ts +1 -1
- package/lib/rules/pilet-has-externals-as-peers.js +9 -7
- package/lib/rules/pilet-has-externals-as-peers.js.map +1 -1
- package/lib/rules/pilet-has-no-self-reference.d.ts +1 -1
- package/lib/rules/pilet-has-no-self-reference.js +2 -2
- package/lib/rules/pilet-has-no-self-reference.js.map +1 -1
- package/lib/rules/pilet-has-no-third-party-dependency.d.ts +1 -1
- package/lib/rules/pilet-stays-small.d.ts +1 -1
- package/lib/rules/pilet-stays-small.js +4 -4
- package/lib/rules/pilet-stays-small.js.map +1 -1
- package/lib/rules/pilet-uses-latest-piral.d.ts +1 -1
- package/lib/rules/pilet-uses-latest-piral.js +18 -9
- package/lib/rules/pilet-uses-latest-piral.js.map +1 -1
- package/lib/rules/piral-depends-on-piral.d.ts +1 -1
- package/lib/rules/piral-entry-ends-with-html.d.ts +1 -1
- package/lib/rules/piral-entry-ends-with-html.js +1 -1
- package/lib/rules/piral-entry-ends-with-html.js.map +1 -1
- package/lib/rules/piral-has-valid-devDependencies.d.ts +1 -1
- package/lib/rules/piral-has-valid-externals.d.ts +1 -1
- package/lib/rules/piral-has-valid-externals.js +10 -24
- package/lib/rules/piral-has-valid-externals.js.map +1 -1
- package/lib/rules/piral-has-valid-files.d.ts +1 -1
- package/lib/rules/piral-has-valid-files.js +5 -5
- package/lib/rules/piral-has-valid-files.js.map +1 -1
- package/lib/rules/piral-has-valid-scripts.d.ts +1 -1
- package/lib/runner.js +1 -1
- package/lib/runner.js.map +1 -1
- package/lib/select.js +6 -6
- package/lib/select.js.map +1 -1
- package/lib/types/common.d.ts +88 -8
- package/lib/types/common.js.map +1 -1
- package/lib/types/index.js +5 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/internal.d.ts +12 -13
- package/lib/types/public.d.ts +89 -23
- package/package.json +19 -16
- package/src/apps/add-piral-instance-pilet.ts +98 -0
- package/src/apps/build-pilet.ts +286 -38
- package/src/apps/build-piral.test.ts +20 -7
- package/src/apps/build-piral.ts +90 -39
- package/src/apps/debug-pilet.ts +229 -123
- package/src/apps/debug-piral.ts +121 -68
- package/src/apps/declaration-piral.ts +4 -2
- package/src/apps/index.ts +3 -0
- package/src/apps/new-pilet.test.ts +28 -11
- package/src/apps/new-pilet.ts +60 -48
- package/src/apps/new-piral.test.ts +25 -13
- package/src/apps/new-piral.ts +43 -19
- package/src/apps/pack-pilet.test.ts +2 -2
- package/src/apps/pack-pilet.ts +12 -10
- package/src/apps/publish-pilet.ts +148 -43
- package/src/apps/publish-piral.ts +38 -11
- package/src/apps/remove-piral-instance-pilet.ts +92 -0
- package/src/apps/run-emulator-piral.ts +154 -0
- package/src/apps/upgrade-pilet.ts +37 -31
- package/src/apps/upgrade-piral.ts +9 -7
- package/src/apps/validate-pilet.ts +30 -22
- package/src/apps/validate-piral.ts +5 -2
- package/src/build/bundler-calls.ts +133 -0
- package/src/build/run-build-pilet.ts +91 -0
- package/src/build/run-build-piral.ts +93 -0
- package/src/build/run-debug-mono-piral.ts +86 -0
- package/src/build/run-debug-pilet.ts +116 -0
- package/src/build/run-debug-piral.ts +105 -0
- package/src/bundler.test.ts +86 -68
- package/src/bundler.ts +74 -19
- package/src/cli.ts +6 -2
- package/src/commands.ts +273 -44
- package/src/common/archive.test.ts +51 -45
- package/src/common/archive.ts +28 -1
- package/src/common/browser.test.ts +20 -10
- package/src/common/browser.ts +13 -6
- package/src/common/clients/index.ts +41 -0
- package/src/common/clients/lerna.ts +85 -1
- package/src/common/clients/npm.ts +56 -14
- package/src/common/clients/pnp.ts +84 -0
- package/src/common/clients/pnpm.ts +45 -1
- package/src/common/clients/rush.ts +118 -0
- package/src/common/clients/yarn.ts +49 -3
- package/src/common/compatibility.ts +8 -1
- package/src/common/config.ts +57 -22
- package/src/common/constants.ts +21 -3
- package/src/common/declaration.ts +124 -50
- package/src/common/emoji.ts +9 -0
- package/src/common/emulator.ts +43 -23
- package/src/common/enums.ts +0 -5
- package/src/common/envs.ts +15 -3
- package/src/common/hash.ts +5 -0
- package/src/common/http.test.ts +76 -64
- package/src/common/http.ts +88 -24
- package/src/common/importmap.ts +242 -0
- package/src/common/index.ts +10 -0
- package/src/common/info.ts +9 -1
- package/src/common/injectors.ts +49 -22
- package/src/common/inspect.ts +13 -14
- package/src/common/interactive.test.ts +6 -0
- package/src/common/interactive.ts +69 -1
- package/src/common/io.ts +199 -82
- package/src/common/language.ts +87 -10
- package/src/common/log.ts +32 -46
- package/src/common/npm.test.ts +187 -166
- package/src/common/npm.ts +263 -119
- package/src/common/pack.test.ts +11 -13
- package/src/common/pack.ts +60 -21
- package/src/common/package.test.ts +59 -49
- package/src/common/package.ts +406 -167
- package/src/common/parallel.test.ts +28 -0
- package/src/common/parallel.ts +21 -0
- package/src/common/platform.ts +31 -0
- package/src/common/port.test.ts +4 -1
- package/src/common/port.ts +10 -0
- package/src/common/rules.test.ts +3 -3
- package/src/common/scaffold.ts +69 -41
- package/src/common/scripts.ts +5 -4
- package/src/common/shell.ts +34 -0
- package/src/common/spec.ts +69 -0
- package/src/common/template.ts +20 -18
- package/src/common/url.test.ts +28 -0
- package/src/common/url.ts +15 -0
- package/src/common/utils.ts +3 -0
- package/src/common/version.test.ts +233 -0
- package/src/common/version.ts +142 -0
- package/src/common/watcher.ts +89 -0
- package/src/external/index.test.ts +2 -2
- package/src/external/index.ts +7 -3
- package/src/external/resolve.ts +29 -0
- package/src/helpers.test.ts +2 -22
- package/src/helpers.ts +21 -30
- package/src/injectors/{pilet.test.ts → pilet-injector.test.ts} +13 -4
- package/src/injectors/pilet-injector.ts +346 -0
- package/src/injectors/{piral.test.ts → piral-injector.test.ts} +14 -5
- package/src/injectors/piral-injector.ts +130 -0
- package/src/messages.ts +649 -63
- package/src/platforms/node.ts +16 -0
- package/src/platforms/web.ts +148 -0
- package/src/plugin.ts +34 -5
- package/src/questionnaire.ts +17 -3
- package/src/release.ts +47 -5
- package/src/rules/index.ts +1 -1
- package/src/rules/pilet-has-externals-as-peers.test.ts +3 -2
- package/src/rules/pilet-has-externals-as-peers.ts +9 -7
- package/src/rules/pilet-has-no-self-reference.ts +1 -1
- package/src/rules/pilet-stays-small.ts +1 -1
- package/src/rules/pilet-uses-latest-piral.ts +22 -12
- package/src/rules/piral-has-valid-externals.ts +10 -29
- package/src/types/common.ts +99 -9
- package/src/types/internal.ts +14 -14
- package/src/types/public.ts +93 -27
- package/lib/external/child.js +0 -144
- package/lib/external/classes.trie +0 -0
- package/lib/external/xdg-open +0 -1066
- package/lib/injectors/pilet.d.ts +0 -47
- package/lib/injectors/pilet.js +0 -187
- package/lib/injectors/pilet.js.map +0 -1
- package/lib/injectors/piral.js +0 -62
- package/lib/injectors/piral.js.map +0 -1
- package/src/injectors/pilet.ts +0 -219
- package/src/injectors/piral.ts +0 -76
- package/templates/piral-index.js.ejs +0 -16
package/src/common/io.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as rimraf from 'rimraf';
|
|
2
2
|
import { transpileModule, ModuleKind, ModuleResolutionKind, ScriptTarget, JsxEmit } from 'typescript';
|
|
3
|
-
import { join, resolve, basename, dirname, extname
|
|
4
|
-
import { exists,
|
|
5
|
-
import {
|
|
3
|
+
import { join, resolve, basename, dirname, extname } from 'path';
|
|
4
|
+
import { exists, lstat, unlink, statSync } from 'fs';
|
|
5
|
+
import { mkdtemp, mkdir, constants } from 'fs';
|
|
6
|
+
import { writeFile, readFile, readdir, copyFile } from 'fs';
|
|
7
|
+
import { packageJson, piletJson } from './constants';
|
|
6
8
|
import { log } from './log';
|
|
7
9
|
import { deepMerge } from './merge';
|
|
8
|
-
import { nodeVersion } from './info';
|
|
9
10
|
import { computeHash } from './hash';
|
|
10
11
|
import { ForceOverwrite } from './enums';
|
|
11
12
|
import { promptConfirm } from './interactive';
|
|
@@ -16,41 +17,29 @@ function promptOverwrite(file: string) {
|
|
|
16
17
|
return promptConfirm(message, false);
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
function createDirectoryLegacy(targetDir: string) {
|
|
20
|
-
const initDir = isAbsolute(targetDir) ? sep : '';
|
|
21
|
-
|
|
22
|
-
return targetDir.split(sep).reduce((parentDir, childDir) => {
|
|
23
|
-
const curDir = resolve(parentDir, childDir);
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
mkdirSync(curDir);
|
|
27
|
-
} catch (err) {
|
|
28
|
-
if (err.code === 'EEXIST') {
|
|
29
|
-
return curDir;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (err.code === 'ENOENT') {
|
|
33
|
-
throw new Error(`EACCES: permission denied, mkdir '${parentDir}'`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const caughtErr = ['EACCES', 'EPERM', 'EISDIR'].indexOf(err.code) > -1;
|
|
37
|
-
|
|
38
|
-
if (!caughtErr || (caughtErr && curDir === resolve(targetDir))) {
|
|
39
|
-
throw err;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return curDir;
|
|
44
|
-
}, initDir);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
20
|
function isFile(file: string) {
|
|
48
21
|
return statSync(file).isFile();
|
|
49
22
|
}
|
|
50
23
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
24
|
+
export interface Destination {
|
|
25
|
+
outDir: string;
|
|
26
|
+
outFile: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getDestination(entryFiles: string, target: string): Destination {
|
|
30
|
+
const isdir = extname(target) !== '.html';
|
|
31
|
+
|
|
32
|
+
if (isdir) {
|
|
33
|
+
return {
|
|
34
|
+
outDir: target,
|
|
35
|
+
outFile: basename(entryFiles),
|
|
36
|
+
};
|
|
37
|
+
} else {
|
|
38
|
+
return {
|
|
39
|
+
outDir: dirname(target),
|
|
40
|
+
outFile: basename(target),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
54
43
|
}
|
|
55
44
|
|
|
56
45
|
export async function removeAny(target: string) {
|
|
@@ -69,20 +58,8 @@ export function removeDirectory(targetDir: string) {
|
|
|
69
58
|
}
|
|
70
59
|
|
|
71
60
|
export async function createDirectory(targetDir: string) {
|
|
72
|
-
if (isLegacy()) {
|
|
73
|
-
try {
|
|
74
|
-
log('generalDebug_0003', `Trying to create "${targetDir}" in legacy mode ...`);
|
|
75
|
-
createDirectoryLegacy(targetDir);
|
|
76
|
-
return true;
|
|
77
|
-
} catch (e) {
|
|
78
|
-
log('cannotCreateDirectory_0044');
|
|
79
|
-
log('generalDebug_0003', `Error while creating ${targetDir}: ${e}`);
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
61
|
try {
|
|
85
|
-
log('generalDebug_0003', `Trying to create "${targetDir}"
|
|
62
|
+
log('generalDebug_0003', `Trying to create "${targetDir}" ...`);
|
|
86
63
|
await new Promise<void>((resolve, reject) => {
|
|
87
64
|
mkdir(targetDir, { recursive: true }, (err) => (err ? reject(err) : resolve()));
|
|
88
65
|
});
|
|
@@ -114,6 +91,18 @@ export async function getEntryFiles(content: string, basePath: string) {
|
|
|
114
91
|
return results;
|
|
115
92
|
}
|
|
116
93
|
|
|
94
|
+
export function makeTempDir(prefix: string) {
|
|
95
|
+
return new Promise<string>((resolve, reject) =>
|
|
96
|
+
mkdtemp(prefix, (err, folder) => {
|
|
97
|
+
if (err) {
|
|
98
|
+
reject(err);
|
|
99
|
+
} else {
|
|
100
|
+
resolve(folder);
|
|
101
|
+
}
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
117
106
|
export function checkExists(target: string) {
|
|
118
107
|
return new Promise<boolean>((resolve) => {
|
|
119
108
|
if (target !== undefined) {
|
|
@@ -153,46 +142,155 @@ export function getFileNames(target: string) {
|
|
|
153
142
|
});
|
|
154
143
|
}
|
|
155
144
|
|
|
156
|
-
export async function findFile(
|
|
157
|
-
|
|
158
|
-
|
|
145
|
+
export async function findFile(
|
|
146
|
+
topDir: string,
|
|
147
|
+
fileName: string | Array<string>,
|
|
148
|
+
stopDir = resolve(topDir, '/'),
|
|
149
|
+
): Promise<string> {
|
|
150
|
+
const fileNames = Array.isArray(fileName) ? fileName : [fileName];
|
|
159
151
|
|
|
160
|
-
|
|
161
|
-
const
|
|
152
|
+
for (const fn of fileNames) {
|
|
153
|
+
const path = join(topDir, fn);
|
|
154
|
+
const exists = await checkExists(path);
|
|
162
155
|
|
|
163
|
-
if (
|
|
164
|
-
return
|
|
156
|
+
if (exists) {
|
|
157
|
+
return path;
|
|
165
158
|
}
|
|
159
|
+
}
|
|
166
160
|
|
|
167
|
-
|
|
161
|
+
if (topDir !== stopDir) {
|
|
162
|
+
const parentDir = resolve(topDir, '..');
|
|
163
|
+
return await findFile(parentDir, fileNames, stopDir);
|
|
168
164
|
}
|
|
169
165
|
|
|
170
|
-
return
|
|
166
|
+
return undefined;
|
|
171
167
|
}
|
|
172
168
|
|
|
173
|
-
|
|
169
|
+
interface AnyPattern {
|
|
170
|
+
original: string;
|
|
171
|
+
patterns: Array<string>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function matchPattern(baseDir: string, pattern: string) {
|
|
175
|
+
return new Promise<Array<string>>((resolve, reject) => {
|
|
176
|
+
glob(
|
|
177
|
+
pattern,
|
|
178
|
+
{
|
|
179
|
+
cwd: baseDir,
|
|
180
|
+
nodir: true,
|
|
181
|
+
absolute: true,
|
|
182
|
+
},
|
|
183
|
+
(err, files) => {
|
|
184
|
+
if (err) {
|
|
185
|
+
reject(err);
|
|
186
|
+
} else {
|
|
187
|
+
resolve(files);
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function matchAnyPattern(baseDir: string, pattern: AnyPattern) {
|
|
195
|
+
const matches = await Promise.all(pattern.patterns.map((pattern) => matchPattern(baseDir, pattern)));
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
pattern: pattern.original,
|
|
199
|
+
results: matches.reduce((agg, curr) => [...agg, ...curr], []),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const preferences = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs', '.esm', '.es', '.es6', '.html'];
|
|
204
|
+
|
|
205
|
+
export async function matchAnyPilet(baseDir: string, patterns: Array<string>) {
|
|
174
206
|
const matches: Array<string> = [];
|
|
207
|
+
const pilets: Array<string> = [];
|
|
208
|
+
const matched = (name: string, path: string) => {
|
|
209
|
+
pilets.push(name);
|
|
210
|
+
matches.push(path);
|
|
211
|
+
};
|
|
212
|
+
const exts = preferences.map((s) => s.substring(1)).join(',');
|
|
213
|
+
const allPatterns = patterns.reduce<Array<AnyPattern>>((agg, curr) => {
|
|
214
|
+
const patterns = [];
|
|
215
|
+
|
|
216
|
+
if (/[a-zA-Z0-9\-\*]$/.test(curr) && !preferences.find((ext) => curr.endsWith(ext))) {
|
|
217
|
+
patterns.push(curr, `${curr}.{${exts}}`, `${curr}/${packageJson}`, `${curr}/${piletJson}`);
|
|
218
|
+
} else if (curr.endsWith('/')) {
|
|
219
|
+
patterns.push(`${curr}index.{${exts}}`, `${curr}${packageJson}`, `${curr}${piletJson}`);
|
|
220
|
+
} else if (curr === '.' || curr === '..') {
|
|
221
|
+
patterns.push(`${curr}/index.{${exts}}`, `${curr}/${packageJson}`, `${curr}/${piletJson}`);
|
|
222
|
+
} else {
|
|
223
|
+
patterns.push(curr);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
agg.push({ original: curr, patterns });
|
|
227
|
+
return agg;
|
|
228
|
+
}, []);
|
|
229
|
+
|
|
175
230
|
await Promise.all(
|
|
176
|
-
|
|
177
|
-
(pattern) =>
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
231
|
+
allPatterns.map((patterns) =>
|
|
232
|
+
matchAnyPattern(baseDir, patterns).then(async ({ results, pattern }) => {
|
|
233
|
+
if (!results.length) {
|
|
234
|
+
log('generalDebug_0003', `Found no potential entry points using "${pattern}".`);
|
|
235
|
+
} else {
|
|
236
|
+
//TODO -> shouldn't take the first one,
|
|
237
|
+
// should be the first one, yes, but, PER pilet
|
|
238
|
+
// so that multiple pilets can be considered, too
|
|
239
|
+
log('generalDebug_0003', `Found ${results.length} potential entry points in "${pattern}".`);
|
|
240
|
+
|
|
241
|
+
for (const result of results) {
|
|
242
|
+
const fileName = basename(result);
|
|
243
|
+
|
|
244
|
+
if (fileName === packageJson) {
|
|
245
|
+
log('generalDebug_0003', `Entry point is a "${packageJson}" and needs further inspection.`);
|
|
246
|
+
const targetDir = dirname(result);
|
|
247
|
+
const { source, name } = await readJson(targetDir, fileName);
|
|
248
|
+
|
|
249
|
+
if (!pilets.includes(name)) {
|
|
250
|
+
if (typeof source === 'string') {
|
|
251
|
+
log('generalDebug_0003', `Found a "source" field with value "${source}".`);
|
|
252
|
+
const target = resolve(targetDir, source);
|
|
253
|
+
const exists = await checkExists(target);
|
|
254
|
+
|
|
255
|
+
if (exists) {
|
|
256
|
+
log('generalDebug_0003', `Taking existing target as "${target}".`);
|
|
257
|
+
matched(name, target);
|
|
258
|
+
} else {
|
|
259
|
+
log('generalDebug_0003', `Source target "${target}" does not exist. Skipped.`);
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
log('generalDebug_0003', `No "source" field found. Trying combinations in "src".`);
|
|
263
|
+
const files = await matchPattern(targetDir, `src/index.{${exts}}`);
|
|
264
|
+
|
|
265
|
+
if (files.length > 0) {
|
|
266
|
+
log('generalDebug_0003', `Found a result; taking "${files[0]}".`);
|
|
267
|
+
matched(name, files[0]);
|
|
268
|
+
} else {
|
|
269
|
+
log('generalDebug_0003', `Found no results in "src". Skipped.`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
const packageJsonPath = await findFile(result, packageJson);
|
|
275
|
+
|
|
276
|
+
if (packageJsonPath) {
|
|
277
|
+
const targetDir = dirname(packageJsonPath);
|
|
278
|
+
const { name } = await readJson(targetDir, packageJson);
|
|
279
|
+
|
|
280
|
+
if (!pilets.includes(name)) {
|
|
281
|
+
log('generalDebug_0003', `Entry point result is "${result}".`);
|
|
282
|
+
matched(name, result);
|
|
283
|
+
}
|
|
187
284
|
} else {
|
|
188
|
-
|
|
189
|
-
resolve();
|
|
285
|
+
log('generalDebug_0003', `Could not find "${packageJson}" for entry "${result}". Skipping.`);
|
|
190
286
|
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}),
|
|
194
291
|
),
|
|
195
292
|
);
|
|
293
|
+
|
|
196
294
|
return matches;
|
|
197
295
|
}
|
|
198
296
|
|
|
@@ -263,19 +361,28 @@ export async function getHash(targetFile: string) {
|
|
|
263
361
|
|
|
264
362
|
export async function mergeWithJson<T>(targetDir: string, fileName: string, newContent: T) {
|
|
265
363
|
const targetFile = join(targetDir, fileName);
|
|
266
|
-
const content = await new Promise<string>((resolve
|
|
267
|
-
readFile(targetFile, 'utf8', (err, c) => (err ?
|
|
364
|
+
const content = await new Promise<string>((resolve) => {
|
|
365
|
+
readFile(targetFile, 'utf8', (err, c) => (err ? resolve('{}') : resolve(c)));
|
|
268
366
|
});
|
|
269
367
|
const originalContent = JSON.parse(content);
|
|
270
368
|
return deepMerge(originalContent, newContent);
|
|
271
369
|
}
|
|
272
370
|
|
|
273
|
-
export async function readJson<T = any>(targetDir: string, fileName: string) {
|
|
371
|
+
export async function readJson<T = any>(targetDir: string, fileName: string, defaultValue = {}) {
|
|
274
372
|
const targetFile = join(targetDir, fileName);
|
|
275
373
|
const content = await new Promise<string>((resolve) => {
|
|
276
374
|
readFile(targetFile, 'utf8', (err, c) => (err ? resolve('') : resolve(c)));
|
|
277
375
|
});
|
|
278
|
-
|
|
376
|
+
|
|
377
|
+
if (content) {
|
|
378
|
+
try {
|
|
379
|
+
return JSON.parse(content) as T;
|
|
380
|
+
} catch (ex) {
|
|
381
|
+
log('generalError_0002', `Invalid JSON found in file "${fileName}" at "${targetDir}".`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return defaultValue as T;
|
|
279
386
|
}
|
|
280
387
|
|
|
281
388
|
export function readBinary(targetDir: string, fileName: string) {
|
|
@@ -319,10 +426,20 @@ export async function copy(source: string, target: string, forceOverwrite = Forc
|
|
|
319
426
|
|
|
320
427
|
try {
|
|
321
428
|
const flag = forceOverwrite === ForceOverwrite.yes ? 0 : constants.COPYFILE_EXCL;
|
|
322
|
-
await
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
429
|
+
const isDir = await checkIsDirectory(source);
|
|
430
|
+
|
|
431
|
+
if (isDir) {
|
|
432
|
+
const files = await getFileNames(source);
|
|
433
|
+
const results = await Promise.all(
|
|
434
|
+
files.map((file) => copy(resolve(source, file), resolve(target, file), forceOverwrite)),
|
|
435
|
+
);
|
|
436
|
+
return results.every(Boolean);
|
|
437
|
+
} else {
|
|
438
|
+
await new Promise<void>((resolve, reject) => {
|
|
439
|
+
copyFile(source, target, flag, (err) => (err ? reject(err) : resolve()));
|
|
440
|
+
});
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
326
443
|
} catch (e) {
|
|
327
444
|
if (forceOverwrite === ForceOverwrite.prompt) {
|
|
328
445
|
const shouldOverwrite = await promptOverwrite(target);
|
package/src/common/language.ts
CHANGED
|
@@ -1,24 +1,101 @@
|
|
|
1
1
|
import { log } from './log';
|
|
2
|
-
import { SourceLanguage } from '
|
|
2
|
+
import { Framework, SourceLanguage } from '../types';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
'
|
|
7
|
-
'@types/react-router': 'latest',
|
|
8
|
-
'@types/react-router-dom': 'latest',
|
|
4
|
+
const react17Deps = {
|
|
5
|
+
react: '^17',
|
|
6
|
+
'react-dom': '^17',
|
|
9
7
|
};
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
const react18Deps = {
|
|
10
|
+
react: '^18',
|
|
11
|
+
'react-dom': '^18',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const reactRouter5Deps = {
|
|
15
|
+
'react-router': '^5',
|
|
16
|
+
'react-router-dom': '^5',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const reactRouter6Deps = {
|
|
20
|
+
'react-router': '^6',
|
|
21
|
+
'react-router-dom': '^6',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const react17Typings = {
|
|
25
|
+
'@types/react': '^17',
|
|
26
|
+
'@types/react-dom': '^17',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const react18Typings = {
|
|
30
|
+
'@types/react': '^18',
|
|
31
|
+
'@types/react-dom': '^18',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const reactRouter5Typings = {
|
|
35
|
+
'@types/react-router': '^5',
|
|
36
|
+
'@types/react-router-dom': '^5',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const defaultDeps = {};
|
|
40
|
+
|
|
41
|
+
const defaultTypings = {
|
|
42
|
+
'@types/react': '*',
|
|
43
|
+
'@types/react-dom': '*',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export function getDependencyPackages(framework: Framework, reactVersion: number, reactRouterVersion: number) {
|
|
47
|
+
// take default packages only if piral-core
|
|
48
|
+
return framework === 'piral-base'
|
|
49
|
+
? {}
|
|
50
|
+
: {
|
|
51
|
+
...(reactVersion < 18 ? react17Deps : react18Deps),
|
|
52
|
+
...(reactRouterVersion < 6 ? reactRouter5Deps : reactRouter6Deps),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getDevDependencyPackages(framework: Framework, reactVersion: number, reactRouterVersion: number) {
|
|
57
|
+
// take default dev packages only if not piral-base
|
|
58
|
+
return framework === 'piral-base'
|
|
59
|
+
? {}
|
|
60
|
+
: {
|
|
61
|
+
...(reactVersion < 18 ? react17Typings : react18Typings),
|
|
62
|
+
...(reactRouterVersion < 6 ? reactRouter5Typings : {}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function getFrameworkDependencies(framework: Framework, version: string) {
|
|
67
|
+
return {
|
|
68
|
+
...(framework !== 'piral-base' ? { 'piral-base': `${version}` } : {}),
|
|
69
|
+
...(framework !== 'piral-base' && framework !== 'piral-core' ? { 'piral-core': `${version}` } : {}),
|
|
70
|
+
[framework]: `${version}`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function getDependencies(language: SourceLanguage, packages: Record<string, string> = defaultDeps) {
|
|
75
|
+
switch (language) {
|
|
76
|
+
case 'js':
|
|
77
|
+
case 'ts':
|
|
78
|
+
return {
|
|
79
|
+
...packages,
|
|
80
|
+
};
|
|
81
|
+
default:
|
|
82
|
+
log('generalDebug_0003', 'Did not find a valid language. Skipping "dependencies".');
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function getDevDependencies(language: SourceLanguage, typings: Record<string, string> = defaultTypings) {
|
|
12
88
|
switch (language) {
|
|
13
|
-
case
|
|
89
|
+
case 'ts':
|
|
14
90
|
return {
|
|
15
91
|
...typings,
|
|
16
92
|
'@types/node': 'latest',
|
|
17
93
|
typescript: 'latest',
|
|
18
94
|
};
|
|
19
|
-
case
|
|
95
|
+
case 'js':
|
|
96
|
+
return {};
|
|
20
97
|
default:
|
|
21
|
-
log('generalDebug_0003', 'Did not find a valid language.
|
|
98
|
+
log('generalDebug_0003', 'Did not find a valid language. Skipping "devDependencies".');
|
|
22
99
|
return {};
|
|
23
100
|
}
|
|
24
101
|
}
|
package/src/common/log.ts
CHANGED
|
@@ -1,94 +1,80 @@
|
|
|
1
1
|
import * as messages from '../messages';
|
|
2
|
-
import { join } from 'path';
|
|
3
2
|
import { format } from 'util';
|
|
4
|
-
import {
|
|
5
|
-
import { isWindows } from './info';
|
|
6
|
-
import { stripAnsi } from '../external';
|
|
3
|
+
import { ora } from '../external';
|
|
7
4
|
import { LogLevels, QuickMessage } from '../types';
|
|
8
5
|
|
|
9
6
|
type Messages = typeof messages;
|
|
10
7
|
type MessageTypes = keyof Messages;
|
|
8
|
+
let currentProgress: string = undefined;
|
|
9
|
+
let logLevel = LogLevels.info;
|
|
10
|
+
let instance = ora();
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return require('@parcel/logger');
|
|
15
|
-
} catch {
|
|
16
|
-
return require('../external').logger;
|
|
17
|
-
}
|
|
18
|
-
})();
|
|
19
|
-
|
|
20
|
-
// unfortunately, Parcel's support for verbose logging on Windows is broken
|
|
21
|
-
if (isWindows) {
|
|
22
|
-
logger.verbose = function (message: string) {
|
|
23
|
-
if (this.logLevel < 4) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const currDate = new Date();
|
|
28
|
-
message = `[${currDate.toLocaleTimeString()}]: ${message}`;
|
|
29
|
-
|
|
30
|
-
if (this.logLevel > 4) {
|
|
31
|
-
if (!this.logFile) {
|
|
32
|
-
// the critical line is the filename; it must not contain colons!
|
|
33
|
-
const timestamp = currDate.toISOString().replace(/:/g, '');
|
|
34
|
-
const fileName = `parcel-debug-${timestamp}.log`;
|
|
35
|
-
this.logFile = createWriteStream(join(process.cwd(), fileName));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
this.logFile.write(stripAnsi.default(message) + '\n');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
this._log(message);
|
|
42
|
-
};
|
|
12
|
+
export function getLogLevel(): LogLevels {
|
|
13
|
+
return logLevel;
|
|
43
14
|
}
|
|
44
15
|
|
|
45
|
-
export function setLogLevel(
|
|
46
|
-
|
|
16
|
+
export function setLogLevel(value: LogLevels) {
|
|
17
|
+
logLevel = value;
|
|
47
18
|
}
|
|
48
19
|
|
|
49
20
|
export function logInfo(message: string, ...args: Array<string | number | boolean>) {
|
|
50
21
|
const msg = format(message, ...args);
|
|
51
|
-
|
|
22
|
+
instance.info(msg);
|
|
52
23
|
return msg;
|
|
53
24
|
}
|
|
54
25
|
|
|
55
26
|
export function logDebug(message: string, ...args: Array<string | number | boolean>) {
|
|
56
27
|
const msg = format(message, ...args);
|
|
57
|
-
|
|
28
|
+
|
|
29
|
+
if (logLevel >= LogLevels.debug) {
|
|
30
|
+
instance.info(msg);
|
|
31
|
+
}
|
|
32
|
+
|
|
58
33
|
return msg;
|
|
59
34
|
}
|
|
60
35
|
|
|
61
36
|
export function logVerbose(message: string, ...args: Array<string | number | boolean>) {
|
|
62
37
|
const msg = format(message, ...args);
|
|
63
|
-
|
|
38
|
+
|
|
39
|
+
if (logLevel >= LogLevels.verbose) {
|
|
40
|
+
instance.info(msg);
|
|
41
|
+
}
|
|
42
|
+
|
|
64
43
|
return msg;
|
|
65
44
|
}
|
|
66
45
|
|
|
67
46
|
export function logDone(message: string, ...args: Array<string | number | boolean>) {
|
|
68
47
|
const msg = format(message, ...args);
|
|
69
|
-
|
|
48
|
+
instance.succeed(msg);
|
|
70
49
|
return msg;
|
|
71
50
|
}
|
|
72
51
|
|
|
73
52
|
export function logWarn(message: string, ...args: Array<string | number | boolean>) {
|
|
74
53
|
const msg = format(message, ...args);
|
|
75
|
-
|
|
54
|
+
instance.warn(msg);
|
|
76
55
|
return msg;
|
|
77
56
|
}
|
|
78
57
|
|
|
79
58
|
export function logFail(message: string, ...args: Array<string | number | boolean>) {
|
|
80
59
|
const msg = format(message, ...args);
|
|
81
|
-
|
|
60
|
+
instance.fail(msg);
|
|
82
61
|
return msg;
|
|
83
62
|
}
|
|
84
63
|
|
|
85
64
|
export function progress(message: string, ...args: Array<string | number | boolean>) {
|
|
86
|
-
|
|
65
|
+
const msg = format(message, ...args)
|
|
66
|
+
instance.start(msg);
|
|
67
|
+
currentProgress = msg;
|
|
87
68
|
}
|
|
88
69
|
|
|
89
70
|
export function logReset() {
|
|
90
|
-
|
|
91
|
-
|
|
71
|
+
instance.stop();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function logSuspend() {
|
|
75
|
+
logReset();
|
|
76
|
+
|
|
77
|
+
return () => instance.start(currentProgress);
|
|
92
78
|
}
|
|
93
79
|
|
|
94
80
|
export function fail<T extends MessageTypes>(type: T, ...args: Parameters<Messages[T]>): never {
|