@modern-js/utils 2.18.0 → 2.18.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +2 -0
- package/dist/cjs/{alias.js → cli/alias.js} +3 -3
- package/dist/cjs/{applyOptionsChain.js → cli/applyOptionsChain.js} +6 -5
- package/dist/cjs/{babel.js → cli/babel.js} +3 -3
- package/dist/cjs/cli/common.js +26 -0
- package/dist/cjs/{constants.js → cli/constants/index.js} +14 -2
- package/dist/cjs/{readTsConfig.js → cli/ensure.js} +10 -9
- package/dist/cjs/cli/fs.js +29 -0
- package/dist/cjs/{getEntryOptions.js → cli/get/config.js} +2 -2
- package/dist/cjs/cli/get/data.js +112 -0
- package/dist/cjs/cli/get/index.js +46 -0
- package/dist/cjs/cli/index.js +41 -0
- package/dist/cjs/{is/index.js → cli/is/config.js} +2 -43
- package/dist/cjs/{is/nodeEnv.js → cli/is/env.js} +3 -1
- package/dist/cjs/cli/is/index.js +22 -0
- package/dist/cjs/cli/is/project.js +92 -0
- package/dist/cjs/{is → cli/is}/type.js +3 -1
- package/dist/cjs/{logger.js → cli/logger.js} +1 -1
- package/dist/cjs/{monorepo.js → cli/monorepo.js} +1 -1
- package/dist/cjs/{nodeEnv.js → cli/package.js} +8 -1
- package/dist/cjs/{path.js → cli/path.js} +8 -2
- package/dist/cjs/{pathSerializer.js → cli/pathSerializer.js} +1 -1
- package/dist/cjs/{getPort.js → cli/port.js} +1 -1
- package/dist/cjs/{prettyInstructions.js → cli/prettyInstructions.js} +1 -2
- package/dist/cjs/{printBuildError.js → cli/print.js} +1 -1
- package/dist/cjs/{compatRequire.js → cli/require.js} +21 -3
- package/dist/cjs/{routes.js → cli/routes.js} +4 -11
- package/dist/cjs/{runtimeExports.js → cli/runtimeExports.js} +1 -1
- package/dist/cjs/cli/watch.js +61 -0
- package/dist/cjs/index.js +1 -42
- package/dist/cjs/runtime/router.js +19 -0
- package/dist/cjs/{ssr.js → runtime-node/index.js} +3 -1
- package/dist/esm/{alias.js → cli/alias.js} +2 -2
- package/dist/esm/{applyOptionsChain.js → cli/applyOptionsChain.js} +2 -1
- package/dist/esm/{babel.js → cli/babel.js} +1 -1
- package/dist/esm/cli/common.js +10 -0
- package/dist/esm/{constants.js → cli/constants/index.js} +1 -1
- package/dist/esm/{ensureAbsolutePath.js → cli/ensure.js} +8 -0
- package/dist/esm/{findExists.js → cli/fs.js} +6 -1
- package/dist/esm/{getEntryOptions.js → cli/get/config.js} +2 -2
- package/dist/esm/cli/get/data.js +86 -0
- package/dist/esm/cli/get/index.js +13 -0
- package/dist/esm/cli/index.js +24 -0
- package/dist/esm/{is/index.js → cli/is/config.js} +1 -21
- package/dist/esm/{is/nodeEnv.js → cli/is/env.js} +1 -0
- package/dist/esm/cli/is/index.js +5 -0
- package/dist/esm/cli/is/project.js +67 -0
- package/dist/esm/{is → cli/is}/type.js +1 -0
- package/dist/esm/{logger.js → cli/logger.js} +1 -1
- package/dist/esm/{monorepo.js → cli/monorepo.js} +1 -1
- package/dist/esm/{nodeEnv.js → cli/package.js} +7 -1
- package/dist/esm/{path.js → cli/path.js} +4 -1
- package/dist/esm/{pathSerializer.js → cli/pathSerializer.js} +1 -1
- package/dist/esm/{getPort.js → cli/port.js} +1 -1
- package/dist/esm/{prettyInstructions.js → cli/prettyInstructions.js} +2 -2
- package/dist/esm/{printBuildError.js → cli/print.js} +1 -1
- package/dist/esm/{compatRequire.js → cli/require.js} +18 -1
- package/dist/esm/{routes.js → cli/routes.js} +2 -2
- package/dist/esm/{runtimeExports.js → cli/runtimeExports.js} +1 -1
- package/dist/esm/{watch.js → cli/watch.js} +2 -2
- package/dist/esm/index.js +1 -42
- package/dist/esm/runtime/router.js +2 -0
- package/dist/esm/{ssr.js → runtime-node/index.js} +1 -0
- package/dist/types/{applyOptionsChain.d.ts → cli/applyOptionsChain.d.ts} +1 -1
- package/dist/types/{debug.d.ts → cli/common.d.ts} +3 -1
- package/dist/types/{constants.d.ts → cli/constants/index.d.ts} +2 -6
- package/dist/types/{ensureAbsolutePath.d.ts → cli/ensure.d.ts} +2 -1
- package/dist/types/{findExists.d.ts → cli/fs.d.ts} +2 -1
- package/dist/types/cli/get/data.d.ts +9 -0
- package/dist/types/cli/get/index.d.ts +4 -0
- package/dist/types/cli/index.d.ts +24 -0
- package/dist/types/cli/is/config.d.ts +30 -0
- package/dist/types/{is/nodeEnv.d.ts → cli/is/env.d.ts} +2 -1
- package/dist/types/cli/is/index.d.ts +5 -0
- package/dist/types/cli/is/project.d.ts +25 -0
- package/dist/types/{is → cli/is}/type.d.ts +9 -1
- package/dist/types/{logger.d.ts → cli/logger.d.ts} +1 -1
- package/dist/types/cli/package.d.ts +4 -0
- package/dist/types/{path.d.ts → cli/path.d.ts} +5 -2
- package/dist/types/{prettyInstructions.d.ts → cli/prettyInstructions.d.ts} +0 -3
- package/dist/types/{compatRequire.d.ts → cli/require.d.ts} +9 -1
- package/dist/types/cli/routes.d.ts +1 -0
- package/dist/types/{watch.d.ts → cli/watch.d.ts} +1 -1
- package/dist/types/index.d.ts +2 -43
- package/dist/types/runtime/router.d.ts +2 -0
- package/dist/types/{ssr.d.ts → runtime-node/index.d.ts} +2 -1
- package/package.json +55 -92
- package/dist/cjs/FileSizeReporter.js +0 -139
- package/dist/cjs/analyzeProject.js +0 -68
- package/dist/cjs/clearConsole.js +0 -13
- package/dist/cjs/debug.js +0 -10
- package/dist/cjs/emptyDir.js +0 -14
- package/dist/cjs/ensureAbsolutePath.js +0 -15
- package/dist/cjs/ensureArray.js +0 -16
- package/dist/cjs/findExists.js +0 -22
- package/dist/cjs/getBrowserslist.js +0 -24
- package/dist/cjs/getCoreJsVersion.js +0 -58
- package/dist/cjs/getPackageManager.js +0 -42
- package/dist/cjs/getServerConfig.js +0 -55
- package/dist/cjs/getTargetDir.js +0 -53
- package/dist/cjs/plugin.js +0 -28
- package/dist/cjs/react.js +0 -30
- package/dist/cjs/removeSlash.js +0 -19
- package/dist/cjs/resolve.js +0 -57
- package/dist/cjs/types.js +0 -4
- package/dist/cjs/version.js +0 -43
- package/dist/cjs/wait.js +0 -11
- package/dist/cjs/watch.js +0 -96
- package/dist/esm/FileSizeReporter.js +0 -121
- package/dist/esm/analyzeProject.js +0 -13
- package/dist/esm/clearConsole.js +0 -5
- package/dist/esm/debug.js +0 -2
- package/dist/esm/emptyDir.js +0 -6
- package/dist/esm/ensureArray.js +0 -8
- package/dist/esm/getBrowserslist.js +0 -9
- package/dist/esm/getCoreJsVersion.js +0 -10
- package/dist/esm/getPackageManager.js +0 -29
- package/dist/esm/getServerConfig.js +0 -7
- package/dist/esm/getTargetDir.js +0 -5
- package/dist/esm/plugin.js +0 -20
- package/dist/esm/react.js +0 -17
- package/dist/esm/readTsConfig.js +0 -9
- package/dist/esm/removeSlash.js +0 -3
- package/dist/esm/resolve.js +0 -41
- package/dist/esm/types.js +0 -1
- package/dist/esm/version.js +0 -23
- package/dist/esm/wait.js +0 -4
- package/dist/types/FileSizeReporter.d.ts +0 -16
- package/dist/types/analyzeProject.d.ts +0 -2
- package/dist/types/clearConsole.d.ts +0 -1
- package/dist/types/emptyDir.d.ts +0 -1
- package/dist/types/ensureArray.d.ts +0 -1
- package/dist/types/getBrowserslist.d.ts +0 -2
- package/dist/types/getCoreJsVersion.d.ts +0 -1
- package/dist/types/getPackageManager.d.ts +0 -1
- package/dist/types/getServerConfig.d.ts +0 -1
- package/dist/types/getTargetDir.d.ts +0 -1
- package/dist/types/is/index.d.ts +0 -58
- package/dist/types/nodeEnv.d.ts +0 -3
- package/dist/types/plugin.d.ts +0 -2
- package/dist/types/react.d.ts +0 -1
- package/dist/types/readTsConfig.d.ts +0 -2
- package/dist/types/removeSlash.d.ts +0 -3
- package/dist/types/resolve.d.ts +0 -13
- package/dist/types/routes.d.ts +0 -2
- package/dist/types/types.d.ts +0 -1
- package/dist/types/version.d.ts +0 -2
- package/dist/types/wait.d.ts +0 -2
- /package/dist/cjs/{commands.js → cli/commands.js} +0 -0
- /package/dist/cjs/{chainId.js → cli/constants/chainId.js} +0 -0
- /package/dist/cjs/{generateMetaTags.js → cli/generateMetaTags.js} +0 -0
- /package/dist/cjs/{is → cli/is}/platform.js +0 -0
- /package/dist/cjs/{testUtils.js → cli/test.js} +0 -0
- /package/dist/cjs/{universal → runtime}/nestedRoutes.js +0 -0
- /package/dist/cjs/{universal → runtime}/remixRouter.js +0 -0
- /package/dist/cjs/{runtime → runtime-browser}/index.js +0 -0
- /package/dist/cjs/{runtime → runtime-browser}/parsed.js +0 -0
- /package/dist/cjs/{universal → runtime-node}/serialize.js +0 -0
- /package/dist/cjs/{storage.js → runtime-node/storage.js} +0 -0
- /package/dist/esm/{commands.js → cli/commands.js} +0 -0
- /package/dist/esm/{chainId.js → cli/constants/chainId.js} +0 -0
- /package/dist/esm/{generateMetaTags.js → cli/generateMetaTags.js} +0 -0
- /package/dist/esm/{is → cli/is}/platform.js +0 -0
- /package/dist/esm/{testUtils.js → cli/test.js} +0 -0
- /package/dist/esm/{universal → runtime}/nestedRoutes.js +0 -0
- /package/dist/esm/{universal → runtime}/remixRouter.js +0 -0
- /package/dist/esm/{runtime → runtime-browser}/index.js +0 -0
- /package/dist/esm/{runtime → runtime-browser}/parsed.js +0 -0
- /package/dist/esm/{universal → runtime-node}/serialize.js +0 -0
- /package/dist/esm/{storage.js → runtime-node/storage.js} +0 -0
- /package/dist/types/{alias.d.ts → cli/alias.d.ts} +0 -0
- /package/dist/types/{babel.d.ts → cli/babel.d.ts} +0 -0
- /package/dist/types/{commands.d.ts → cli/commands.d.ts} +0 -0
- /package/dist/types/{chainId.d.ts → cli/constants/chainId.d.ts} +0 -0
- /package/dist/types/{generateMetaTags.d.ts → cli/generateMetaTags.d.ts} +0 -0
- /package/dist/types/{getEntryOptions.d.ts → cli/get/config.d.ts} +0 -0
- /package/dist/types/{is → cli/is}/platform.d.ts +0 -0
- /package/dist/types/{monorepo.d.ts → cli/monorepo.d.ts} +0 -0
- /package/dist/types/{pathSerializer.d.ts → cli/pathSerializer.d.ts} +0 -0
- /package/dist/types/{getPort.d.ts → cli/port.d.ts} +0 -0
- /package/dist/types/{printBuildError.d.ts → cli/print.d.ts} +0 -0
- /package/dist/types/{runtimeExports.d.ts → cli/runtimeExports.d.ts} +0 -0
- /package/dist/types/{testUtils.d.ts → cli/test.d.ts} +0 -0
- /package/dist/types/{universal → runtime}/nestedRoutes.d.ts +0 -0
- /package/dist/types/{universal → runtime}/remixRouter.d.ts +0 -0
- /package/dist/types/{runtime → runtime-browser}/index.d.ts +0 -0
- /package/dist/types/{runtime → runtime-browser}/parsed.d.ts +0 -0
- /package/dist/types/{universal → runtime-node}/serialize.d.ts +0 -0
- /package/dist/types/{storage.d.ts → runtime-node/storage.d.ts} +0 -0
package/dist/esm/readTsConfig.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { fs, json5 } from "./compiled";
|
3
|
-
export const readTsConfig = (root) => {
|
4
|
-
return readTsConfigByFile(path.resolve(root, "./tsconfig.json"));
|
5
|
-
};
|
6
|
-
export const readTsConfigByFile = (filename) => {
|
7
|
-
const content = fs.readFileSync(path.resolve(filename), "utf-8");
|
8
|
-
return json5.parse(content);
|
9
|
-
};
|
package/dist/esm/removeSlash.js
DELETED
package/dist/esm/resolve.js
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
import { ensureArray } from "./ensureArray";
|
2
|
-
export const tryResolve = (name, resolvePath) => {
|
3
|
-
let filePath = "";
|
4
|
-
try {
|
5
|
-
filePath = require.resolve(name, {
|
6
|
-
paths: [
|
7
|
-
resolvePath
|
8
|
-
]
|
9
|
-
});
|
10
|
-
delete require.cache[filePath];
|
11
|
-
} catch (err) {
|
12
|
-
if (err.code === "MODULE_NOT_FOUND") {
|
13
|
-
throw new Error(`Can not find module ${name}.`);
|
14
|
-
}
|
15
|
-
throw err;
|
16
|
-
}
|
17
|
-
return filePath;
|
18
|
-
};
|
19
|
-
export const isPackageInstalled = (name, resolvePaths) => {
|
20
|
-
try {
|
21
|
-
require.resolve(name, {
|
22
|
-
paths: ensureArray(resolvePaths)
|
23
|
-
});
|
24
|
-
return true;
|
25
|
-
} catch (err) {
|
26
|
-
return false;
|
27
|
-
}
|
28
|
-
};
|
29
|
-
export const getAntdMajorVersion = (appDirectory) => {
|
30
|
-
try {
|
31
|
-
const pkgJsonPath = require.resolve("antd/package.json", {
|
32
|
-
paths: [
|
33
|
-
appDirectory
|
34
|
-
]
|
35
|
-
});
|
36
|
-
const { version } = require(pkgJsonPath);
|
37
|
-
return Number(version.split(".")[0]);
|
38
|
-
} catch (err) {
|
39
|
-
return null;
|
40
|
-
}
|
41
|
-
};
|
package/dist/esm/types.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/esm/version.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { fs, execa, semver } from "./compiled";
|
3
|
-
export async function getPnpmVersion() {
|
4
|
-
const { stdout } = await execa("pnpm", [
|
5
|
-
"--version"
|
6
|
-
]);
|
7
|
-
return stdout;
|
8
|
-
}
|
9
|
-
export const isReact18 = (cwd) => {
|
10
|
-
const pkgPath = path.join(cwd, "package.json");
|
11
|
-
if (!fs.existsSync(pkgPath)) {
|
12
|
-
return false;
|
13
|
-
}
|
14
|
-
const pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
15
|
-
const deps = {
|
16
|
-
...pkgInfo.devDependencies,
|
17
|
-
...pkgInfo.dependencies
|
18
|
-
};
|
19
|
-
if (typeof deps.react !== "string") {
|
20
|
-
return false;
|
21
|
-
}
|
22
|
-
return semver.satisfies(semver.minVersion(deps.react), ">=18.0.0");
|
23
|
-
};
|
package/dist/esm/wait.js
DELETED
@@ -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 };
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const clearConsole: () => void;
|
package/dist/types/emptyDir.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export declare const emptyDir: (dir: string) => Promise<void>;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const ensureArray: <T>(params: T | T[]) => T[];
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const getCoreJsVersion: (corejsPkgPath: string) => string;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare function getPackageManager(cwd?: string): Promise<"npm" | "yarn" | "pnpm">;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const getServerConfig: (appDirectory: string, configFile: string) => Promise<string | false>;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const getTargetDir: (from: string, baseDir: string, targetBaseDir: string) => string;
|
package/dist/types/is/index.d.ts
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
interface EntryPoint {
|
2
|
-
entryName: string;
|
3
|
-
}
|
4
|
-
/**
|
5
|
-
* Check if the package name is in dependencies or devDependencies.
|
6
|
-
*
|
7
|
-
* @param appDirectory - Project root directory.
|
8
|
-
* @param name - Package name.
|
9
|
-
* @returns True if the name is in dependencies or devDependencies, false otherwise.
|
10
|
-
*/
|
11
|
-
|
12
|
-
export declare const isDepExists: (appDirectory: string, name: string) => boolean;
|
13
|
-
/**
|
14
|
-
* Is typescript project.
|
15
|
-
*
|
16
|
-
* @param root - App directory.
|
17
|
-
* @returns Whether to use typescript.
|
18
|
-
*/
|
19
|
-
|
20
|
-
export declare const isTypescript: (root: string) => boolean;
|
21
|
-
/**
|
22
|
-
* Is Empty object
|
23
|
-
*
|
24
|
-
* @param o - Any object.
|
25
|
-
* @returns Whether it is empty object.
|
26
|
-
*/
|
27
|
-
|
28
|
-
export declare const isEmpty: (o: Record<string, unknown>) => boolean;
|
29
|
-
/**
|
30
|
-
* Is SSR project
|
31
|
-
*
|
32
|
-
* @param config - User config.
|
33
|
-
* @returns Whether to use server side render.
|
34
|
-
*/
|
35
|
-
|
36
|
-
export declare const isSSR: (config: any) => boolean;
|
37
|
-
export declare const isUseSSRBundle: (config: any) => boolean;
|
38
|
-
/**
|
39
|
-
* Is Worker project
|
40
|
-
*
|
41
|
-
* @param config - User config.
|
42
|
-
* @returns Whether to use worker deploy.
|
43
|
-
*/
|
44
|
-
|
45
|
-
export declare const isServiceWorker: (config: any) => boolean;
|
46
|
-
export declare const isFastRefresh: () => boolean;
|
47
|
-
export declare const isRouterV5: (config: {
|
48
|
-
runtime?: {
|
49
|
-
router?: {
|
50
|
-
mode?: string;
|
51
|
-
} | boolean;
|
52
|
-
};
|
53
|
-
}) => boolean;
|
54
|
-
export declare const isSSGEntry: (config: any, entryName: string, entrypoints: EntryPoint[]) => boolean;
|
55
|
-
export declare const isSingleEntry: (entrypoints: EntryPoint[]) => boolean;
|
56
|
-
export * from './nodeEnv';
|
57
|
-
export * from './platform';
|
58
|
-
export * from './type';
|
package/dist/types/nodeEnv.d.ts
DELETED
package/dist/types/plugin.d.ts
DELETED
package/dist/types/react.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export declare const isBeyondReact17: (cwd: string) => boolean;
|
package/dist/types/resolve.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Try to resolve npm package entry file path.
|
3
|
-
* @param name - Package name.
|
4
|
-
* @param resolvePath - Path to resolve dependencies.
|
5
|
-
* @returns Resolved file path.
|
6
|
-
*/
|
7
|
-
export declare const tryResolve: (name: string, resolvePath: string) => string;
|
8
|
-
/**
|
9
|
-
* Try to resolve npm package, return true if package is installed.
|
10
|
-
*/
|
11
|
-
|
12
|
-
export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
|
13
|
-
export declare const getAntdMajorVersion: (appDirectory: string) => number | null;
|
package/dist/types/routes.d.ts
DELETED
package/dist/types/types.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export type Falsy = false | null | undefined | 0 | '';
|
package/dist/types/version.d.ts
DELETED
package/dist/types/wait.d.ts
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|