@modern-js/utils 1.3.8-canary.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -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/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/compiled/globby/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/compiled/globby/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/compiled/globby/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/compiled/globby/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/compiled/globby/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/compiled/globby/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/compiled/globby/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/compiled/globby/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/compiled/globby/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/compiled/globby/fast-glob/index.d.ts +27 -0
- package/compiled/globby/fast-glob/managers/tasks.d.ts +22 -0
- package/compiled/globby/fast-glob/settings.d.ts +164 -0
- package/compiled/globby/fast-glob/types/index.d.ts +31 -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/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/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/analyzeProject.d.ts +1 -0
- package/dist/analyzeProject.js +40 -0
- package/dist/compiled.d.ts +33 -17
- package/dist/compiled.js +57 -21
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/prettyInstructions.js +3 -3
- package/dist/{ssrHelpers.d.ts → ssr.d.ts} +3 -0
- package/dist/{ssrHelpers.js → ssr.js} +0 -0
- package/dist/storage.js +1 -1
- package/package.json +12 -30
- package/dist/getCacheIdentifier.d.ts +0 -7
- package/dist/getCacheIdentifier.js +0 -24
- package/dist/js/modern/monorepo.js +0 -83
- package/dist/js/node/monorepo.js +0 -116
- package/dist/js/treeshaking/monorepo.js +0 -96
- package/dist/pkgUp.d.ts +0 -2
- package/dist/pkgUp.js +0 -8
- package/dist/types/FileSizeReporter.d.ts +0 -16
- package/dist/types/alias.d.ts +0 -21
- package/dist/types/applyOptionsChain.d.ts +0 -6
- package/dist/types/clearConsole.d.ts +0 -1
- package/dist/types/compatRequire.d.ts +0 -8
- package/dist/types/compiled.d.ts +0 -17
- package/dist/types/constants.d.ts +0 -222
- package/dist/types/debug.d.ts +0 -6
- package/dist/types/emptyDir.d.ts +0 -1
- package/dist/types/ensureAbsolutePath.d.ts +0 -7
- package/dist/types/findExists.d.ts +0 -6
- package/dist/types/format.d.ts +0 -16
- package/dist/types/generateMetaTags.d.ts +0 -16
- package/dist/types/getBrowserslist.d.ts +0 -2
- package/dist/types/getCacheIdentifier.d.ts +0 -7
- package/dist/types/getEntryOptions.d.ts +0 -1
- package/dist/types/getPackageManager.d.ts +0 -1
- package/dist/types/getPort.d.ts +0 -7
- package/dist/types/getServerConfig.d.ts +0 -1
- package/dist/types/import.d.ts +0 -5
- package/dist/types/index.d.ts +0 -32
- package/dist/types/is/index.d.ts +0 -34
- package/dist/types/is/node-env.d.ts +0 -4
- 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
- package/dist/types/monorepo.d.ts +0 -11
- package/dist/types/nodeEnv.d.ts +0 -3
- package/dist/types/path.d.ts +0 -3
- package/dist/types/prettyInstructions.d.ts +0 -6
- package/dist/types/printBuildError.d.ts +0 -8
- package/dist/types/readTsConfig.d.ts +0 -2
- package/dist/types/removeSlash.d.ts +0 -3
- package/dist/types/runtimeExports.d.ts +0 -4
- package/dist/types/wait.d.ts +0 -2
- package/dist/types/watch.d.ts +0 -8
- package/modern.config.js +0 -6
- package/tests/.eslintrc.js +0 -6
- package/tests/__snapshots__/prettyInstructions.test.ts.snap +0 -19
- package/tests/applyOptionsChain.test.ts +0 -100
- package/tests/compatRequire.test.ts +0 -32
- package/tests/debug.test.ts +0 -25
- package/tests/ensureAbsolutePath.test.ts +0 -16
- package/tests/findExists.test.ts +0 -22
- package/tests/fixtures/browserlist/develop/package.json +0 -11
- package/tests/fixtures/browserlist/dotfile/.browserslistrc +0 -3
- package/tests/fixtures/browserlist/pkg/package.json +0 -7
- package/tests/fixtures/compat-require/cjs.js +0 -1
- package/tests/fixtures/compat-require/empty.js +0 -1
- package/tests/fixtures/compat-require/esm.js +0 -5
- package/tests/fixtures/compat-require/foo.js +0 -3
- package/tests/fixtures/file-exists/a.ejs +0 -0
- package/tests/fixtures/file-exists/a.js/.gitkeep +0 -0
- package/tests/fixtures/file-exists/a.mjs +0 -0
- package/tests/fixtures/file-exists/a.ts +0 -0
- package/tests/format.test.ts +0 -60
- package/tests/generateMetaTags.test.ts +0 -19
- package/tests/getBrowserslist.test.ts +0 -32
- package/tests/getCacheIdentifier.test.ts +0 -37
- package/tests/getEntryOptions.test.ts +0 -53
- package/tests/index.test.ts +0 -18
- package/tests/is.test.ts +0 -27
- package/tests/isPlatform.test.ts +0 -19
- package/tests/isType.test.ts +0 -85
- package/tests/logger.test.ts +0 -53
- package/tests/prettyInstructions.test.ts +0 -139
- package/tests/removeSlash.test.ts +0 -19
- package/tests/tsconfig.json +0 -11
- package/tests/wait.ts +0 -38
|
@@ -33,13 +33,13 @@ const getAddressUrls = (protocol = 'http', port) => {
|
|
|
33
33
|
}, []);
|
|
34
34
|
};
|
|
35
35
|
const prettyInstructions = (appContext, config) => {
|
|
36
|
-
const { entrypoints, serverRoutes, port,
|
|
36
|
+
const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
|
|
37
37
|
const urls = getAddressUrls(config.dev.https && (0, is_1.isDev)() ? 'https' : 'http', port);
|
|
38
|
-
const routes =
|
|
38
|
+
const routes = !apiOnly
|
|
39
39
|
? serverRoutes.filter(route => route.entryName)
|
|
40
40
|
: serverRoutes;
|
|
41
41
|
let message = 'App running at:\n\n';
|
|
42
|
-
if ((0, exports.isSingleEntry)(entrypoints) ||
|
|
42
|
+
if ((0, exports.isSingleEntry)(entrypoints) || apiOnly) {
|
|
43
43
|
message += urls
|
|
44
44
|
.map(({ type, url }) => ` ${compiled_1.chalk.bold(`> ${type.padEnd(10)}`)}${compiled_1.chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}\n`)
|
|
45
45
|
.join('');
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* ssr helpers
|
|
4
|
+
*/
|
|
2
5
|
import type { IncomingHttpHeaders } from 'http';
|
|
3
6
|
declare const run: <O>(context: IncomingHttpHeaders, cb: () => O | Promise<O>) => Promise<O>, useHeaders: () => IncomingHttpHeaders;
|
|
4
7
|
export { run, useHeaders };
|
|
File without changes
|
package/dist/storage.js
CHANGED
|
@@ -49,7 +49,7 @@ const createStorage = () => {
|
|
|
49
49
|
}
|
|
50
50
|
const context = storage.getStore();
|
|
51
51
|
if (!context) {
|
|
52
|
-
throw new Error(`Can't call useContext out of scope,
|
|
52
|
+
throw new Error(`Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules`);
|
|
53
53
|
}
|
|
54
54
|
return context;
|
|
55
55
|
};
|
package/package.json
CHANGED
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.6.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"main": "./dist/index.js",
|
|
18
18
|
"module": "./dist/index.js",
|
|
19
19
|
"jsnext:modern": "./dist/index.js",
|
|
20
|
+
"_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
|
|
20
21
|
"exports": {
|
|
21
22
|
".": {
|
|
22
23
|
"jsnext:source": "./src/index.ts",
|
|
@@ -30,6 +31,10 @@
|
|
|
30
31
|
"jsnext:source": "./src/constants.ts",
|
|
31
32
|
"default": "./dist/constants.js"
|
|
32
33
|
},
|
|
34
|
+
"./ssr": {
|
|
35
|
+
"jsnext:source": "./src/ssr.ts",
|
|
36
|
+
"default": "./dist/ssr.js"
|
|
37
|
+
},
|
|
33
38
|
"./lodash": {
|
|
34
39
|
"jsnext:source": "./compiled/lodash/index.js",
|
|
35
40
|
"default": "./compiled/lodash/index.js"
|
|
@@ -47,6 +52,9 @@
|
|
|
47
52
|
"constants": [
|
|
48
53
|
"./dist/constants.d.ts"
|
|
49
54
|
],
|
|
55
|
+
"ssr": [
|
|
56
|
+
"./dist/ssr.d.ts"
|
|
57
|
+
],
|
|
50
58
|
"lodash": [
|
|
51
59
|
"./compiled/lodash/index.d.ts"
|
|
52
60
|
],
|
|
@@ -56,48 +64,22 @@
|
|
|
56
64
|
}
|
|
57
65
|
},
|
|
58
66
|
"dependencies": {
|
|
59
|
-
"
|
|
67
|
+
"caniuse-lite": "^1.0.30001332",
|
|
60
68
|
"typescript": "^4"
|
|
61
69
|
},
|
|
62
70
|
"devDependencies": {
|
|
63
|
-
"@modern-js/types": "
|
|
71
|
+
"@modern-js/types": "1.5.1",
|
|
64
72
|
"@scripts/build": "0.0.0",
|
|
65
73
|
"@scripts/jest-config": "0.0.0",
|
|
66
|
-
"@types/debug": "4.1.7",
|
|
67
|
-
"@types/fs-extra": "9.0.13",
|
|
68
|
-
"@types/glob": "^7.1.4",
|
|
69
74
|
"@types/jest": "^26",
|
|
70
|
-
"@types/js-yaml": "4.0.5",
|
|
71
|
-
"@types/lodash": "4.14.181",
|
|
72
75
|
"@types/node": "^14",
|
|
73
|
-
"@types/recursive-readdir": "2.2.0",
|
|
74
|
-
"@types/signale": "1.4.4",
|
|
75
|
-
"browserslist": "4.20.2",
|
|
76
|
-
"chalk": "4.1.2",
|
|
77
|
-
"chokidar": "3.5.3",
|
|
78
|
-
"commander": "8.3.0",
|
|
79
|
-
"debug": "4.3.4",
|
|
80
|
-
"execa": "5.1.1",
|
|
81
|
-
"filesize": "8.0.7",
|
|
82
|
-
"fs-extra": "10.0.1",
|
|
83
|
-
"glob": "7.2.0",
|
|
84
|
-
"gzip-size": "6.0.0",
|
|
85
|
-
"import-lazy": "4.0.0",
|
|
86
76
|
"jest": "^27",
|
|
87
|
-
"js-yaml": "4.1.0",
|
|
88
|
-
"lodash": "4.17.21",
|
|
89
|
-
"pkg-up": "3.1.0",
|
|
90
|
-
"recursive-readdir": "2.2.2",
|
|
91
|
-
"signale": "1.4.0",
|
|
92
|
-
"strip-ansi": "6.0.1",
|
|
93
|
-
"upath": "2.0.1",
|
|
94
77
|
"webpack": "^5.71.0"
|
|
95
78
|
},
|
|
96
79
|
"sideEffects": false,
|
|
97
80
|
"publishConfig": {
|
|
98
81
|
"registry": "https://registry.npmjs.org/",
|
|
99
|
-
"access": "public"
|
|
100
|
-
"types": "./dist/index.d.ts"
|
|
82
|
+
"access": "public"
|
|
101
83
|
},
|
|
102
84
|
"scripts": {
|
|
103
85
|
"new": "modern new",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCacheIdentifier = void 0;
|
|
4
|
-
const is_1 = require("./is");
|
|
5
|
-
/**
|
|
6
|
-
* Generate cache identifier from some packages and config files.
|
|
7
|
-
*/
|
|
8
|
-
function getCacheIdentifier(packages, _files) {
|
|
9
|
-
/* eslint-disable no-nested-ternary */
|
|
10
|
-
let cacheIdentifier = (0, is_1.isProd)()
|
|
11
|
-
? 'production'
|
|
12
|
-
: (0, is_1.isDev)()
|
|
13
|
-
? 'development'
|
|
14
|
-
: (0, is_1.isTest)()
|
|
15
|
-
? 'test'
|
|
16
|
-
: '';
|
|
17
|
-
/* eslint-enable no-nested-ternary */
|
|
18
|
-
for (const { name, version } of packages) {
|
|
19
|
-
cacheIdentifier += `:${name}@${version}`;
|
|
20
|
-
}
|
|
21
|
-
// TODO: config file hash
|
|
22
|
-
return cacheIdentifier;
|
|
23
|
-
}
|
|
24
|
-
exports.getCacheIdentifier = getCacheIdentifier;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { glob, yaml } from "./compiled";
|
|
10
|
-
const PACKAGE_MAX_DEPTH = 5;
|
|
11
|
-
const WOKRSPACES_FILES = {
|
|
12
|
-
YARN: 'package.json',
|
|
13
|
-
PNPM: 'pnpm-workspaces.yaml',
|
|
14
|
-
LERNA: 'lerna.json'
|
|
15
|
-
};
|
|
16
|
-
export const isLerna = root => fs.existsSync(path.join(root, WOKRSPACES_FILES.LERNA));
|
|
17
|
-
export const isYarnWorkspaces = root => {
|
|
18
|
-
var _json$workspaces;
|
|
19
|
-
|
|
20
|
-
const pkg = path.join(root, WOKRSPACES_FILES.YARN);
|
|
21
|
-
|
|
22
|
-
if (!fs.existsSync(pkg)) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const json = JSON.parse(fs.readFileSync(pkg, 'utf8'));
|
|
27
|
-
return Boolean((_json$workspaces = json.workspaces) === null || _json$workspaces === void 0 ? void 0 : _json$workspaces.packages);
|
|
28
|
-
};
|
|
29
|
-
export const isPnpmWorkspaces = root => fs.existsSync(path.join(root, WOKRSPACES_FILES.PNPM));
|
|
30
|
-
export const isMonorepo = root => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
|
31
|
-
export const isModernjsMonorepo = root => {
|
|
32
|
-
const json = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
33
|
-
|
|
34
|
-
const deps = _objectSpread(_objectSpread({}, json.dependencies || {}), json.devDependencies || {});
|
|
35
|
-
|
|
36
|
-
return Boolean(deps['@modern-js/monorepo-tools']);
|
|
37
|
-
};
|
|
38
|
-
export const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
|
39
|
-
let inMonorepo = false;
|
|
40
|
-
|
|
41
|
-
for (let depth = 0; depth < maxDepth; depth++) {
|
|
42
|
-
if (isMonorepo(appDirectory)) {
|
|
43
|
-
inMonorepo = true;
|
|
44
|
-
break;
|
|
45
|
-
} // eslint-d isable-next-line no-param-reassign
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
appDirectory = path.dirname(appDirectory);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return inMonorepo ? appDirectory : undefined;
|
|
52
|
-
};
|
|
53
|
-
export const getMonorepoPackages = root => {
|
|
54
|
-
let packages = [];
|
|
55
|
-
|
|
56
|
-
if (isYarnWorkspaces(root)) {
|
|
57
|
-
const json = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
58
|
-
({
|
|
59
|
-
packages
|
|
60
|
-
} = json.workspaces);
|
|
61
|
-
} else if (isLerna(root)) {
|
|
62
|
-
const json = JSON.parse(fs.readFileSync(path.resolve(root, 'lerna.json'), 'utf8'));
|
|
63
|
-
({
|
|
64
|
-
packages
|
|
65
|
-
} = json);
|
|
66
|
-
} else {
|
|
67
|
-
({
|
|
68
|
-
packages
|
|
69
|
-
} = yaml.load(fs.readFileSync(path.join(root, WOKRSPACES_FILES.PNPM), 'utf8')));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (packages) {
|
|
73
|
-
return packages.map(name => // The trailing / ensures only dirs are picked up
|
|
74
|
-
glob.sync(path.join(root, `${name}/`), {
|
|
75
|
-
ignore: ['**/node_modules/**']
|
|
76
|
-
})).reduce((acc, val) => acc.concat(val), []).filter(filepath => fs.existsSync(path.resolve(filepath, 'package.json'))).map(filepath => ({
|
|
77
|
-
path: filepath,
|
|
78
|
-
name: JSON.parse(fs.readFileSync(path.resolve(filepath, 'package.json'), 'utf8')).name
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return [];
|
|
83
|
-
};
|
package/dist/js/node/monorepo.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isYarnWorkspaces = exports.isPnpmWorkspaces = exports.isMonorepo = exports.isModernjsMonorepo = exports.isLerna = exports.getMonorepoPackages = exports.findMonorepoRoot = void 0;
|
|
7
|
-
|
|
8
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
|
-
var _compiled = require("./compiled");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
|
|
20
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
-
|
|
22
|
-
const PACKAGE_MAX_DEPTH = 5;
|
|
23
|
-
const WOKRSPACES_FILES = {
|
|
24
|
-
YARN: 'package.json',
|
|
25
|
-
PNPM: 'pnpm-workspaces.yaml',
|
|
26
|
-
LERNA: 'lerna.json'
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const isLerna = root => _fs.default.existsSync(_path.default.join(root, WOKRSPACES_FILES.LERNA));
|
|
30
|
-
|
|
31
|
-
exports.isLerna = isLerna;
|
|
32
|
-
|
|
33
|
-
const isYarnWorkspaces = root => {
|
|
34
|
-
var _json$workspaces;
|
|
35
|
-
|
|
36
|
-
const pkg = _path.default.join(root, WOKRSPACES_FILES.YARN);
|
|
37
|
-
|
|
38
|
-
if (!_fs.default.existsSync(pkg)) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const json = JSON.parse(_fs.default.readFileSync(pkg, 'utf8'));
|
|
43
|
-
return Boolean((_json$workspaces = json.workspaces) === null || _json$workspaces === void 0 ? void 0 : _json$workspaces.packages);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
exports.isYarnWorkspaces = isYarnWorkspaces;
|
|
47
|
-
|
|
48
|
-
const isPnpmWorkspaces = root => _fs.default.existsSync(_path.default.join(root, WOKRSPACES_FILES.PNPM));
|
|
49
|
-
|
|
50
|
-
exports.isPnpmWorkspaces = isPnpmWorkspaces;
|
|
51
|
-
|
|
52
|
-
const isMonorepo = root => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
|
53
|
-
|
|
54
|
-
exports.isMonorepo = isMonorepo;
|
|
55
|
-
|
|
56
|
-
const isModernjsMonorepo = root => {
|
|
57
|
-
const json = JSON.parse(_fs.default.readFileSync(_path.default.join(root, 'package.json'), 'utf8'));
|
|
58
|
-
|
|
59
|
-
const deps = _objectSpread(_objectSpread({}, json.dependencies || {}), json.devDependencies || {});
|
|
60
|
-
|
|
61
|
-
return Boolean(deps['@modern-js/monorepo-tools']);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
exports.isModernjsMonorepo = isModernjsMonorepo;
|
|
65
|
-
|
|
66
|
-
const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
|
67
|
-
let inMonorepo = false;
|
|
68
|
-
|
|
69
|
-
for (let depth = 0; depth < maxDepth; depth++) {
|
|
70
|
-
if (isMonorepo(appDirectory)) {
|
|
71
|
-
inMonorepo = true;
|
|
72
|
-
break;
|
|
73
|
-
} // eslint-d isable-next-line no-param-reassign
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
appDirectory = _path.default.dirname(appDirectory);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return inMonorepo ? appDirectory : undefined;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
exports.findMonorepoRoot = findMonorepoRoot;
|
|
83
|
-
|
|
84
|
-
const getMonorepoPackages = root => {
|
|
85
|
-
let packages = [];
|
|
86
|
-
|
|
87
|
-
if (isYarnWorkspaces(root)) {
|
|
88
|
-
const json = JSON.parse(_fs.default.readFileSync(_path.default.join(root, 'package.json'), 'utf8'));
|
|
89
|
-
({
|
|
90
|
-
packages
|
|
91
|
-
} = json.workspaces);
|
|
92
|
-
} else if (isLerna(root)) {
|
|
93
|
-
const json = JSON.parse(_fs.default.readFileSync(_path.default.resolve(root, 'lerna.json'), 'utf8'));
|
|
94
|
-
({
|
|
95
|
-
packages
|
|
96
|
-
} = json);
|
|
97
|
-
} else {
|
|
98
|
-
({
|
|
99
|
-
packages
|
|
100
|
-
} = _compiled.yaml.load(_fs.default.readFileSync(_path.default.join(root, WOKRSPACES_FILES.PNPM), 'utf8')));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (packages) {
|
|
104
|
-
return packages.map(name => // The trailing / ensures only dirs are picked up
|
|
105
|
-
_compiled.glob.sync(_path.default.join(root, `${name}/`), {
|
|
106
|
-
ignore: ['**/node_modules/**']
|
|
107
|
-
})).reduce((acc, val) => acc.concat(val), []).filter(filepath => _fs.default.existsSync(_path.default.resolve(filepath, 'package.json'))).map(filepath => ({
|
|
108
|
-
path: filepath,
|
|
109
|
-
name: JSON.parse(_fs.default.readFileSync(_path.default.resolve(filepath, 'package.json'), 'utf8')).name
|
|
110
|
-
}));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return [];
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
exports.getMonorepoPackages = getMonorepoPackages;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { glob, yaml } from "./compiled";
|
|
10
|
-
var PACKAGE_MAX_DEPTH = 5;
|
|
11
|
-
var WOKRSPACES_FILES = {
|
|
12
|
-
YARN: 'package.json',
|
|
13
|
-
PNPM: 'pnpm-workspaces.yaml',
|
|
14
|
-
LERNA: 'lerna.json'
|
|
15
|
-
};
|
|
16
|
-
export var isLerna = function isLerna(root) {
|
|
17
|
-
return fs.existsSync(path.join(root, WOKRSPACES_FILES.LERNA));
|
|
18
|
-
};
|
|
19
|
-
export var isYarnWorkspaces = function isYarnWorkspaces(root) {
|
|
20
|
-
var _json$workspaces;
|
|
21
|
-
|
|
22
|
-
var pkg = path.join(root, WOKRSPACES_FILES.YARN);
|
|
23
|
-
|
|
24
|
-
if (!fs.existsSync(pkg)) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var json = JSON.parse(fs.readFileSync(pkg, 'utf8'));
|
|
29
|
-
return Boolean((_json$workspaces = json.workspaces) === null || _json$workspaces === void 0 ? void 0 : _json$workspaces.packages);
|
|
30
|
-
};
|
|
31
|
-
export var isPnpmWorkspaces = function isPnpmWorkspaces(root) {
|
|
32
|
-
return fs.existsSync(path.join(root, WOKRSPACES_FILES.PNPM));
|
|
33
|
-
};
|
|
34
|
-
export var isMonorepo = function isMonorepo(root) {
|
|
35
|
-
return isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
|
36
|
-
};
|
|
37
|
-
export var isModernjsMonorepo = function isModernjsMonorepo(root) {
|
|
38
|
-
var json = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
39
|
-
|
|
40
|
-
var deps = _objectSpread(_objectSpread({}, json.dependencies || {}), json.devDependencies || {});
|
|
41
|
-
|
|
42
|
-
return Boolean(deps['@modern-js/monorepo-tools']);
|
|
43
|
-
};
|
|
44
|
-
export var findMonorepoRoot = function findMonorepoRoot(appDirectory) {
|
|
45
|
-
var maxDepth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PACKAGE_MAX_DEPTH;
|
|
46
|
-
var inMonorepo = false;
|
|
47
|
-
|
|
48
|
-
for (var depth = 0; depth < maxDepth; depth++) {
|
|
49
|
-
if (isMonorepo(appDirectory)) {
|
|
50
|
-
inMonorepo = true;
|
|
51
|
-
break;
|
|
52
|
-
} // eslint-d isable-next-line no-param-reassign
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
appDirectory = path.dirname(appDirectory);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return inMonorepo ? appDirectory : undefined;
|
|
59
|
-
};
|
|
60
|
-
export var getMonorepoPackages = function getMonorepoPackages(root) {
|
|
61
|
-
var packages = [];
|
|
62
|
-
|
|
63
|
-
if (isYarnWorkspaces(root)) {
|
|
64
|
-
var json = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
65
|
-
packages = json.workspaces.packages;
|
|
66
|
-
} else if (isLerna(root)) {
|
|
67
|
-
var _json = JSON.parse(fs.readFileSync(path.resolve(root, 'lerna.json'), 'utf8'));
|
|
68
|
-
|
|
69
|
-
packages = _json.packages;
|
|
70
|
-
} else {
|
|
71
|
-
var _ref = yaml.load(fs.readFileSync(path.join(root, WOKRSPACES_FILES.PNPM), 'utf8'));
|
|
72
|
-
|
|
73
|
-
packages = _ref.packages;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (packages) {
|
|
77
|
-
return packages.map(function (name) {
|
|
78
|
-
return (// The trailing / ensures only dirs are picked up
|
|
79
|
-
glob.sync(path.join(root, "".concat(name, "/")), {
|
|
80
|
-
ignore: ['**/node_modules/**']
|
|
81
|
-
})
|
|
82
|
-
);
|
|
83
|
-
}).reduce(function (acc, val) {
|
|
84
|
-
return acc.concat(val);
|
|
85
|
-
}, []).filter(function (filepath) {
|
|
86
|
-
return fs.existsSync(path.resolve(filepath, 'package.json'));
|
|
87
|
-
}).map(function (filepath) {
|
|
88
|
-
return {
|
|
89
|
-
path: filepath,
|
|
90
|
-
name: JSON.parse(fs.readFileSync(path.resolve(filepath, 'package.json'), 'utf8')).name
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return [];
|
|
96
|
-
};
|
package/dist/pkgUp.d.ts
DELETED
package/dist/pkgUp.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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.pkgUp = void 0;
|
|
7
|
-
const pkg_up_1 = __importDefault(require("pkg-up"));
|
|
8
|
-
exports.pkgUp = pkg_up_1.default;
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
declare function printFileSizesAfterBuild(webpackStats: any, previousSizeMap: {
|
|
9
|
-
root: string;
|
|
10
|
-
sizes: Record<string, number[]>;
|
|
11
|
-
}, buildFolder: string, maxBundleGzipSize: number, maxChunkGzipSize: number): void;
|
|
12
|
-
declare function measureFileSizesBeforeBuild(buildFolder: string): Promise<{
|
|
13
|
-
root: string;
|
|
14
|
-
sizes: Record<string, number[]>;
|
|
15
|
-
}>;
|
|
16
|
-
export { measureFileSizesBeforeBuild, printFileSizesAfterBuild };
|
package/dist/types/alias.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
declare type AliasOption = Record<string, string> | ((aliases: Record<string, string>) => Record<string, unknown>) | Record<string, string> | undefined;
|
|
2
|
-
interface NormalizedConfig {
|
|
3
|
-
source: {
|
|
4
|
-
alias?: AliasOption | Array<AliasOption>;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
interface IAliasConfig {
|
|
8
|
-
absoluteBaseUrl: string;
|
|
9
|
-
paths?: Record<string, string | string[]>;
|
|
10
|
-
isTsPath?: boolean;
|
|
11
|
-
isTsProject?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare const validAlias: <T extends NormalizedConfig>(modernConfig: T, { tsconfigPath }: {
|
|
14
|
-
tsconfigPath: string;
|
|
15
|
-
}) => string | null;
|
|
16
|
-
export declare const getAlias: (aliasOption: AliasOption | Array<AliasOption>, option: {
|
|
17
|
-
appDirectory: string;
|
|
18
|
-
tsconfigPath: string;
|
|
19
|
-
}) => IAliasConfig;
|
|
20
|
-
export declare const getUserAlias: (alias?: Record<string, string | string[]>) => Record<string, string | string[]>;
|
|
21
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const applyOptionsChain: <T, U>(defaults: T, options?: T | (T | ((config: T, utils?: U | undefined) => void | T))[] | ((config: T, utils?: U | undefined) => void | T) | undefined, utils?: U | undefined, mergeFn?: {
|
|
2
|
-
<T_1, U_1>(target: T_1, source: U_1): T_1 & U_1;
|
|
3
|
-
<T_2, U_2, V>(target: T_2, source1: U_2, source2: V): T_2 & U_2 & V;
|
|
4
|
-
<T_3, U_3, V_1, W>(target: T_3, source1: U_3, source2: V_1, source3: W): T_3 & U_3 & V_1 & W;
|
|
5
|
-
(target: object, ...sources: any[]): any;
|
|
6
|
-
}) => T;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const clearConsole: () => void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Require function compatible with esm and cjs module.
|
|
3
|
-
* @param filePath - File to required.
|
|
4
|
-
* @returns module export object.
|
|
5
|
-
*/
|
|
6
|
-
export declare const compatRequire: (filePath: string) => any;
|
|
7
|
-
export declare const requireExistModule: (filename: string, extensions?: string[]) => any;
|
|
8
|
-
export declare const cleanRequireCache: (filelist: string[]) => void;
|
package/dist/types/compiled.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import fs from '../compiled/fs-extra';
|
|
2
|
-
import chalk from '../compiled/chalk';
|
|
3
|
-
export { fs, chalk };
|
|
4
|
-
export type { IOptions as GlobOptions } from '../compiled/glob';
|
|
5
|
-
export type { FSWatcher, WatchOptions } from '../compiled/chokidar';
|
|
6
|
-
export declare const glob: typeof import('../compiled/glob');
|
|
7
|
-
export declare const yaml: typeof import('../compiled/js-yaml');
|
|
8
|
-
export declare const execa: typeof import('../compiled/execa');
|
|
9
|
-
export declare const pkgUp: typeof import('../compiled/pkg-up');
|
|
10
|
-
export declare const upath: typeof import('../compiled/upath');
|
|
11
|
-
export declare const debug: typeof import('../compiled/debug');
|
|
12
|
-
export declare const chokidar: typeof import('../compiled/chokidar');
|
|
13
|
-
export declare const gzipSize: typeof import('../compiled/gzip-size');
|
|
14
|
-
export declare const filesize: typeof import('../compiled/filesize');
|
|
15
|
-
export declare const stripAnsi: typeof import('../compiled/strip-ansi');
|
|
16
|
-
export declare const browserslist: typeof import('../compiled/browserslist');
|
|
17
|
-
export declare const recursiveReaddir: typeof import('../compiled/recursive-readdir');
|