@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.
Files changed (152) hide show
  1. package/CHANGELOG.md +28 -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/index.d.ts +186 -0
  38. package/compiled/globby/index.js +1 -0
  39. package/compiled/globby/license +9 -0
  40. package/compiled/globby/package.json +1 -0
  41. package/compiled/inquirer/index.d.ts +997 -0
  42. package/compiled/inquirer/index.js +9 -0
  43. package/compiled/inquirer/lib/objects/choice.d.ts +65 -0
  44. package/compiled/inquirer/lib/objects/choices.d.ts +206 -0
  45. package/compiled/inquirer/lib/objects/separator.d.ts +37 -0
  46. package/compiled/inquirer/lib/ui/baseUI.d.ts +37 -0
  47. package/compiled/inquirer/lib/ui/bottom-bar.d.ts +65 -0
  48. package/compiled/inquirer/lib/ui/prompt.d.ts +104 -0
  49. package/compiled/inquirer/license +22 -0
  50. package/compiled/inquirer/package.json +1 -0
  51. package/compiled/inquirer/through/index.d.ts +25 -0
  52. package/compiled/json5/index.js +1 -0
  53. package/compiled/json5/lib/index.d.ts +4 -0
  54. package/compiled/json5/lib/parse.d.ts +15 -0
  55. package/compiled/json5/lib/stringify.d.ts +89 -0
  56. package/compiled/json5/package.json +1 -0
  57. package/compiled/lodash/index.js +4 -8
  58. package/compiled/mime-types/index.d.ts +14 -0
  59. package/compiled/mime-types/index.js +14 -0
  60. package/compiled/mime-types/license +23 -0
  61. package/compiled/mime-types/package.json +1 -0
  62. package/compiled/minimist/index.d.ts +95 -0
  63. package/compiled/minimist/index.js +1 -0
  64. package/compiled/minimist/license +18 -0
  65. package/compiled/minimist/package.json +1 -0
  66. package/compiled/ora/cli-spinners/index.d.ts +125 -0
  67. package/compiled/ora/index.d.ts +277 -0
  68. package/compiled/ora/index.js +3 -0
  69. package/compiled/ora/license +9 -0
  70. package/compiled/ora/package.json +1 -0
  71. package/compiled/semver/classes/comparator.d.ts +17 -0
  72. package/compiled/semver/classes/range.d.ts +21 -0
  73. package/compiled/semver/classes/semver.d.ts +62 -0
  74. package/compiled/semver/functions/clean.d.ts +8 -0
  75. package/compiled/semver/functions/cmp.d.ts +16 -0
  76. package/compiled/semver/functions/coerce.d.ts +12 -0
  77. package/compiled/semver/functions/compare-build.d.ts +16 -0
  78. package/compiled/semver/functions/compare-loose.d.ts +5 -0
  79. package/compiled/semver/functions/compare.d.ts +20 -0
  80. package/compiled/semver/functions/diff.d.ts +13 -0
  81. package/compiled/semver/functions/eq.d.ts +9 -0
  82. package/compiled/semver/functions/gt.d.ts +9 -0
  83. package/compiled/semver/functions/gte.d.ts +9 -0
  84. package/compiled/semver/functions/inc.d.ts +15 -0
  85. package/compiled/semver/functions/lt.d.ts +9 -0
  86. package/compiled/semver/functions/lte.d.ts +8 -0
  87. package/compiled/semver/functions/major.d.ts +9 -0
  88. package/compiled/semver/functions/minor.d.ts +9 -0
  89. package/compiled/semver/functions/neq.d.ts +9 -0
  90. package/compiled/semver/functions/parse.d.ts +12 -0
  91. package/compiled/semver/functions/patch.d.ts +9 -0
  92. package/compiled/semver/functions/prerelease.d.ts +12 -0
  93. package/compiled/semver/functions/rcompare.d.ts +15 -0
  94. package/compiled/semver/functions/rsort.d.ts +9 -0
  95. package/compiled/semver/functions/satisfies.d.ts +14 -0
  96. package/compiled/semver/functions/sort.d.ts +9 -0
  97. package/compiled/semver/functions/valid.d.ts +11 -0
  98. package/compiled/semver/index.d.ts +133 -0
  99. package/compiled/semver/index.js +1 -0
  100. package/compiled/semver/internals/identifiers.d.ts +13 -0
  101. package/compiled/semver/license +15 -0
  102. package/compiled/semver/package.json +1 -0
  103. package/compiled/semver/ranges/gtr.d.ts +14 -0
  104. package/compiled/semver/ranges/intersects.d.ts +13 -0
  105. package/compiled/semver/ranges/ltr.d.ts +14 -0
  106. package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
  107. package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
  108. package/compiled/semver/ranges/min-version.d.ts +10 -0
  109. package/compiled/semver/ranges/outside.d.ts +15 -0
  110. package/compiled/semver/ranges/simplify.d.ts +14 -0
  111. package/compiled/semver/ranges/subset.d.ts +13 -0
  112. package/compiled/semver/ranges/to-comparators.d.ts +9 -0
  113. package/compiled/semver/ranges/valid.d.ts +12 -0
  114. package/compiled/slash/index.d.ts +25 -0
  115. package/compiled/slash/index.js +1 -0
  116. package/compiled/slash/license +9 -0
  117. package/compiled/slash/package.json +1 -0
  118. package/compiled/url-join/index.d.ts +17 -0
  119. package/compiled/url-join/index.js +1 -0
  120. package/compiled/url-join/license +21 -0
  121. package/compiled/url-join/package.json +1 -0
  122. package/dist/alias.js +4 -1
  123. package/dist/analyzeProject.js +4 -17
  124. package/dist/compiled.d.ts +34 -17
  125. package/dist/compiled.js +59 -21
  126. package/dist/emptyDir.js +4 -13
  127. package/dist/ensureAbsolutePath.d.ts +1 -1
  128. package/dist/ensureAbsolutePath.js +1 -1
  129. package/dist/findExists.d.ts +1 -1
  130. package/dist/findExists.js +1 -1
  131. package/dist/format.js +11 -6
  132. package/dist/getEntryOptions.js +2 -1
  133. package/dist/getPackageManager.js +19 -30
  134. package/dist/getPort.js +3 -12
  135. package/dist/getServerConfig.js +2 -11
  136. package/dist/index.d.ts +1 -2
  137. package/dist/index.js +1 -2
  138. package/dist/logger.d.ts +3 -0
  139. package/dist/logger.js +21 -6
  140. package/dist/monorepo.js +9 -6
  141. package/dist/nodeEnv.js +24 -39
  142. package/dist/prettyInstructions.js +1 -1
  143. package/dist/readTsConfig.js +2 -2
  144. package/dist/runtimeExports.js +1 -1
  145. package/dist/{ssrHelpers.d.ts → ssr.d.ts} +3 -0
  146. package/dist/{ssrHelpers.js → ssr.js} +0 -0
  147. package/dist/watch.js +9 -18
  148. package/package.json +33 -50
  149. package/tsconfig.json +1 -0
  150. package/dist/getCacheIdentifier.d.ts +0 -7
  151. package/dist/getCacheIdentifier.js +0 -24
  152. package/modern.config.js +0 -6
@@ -57,7 +57,7 @@ const prettyInstructions = (appContext, config) => {
57
57
  });
58
58
  message += '\n';
59
59
  message += compiled_1.chalk.cyanBright(' λ (Server) server-side renders at runtime\n');
60
- message += compiled_1.chalk.cyanBright(' ○ (Static) client-side rendered as static HTML\n');
60
+ message += compiled_1.chalk.cyanBright(' ○ (Static) client-side renders as static HTML\n');
61
61
  }
62
62
  return message;
63
63
  };
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.readTsConfigByFile = exports.readTsConfig = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const readTsConfig = (root) => {
9
- // import typescript from 'typescript' cause eslint fromat error.
9
+ // import typescript from 'typescript' cause eslint format error.
10
10
  const typescript = require('typescript');
11
11
  return typescript.readConfigFile(path_1.default.resolve(root, './tsconfig.json'), typescript.sys.readFile).config;
12
12
  };
13
13
  exports.readTsConfig = readTsConfig;
14
14
  const readTsConfigByFile = (filename) => {
15
- // import typescript from 'typescript' cause eslint fromat error.
15
+ // import typescript from 'typescript' cause eslint format error.
16
16
  const typescript = require('typescript');
17
17
  return typescript.readConfigFile(path_1.default.resolve(filename), typescript.sys.readFile).config;
18
18
  };
@@ -41,7 +41,7 @@ exports.createRuntimeExportsUtils = memo((pwd = '', namespace, ts = false) => {
41
41
  compiled_1.fs.appendFileSync(entryExportTsFile, `${statement.replace('.js', '.d')}\n`);
42
42
  }
43
43
  }
44
- catch (_a) {
44
+ catch {
45
45
  // FIXME:
46
46
  }
47
47
  };
@@ -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/watch.js CHANGED
@@ -18,15 +18,6 @@ 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.watch = exports.WatchChangeType = void 0;
32
23
  const path = __importStar(require("path"));
@@ -42,20 +33,20 @@ const watch = (watchDir, runTask, ignored = []) => {
42
33
  ignored,
43
34
  });
44
35
  watcher.on('ready', () => (ready = true));
45
- watcher.on('change', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
36
+ watcher.on('change', async (filePath) => {
46
37
  const changedFilePath = path.resolve(filePath);
47
- yield runTask({ changedFilePath, changeType: exports.WatchChangeType.CHANGE });
48
- }));
49
- watcher.on('add', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
38
+ await runTask({ changedFilePath, changeType: exports.WatchChangeType.CHANGE });
39
+ });
40
+ watcher.on('add', async (filePath) => {
50
41
  const changedFilePath = path.resolve(filePath);
51
42
  if (ready) {
52
- yield runTask({ changedFilePath, changeType: exports.WatchChangeType.ADD });
43
+ await runTask({ changedFilePath, changeType: exports.WatchChangeType.ADD });
53
44
  }
54
- }));
55
- watcher.on('unlink', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
45
+ });
46
+ watcher.on('unlink', async (filePath) => {
56
47
  const changedFilePath = path.resolve(filePath);
57
- yield runTask({ changedFilePath, changeType: exports.WatchChangeType.UNLINK });
58
- }));
48
+ await runTask({ changedFilePath, changeType: exports.WatchChangeType.UNLINK });
49
+ });
59
50
  watcher.on('error', err => {
60
51
  throw err;
61
52
  });
package/package.json CHANGED
@@ -11,33 +11,18 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.5.0",
14
+ "version": "1.7.1-alpha.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
- "jsnext:source": "./src/index.ts",
23
- "default": "./dist/index.js"
24
- },
25
- "./format": {
26
- "jsnext:source": "./src/format.ts",
27
- "default": "./dist/format.js"
28
- },
29
- "./constants": {
30
- "jsnext:source": "./src/constants.ts",
31
- "default": "./dist/constants.js"
32
- },
33
- "./lodash": {
34
- "jsnext:source": "./compiled/lodash/index.js",
35
- "default": "./compiled/lodash/index.js"
36
- },
37
- "./strip-ansi": {
38
- "jsnext:source": "./compiled/strip-ansi/index.js",
39
- "default": "./compiled/strip-ansi/index.js"
40
- }
22
+ ".": "./dist/index.js",
23
+ "./format": "./dist/format.js",
24
+ "./constants": "./dist/constants.js",
25
+ "./ssr": "./dist/ssr.js"
41
26
  },
42
27
  "typesVersions": {
43
28
  "*": {
@@ -47,52 +32,50 @@
47
32
  "constants": [
48
33
  "./dist/constants.d.ts"
49
34
  ],
35
+ "ssr": [
36
+ "./dist/ssr.d.ts"
37
+ ],
38
+ "chalk": [
39
+ "./compiled/chalk/index.d.ts"
40
+ ],
41
+ "json5": [
42
+ "./compiled/json5/index.d.ts"
43
+ ],
44
+ "semver": [
45
+ "./compiled/semver/index.d.ts"
46
+ ],
50
47
  "lodash": [
51
48
  "./compiled/lodash/index.d.ts"
52
49
  ],
50
+ "globby": [
51
+ "./compiled/globby/index.d.ts"
52
+ ],
53
+ "fast-glob": [
54
+ "./compiled/fast-glob/index.d.ts"
55
+ ],
56
+ "gzip-size": [
57
+ "./compiled/gzip-size/index.d.ts"
58
+ ],
59
+ "mime-types": [
60
+ "./compiled/mime-types/index.d.ts"
61
+ ],
53
62
  "strip-ansi": [
54
63
  "./compiled/strip-ansi/index.d.ts"
55
64
  ]
56
65
  }
57
66
  },
58
67
  "dependencies": {
59
- "@babel/runtime": "^7",
60
- "minimist": "^1.2.0",
68
+ "caniuse-lite": "^1.0.30001332",
69
+ "lodash": "^4.17.21",
61
70
  "typescript": "^4"
62
71
  },
63
72
  "devDependencies": {
64
- "@modern-js/types": "^1.5.0",
73
+ "@modern-js/types": "1.5.2",
65
74
  "@scripts/build": "0.0.0",
66
75
  "@scripts/jest-config": "0.0.0",
67
- "@types/debug": "4.1.7",
68
- "@types/fs-extra": "9.0.13",
69
- "@types/glob": "^7.1.4",
70
76
  "@types/jest": "^26",
71
- "@types/js-yaml": "4.0.5",
72
- "@types/lodash": "4.14.181",
73
- "@types/minimist": "^1.2.2",
74
77
  "@types/node": "^14",
75
- "@types/recursive-readdir": "2.2.0",
76
- "@types/signale": "1.4.4",
77
- "browserslist": "4.20.2",
78
- "chalk": "4.1.2",
79
- "chokidar": "3.5.3",
80
- "commander": "8.3.0",
81
- "debug": "4.3.4",
82
- "execa": "5.1.1",
83
- "filesize": "8.0.7",
84
- "fs-extra": "10.0.1",
85
- "glob": "7.2.0",
86
- "gzip-size": "6.0.0",
87
- "import-lazy": "4.0.0",
88
78
  "jest": "^27",
89
- "js-yaml": "4.1.0",
90
- "lodash": "4.17.21",
91
- "pkg-up": "3.1.0",
92
- "recursive-readdir": "2.2.2",
93
- "signale": "1.4.0",
94
- "strip-ansi": "6.0.1",
95
- "upath": "2.0.1",
96
79
  "webpack": "^5.71.0"
97
80
  },
98
81
  "sideEffects": false,
package/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "extends": "@modern-js/tsconfig/base",
3
3
  "compilerOptions": {
4
+ "target": "ES2019",
4
5
  "declaration": true,
5
6
  "outDir": "./dist",
6
7
  "baseUrl": "./",
@@ -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;
package/modern.config.js DELETED
@@ -1,6 +0,0 @@
1
- /** @type {import('@modern-js/module-tools').UserConfig} */
2
- module.exports = {
3
- output: {
4
- disableSourceMap: true,
5
- },
6
- };