@modern-js/utils 1.3.4 → 1.3.7-alpha.prebundle.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +9 -0
- package/CHANGELOG.md +18 -0
- package/compiled/browserslist/index.d.ts +178 -0
- package/compiled/browserslist/index.js +1 -0
- package/compiled/browserslist/license +20 -0
- package/compiled/browserslist/package.json +1 -0
- package/compiled/chalk/index.d.ts +415 -0
- package/compiled/chalk/index.js +1 -0
- package/compiled/chalk/license +9 -0
- package/compiled/chalk/package.json +1 -0
- package/compiled/chokidar/anymatch/index.d.ts +19 -0
- package/compiled/chokidar/fsevents.node +0 -0
- package/compiled/chokidar/index.js +40 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/chokidar/types/index.d.ts +188 -0
- package/compiled/commander/index.js +1 -0
- package/compiled/commander/license +22 -0
- package/compiled/commander/package.json +1 -0
- package/compiled/commander/typings/index.d.ts +774 -0
- package/compiled/debug/index.d.ts +54 -0
- package/compiled/debug/index.js +1 -0
- package/compiled/debug/license +20 -0
- package/compiled/debug/ms/index.d.ts +25 -0
- package/compiled/debug/package.json +1 -0
- package/compiled/execa/index.d.ts +564 -0
- package/compiled/execa/index.js +1 -0
- package/compiled/execa/license +9 -0
- package/compiled/execa/package.json +1 -0
- package/compiled/filesize/filesize.d.ts +131 -0
- package/compiled/filesize/index.js +9 -0
- package/compiled/filesize/license +28 -0
- package/compiled/filesize/package.json +1 -0
- package/compiled/fs-extra/index.d.ts +563 -0
- package/compiled/fs-extra/index.js +1 -0
- package/compiled/fs-extra/license +15 -0
- package/compiled/fs-extra/package.json +1 -0
- package/compiled/glob/index.d.ts +91 -0
- package/compiled/glob/index.js +1 -0
- package/compiled/glob/license +21 -0
- package/compiled/glob/minimatch/index.d.ts +204 -0
- package/compiled/glob/package.json +1 -0
- package/compiled/gzip-size/index.d.ts +96 -0
- package/compiled/gzip-size/index.js +1 -0
- package/compiled/gzip-size/license +9 -0
- package/compiled/gzip-size/package.json +1 -0
- package/compiled/import-lazy/index.d.ts +26 -0
- package/compiled/import-lazy/index.js +1 -0
- package/compiled/import-lazy/license +9 -0
- package/compiled/import-lazy/package.json +1 -0
- package/compiled/js-yaml/index.d.ts +154 -0
- package/compiled/js-yaml/index.js +1 -0
- package/compiled/js-yaml/license +21 -0
- package/compiled/js-yaml/package.json +1 -0
- package/compiled/lodash/common/array.d.ts +2126 -0
- package/compiled/lodash/common/collection.d.ts +1930 -0
- package/compiled/lodash/common/common.d.ts +280 -0
- package/compiled/lodash/common/date.d.ts +23 -0
- package/compiled/lodash/common/function.d.ts +1446 -0
- package/compiled/lodash/common/lang.d.ts +1693 -0
- package/compiled/lodash/common/math.d.ts +405 -0
- package/compiled/lodash/common/number.d.ts +131 -0
- package/compiled/lodash/common/object.d.ts +2519 -0
- package/compiled/lodash/common/seq.d.ts +210 -0
- package/compiled/lodash/common/string.d.ts +788 -0
- package/compiled/lodash/common/util.d.ts +1220 -0
- package/compiled/lodash/index.d.ts +46 -0
- package/compiled/lodash/index.js +9 -0
- package/compiled/lodash/license +47 -0
- package/compiled/lodash/package.json +1 -0
- package/compiled/pkg-up/index.d.ts +48 -0
- package/compiled/pkg-up/index.js +1 -0
- package/compiled/pkg-up/license +9 -0
- package/compiled/pkg-up/package.json +1 -0
- package/compiled/recursive-readdir/index.d.ts +21 -0
- package/compiled/recursive-readdir/index.js +1 -0
- package/compiled/recursive-readdir/license +21 -0
- package/compiled/recursive-readdir/package.json +1 -0
- package/compiled/signale/index.d.ts +162 -0
- package/compiled/signale/index.js +1 -0
- package/compiled/signale/package.json +1 -0
- package/compiled/strip-ansi/index.d.ts +17 -0
- package/compiled/strip-ansi/index.js +1 -0
- package/compiled/strip-ansi/license +9 -0
- package/compiled/strip-ansi/package.json +1 -0
- package/compiled/upath/index.js +1 -0
- package/compiled/upath/license +22 -0
- package/compiled/upath/package.json +1 -0
- package/compiled/upath/upath.d.ts +241 -0
- package/dist/{types/FileSizeReporter.d.ts → FileSizeReporter.d.ts} +5 -5
- package/dist/FileSizeReporter.js +151 -0
- package/dist/{types/alias.d.ts → alias.d.ts} +12 -14
- package/dist/alias.js +62 -0
- package/dist/applyOptionsChain.d.ts +6 -0
- package/dist/applyOptionsChain.js +30 -0
- package/dist/clearConsole.d.ts +1 -0
- package/dist/clearConsole.js +9 -0
- package/dist/{types/compatRequire.d.ts → compatRequire.d.ts} +1 -1
- package/dist/compatRequire.js +28 -0
- package/dist/compiled/upath/index.d.ts +225 -0
- package/dist/compiled/upath/index.js +1 -0
- package/dist/compiled.d.ts +21 -0
- package/dist/compiled.js +33 -0
- package/dist/constants.d.ts +209 -0
- package/dist/constants.js +264 -0
- package/dist/{js/modern/debug.js → debug.d.ts} +1 -3
- package/dist/debug.js +11 -0
- package/dist/emptyDir.d.ts +1 -0
- package/dist/emptyDir.js +19 -0
- package/dist/{types/ensureAbsolutePath.d.ts → ensureAbsolutePath.d.ts} +1 -1
- package/dist/ensureAbsolutePath.js +15 -0
- package/dist/{types/findExists.d.ts → findExists.d.ts} +1 -1
- package/dist/findExists.js +21 -0
- package/dist/{types/format.d.ts → format.d.ts} +5 -5
- package/dist/format.js +113 -0
- package/dist/{types/generateMetaTags.d.ts → generateMetaTags.d.ts} +3 -3
- package/dist/generateMetaTags.js +48 -0
- package/dist/{types/getBrowserslist.d.ts → getBrowserslist.d.ts} +1 -1
- package/dist/getBrowserslist.js +7 -0
- package/dist/{types/getCacheIdentifier.d.ts → getCacheIdentifier.d.ts} +3 -3
- package/dist/getCacheIdentifier.js +24 -0
- package/dist/{types/getEntryOptions.d.ts → getEntryOptions.d.ts} +1 -1
- package/dist/getEntryOptions.js +26 -0
- package/dist/{types/getPackageManager.d.ts → getPackageManager.d.ts} +1 -1
- package/dist/getPackageManager.js +47 -0
- package/dist/{types/getPort.d.ts → getPort.d.ts} +1 -1
- package/dist/getPort.js +62 -0
- package/dist/{types/import.d.ts → import.d.ts} +2 -2
- package/dist/import.js +10 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +43 -0
- package/dist/{types/is → is}/index.d.ts +1 -4
- package/dist/is/index.js +82 -0
- package/dist/{types/is → is}/node-env.d.ts +1 -1
- package/dist/is/node-env.js +12 -0
- package/dist/is/platform.d.ts +2 -0
- package/dist/is/platform.js +10 -0
- package/dist/is/type.d.ts +8 -0
- package/dist/is/type.js +38 -0
- package/dist/logger.d.ts +63 -0
- package/dist/logger.js +128 -0
- package/dist/{types/monorepo.d.ts → monorepo.d.ts} +3 -3
- package/dist/monorepo.js +80 -0
- package/dist/{types/nodeEnv.d.ts → nodeEnv.d.ts} +1 -1
- package/dist/nodeEnv.js +49 -0
- package/dist/{types/path.d.ts → path.d.ts} +1 -1
- package/dist/path.js +14 -0
- package/dist/{types/pkgUp.d.ts → pkgUp.d.ts} +1 -1
- package/dist/pkgUp.js +8 -0
- package/dist/{types/prettyInstructions.d.ts → prettyInstructions.d.ts} +2 -2
- package/dist/prettyInstructions.js +64 -0
- package/dist/{types/printBuildError.d.ts → printBuildError.d.ts} +1 -1
- package/dist/printBuildError.js +43 -0
- package/dist/{types/readTsConfig.d.ts → readTsConfig.d.ts} +1 -1
- package/dist/readTsConfig.js +19 -0
- package/dist/{types/removeSlash.d.ts → removeSlash.d.ts} +1 -1
- package/dist/removeSlash.js +9 -0
- package/dist/{types/runtimeExports.d.ts → runtimeExports.d.ts} +3 -3
- package/dist/runtimeExports.js +53 -0
- package/dist/src/FileSizeReporter.d.ts +16 -0
- package/dist/src/FileSizeReporter.js +152 -0
- package/dist/src/alias.d.ts +21 -0
- package/dist/src/alias.js +62 -0
- package/dist/src/applyOptionsChain.d.ts +6 -0
- package/dist/src/applyOptionsChain.js +30 -0
- package/dist/src/clearConsole.d.ts +1 -0
- package/dist/src/clearConsole.js +9 -0
- package/dist/src/compatRequire.d.ts +8 -0
- package/dist/src/compatRequire.js +28 -0
- package/dist/src/compiled.d.ts +7 -0
- package/dist/src/compiled.js +19 -0
- package/dist/src/constants.d.ts +209 -0
- package/dist/src/constants.js +264 -0
- package/dist/{types → src}/debug.d.ts +1 -2
- package/dist/src/debug.js +14 -0
- package/dist/src/emptyDir.d.ts +1 -0
- package/dist/src/emptyDir.js +22 -0
- package/dist/{js/modern/ensureAbsolutePath.js → src/ensureAbsolutePath.d.ts} +1 -3
- package/dist/src/ensureAbsolutePath.js +15 -0
- package/dist/src/findExists.d.ts +6 -0
- package/dist/src/findExists.js +21 -0
- package/dist/src/format.d.ts +16 -0
- package/dist/src/format.js +115 -0
- package/dist/src/generateMetaTags.d.ts +16 -0
- package/dist/src/generateMetaTags.js +48 -0
- package/dist/src/getBrowserslist.d.ts +2 -0
- package/dist/src/getBrowserslist.js +7 -0
- package/dist/src/getCacheIdentifier.d.ts +7 -0
- package/dist/src/getCacheIdentifier.js +24 -0
- package/dist/src/getEntryOptions.d.ts +1 -0
- package/dist/src/getEntryOptions.js +26 -0
- package/dist/src/getPackageManager.d.ts +1 -0
- package/dist/src/getPackageManager.js +47 -0
- package/dist/src/getPort.d.ts +7 -0
- package/dist/src/getPort.js +62 -0
- package/dist/src/import.d.ts +5 -0
- package/dist/src/import.js +10 -0
- package/dist/{types → src}/index.d.ts +2 -3
- package/dist/src/index.js +57 -0
- package/dist/src/is/index.d.ts +34 -0
- package/dist/src/is/index.js +82 -0
- package/dist/src/is/node-env.d.ts +4 -0
- package/dist/src/is/node-env.js +12 -0
- package/dist/src/is/platform.d.ts +2 -0
- package/dist/src/is/platform.js +10 -0
- package/dist/src/is/type.d.ts +8 -0
- package/dist/src/is/type.js +38 -0
- package/dist/src/logger.d.ts +63 -0
- package/dist/src/logger.js +129 -0
- package/dist/src/monorepo.d.ts +11 -0
- package/dist/src/monorepo.js +81 -0
- package/dist/src/nodeEnv.d.ts +3 -0
- package/dist/src/nodeEnv.js +52 -0
- package/dist/src/path.d.ts +3 -0
- package/dist/src/path.js +14 -0
- package/dist/src/prettyInstructions.d.ts +6 -0
- package/dist/src/prettyInstructions.js +64 -0
- package/dist/src/printBuildError.d.ts +8 -0
- package/dist/src/printBuildError.js +43 -0
- package/dist/src/readTsConfig.d.ts +2 -0
- package/dist/src/readTsConfig.js +19 -0
- package/dist/src/removeSlash.d.ts +3 -0
- package/dist/src/removeSlash.js +9 -0
- package/dist/src/runtimeExports.d.ts +4 -0
- package/dist/src/runtimeExports.js +53 -0
- package/dist/{types → src}/wait.d.ts +1 -1
- package/dist/src/wait.js +7 -0
- package/dist/{types → src}/watch.d.ts +3 -3
- package/dist/src/watch.js +65 -0
- package/dist/wait.d.ts +2 -0
- package/dist/wait.js +7 -0
- package/dist/watch.d.ts +8 -0
- package/dist/watch.js +64 -0
- package/jest.config.js +0 -1
- package/package.json +55 -39
- package/tests/debug.test.ts +2 -2
- package/tests/is.test.ts +27 -0
- package/tests/isPlatform.test.ts +19 -0
- package/tests/isType.test.ts +70 -2
- package/tests/prettyInstructions.test.ts +1 -1
- package/tsconfig.json +3 -5
- package/dist/js/modern/FileSizeReporter.js +0 -156
- package/dist/js/modern/alias.js +0 -74
- package/dist/js/modern/applyOptionsChain.js +0 -27
- package/dist/js/modern/chalk.js +0 -2
- package/dist/js/modern/clearConsole.js +0 -5
- package/dist/js/modern/compatRequire.js +0 -26
- package/dist/js/modern/constants.js +0 -338
- package/dist/js/modern/emptyDir.js +0 -6
- package/dist/js/modern/findExists.js +0 -16
- package/dist/js/modern/format.js +0 -137
- package/dist/js/modern/generateMetaTags.js +0 -49
- package/dist/js/modern/getBrowserslist.js +0 -5
- package/dist/js/modern/getCacheIdentifier.js +0 -20
- package/dist/js/modern/getEntryOptions.js +0 -24
- package/dist/js/modern/getPackageManager.js +0 -37
- package/dist/js/modern/getPort.js +0 -52
- package/dist/js/modern/import.js +0 -11
- package/dist/js/modern/index.js +0 -34
- package/dist/js/modern/is/index.js +0 -77
- package/dist/js/modern/is/node-env.js +0 -5
- package/dist/js/modern/is/platform.js +0 -2
- package/dist/js/modern/is/type.js +0 -28
- package/dist/js/modern/logger.js +0 -152
- package/dist/js/modern/monorepo.js +0 -84
- package/dist/js/modern/nodeEnv.js +0 -31
- package/dist/js/modern/path.js +0 -5
- package/dist/js/modern/pkgUp.js +0 -2
- package/dist/js/modern/prettyInstructions.js +0 -79
- package/dist/js/modern/printBuildError.js +0 -40
- package/dist/js/modern/readTsConfig.js +0 -13
- package/dist/js/modern/removeSlash.js +0 -3
- package/dist/js/modern/runtimeExports.js +0 -52
- package/dist/js/modern/wait.js +0 -5
- package/dist/js/modern/watch.js +0 -43
- package/dist/js/node/FileSizeReporter.js +0 -175
- package/dist/js/node/alias.js +0 -97
- package/dist/js/node/applyOptionsChain.js +0 -37
- package/dist/js/node/chalk.js +0 -15
- package/dist/js/node/clearConsole.js +0 -14
- package/dist/js/node/compatRequire.js +0 -41
- package/dist/js/node/constants.js +0 -358
- package/dist/js/node/debug.js +0 -19
- package/dist/js/node/emptyDir.js +0 -18
- package/dist/js/node/ensureAbsolutePath.js +0 -20
- package/dist/js/node/findExists.js +0 -27
- package/dist/js/node/format.js +0 -141
- package/dist/js/node/generateMetaTags.js +0 -58
- package/dist/js/node/getBrowserslist.js +0 -17
- package/dist/js/node/getCacheIdentifier.js +0 -27
- package/dist/js/node/getEntryOptions.js +0 -35
- package/dist/js/node/getPackageManager.js +0 -51
- package/dist/js/node/getPort.js +0 -67
- package/dist/js/node/import.js +0 -19
- package/dist/js/node/index.js +0 -465
- package/dist/js/node/is/index.js +0 -150
- package/dist/js/node/is/node-env.js +0 -23
- package/dist/js/node/is/platform.js +0 -14
- package/dist/js/node/is/type.js +0 -49
- package/dist/js/node/logger.js +0 -162
- package/dist/js/node/monorepo.js +0 -118
- package/dist/js/node/nodeEnv.js +0 -45
- package/dist/js/node/path.js +0 -24
- package/dist/js/node/pkgUp.js +0 -15
- package/dist/js/node/prettyInstructions.js +0 -95
- package/dist/js/node/printBuildError.js +0 -52
- package/dist/js/node/readTsConfig.js +0 -28
- package/dist/js/node/removeSlash.js +0 -18
- package/dist/js/node/runtimeExports.js +0 -68
- package/dist/js/node/wait.js +0 -12
- package/dist/js/node/watch.js +0 -61
- package/dist/js/treeshaking/FileSizeReporter.js +0 -185
- package/dist/js/treeshaking/alias.js +0 -72
- package/dist/js/treeshaking/applyOptionsChain.js +0 -31
- package/dist/js/treeshaking/chalk.js +0 -2
- package/dist/js/treeshaking/clearConsole.js +0 -5
- package/dist/js/treeshaking/compatRequire.js +0 -29
- package/dist/js/treeshaking/constants.js +0 -338
- package/dist/js/treeshaking/debug.js +0 -10
- package/dist/js/treeshaking/emptyDir.js +0 -37
- package/dist/js/treeshaking/ensureAbsolutePath.js +0 -11
- package/dist/js/treeshaking/findExists.js +0 -33
- package/dist/js/treeshaking/format.js +0 -167
- package/dist/js/treeshaking/generateMetaTags.js +0 -55
- package/dist/js/treeshaking/getBrowserslist.js +0 -7
- package/dist/js/treeshaking/getCacheIdentifier.js +0 -35
- package/dist/js/treeshaking/getEntryOptions.js +0 -26
- package/dist/js/treeshaking/getPackageManager.js +0 -101
- package/dist/js/treeshaking/getPort.js +0 -103
- package/dist/js/treeshaking/import.js +0 -11
- package/dist/js/treeshaking/index.js +0 -34
- package/dist/js/treeshaking/is/index.js +0 -81
- package/dist/js/treeshaking/is/node-env.js +0 -13
- package/dist/js/treeshaking/is/platform.js +0 -6
- package/dist/js/treeshaking/is/type.js +0 -30
- package/dist/js/treeshaking/logger.js +0 -188
- package/dist/js/treeshaking/monorepo.js +0 -95
- package/dist/js/treeshaking/nodeEnv.js +0 -108
- package/dist/js/treeshaking/path.js +0 -11
- package/dist/js/treeshaking/pkgUp.js +0 -2
- package/dist/js/treeshaking/prettyInstructions.js +0 -100
- package/dist/js/treeshaking/printBuildError.js +0 -40
- package/dist/js/treeshaking/readTsConfig.js +0 -13
- package/dist/js/treeshaking/removeSlash.js +0 -9
- package/dist/js/treeshaking/runtimeExports.js +0 -61
- package/dist/js/treeshaking/wait.js +0 -8
- package/dist/js/treeshaking/watch.js +0 -112
- package/dist/types/applyOptionsChain.d.ts +0 -6
- package/dist/types/chalk.d.ts +0 -2
- package/dist/types/clearConsole.d.ts +0 -1
- package/dist/types/constants.d.ts +0 -219
- package/dist/types/emptyDir.d.ts +0 -1
- package/dist/types/is/platform.d.ts +0 -2
- package/dist/types/is/type.d.ts +0 -8
- package/dist/types/logger.d.ts +0 -63
@@ -0,0 +1,81 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.getMonorepoPackages = exports.findMonorepoRoot = exports.isModernjsMonorepo = exports.isMonorepo = exports.isPnpmWorkspaces = exports.isYarnWorkspaces = exports.isLerna = void 0;
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
8
|
+
const path_1 = __importDefault(require("path"));
|
9
|
+
const glob_1 = __importDefault(require("glob"));
|
10
|
+
const yaml_1 = __importDefault(require("yaml"));
|
11
|
+
const PACKAGE_MAX_DEPTH = 5;
|
12
|
+
const WOKRSPACES_FILES = {
|
13
|
+
YARN: 'package.json',
|
14
|
+
PNPM: 'pnpm-workspaces.yaml',
|
15
|
+
LERNA: 'lerna.json',
|
16
|
+
};
|
17
|
+
const isLerna = (root) => fs_1.default.existsSync(path_1.default.join(root, WOKRSPACES_FILES.LERNA));
|
18
|
+
exports.isLerna = isLerna;
|
19
|
+
const isYarnWorkspaces = (root) => {
|
20
|
+
var _a;
|
21
|
+
const pkg = path_1.default.join(root, WOKRSPACES_FILES.YARN);
|
22
|
+
if (!fs_1.default.existsSync(pkg)) {
|
23
|
+
return false;
|
24
|
+
}
|
25
|
+
const json = JSON.parse(fs_1.default.readFileSync(pkg, 'utf8'));
|
26
|
+
return Boolean((_a = json.workspaces) === null || _a === void 0 ? void 0 : _a.packages);
|
27
|
+
};
|
28
|
+
exports.isYarnWorkspaces = isYarnWorkspaces;
|
29
|
+
const isPnpmWorkspaces = (root) => fs_1.default.existsSync(path_1.default.join(root, WOKRSPACES_FILES.PNPM));
|
30
|
+
exports.isPnpmWorkspaces = isPnpmWorkspaces;
|
31
|
+
const isMonorepo = (root) => (0, exports.isLerna)(root) || (0, exports.isYarnWorkspaces)(root) || (0, exports.isPnpmWorkspaces)(root);
|
32
|
+
exports.isMonorepo = isMonorepo;
|
33
|
+
const isModernjsMonorepo = (root) => {
|
34
|
+
const json = JSON.parse(fs_1.default.readFileSync(path_1.default.join(root, 'package.json'), 'utf8'));
|
35
|
+
const deps = Object.assign(Object.assign({}, (json.dependencies || {})), (json.devDependencies || {}));
|
36
|
+
return Boolean(deps['@modern-js/monorepo-tools']);
|
37
|
+
};
|
38
|
+
exports.isModernjsMonorepo = isModernjsMonorepo;
|
39
|
+
const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
40
|
+
let inMonorepo = false;
|
41
|
+
for (let depth = 0; depth < maxDepth; depth++) {
|
42
|
+
if ((0, exports.isMonorepo)(appDirectory)) {
|
43
|
+
inMonorepo = true;
|
44
|
+
break;
|
45
|
+
}
|
46
|
+
// eslint-disable-next-line no-param-reassign
|
47
|
+
appDirectory = path_1.default.dirname(appDirectory);
|
48
|
+
}
|
49
|
+
return inMonorepo ? appDirectory : undefined;
|
50
|
+
};
|
51
|
+
exports.findMonorepoRoot = findMonorepoRoot;
|
52
|
+
const getMonorepoPackages = (root) => {
|
53
|
+
let packages = [];
|
54
|
+
if ((0, exports.isYarnWorkspaces)(root)) {
|
55
|
+
const json = JSON.parse(fs_1.default.readFileSync(path_1.default.join(root, 'package.json'), 'utf8'));
|
56
|
+
({ packages } = json.workspaces);
|
57
|
+
}
|
58
|
+
else if ((0, exports.isLerna)(root)) {
|
59
|
+
const json = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(root, 'lerna.json'), 'utf8'));
|
60
|
+
({ packages } = json);
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
({ packages } = yaml_1.default.parse(fs_1.default.readFileSync(path_1.default.join(root, WOKRSPACES_FILES.PNPM), 'utf8')));
|
64
|
+
}
|
65
|
+
if (packages) {
|
66
|
+
return packages
|
67
|
+
.map(name =>
|
68
|
+
// The trailing / ensures only dirs are picked up
|
69
|
+
glob_1.default.sync(path_1.default.join(root, `${name}/`), {
|
70
|
+
ignore: ['**/node_modules/**'],
|
71
|
+
}))
|
72
|
+
.reduce((acc, val) => acc.concat(val), [])
|
73
|
+
.filter(filepath => fs_1.default.existsSync(path_1.default.resolve(filepath, 'package.json')))
|
74
|
+
.map(filepath => ({
|
75
|
+
path: filepath,
|
76
|
+
name: JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(filepath, 'package.json'), 'utf8')).name,
|
77
|
+
}));
|
78
|
+
}
|
79
|
+
return [];
|
80
|
+
};
|
81
|
+
exports.getMonorepoPackages = getMonorepoPackages;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.canUsePnpm = exports.canUseYarn = exports.canUseNpm = void 0;
|
16
|
+
const execa_1 = __importDefault(require("execa"));
|
17
|
+
function canUseNpm() {
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
19
|
+
try {
|
20
|
+
yield (0, execa_1.default)('npm', ['--version'], { env: process.env });
|
21
|
+
return true;
|
22
|
+
}
|
23
|
+
catch (e) {
|
24
|
+
return false;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
}
|
28
|
+
exports.canUseNpm = canUseNpm;
|
29
|
+
function canUseYarn() {
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
31
|
+
try {
|
32
|
+
yield (0, execa_1.default)('yarn', ['--version'], { env: process.env });
|
33
|
+
return true;
|
34
|
+
}
|
35
|
+
catch (e) {
|
36
|
+
return false;
|
37
|
+
}
|
38
|
+
});
|
39
|
+
}
|
40
|
+
exports.canUseYarn = canUseYarn;
|
41
|
+
function canUsePnpm() {
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
43
|
+
try {
|
44
|
+
yield (0, execa_1.default)('pnpm', ['--version'], { env: process.env });
|
45
|
+
return true;
|
46
|
+
}
|
47
|
+
catch (e) {
|
48
|
+
return false;
|
49
|
+
}
|
50
|
+
});
|
51
|
+
}
|
52
|
+
exports.canUsePnpm = canUsePnpm;
|
package/dist/src/path.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.normalizeToPosixPath = exports.normalizeOutputPath = exports.isRelativePath = void 0;
|
7
|
+
const path_1 = __importDefault(require("path"));
|
8
|
+
const upath_1 = __importDefault(require("upath"));
|
9
|
+
const isRelativePath = (test) => /^\.\.?($|[\\/])/.test(test);
|
10
|
+
exports.isRelativePath = isRelativePath;
|
11
|
+
const normalizeOutputPath = (s) => s.replace(/\\/g, '\\\\');
|
12
|
+
exports.normalizeOutputPath = normalizeOutputPath;
|
13
|
+
const normalizeToPosixPath = (p) => upath_1.default.normalizeSafe(path_1.default.normalize(p));
|
14
|
+
exports.normalizeToPosixPath = normalizeToPosixPath;
|
@@ -0,0 +1,64 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.prettyInstructions = exports.isSingleEntry = void 0;
|
7
|
+
const os_1 = __importDefault(require("os"));
|
8
|
+
const compiled_1 = require("./compiled");
|
9
|
+
const is_1 = require("./is");
|
10
|
+
// TODO: remove hard code 'main'
|
11
|
+
const isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === 'main';
|
12
|
+
exports.isSingleEntry = isSingleEntry;
|
13
|
+
const normalizeUrl = (url) => url.replace(/([^:]\/)\/+/g, '$1');
|
14
|
+
const getAddressUrls = (protocol = 'http', port) => {
|
15
|
+
const interfaces = os_1.default.networkInterfaces();
|
16
|
+
const ipv4Interfaces = [];
|
17
|
+
Object.keys(interfaces).forEach(key => {
|
18
|
+
interfaces[key].forEach(detail => {
|
19
|
+
if (detail.family === 'IPv4') {
|
20
|
+
ipv4Interfaces.push(detail);
|
21
|
+
}
|
22
|
+
});
|
23
|
+
});
|
24
|
+
return ipv4Interfaces.reduce((memo, detail) => {
|
25
|
+
let type = 'Network: ';
|
26
|
+
let url = `${protocol}://${detail.address}:${port}`;
|
27
|
+
if (detail.address.includes(`localhost`)) {
|
28
|
+
type = 'Local: ';
|
29
|
+
url = `${protocol}://localhost:${port}`;
|
30
|
+
}
|
31
|
+
memo.push({ type, url });
|
32
|
+
return memo;
|
33
|
+
}, []);
|
34
|
+
};
|
35
|
+
const prettyInstructions = (appContext, config) => {
|
36
|
+
const { entrypoints, serverRoutes, port, existSrc, checkedEntries } = appContext;
|
37
|
+
const urls = getAddressUrls(config.dev.https && (0, is_1.isDev)() ? 'https' : 'http', port);
|
38
|
+
const routes = existSrc
|
39
|
+
? serverRoutes.filter(route => route.entryName)
|
40
|
+
: serverRoutes;
|
41
|
+
let message = 'App running at:\n\n';
|
42
|
+
if ((0, exports.isSingleEntry)(entrypoints) || !existSrc) {
|
43
|
+
message += urls
|
44
|
+
.map(({ type, url }) => ` ${compiled_1.chalk.bold(`> ${type.padEnd(10)}`)}${compiled_1.chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}\n`)
|
45
|
+
.join('');
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
const maxNameLength = Math.max(...routes.map(r => r.entryName.length));
|
49
|
+
urls.forEach(({ type, url }) => {
|
50
|
+
message += ` ${compiled_1.chalk.bold(`> ${type}`)}\n`;
|
51
|
+
routes.forEach(({ entryName, urlPath, isSSR }) => {
|
52
|
+
if (!checkedEntries.includes(entryName)) {
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
message += ` ${compiled_1.chalk.yellowBright(isSSR ? 'λ' : '○')} ${compiled_1.chalk.yellowBright(entryName.padEnd(maxNameLength + 8))}${compiled_1.chalk.cyanBright(normalizeUrl(`${url}/${urlPath}`))}\n`;
|
56
|
+
});
|
57
|
+
});
|
58
|
+
message += '\n';
|
59
|
+
message += compiled_1.chalk.cyanBright(' λ (Server) server-side renders at runtime\n');
|
60
|
+
message += compiled_1.chalk.cyanBright(' ○ (Static) client-side rendered as static HTML\n');
|
61
|
+
}
|
62
|
+
return message;
|
63
|
+
};
|
64
|
+
exports.prettyInstructions = prettyInstructions;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file at
|
6
|
+
* https://github.com/facebook/create-react-app/blob/master/LICENSE
|
7
|
+
*/
|
8
|
+
export declare function printBuildError(err: Error): void;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
/* eslint-disable eslint-comments/no-unlimited-disable */
|
3
|
+
/* eslint-disable */
|
4
|
+
/**
|
5
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
6
|
+
*
|
7
|
+
* This source code is licensed under the MIT license found in the
|
8
|
+
* LICENSE file at
|
9
|
+
* https://github.com/facebook/create-react-app/blob/master/LICENSE
|
10
|
+
*/
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.printBuildError = void 0;
|
13
|
+
// Modified by Chao Xu (xuchaobei)
|
14
|
+
const compiled_1 = require("./compiled");
|
15
|
+
const logger_1 = require("./logger");
|
16
|
+
function printBuildError(err) {
|
17
|
+
const message = err != null && err.message;
|
18
|
+
const stack = err != null && err.stack;
|
19
|
+
// Add more helpful message for Terser error
|
20
|
+
if (stack &&
|
21
|
+
typeof message === 'string' &&
|
22
|
+
message.indexOf('from Terser') !== -1) {
|
23
|
+
try {
|
24
|
+
const matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack);
|
25
|
+
if (!matched) {
|
26
|
+
throw new Error('Using errors for control flow is bad.');
|
27
|
+
}
|
28
|
+
const problemPath = matched[2];
|
29
|
+
const line = matched[3];
|
30
|
+
const column = matched[4];
|
31
|
+
logger_1.logger.error(`Failed to minify the code from this file: \n\n ${compiled_1.chalk.yellow(`\t${problemPath}:${line}${column !== '0' ? ':' + column : ''}`)}\n`);
|
32
|
+
}
|
33
|
+
catch (ignored) {
|
34
|
+
logger_1.logger.error(`Failed to minify the bundle. ${err}\n`);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
logger_1.logger.error((message || err) + '\n');
|
39
|
+
}
|
40
|
+
logger_1.logger.log();
|
41
|
+
}
|
42
|
+
exports.printBuildError = printBuildError;
|
43
|
+
/* eslint-enable */
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.readTsConfigByFile = exports.readTsConfig = void 0;
|
7
|
+
const path_1 = __importDefault(require("path"));
|
8
|
+
const readTsConfig = (root) => {
|
9
|
+
// import typescript from 'typescript' cause eslint fromat error.
|
10
|
+
const typescript = require('typescript');
|
11
|
+
return typescript.readConfigFile(path_1.default.resolve(root, './tsconfig.json'), typescript.sys.readFile).config;
|
12
|
+
};
|
13
|
+
exports.readTsConfig = readTsConfig;
|
14
|
+
const readTsConfigByFile = (filename) => {
|
15
|
+
// import typescript from 'typescript' cause eslint fromat error.
|
16
|
+
const typescript = require('typescript');
|
17
|
+
return typescript.readConfigFile(path_1.default.resolve(filename), typescript.sys.readFile).config;
|
18
|
+
};
|
19
|
+
exports.readTsConfigByFile = readTsConfigByFile;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.removeSlash = exports.removeTailSlash = exports.removeLeadingSlash = void 0;
|
4
|
+
const removeLeadingSlash = (s) => s.replace(/^\/+/, '');
|
5
|
+
exports.removeLeadingSlash = removeLeadingSlash;
|
6
|
+
const removeTailSlash = (s) => s.replace(/\/+$/, '');
|
7
|
+
exports.removeTailSlash = removeTailSlash;
|
8
|
+
const removeSlash = (s) => (0, exports.removeLeadingSlash)((0, exports.removeTailSlash)(s));
|
9
|
+
exports.removeSlash = removeSlash;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.createRuntimeExportsUtils = void 0;
|
7
|
+
const path_1 = __importDefault(require("path"));
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
9
|
+
const path_2 = require("./path");
|
10
|
+
const memo = (fn) => {
|
11
|
+
const cache = new Map();
|
12
|
+
return (...params) => {
|
13
|
+
const stringifiedParams = JSON.stringify(params);
|
14
|
+
const cachedResult = cache.get(stringifiedParams);
|
15
|
+
if (cachedResult) {
|
16
|
+
return cachedResult;
|
17
|
+
}
|
18
|
+
const res = fn(...params);
|
19
|
+
cache.set(stringifiedParams, res);
|
20
|
+
return res;
|
21
|
+
};
|
22
|
+
};
|
23
|
+
exports.createRuntimeExportsUtils = memo((pwd = '', namespace, ts = false) => {
|
24
|
+
const entryExportFile = path_1.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.js` : 'index.js'}`);
|
25
|
+
const entryExportTsFile = path_1.default.join(pwd, `.runtime-exports/${namespace ? `${namespace}.d.ts` : 'index.d.ts'}`);
|
26
|
+
// const ensure = () => {
|
27
|
+
// if (!fs.existsSync(entryExportFile)) {
|
28
|
+
// fs.outputFileSync(entryExportFile, '');
|
29
|
+
// }
|
30
|
+
// fs.ensureFileSync(entryExportFile);
|
31
|
+
// };
|
32
|
+
const addExport = (statement) => {
|
33
|
+
// eslint-disable-next-line no-param-reassign
|
34
|
+
statement = (0, path_2.normalizeOutputPath)(statement);
|
35
|
+
try {
|
36
|
+
fs_extra_1.default.ensureFileSync(entryExportFile);
|
37
|
+
fs_extra_1.default.ensureFileSync(entryExportTsFile);
|
38
|
+
if (!fs_extra_1.default.readFileSync(entryExportFile, 'utf8').includes(statement)) {
|
39
|
+
fs_extra_1.default.appendFileSync(entryExportFile, `${statement}\n`);
|
40
|
+
ts &&
|
41
|
+
fs_extra_1.default.appendFileSync(entryExportTsFile, `${statement.replace('.js', '.d')}\n`);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
catch (_a) {
|
45
|
+
// FIXME:
|
46
|
+
}
|
47
|
+
};
|
48
|
+
const getPath = () => entryExportFile;
|
49
|
+
return {
|
50
|
+
addExport,
|
51
|
+
getPath,
|
52
|
+
};
|
53
|
+
});
|
@@ -1,2 +1,2 @@
|
|
1
1
|
declare const wait: (time?: number) => Promise<unknown>;
|
2
|
-
export { wait };
|
2
|
+
export { wait };
|
package/dist/src/wait.js
ADDED
@@ -1,8 +1,8 @@
|
|
1
1
|
export declare type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
|
2
2
|
export declare const WatchChangeType: Record<'ADD' | 'UNLINK' | 'CHANGE', WatchChangeTypeValueT>;
|
3
3
|
declare type RunTaskType = (option: {
|
4
|
-
|
5
|
-
|
4
|
+
changedFilePath: string;
|
5
|
+
changeType: WatchChangeTypeValueT;
|
6
6
|
}) => void | Promise<void>;
|
7
7
|
export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("chokidar").FSWatcher;
|
8
|
-
export {};
|
8
|
+
export {};
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
28
|
+
});
|
29
|
+
};
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
31
|
+
exports.watch = exports.WatchChangeType = void 0;
|
32
|
+
const path = __importStar(require("path"));
|
33
|
+
const import_1 = require("./import");
|
34
|
+
const chokidar = import_1.Import.lazy('chokidar', require);
|
35
|
+
exports.WatchChangeType = {
|
36
|
+
ADD: 'add',
|
37
|
+
UNLINK: 'unlink',
|
38
|
+
CHANGE: 'change',
|
39
|
+
};
|
40
|
+
const watch = (watchDir, runTask, ignored = []) => {
|
41
|
+
let ready = false;
|
42
|
+
const watcher = chokidar.watch(watchDir, {
|
43
|
+
ignored,
|
44
|
+
});
|
45
|
+
watcher.on('ready', () => (ready = true));
|
46
|
+
watcher.on('change', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
47
|
+
const changedFilePath = path.resolve(filePath);
|
48
|
+
yield runTask({ changedFilePath, changeType: exports.WatchChangeType.CHANGE });
|
49
|
+
}));
|
50
|
+
watcher.on('add', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
51
|
+
const changedFilePath = path.resolve(filePath);
|
52
|
+
if (ready) {
|
53
|
+
yield runTask({ changedFilePath, changeType: exports.WatchChangeType.ADD });
|
54
|
+
}
|
55
|
+
}));
|
56
|
+
watcher.on('unlink', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
57
|
+
const changedFilePath = path.resolve(filePath);
|
58
|
+
yield runTask({ changedFilePath, changeType: exports.WatchChangeType.UNLINK });
|
59
|
+
}));
|
60
|
+
watcher.on('error', err => {
|
61
|
+
throw err;
|
62
|
+
});
|
63
|
+
return watcher;
|
64
|
+
};
|
65
|
+
exports.watch = watch;
|
package/dist/wait.d.ts
ADDED
package/dist/wait.js
ADDED
package/dist/watch.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
export declare type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
|
2
|
+
export declare const WatchChangeType: Record<'ADD' | 'UNLINK' | 'CHANGE', WatchChangeTypeValueT>;
|
3
|
+
declare type RunTaskType = (option: {
|
4
|
+
changedFilePath: string;
|
5
|
+
changeType: WatchChangeTypeValueT;
|
6
|
+
}) => void | Promise<void>;
|
7
|
+
export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("./compiled").FSWatcher;
|
8
|
+
export {};
|
package/dist/watch.js
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
28
|
+
});
|
29
|
+
};
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
31
|
+
exports.watch = exports.WatchChangeType = void 0;
|
32
|
+
const path = __importStar(require("path"));
|
33
|
+
const compiled_1 = require("./compiled");
|
34
|
+
exports.WatchChangeType = {
|
35
|
+
ADD: 'add',
|
36
|
+
UNLINK: 'unlink',
|
37
|
+
CHANGE: 'change',
|
38
|
+
};
|
39
|
+
const watch = (watchDir, runTask, ignored = []) => {
|
40
|
+
let ready = false;
|
41
|
+
const watcher = compiled_1.chokidar.watch(watchDir, {
|
42
|
+
ignored,
|
43
|
+
});
|
44
|
+
watcher.on('ready', () => (ready = true));
|
45
|
+
watcher.on('change', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
46
|
+
const changedFilePath = path.resolve(filePath);
|
47
|
+
yield runTask({ changedFilePath, changeType: exports.WatchChangeType.CHANGE });
|
48
|
+
}));
|
49
|
+
watcher.on('add', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
50
|
+
const changedFilePath = path.resolve(filePath);
|
51
|
+
if (ready) {
|
52
|
+
yield runTask({ changedFilePath, changeType: exports.WatchChangeType.ADD });
|
53
|
+
}
|
54
|
+
}));
|
55
|
+
watcher.on('unlink', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
56
|
+
const changedFilePath = path.resolve(filePath);
|
57
|
+
yield runTask({ changedFilePath, changeType: exports.WatchChangeType.UNLINK });
|
58
|
+
}));
|
59
|
+
watcher.on('error', err => {
|
60
|
+
throw err;
|
61
|
+
});
|
62
|
+
return watcher;
|
63
|
+
};
|
64
|
+
exports.watch = watch;
|
package/jest.config.js
CHANGED
@@ -2,7 +2,6 @@ const sharedConfig = require('@scripts/jest-config');
|
|
2
2
|
|
3
3
|
/** @type {import('@jest/types').Config.InitialOptions} */
|
4
4
|
module.exports = {
|
5
|
-
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
6
5
|
...sharedConfig,
|
7
6
|
rootDir: __dirname,
|
8
7
|
modulePathIgnorePatterns: [
|