@modern-js/utils 1.3.8-canary.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/compiled/address/index.js +1 -0
  3. package/compiled/address/lib/address.d.ts +28 -0
  4. package/compiled/address/package.json +1 -0
  5. package/compiled/browserslist/index.js +1 -1
  6. package/compiled/dotenv/index.js +1 -0
  7. package/compiled/dotenv/license +23 -0
  8. package/compiled/dotenv/package.json +1 -0
  9. package/compiled/dotenv/types/index.d.ts +59 -0
  10. package/compiled/dotenv-expand/index.d.ts +15 -0
  11. package/compiled/dotenv-expand/index.js +1 -0
  12. package/compiled/dotenv-expand/license +24 -0
  13. package/compiled/dotenv-expand/package.json +1 -0
  14. package/compiled/fast-glob/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
  15. package/compiled/fast-glob/@nodelib/fs.scandir/out/index.d.ts +12 -0
  16. package/compiled/fast-glob/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
  17. package/compiled/fast-glob/@nodelib/fs.scandir/out/settings.d.ts +20 -0
  18. package/compiled/fast-glob/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
  19. package/compiled/fast-glob/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
  20. package/compiled/fast-glob/@nodelib/fs.stat/out/index.d.ts +12 -0
  21. package/compiled/fast-glob/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
  22. package/compiled/fast-glob/@nodelib/fs.stat/out/settings.d.ts +16 -0
  23. package/compiled/fast-glob/@nodelib/fs.stat/out/types/index.d.ts +4 -0
  24. package/compiled/fast-glob/@nodelib/fs.walk/out/index.d.ts +14 -0
  25. package/compiled/fast-glob/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
  26. package/compiled/fast-glob/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
  27. package/compiled/fast-glob/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
  28. package/compiled/fast-glob/@nodelib/fs.walk/out/settings.d.ts +30 -0
  29. package/compiled/fast-glob/@nodelib/fs.walk/out/types/index.d.ts +8 -0
  30. package/compiled/fast-glob/index.js +37 -0
  31. package/compiled/fast-glob/license +21 -0
  32. package/compiled/fast-glob/out/index.d.ts +27 -0
  33. package/compiled/fast-glob/out/managers/tasks.d.ts +22 -0
  34. package/compiled/fast-glob/out/settings.d.ts +164 -0
  35. package/compiled/fast-glob/out/types/index.d.ts +31 -0
  36. package/compiled/fast-glob/package.json +1 -0
  37. package/compiled/globby/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
  38. package/compiled/globby/@nodelib/fs.scandir/out/index.d.ts +12 -0
  39. package/compiled/globby/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
  40. package/compiled/globby/@nodelib/fs.scandir/out/settings.d.ts +20 -0
  41. package/compiled/globby/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
  42. package/compiled/globby/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
  43. package/compiled/globby/@nodelib/fs.stat/out/index.d.ts +12 -0
  44. package/compiled/globby/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
  45. package/compiled/globby/@nodelib/fs.stat/out/settings.d.ts +16 -0
  46. package/compiled/globby/@nodelib/fs.stat/out/types/index.d.ts +4 -0
  47. package/compiled/globby/@nodelib/fs.walk/out/index.d.ts +14 -0
  48. package/compiled/globby/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
  49. package/compiled/globby/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
  50. package/compiled/globby/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
  51. package/compiled/globby/@nodelib/fs.walk/out/settings.d.ts +30 -0
  52. package/compiled/globby/@nodelib/fs.walk/out/types/index.d.ts +8 -0
  53. package/compiled/globby/fast-glob/index.d.ts +27 -0
  54. package/compiled/globby/fast-glob/managers/tasks.d.ts +22 -0
  55. package/compiled/globby/fast-glob/settings.d.ts +164 -0
  56. package/compiled/globby/fast-glob/types/index.d.ts +31 -0
  57. package/compiled/globby/index.d.ts +186 -0
  58. package/compiled/globby/index.js +1 -0
  59. package/compiled/globby/license +9 -0
  60. package/compiled/globby/package.json +1 -0
  61. package/compiled/inquirer/index.d.ts +997 -0
  62. package/compiled/inquirer/index.js +9 -0
  63. package/compiled/inquirer/lib/objects/choice.d.ts +65 -0
  64. package/compiled/inquirer/lib/objects/choices.d.ts +206 -0
  65. package/compiled/inquirer/lib/objects/separator.d.ts +37 -0
  66. package/compiled/inquirer/lib/ui/baseUI.d.ts +37 -0
  67. package/compiled/inquirer/lib/ui/bottom-bar.d.ts +65 -0
  68. package/compiled/inquirer/lib/ui/prompt.d.ts +104 -0
  69. package/compiled/inquirer/license +22 -0
  70. package/compiled/inquirer/package.json +1 -0
  71. package/compiled/inquirer/through/index.d.ts +25 -0
  72. package/compiled/json5/index.js +1 -0
  73. package/compiled/json5/lib/index.d.ts +4 -0
  74. package/compiled/json5/lib/parse.d.ts +15 -0
  75. package/compiled/json5/lib/stringify.d.ts +89 -0
  76. package/compiled/json5/package.json +1 -0
  77. package/compiled/mime-types/index.d.ts +14 -0
  78. package/compiled/mime-types/index.js +14 -0
  79. package/compiled/mime-types/license +23 -0
  80. package/compiled/mime-types/package.json +1 -0
  81. package/compiled/minimist/index.d.ts +95 -0
  82. package/compiled/minimist/index.js +1 -0
  83. package/compiled/minimist/license +18 -0
  84. package/compiled/minimist/package.json +1 -0
  85. package/compiled/ora/cli-spinners/index.d.ts +125 -0
  86. package/compiled/ora/index.d.ts +277 -0
  87. package/compiled/ora/index.js +3 -0
  88. package/compiled/ora/license +9 -0
  89. package/compiled/ora/package.json +1 -0
  90. package/compiled/slash/index.d.ts +25 -0
  91. package/compiled/slash/index.js +1 -0
  92. package/compiled/slash/license +9 -0
  93. package/compiled/slash/package.json +1 -0
  94. package/compiled/url-join/index.d.ts +17 -0
  95. package/compiled/url-join/index.js +1 -0
  96. package/compiled/url-join/license +21 -0
  97. package/compiled/url-join/package.json +1 -0
  98. package/dist/analyzeProject.d.ts +1 -0
  99. package/dist/analyzeProject.js +40 -0
  100. package/dist/compiled.d.ts +33 -17
  101. package/dist/compiled.js +57 -21
  102. package/dist/constants.d.ts +1 -1
  103. package/dist/constants.js +1 -1
  104. package/dist/index.d.ts +2 -2
  105. package/dist/index.js +2 -2
  106. package/dist/prettyInstructions.js +3 -3
  107. package/dist/{ssrHelpers.d.ts → ssr.d.ts} +3 -0
  108. package/dist/{ssrHelpers.js → ssr.js} +0 -0
  109. package/dist/storage.js +1 -1
  110. package/package.json +12 -30
  111. package/dist/getCacheIdentifier.d.ts +0 -7
  112. package/dist/getCacheIdentifier.js +0 -24
  113. package/dist/js/modern/monorepo.js +0 -83
  114. package/dist/js/node/monorepo.js +0 -116
  115. package/dist/js/treeshaking/monorepo.js +0 -96
  116. package/dist/pkgUp.d.ts +0 -2
  117. package/dist/pkgUp.js +0 -8
  118. package/dist/types/FileSizeReporter.d.ts +0 -16
  119. package/dist/types/alias.d.ts +0 -21
  120. package/dist/types/applyOptionsChain.d.ts +0 -6
  121. package/dist/types/clearConsole.d.ts +0 -1
  122. package/dist/types/compatRequire.d.ts +0 -8
  123. package/dist/types/compiled.d.ts +0 -17
  124. package/dist/types/constants.d.ts +0 -222
  125. package/dist/types/debug.d.ts +0 -6
  126. package/dist/types/emptyDir.d.ts +0 -1
  127. package/dist/types/ensureAbsolutePath.d.ts +0 -7
  128. package/dist/types/findExists.d.ts +0 -6
  129. package/dist/types/format.d.ts +0 -16
  130. package/dist/types/generateMetaTags.d.ts +0 -16
  131. package/dist/types/getBrowserslist.d.ts +0 -2
  132. package/dist/types/getCacheIdentifier.d.ts +0 -7
  133. package/dist/types/getEntryOptions.d.ts +0 -1
  134. package/dist/types/getPackageManager.d.ts +0 -1
  135. package/dist/types/getPort.d.ts +0 -7
  136. package/dist/types/getServerConfig.d.ts +0 -1
  137. package/dist/types/import.d.ts +0 -5
  138. package/dist/types/index.d.ts +0 -32
  139. package/dist/types/is/index.d.ts +0 -34
  140. package/dist/types/is/node-env.d.ts +0 -4
  141. package/dist/types/is/platform.d.ts +0 -2
  142. package/dist/types/is/type.d.ts +0 -8
  143. package/dist/types/logger.d.ts +0 -63
  144. package/dist/types/monorepo.d.ts +0 -11
  145. package/dist/types/nodeEnv.d.ts +0 -3
  146. package/dist/types/path.d.ts +0 -3
  147. package/dist/types/prettyInstructions.d.ts +0 -6
  148. package/dist/types/printBuildError.d.ts +0 -8
  149. package/dist/types/readTsConfig.d.ts +0 -2
  150. package/dist/types/removeSlash.d.ts +0 -3
  151. package/dist/types/runtimeExports.d.ts +0 -4
  152. package/dist/types/wait.d.ts +0 -2
  153. package/dist/types/watch.d.ts +0 -8
  154. package/modern.config.js +0 -6
  155. package/tests/.eslintrc.js +0 -6
  156. package/tests/__snapshots__/prettyInstructions.test.ts.snap +0 -19
  157. package/tests/applyOptionsChain.test.ts +0 -100
  158. package/tests/compatRequire.test.ts +0 -32
  159. package/tests/debug.test.ts +0 -25
  160. package/tests/ensureAbsolutePath.test.ts +0 -16
  161. package/tests/findExists.test.ts +0 -22
  162. package/tests/fixtures/browserlist/develop/package.json +0 -11
  163. package/tests/fixtures/browserlist/dotfile/.browserslistrc +0 -3
  164. package/tests/fixtures/browserlist/pkg/package.json +0 -7
  165. package/tests/fixtures/compat-require/cjs.js +0 -1
  166. package/tests/fixtures/compat-require/empty.js +0 -1
  167. package/tests/fixtures/compat-require/esm.js +0 -5
  168. package/tests/fixtures/compat-require/foo.js +0 -3
  169. package/tests/fixtures/file-exists/a.ejs +0 -0
  170. package/tests/fixtures/file-exists/a.js/.gitkeep +0 -0
  171. package/tests/fixtures/file-exists/a.mjs +0 -0
  172. package/tests/fixtures/file-exists/a.ts +0 -0
  173. package/tests/format.test.ts +0 -60
  174. package/tests/generateMetaTags.test.ts +0 -19
  175. package/tests/getBrowserslist.test.ts +0 -32
  176. package/tests/getCacheIdentifier.test.ts +0 -37
  177. package/tests/getEntryOptions.test.ts +0 -53
  178. package/tests/index.test.ts +0 -18
  179. package/tests/is.test.ts +0 -27
  180. package/tests/isPlatform.test.ts +0 -19
  181. package/tests/isType.test.ts +0 -85
  182. package/tests/logger.test.ts +0 -53
  183. package/tests/prettyInstructions.test.ts +0 -139
  184. package/tests/removeSlash.test.ts +0 -19
  185. package/tests/tsconfig.json +0 -11
  186. 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, existSrc, checkedEntries } = appContext;
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 = existSrc
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) || !existSrc) {
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, it should be placed on top of the function`);
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.3.8-canary.0",
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
- "@babel/runtime": "^7",
67
+ "caniuse-lite": "^1.0.30001332",
60
68
  "typescript": "^4"
61
69
  },
62
70
  "devDependencies": {
63
- "@modern-js/types": "^1.3.6",
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,7 +0,0 @@
1
- /**
2
- * Generate cache identifier from some packages and config files.
3
- */
4
- export declare function getCacheIdentifier(packages: {
5
- name: string;
6
- version: string;
7
- }[], _files?: string[]): string;
@@ -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
- };
@@ -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
@@ -1,2 +0,0 @@
1
- import pkgUp from 'pkg-up';
2
- export { pkgUp };
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 };
@@ -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;
@@ -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');