@modern-js/utils 1.5.0 → 1.7.1-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +28 -0
- package/compiled/address/index.js +1 -0
- package/compiled/address/lib/address.d.ts +28 -0
- package/compiled/address/package.json +1 -0
- package/compiled/browserslist/index.js +1 -1
- package/compiled/dotenv/index.js +1 -0
- package/compiled/dotenv/license +23 -0
- package/compiled/dotenv/package.json +1 -0
- package/compiled/dotenv/types/index.d.ts +59 -0
- package/compiled/dotenv-expand/index.d.ts +15 -0
- package/compiled/dotenv-expand/index.js +1 -0
- package/compiled/dotenv-expand/license +24 -0
- package/compiled/dotenv-expand/package.json +1 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/compiled/fast-glob/index.js +37 -0
- package/compiled/fast-glob/license +21 -0
- package/compiled/fast-glob/out/index.d.ts +27 -0
- package/compiled/fast-glob/out/managers/tasks.d.ts +22 -0
- package/compiled/fast-glob/out/settings.d.ts +164 -0
- package/compiled/fast-glob/out/types/index.d.ts +31 -0
- package/compiled/fast-glob/package.json +1 -0
- package/compiled/globby/index.d.ts +186 -0
- package/compiled/globby/index.js +1 -0
- package/compiled/globby/license +9 -0
- package/compiled/globby/package.json +1 -0
- package/compiled/inquirer/index.d.ts +997 -0
- package/compiled/inquirer/index.js +9 -0
- package/compiled/inquirer/lib/objects/choice.d.ts +65 -0
- package/compiled/inquirer/lib/objects/choices.d.ts +206 -0
- package/compiled/inquirer/lib/objects/separator.d.ts +37 -0
- package/compiled/inquirer/lib/ui/baseUI.d.ts +37 -0
- package/compiled/inquirer/lib/ui/bottom-bar.d.ts +65 -0
- package/compiled/inquirer/lib/ui/prompt.d.ts +104 -0
- package/compiled/inquirer/license +22 -0
- package/compiled/inquirer/package.json +1 -0
- package/compiled/inquirer/through/index.d.ts +25 -0
- package/compiled/json5/index.js +1 -0
- package/compiled/json5/lib/index.d.ts +4 -0
- package/compiled/json5/lib/parse.d.ts +15 -0
- package/compiled/json5/lib/stringify.d.ts +89 -0
- package/compiled/json5/package.json +1 -0
- package/compiled/lodash/index.js +4 -8
- package/compiled/mime-types/index.d.ts +14 -0
- package/compiled/mime-types/index.js +14 -0
- package/compiled/mime-types/license +23 -0
- package/compiled/mime-types/package.json +1 -0
- package/compiled/minimist/index.d.ts +95 -0
- package/compiled/minimist/index.js +1 -0
- package/compiled/minimist/license +18 -0
- package/compiled/minimist/package.json +1 -0
- package/compiled/ora/cli-spinners/index.d.ts +125 -0
- package/compiled/ora/index.d.ts +277 -0
- package/compiled/ora/index.js +3 -0
- package/compiled/ora/license +9 -0
- package/compiled/ora/package.json +1 -0
- package/compiled/semver/classes/comparator.d.ts +17 -0
- package/compiled/semver/classes/range.d.ts +21 -0
- package/compiled/semver/classes/semver.d.ts +62 -0
- package/compiled/semver/functions/clean.d.ts +8 -0
- package/compiled/semver/functions/cmp.d.ts +16 -0
- package/compiled/semver/functions/coerce.d.ts +12 -0
- package/compiled/semver/functions/compare-build.d.ts +16 -0
- package/compiled/semver/functions/compare-loose.d.ts +5 -0
- package/compiled/semver/functions/compare.d.ts +20 -0
- package/compiled/semver/functions/diff.d.ts +13 -0
- package/compiled/semver/functions/eq.d.ts +9 -0
- package/compiled/semver/functions/gt.d.ts +9 -0
- package/compiled/semver/functions/gte.d.ts +9 -0
- package/compiled/semver/functions/inc.d.ts +15 -0
- package/compiled/semver/functions/lt.d.ts +9 -0
- package/compiled/semver/functions/lte.d.ts +8 -0
- package/compiled/semver/functions/major.d.ts +9 -0
- package/compiled/semver/functions/minor.d.ts +9 -0
- package/compiled/semver/functions/neq.d.ts +9 -0
- package/compiled/semver/functions/parse.d.ts +12 -0
- package/compiled/semver/functions/patch.d.ts +9 -0
- package/compiled/semver/functions/prerelease.d.ts +12 -0
- package/compiled/semver/functions/rcompare.d.ts +15 -0
- package/compiled/semver/functions/rsort.d.ts +9 -0
- package/compiled/semver/functions/satisfies.d.ts +14 -0
- package/compiled/semver/functions/sort.d.ts +9 -0
- package/compiled/semver/functions/valid.d.ts +11 -0
- package/compiled/semver/index.d.ts +133 -0
- package/compiled/semver/index.js +1 -0
- package/compiled/semver/internals/identifiers.d.ts +13 -0
- package/compiled/semver/license +15 -0
- package/compiled/semver/package.json +1 -0
- package/compiled/semver/ranges/gtr.d.ts +14 -0
- package/compiled/semver/ranges/intersects.d.ts +13 -0
- package/compiled/semver/ranges/ltr.d.ts +14 -0
- package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
- package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
- package/compiled/semver/ranges/min-version.d.ts +10 -0
- package/compiled/semver/ranges/outside.d.ts +15 -0
- package/compiled/semver/ranges/simplify.d.ts +14 -0
- package/compiled/semver/ranges/subset.d.ts +13 -0
- package/compiled/semver/ranges/to-comparators.d.ts +9 -0
- package/compiled/semver/ranges/valid.d.ts +12 -0
- package/compiled/slash/index.d.ts +25 -0
- package/compiled/slash/index.js +1 -0
- package/compiled/slash/license +9 -0
- package/compiled/slash/package.json +1 -0
- package/compiled/url-join/index.d.ts +17 -0
- package/compiled/url-join/index.js +1 -0
- package/compiled/url-join/license +21 -0
- package/compiled/url-join/package.json +1 -0
- package/dist/alias.js +4 -1
- package/dist/analyzeProject.js +4 -17
- package/dist/compiled.d.ts +34 -17
- package/dist/compiled.js +59 -21
- package/dist/emptyDir.js +4 -13
- package/dist/ensureAbsolutePath.d.ts +1 -1
- package/dist/ensureAbsolutePath.js +1 -1
- package/dist/findExists.d.ts +1 -1
- package/dist/findExists.js +1 -1
- package/dist/format.js +11 -6
- package/dist/getEntryOptions.js +2 -1
- package/dist/getPackageManager.js +19 -30
- package/dist/getPort.js +3 -12
- package/dist/getServerConfig.js +2 -11
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/logger.d.ts +3 -0
- package/dist/logger.js +21 -6
- package/dist/monorepo.js +9 -6
- package/dist/nodeEnv.js +24 -39
- package/dist/prettyInstructions.js +1 -1
- package/dist/readTsConfig.js +2 -2
- package/dist/runtimeExports.js +1 -1
- package/dist/{ssrHelpers.d.ts → ssr.d.ts} +3 -0
- package/dist/{ssrHelpers.js → ssr.js} +0 -0
- package/dist/watch.js +9 -18
- package/package.json +33 -50
- package/tsconfig.json +1 -0
- package/dist/getCacheIdentifier.d.ts +0 -7
- package/dist/getCacheIdentifier.js +0 -24
- package/modern.config.js +0 -6
package/dist/compiled.d.ts
CHANGED
@@ -1,21 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
export {
|
1
|
+
export { default as fs } from '../compiled/fs-extra';
|
2
|
+
export { default as ora } from '../compiled/ora';
|
3
|
+
export { default as glob } from '../compiled/glob';
|
4
|
+
export { default as yaml } from '../compiled/js-yaml';
|
5
|
+
export { default as chalk } from '../compiled/chalk';
|
6
|
+
export { default as debug } from '../compiled/debug';
|
7
|
+
export { default as slash } from '../compiled/slash';
|
8
|
+
export { default as execa } from '../compiled/execa';
|
9
|
+
export { default as json5 } from '../compiled/json5';
|
10
|
+
export { default as upath } from '../compiled/upath';
|
11
|
+
export { default as pkgUp } from '../compiled/pkg-up';
|
12
|
+
export { default as semver } from '../compiled/semver';
|
13
|
+
export { default as dotenv } from '../compiled/dotenv';
|
14
|
+
export { default as lodash } from '../compiled/lodash';
|
15
|
+
export { default as globby } from '../compiled/globby';
|
16
|
+
export { default as address } from '../compiled/address';
|
17
|
+
export { default as signale } from '../compiled/signale';
|
18
|
+
export { default as urlJoin } from '../compiled/url-join';
|
19
|
+
export { default as minimist } from '../compiled/minimist';
|
20
|
+
export { default as fastGlob } from '../compiled/fast-glob';
|
21
|
+
export { default as filesize } from '../compiled/filesize';
|
22
|
+
export { default as gzipSize } from '../compiled/gzip-size';
|
23
|
+
export { default as stripAnsi } from '../compiled/strip-ansi';
|
24
|
+
export { default as dotenvExpand } from '../compiled/dotenv-expand';
|
25
|
+
export { default as browserslist } from '../compiled/browserslist';
|
26
|
+
export { default as recursiveReaddir } from '../compiled/recursive-readdir';
|
6
27
|
export { program, Command } from '../compiled/commander';
|
7
|
-
export { Signale, SignaleOptions } from '../compiled/signale';
|
28
|
+
export { Signale, type SignaleOptions } from '../compiled/signale';
|
8
29
|
export type { IOptions as GlobOptions } from '../compiled/glob';
|
30
|
+
export type { GlobbyOptions } from '../compiled/globby';
|
9
31
|
export type { FSWatcher, WatchOptions } from '../compiled/chokidar';
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
export declare const
|
15
|
-
export declare const debug: typeof import('../compiled/debug');
|
32
|
+
/**
|
33
|
+
* Lazy import some expensive modules that will slow down startup speed.
|
34
|
+
* Notice that `csmith-tools build` can not bundle lazy imported modules.
|
35
|
+
*/
|
36
|
+
export declare const mime: typeof import('../compiled/mime-types');
|
16
37
|
export declare const chokidar: typeof import('../compiled/chokidar');
|
17
|
-
export declare const
|
18
|
-
export declare const filesize: typeof import('../compiled/filesize');
|
19
|
-
export declare const stripAnsi: typeof import('../compiled/strip-ansi');
|
20
|
-
export declare const browserslist: typeof import('../compiled/browserslist');
|
21
|
-
export declare const recursiveReaddir: typeof import('../compiled/recursive-readdir');
|
38
|
+
export declare const inquirer: typeof import('../compiled/inquirer');
|
package/dist/compiled.js
CHANGED
@@ -3,31 +3,69 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.recursiveReaddir = exports.browserslist = exports.stripAnsi = exports.filesize = exports.
|
7
|
-
const fs_extra_1 = __importDefault(require("../compiled/fs-extra"));
|
8
|
-
exports.fs = fs_extra_1.default;
|
9
|
-
const chalk_1 = __importDefault(require("../compiled/chalk"));
|
10
|
-
exports.chalk = chalk_1.default;
|
11
|
-
const lodash_1 = __importDefault(require("../compiled/lodash"));
|
12
|
-
exports.lodash = lodash_1.default;
|
13
|
-
const signale_1 = __importDefault(require("../compiled/signale"));
|
14
|
-
exports.signale = signale_1.default;
|
6
|
+
exports.inquirer = exports.chokidar = exports.mime = exports.Signale = exports.Command = exports.program = exports.recursiveReaddir = exports.browserslist = exports.dotenvExpand = exports.stripAnsi = exports.gzipSize = exports.filesize = exports.fastGlob = exports.minimist = exports.urlJoin = exports.signale = exports.address = exports.globby = exports.lodash = exports.dotenv = exports.semver = exports.pkgUp = exports.upath = exports.json5 = exports.execa = exports.slash = exports.debug = exports.chalk = exports.yaml = exports.glob = exports.ora = exports.fs = void 0;
|
15
7
|
const import_1 = require("./import");
|
8
|
+
var fs_extra_1 = require("../compiled/fs-extra");
|
9
|
+
Object.defineProperty(exports, "fs", { enumerable: true, get: function () { return __importDefault(fs_extra_1).default; } });
|
10
|
+
var ora_1 = require("../compiled/ora");
|
11
|
+
Object.defineProperty(exports, "ora", { enumerable: true, get: function () { return __importDefault(ora_1).default; } });
|
12
|
+
var glob_1 = require("../compiled/glob");
|
13
|
+
Object.defineProperty(exports, "glob", { enumerable: true, get: function () { return __importDefault(glob_1).default; } });
|
14
|
+
var js_yaml_1 = require("../compiled/js-yaml");
|
15
|
+
Object.defineProperty(exports, "yaml", { enumerable: true, get: function () { return __importDefault(js_yaml_1).default; } });
|
16
|
+
var chalk_1 = require("../compiled/chalk");
|
17
|
+
Object.defineProperty(exports, "chalk", { enumerable: true, get: function () { return __importDefault(chalk_1).default; } });
|
18
|
+
var debug_1 = require("../compiled/debug");
|
19
|
+
Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return __importDefault(debug_1).default; } });
|
20
|
+
var slash_1 = require("../compiled/slash");
|
21
|
+
Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return __importDefault(slash_1).default; } });
|
22
|
+
var execa_1 = require("../compiled/execa");
|
23
|
+
Object.defineProperty(exports, "execa", { enumerable: true, get: function () { return __importDefault(execa_1).default; } });
|
24
|
+
var json5_1 = require("../compiled/json5");
|
25
|
+
Object.defineProperty(exports, "json5", { enumerable: true, get: function () { return __importDefault(json5_1).default; } });
|
26
|
+
var upath_1 = require("../compiled/upath");
|
27
|
+
Object.defineProperty(exports, "upath", { enumerable: true, get: function () { return __importDefault(upath_1).default; } });
|
28
|
+
var pkg_up_1 = require("../compiled/pkg-up");
|
29
|
+
Object.defineProperty(exports, "pkgUp", { enumerable: true, get: function () { return __importDefault(pkg_up_1).default; } });
|
30
|
+
var semver_1 = require("../compiled/semver");
|
31
|
+
Object.defineProperty(exports, "semver", { enumerable: true, get: function () { return __importDefault(semver_1).default; } });
|
32
|
+
var dotenv_1 = require("../compiled/dotenv");
|
33
|
+
Object.defineProperty(exports, "dotenv", { enumerable: true, get: function () { return __importDefault(dotenv_1).default; } });
|
34
|
+
var lodash_1 = require("../compiled/lodash");
|
35
|
+
Object.defineProperty(exports, "lodash", { enumerable: true, get: function () { return __importDefault(lodash_1).default; } });
|
36
|
+
var globby_1 = require("../compiled/globby");
|
37
|
+
Object.defineProperty(exports, "globby", { enumerable: true, get: function () { return __importDefault(globby_1).default; } });
|
38
|
+
var address_1 = require("../compiled/address");
|
39
|
+
Object.defineProperty(exports, "address", { enumerable: true, get: function () { return __importDefault(address_1).default; } });
|
40
|
+
var signale_1 = require("../compiled/signale");
|
41
|
+
Object.defineProperty(exports, "signale", { enumerable: true, get: function () { return __importDefault(signale_1).default; } });
|
42
|
+
var url_join_1 = require("../compiled/url-join");
|
43
|
+
Object.defineProperty(exports, "urlJoin", { enumerable: true, get: function () { return __importDefault(url_join_1).default; } });
|
44
|
+
var minimist_1 = require("../compiled/minimist");
|
45
|
+
Object.defineProperty(exports, "minimist", { enumerable: true, get: function () { return __importDefault(minimist_1).default; } });
|
46
|
+
var fast_glob_1 = require("../compiled/fast-glob");
|
47
|
+
Object.defineProperty(exports, "fastGlob", { enumerable: true, get: function () { return __importDefault(fast_glob_1).default; } });
|
48
|
+
var filesize_1 = require("../compiled/filesize");
|
49
|
+
Object.defineProperty(exports, "filesize", { enumerable: true, get: function () { return __importDefault(filesize_1).default; } });
|
50
|
+
var gzip_size_1 = require("../compiled/gzip-size");
|
51
|
+
Object.defineProperty(exports, "gzipSize", { enumerable: true, get: function () { return __importDefault(gzip_size_1).default; } });
|
52
|
+
var strip_ansi_1 = require("../compiled/strip-ansi");
|
53
|
+
Object.defineProperty(exports, "stripAnsi", { enumerable: true, get: function () { return __importDefault(strip_ansi_1).default; } });
|
54
|
+
var dotenv_expand_1 = require("../compiled/dotenv-expand");
|
55
|
+
Object.defineProperty(exports, "dotenvExpand", { enumerable: true, get: function () { return __importDefault(dotenv_expand_1).default; } });
|
56
|
+
var browserslist_1 = require("../compiled/browserslist");
|
57
|
+
Object.defineProperty(exports, "browserslist", { enumerable: true, get: function () { return __importDefault(browserslist_1).default; } });
|
58
|
+
var recursive_readdir_1 = require("../compiled/recursive-readdir");
|
59
|
+
Object.defineProperty(exports, "recursiveReaddir", { enumerable: true, get: function () { return __importDefault(recursive_readdir_1).default; } });
|
16
60
|
var commander_1 = require("../compiled/commander");
|
17
61
|
Object.defineProperty(exports, "program", { enumerable: true, get: function () { return commander_1.program; } });
|
18
62
|
Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return commander_1.Command; } });
|
19
63
|
var signale_2 = require("../compiled/signale");
|
20
64
|
Object.defineProperty(exports, "Signale", { enumerable: true, get: function () { return signale_2.Signale; } });
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
exports.
|
26
|
-
exports.upath = import_1.Import.lazy('../compiled/upath', require);
|
27
|
-
exports.debug = import_1.Import.lazy('../compiled/debug', require);
|
65
|
+
/**
|
66
|
+
* Lazy import some expensive modules that will slow down startup speed.
|
67
|
+
* Notice that `csmith-tools build` can not bundle lazy imported modules.
|
68
|
+
*/
|
69
|
+
exports.mime = import_1.Import.lazy('../compiled/mime-types', require);
|
28
70
|
exports.chokidar = import_1.Import.lazy('../compiled/chokidar', require);
|
29
|
-
exports.
|
30
|
-
exports.filesize = import_1.Import.lazy('../compiled/filesize', require);
|
31
|
-
exports.stripAnsi = import_1.Import.lazy('../compiled/strip-ansi', require);
|
32
|
-
exports.browserslist = import_1.Import.lazy('../compiled/browserslist', require);
|
33
|
-
exports.recursiveReaddir = import_1.Import.lazy('../compiled/recursive-readdir', require);
|
71
|
+
exports.inquirer = import_1.Import.lazy('../compiled/inquirer', require);
|
package/dist/emptyDir.js
CHANGED
@@ -1,19 +1,10 @@
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
3
|
exports.emptyDir = void 0;
|
13
4
|
const compiled_1 = require("./compiled");
|
14
|
-
const emptyDir = (dir) =>
|
15
|
-
if (
|
16
|
-
|
5
|
+
const emptyDir = async (dir) => {
|
6
|
+
if (await compiled_1.fs.pathExists(dir)) {
|
7
|
+
await compiled_1.fs.emptyDir(dir);
|
17
8
|
}
|
18
|
-
}
|
9
|
+
};
|
19
10
|
exports.emptyDir = emptyDir;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* ensure absolute file path.
|
3
3
|
* @param base - Base path to resolve relative from.
|
4
|
-
* @param filePath -
|
4
|
+
* @param filePath - Absolute or relative file path.
|
5
5
|
* @returns Resolved absolute file path.
|
6
6
|
*/
|
7
7
|
export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
|
@@ -8,7 +8,7 @@ const path_1 = __importDefault(require("path"));
|
|
8
8
|
/**
|
9
9
|
* ensure absolute file path.
|
10
10
|
* @param base - Base path to resolve relative from.
|
11
|
-
* @param filePath -
|
11
|
+
* @param filePath - Absolute or relative file path.
|
12
12
|
* @returns Resolved absolute file path.
|
13
13
|
*/
|
14
14
|
const ensureAbsolutePath = (base, filePath) => path_1.default.isAbsolute(filePath) ? filePath : path_1.default.resolve(base, filePath);
|
package/dist/findExists.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* Find first already exists file.
|
3
|
-
* @param files -
|
3
|
+
* @param files - Absolute file paths with extension.
|
4
4
|
* @returns The file path if exists, or false if no file exists.
|
5
5
|
*/
|
6
6
|
export declare const findExists: (files: string[]) => string | false;
|
package/dist/findExists.js
CHANGED
@@ -7,7 +7,7 @@ exports.findExists = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
8
8
|
/**
|
9
9
|
* Find first already exists file.
|
10
|
-
* @param files -
|
10
|
+
* @param files - Absolute file paths with extension.
|
11
11
|
* @returns The file path if exists, or false if no file exists.
|
12
12
|
*/
|
13
13
|
const findExists = (files) => {
|
package/dist/format.js
CHANGED
@@ -92,22 +92,27 @@ function formatWebpackMessages(json) {
|
|
92
92
|
exports.formatWebpackMessages = formatWebpackMessages;
|
93
93
|
/* eslint-enable no-param-reassign */
|
94
94
|
function formatProxyOptions(proxyOptions) {
|
95
|
-
const
|
95
|
+
const formattedProxy = [];
|
96
96
|
if (!Array.isArray(proxyOptions)) {
|
97
97
|
if ('target' in proxyOptions) {
|
98
|
-
|
98
|
+
formattedProxy.push(proxyOptions);
|
99
99
|
}
|
100
100
|
else {
|
101
|
-
Array.prototype.push.apply(
|
101
|
+
Array.prototype.push.apply(formattedProxy, Object.keys(proxyOptions).reduce((total, source) => {
|
102
102
|
const option = proxyOptions[source];
|
103
|
-
total.push(
|
103
|
+
total.push({
|
104
|
+
context: source,
|
105
|
+
changeOrigin: true,
|
106
|
+
logLevel: 'warn',
|
107
|
+
...(typeof option === 'string' ? { target: option } : option),
|
108
|
+
});
|
104
109
|
return total;
|
105
110
|
}, []));
|
106
111
|
}
|
107
112
|
}
|
108
113
|
else {
|
109
|
-
|
114
|
+
formattedProxy.push(...proxyOptions);
|
110
115
|
}
|
111
|
-
return
|
116
|
+
return formattedProxy;
|
112
117
|
}
|
113
118
|
exports.formatProxyOptions = formatProxyOptions;
|
package/dist/getEntryOptions.js
CHANGED
@@ -15,7 +15,8 @@ const getEntryOptions = (name, baseOptions, optionsByEntries, packageName) => {
|
|
15
15
|
// eslint-disable-next-line no-nested-ternary
|
16
16
|
return optionsByEntry !== undefined
|
17
17
|
? (0, is_1.isPlainObject)(optionsByEntry) && (0, is_1.isPlainObject)(baseOptions)
|
18
|
-
?
|
18
|
+
? { ...baseOptions, ...optionsByEntry }
|
19
|
+
: optionsByEntry
|
19
20
|
: baseOptions;
|
20
21
|
}
|
21
22
|
else {
|
@@ -1,13 +1,4 @@
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
4
|
};
|
@@ -18,30 +9,28 @@ const path_1 = __importDefault(require("path"));
|
|
18
9
|
const compiled_1 = require("./compiled");
|
19
10
|
const nodeEnv_1 = require("./nodeEnv");
|
20
11
|
const MAX_TIMES = 5;
|
21
|
-
function getPackageManager(cwd = process.cwd()) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'pnpm-lock.yaml'))) {
|
28
|
-
return 'pnpm';
|
29
|
-
}
|
30
|
-
if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'yarn.lock'))) {
|
31
|
-
return 'yarn';
|
32
|
-
}
|
33
|
-
if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'package-lock.json'))) {
|
34
|
-
return 'npm';
|
35
|
-
}
|
36
|
-
appDirectory = path_1.default.join(appDirectory, '..');
|
37
|
-
}
|
38
|
-
if (yield (0, nodeEnv_1.canUsePnpm)()) {
|
12
|
+
async function getPackageManager(cwd = process.cwd()) {
|
13
|
+
let appDirectory = cwd;
|
14
|
+
let times = 0;
|
15
|
+
while (os_1.default.homedir() !== appDirectory && times < MAX_TIMES) {
|
16
|
+
times++;
|
17
|
+
if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'pnpm-lock.yaml'))) {
|
39
18
|
return 'pnpm';
|
40
19
|
}
|
41
|
-
if (
|
20
|
+
if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'yarn.lock'))) {
|
42
21
|
return 'yarn';
|
43
22
|
}
|
44
|
-
|
45
|
-
|
23
|
+
if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'package-lock.json'))) {
|
24
|
+
return 'npm';
|
25
|
+
}
|
26
|
+
appDirectory = path_1.default.join(appDirectory, '..');
|
27
|
+
}
|
28
|
+
if (await (0, nodeEnv_1.canUsePnpm)()) {
|
29
|
+
return 'pnpm';
|
30
|
+
}
|
31
|
+
if (await (0, nodeEnv_1.canUseYarn)()) {
|
32
|
+
return 'yarn';
|
33
|
+
}
|
34
|
+
return 'npm';
|
46
35
|
}
|
47
36
|
exports.getPackageManager = getPackageManager;
|
package/dist/getPort.js
CHANGED
@@ -1,13 +1,4 @@
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
4
|
};
|
@@ -23,7 +14,7 @@ const logger_1 = require("./logger");
|
|
23
14
|
* @returns Available port number.
|
24
15
|
*/
|
25
16
|
/* eslint-disable no-param-reassign, @typescript-eslint/no-loop-func */
|
26
|
-
const getPort = (port, tryLimits = 20) =>
|
17
|
+
const getPort = async (port, tryLimits = 20) => {
|
27
18
|
if (typeof port === 'string') {
|
28
19
|
port = parseInt(port, 10);
|
29
20
|
}
|
@@ -32,7 +23,7 @@ const getPort = (port, tryLimits = 20) => __awaiter(void 0, void 0, void 0, func
|
|
32
23
|
let attempts = 0;
|
33
24
|
while (!found && attempts <= tryLimits) {
|
34
25
|
try {
|
35
|
-
|
26
|
+
await new Promise((resolve, reject) => {
|
36
27
|
const server = net_1.default.createServer();
|
37
28
|
server.unref();
|
38
29
|
server.on('error', reject);
|
@@ -57,6 +48,6 @@ const getPort = (port, tryLimits = 20) => __awaiter(void 0, void 0, void 0, func
|
|
57
48
|
logger_1.logger.info(compiled_1.chalk.red(`Something is already running on port ${original}. ${compiled_1.chalk.yellow(`Use port ${port} instead.`)}`));
|
58
49
|
}
|
59
50
|
return port;
|
60
|
-
}
|
51
|
+
};
|
61
52
|
exports.getPort = getPort;
|
62
53
|
/* eslint-enable no-param-reassign, @typescript-eslint/no-loop-func */
|
package/dist/getServerConfig.js
CHANGED
@@ -18,22 +18,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
18
|
__setModuleDefault(result, mod);
|
19
19
|
return result;
|
20
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
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
31
22
|
exports.getServerConfig = void 0;
|
32
23
|
const path = __importStar(require("path"));
|
33
24
|
const constants_1 = require("./constants");
|
34
25
|
const findExists_1 = require("./findExists");
|
35
|
-
const getServerConfig = (appDirectory, configFile) =>
|
26
|
+
const getServerConfig = async (appDirectory, configFile) => {
|
36
27
|
const configFilePath = (0, findExists_1.findExists)(constants_1.CONFIG_FILE_EXTENSIONS.map(extension => path.resolve(appDirectory, `${configFile}${extension}`)));
|
37
28
|
return configFilePath;
|
38
|
-
}
|
29
|
+
};
|
39
30
|
exports.getServerConfig = getServerConfig;
|
package/dist/index.d.ts
CHANGED
@@ -9,7 +9,6 @@ export * from './compatRequire';
|
|
9
9
|
export * from './logger';
|
10
10
|
export * from './constants';
|
11
11
|
export * from './ensureAbsolutePath';
|
12
|
-
export * from './getCacheIdentifier';
|
13
12
|
export * from './clearConsole';
|
14
13
|
export * from './applyOptionsChain';
|
15
14
|
export * from './getBrowserslist';
|
@@ -30,5 +29,5 @@ export * from './nodeEnv';
|
|
30
29
|
export * from './wait';
|
31
30
|
export * from './emptyDir';
|
32
31
|
export * from './getServerConfig';
|
33
|
-
export * from './
|
32
|
+
export * from './ssr';
|
34
33
|
export * from './analyzeProject';
|
package/dist/index.js
CHANGED
@@ -21,7 +21,6 @@ __exportStar(require("./compatRequire"), exports);
|
|
21
21
|
__exportStar(require("./logger"), exports);
|
22
22
|
__exportStar(require("./constants"), exports);
|
23
23
|
__exportStar(require("./ensureAbsolutePath"), exports);
|
24
|
-
__exportStar(require("./getCacheIdentifier"), exports);
|
25
24
|
__exportStar(require("./clearConsole"), exports);
|
26
25
|
__exportStar(require("./applyOptionsChain"), exports);
|
27
26
|
__exportStar(require("./getBrowserslist"), exports);
|
@@ -42,5 +41,5 @@ __exportStar(require("./nodeEnv"), exports);
|
|
42
41
|
__exportStar(require("./wait"), exports);
|
43
42
|
__exportStar(require("./emptyDir"), exports);
|
44
43
|
__exportStar(require("./getServerConfig"), exports);
|
45
|
-
__exportStar(require("./
|
44
|
+
__exportStar(require("./ssr"), exports);
|
46
45
|
__exportStar(require("./analyzeProject"), exports);
|
package/dist/logger.d.ts
CHANGED
@@ -12,6 +12,7 @@ interface InstanceConfiguration {
|
|
12
12
|
}
|
13
13
|
interface ConstructorOptions {
|
14
14
|
config?: InstanceConfiguration;
|
15
|
+
level?: string;
|
15
16
|
types?: Record<string, LoggerConfiguration>;
|
16
17
|
}
|
17
18
|
declare type LoggerFunction = (message?: number | string | Error, ...args: any[]) => void;
|
@@ -42,6 +43,7 @@ declare const LOG_TYPES: {
|
|
42
43
|
};
|
43
44
|
declare class Logger {
|
44
45
|
private readonly logCount;
|
46
|
+
private readonly level;
|
45
47
|
private history;
|
46
48
|
private readonly config;
|
47
49
|
private readonly types;
|
@@ -59,5 +61,6 @@ declare type LoggerInterface = {
|
|
59
61
|
[key in keyof typeof LOG_TYPES]: LoggerFunction;
|
60
62
|
};
|
61
63
|
declare const logger: Logger & LoggerInterface;
|
64
|
+
export { Logger };
|
62
65
|
export { logger };
|
63
66
|
export type { LoggerInterface };
|
package/dist/logger.js
CHANGED
@@ -3,9 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.logger = void 0;
|
6
|
+
exports.logger = exports.Logger = void 0;
|
7
7
|
const chalk_1 = __importDefault(require("../compiled/chalk"));
|
8
8
|
const { grey, underline } = chalk_1.default;
|
9
|
+
const LOG_LEVEL = {
|
10
|
+
error: 0,
|
11
|
+
warn: 1,
|
12
|
+
info: 2,
|
13
|
+
debug: 3,
|
14
|
+
log: 4,
|
15
|
+
};
|
9
16
|
const LOG_TYPES = {
|
10
17
|
error: {
|
11
18
|
color: 'red',
|
@@ -27,7 +34,7 @@ const LOG_TYPES = {
|
|
27
34
|
label: 'debug',
|
28
35
|
level: 'debug',
|
29
36
|
},
|
30
|
-
log: { level: '
|
37
|
+
log: { level: 'log' },
|
31
38
|
};
|
32
39
|
const DEFAULT_CONFIG = {
|
33
40
|
displayLabel: true,
|
@@ -38,8 +45,12 @@ class Logger {
|
|
38
45
|
constructor(options = {}) {
|
39
46
|
this.logCount = 200;
|
40
47
|
this.history = {};
|
41
|
-
this.
|
42
|
-
this.
|
48
|
+
this.level = options.level || LOG_TYPES.log.level;
|
49
|
+
this.config = { ...DEFAULT_CONFIG, ...(options.config || {}) };
|
50
|
+
this.types = {
|
51
|
+
...LOG_TYPES,
|
52
|
+
...(options.types || {}),
|
53
|
+
};
|
43
54
|
this.longestLabel = this.getLongestLabel();
|
44
55
|
Object.keys(this.types).forEach(type => {
|
45
56
|
this[type] = this._log.bind(this, type);
|
@@ -54,12 +65,15 @@ class Logger {
|
|
54
65
|
this.history[type].shift();
|
55
66
|
}
|
56
67
|
}
|
57
|
-
_log(type, message) {
|
68
|
+
_log(type, message, ...args) {
|
58
69
|
if (message === undefined) {
|
59
70
|
// eslint-disable-next-line no-console
|
60
71
|
console.log();
|
61
72
|
return;
|
62
73
|
}
|
74
|
+
if (LOG_LEVEL[type] > LOG_LEVEL[this.level]) {
|
75
|
+
return;
|
76
|
+
}
|
63
77
|
let label = '';
|
64
78
|
let text = '';
|
65
79
|
const logType = this.types[type];
|
@@ -94,7 +108,7 @@ class Logger {
|
|
94
108
|
}
|
95
109
|
const log = label.length > 0 ? `${label} ${text}` : text;
|
96
110
|
// eslint-disable-next-line no-console
|
97
|
-
console.log(log);
|
111
|
+
console.log(log, ...args);
|
98
112
|
}
|
99
113
|
getLongestLabel() {
|
100
114
|
let longestLabel = '';
|
@@ -123,6 +137,7 @@ class Logger {
|
|
123
137
|
}
|
124
138
|
}
|
125
139
|
}
|
140
|
+
exports.Logger = Logger;
|
126
141
|
const logger = new Logger();
|
127
142
|
exports.logger = logger;
|
128
143
|
logger.Logger = Logger;
|
package/dist/monorepo.js
CHANGED
@@ -8,16 +8,16 @@ const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
9
9
|
const compiled_1 = require("./compiled");
|
10
10
|
const PACKAGE_MAX_DEPTH = 5;
|
11
|
-
const
|
11
|
+
const WORKSPACES_FILES = {
|
12
12
|
YARN: 'package.json',
|
13
13
|
PNPM: 'pnpm-workspaces.yaml',
|
14
14
|
LERNA: 'lerna.json',
|
15
15
|
};
|
16
|
-
const isLerna = (root) => fs_1.default.existsSync(path_1.default.join(root,
|
16
|
+
const isLerna = (root) => fs_1.default.existsSync(path_1.default.join(root, WORKSPACES_FILES.LERNA));
|
17
17
|
exports.isLerna = isLerna;
|
18
18
|
const isYarnWorkspaces = (root) => {
|
19
19
|
var _a;
|
20
|
-
const pkg = path_1.default.join(root,
|
20
|
+
const pkg = path_1.default.join(root, WORKSPACES_FILES.YARN);
|
21
21
|
if (!fs_1.default.existsSync(pkg)) {
|
22
22
|
return false;
|
23
23
|
}
|
@@ -25,13 +25,16 @@ const isYarnWorkspaces = (root) => {
|
|
25
25
|
return Boolean((_a = json.workspaces) === null || _a === void 0 ? void 0 : _a.packages);
|
26
26
|
};
|
27
27
|
exports.isYarnWorkspaces = isYarnWorkspaces;
|
28
|
-
const isPnpmWorkspaces = (root) => fs_1.default.existsSync(path_1.default.join(root,
|
28
|
+
const isPnpmWorkspaces = (root) => fs_1.default.existsSync(path_1.default.join(root, WORKSPACES_FILES.PNPM));
|
29
29
|
exports.isPnpmWorkspaces = isPnpmWorkspaces;
|
30
30
|
const isMonorepo = (root) => (0, exports.isLerna)(root) || (0, exports.isYarnWorkspaces)(root) || (0, exports.isPnpmWorkspaces)(root);
|
31
31
|
exports.isMonorepo = isMonorepo;
|
32
32
|
const isModernjsMonorepo = (root) => {
|
33
33
|
const json = JSON.parse(fs_1.default.readFileSync(path_1.default.join(root, 'package.json'), 'utf8'));
|
34
|
-
const deps =
|
34
|
+
const deps = {
|
35
|
+
...(json.dependencies || {}),
|
36
|
+
...(json.devDependencies || {}),
|
37
|
+
};
|
35
38
|
return Boolean(deps['@modern-js/monorepo-tools']);
|
36
39
|
};
|
37
40
|
exports.isModernjsMonorepo = isModernjsMonorepo;
|
@@ -59,7 +62,7 @@ const getMonorepoPackages = (root) => {
|
|
59
62
|
({ packages } = json);
|
60
63
|
}
|
61
64
|
else {
|
62
|
-
({ packages } = compiled_1.yaml.load(fs_1.default.readFileSync(path_1.default.join(root,
|
65
|
+
({ packages } = compiled_1.yaml.load(fs_1.default.readFileSync(path_1.default.join(root, WORKSPACES_FILES.PNPM), 'utf8')));
|
63
66
|
}
|
64
67
|
if (packages) {
|
65
68
|
return packages
|
package/dist/nodeEnv.js
CHANGED
@@ -1,49 +1,34 @@
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
3
|
exports.canUsePnpm = exports.canUseYarn = exports.canUseNpm = void 0;
|
13
4
|
const compiled_1 = require("./compiled");
|
14
|
-
function canUseNpm() {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
23
|
-
});
|
5
|
+
async function canUseNpm() {
|
6
|
+
try {
|
7
|
+
await (0, compiled_1.execa)('npm', ['--version'], { env: process.env });
|
8
|
+
return true;
|
9
|
+
}
|
10
|
+
catch (e) {
|
11
|
+
return false;
|
12
|
+
}
|
24
13
|
}
|
25
14
|
exports.canUseNpm = canUseNpm;
|
26
|
-
function canUseYarn() {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
35
|
-
});
|
15
|
+
async function canUseYarn() {
|
16
|
+
try {
|
17
|
+
await (0, compiled_1.execa)('yarn', ['--version'], { env: process.env });
|
18
|
+
return true;
|
19
|
+
}
|
20
|
+
catch (e) {
|
21
|
+
return false;
|
22
|
+
}
|
36
23
|
}
|
37
24
|
exports.canUseYarn = canUseYarn;
|
38
|
-
function canUsePnpm() {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
}
|
47
|
-
});
|
25
|
+
async function canUsePnpm() {
|
26
|
+
try {
|
27
|
+
await (0, compiled_1.execa)('pnpm', ['--version'], { env: process.env });
|
28
|
+
return true;
|
29
|
+
}
|
30
|
+
catch (e) {
|
31
|
+
return false;
|
32
|
+
}
|
48
33
|
}
|
49
34
|
exports.canUsePnpm = canUsePnpm;
|