@modern-js/utils 2.26.0 → 2.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/cli/alias.js +3 -3
  3. package/dist/cjs/cli/constants/chainId.js +4 -0
  4. package/dist/cjs/cli/constants/index.js +0 -1
  5. package/dist/cjs/cli/is/config.js +11 -8
  6. package/dist/cjs/cli/prettyInstructions.js +3 -2
  7. package/dist/cjs/cli/require.js +2 -1
  8. package/dist/cjs/runtime/nestedRoutes.js +9 -5
  9. package/dist/cjs/runtime-browser/parsed.js +2 -1
  10. package/dist/cjs/universal/formatWebpack.js +55 -12
  11. package/dist/esm/cli/alias.js +27 -23
  12. package/dist/esm/cli/applyOptionsChain.js +8 -6
  13. package/dist/esm/cli/babel.js +50 -35
  14. package/dist/esm/cli/commands.js +7 -7
  15. package/dist/esm/cli/common.js +10 -5
  16. package/dist/esm/cli/constants/chainId.js +5 -1
  17. package/dist/esm/cli/constants/index.js +33 -38
  18. package/dist/esm/cli/ensure.js +4 -2
  19. package/dist/esm/cli/fs.js +56 -9
  20. package/dist/esm/cli/get/config.js +7 -7
  21. package/dist/esm/cli/get/data.js +102 -55
  22. package/dist/esm/cli/get/index.js +21 -6
  23. package/dist/esm/cli/is/config.js +43 -21
  24. package/dist/esm/cli/is/env.js +18 -6
  25. package/dist/esm/cli/is/platform.js +6 -2
  26. package/dist/esm/cli/is/project.js +73 -36
  27. package/dist/esm/cli/is/type.js +3 -1
  28. package/dist/esm/cli/logger.js +49 -38
  29. package/dist/esm/cli/monorepo.js +49 -36
  30. package/dist/esm/cli/package.js +156 -38
  31. package/dist/esm/cli/path.js +44 -20
  32. package/dist/esm/cli/pathSerializer.js +29 -15
  33. package/dist/esm/cli/port.js +89 -40
  34. package/dist/esm/cli/prettyInstructions.js +44 -32
  35. package/dist/esm/cli/require.js +22 -16
  36. package/dist/esm/cli/runtimeExports.js +21 -15
  37. package/dist/esm/cli/watch.js +94 -27
  38. package/dist/esm/compiled.js +3 -3
  39. package/dist/esm/import.js +4 -4
  40. package/dist/esm/runtime/nestedRoutes.js +49 -32
  41. package/dist/esm/runtime-browser/parsed.js +6 -5
  42. package/dist/esm/runtime-node/index.js +1 -1
  43. package/dist/esm/runtime-node/nestedRoutes.js +6 -4
  44. package/dist/esm/runtime-node/serialize.js +1 -1
  45. package/dist/esm/runtime-node/storage.js +12 -14
  46. package/dist/esm/universal/constants.js +3 -3
  47. package/dist/esm/universal/formatWebpack.js +54 -28
  48. package/dist/esm/universal/pluginDagSort.js +49 -26
  49. package/dist/esm-node/cli/alias.js +51 -0
  50. package/dist/esm-node/cli/applyOptionsChain.js +24 -0
  51. package/dist/esm-node/cli/babel.js +103 -0
  52. package/dist/esm-node/cli/commands.js +16 -0
  53. package/dist/esm-node/cli/common.js +10 -0
  54. package/dist/esm-node/cli/constants/chainId.js +184 -0
  55. package/dist/esm-node/cli/constants/index.js +102 -0
  56. package/dist/esm-node/cli/ensure.js +10 -0
  57. package/dist/esm-node/cli/fs.js +14 -0
  58. package/dist/esm-node/cli/get/config.js +16 -0
  59. package/dist/esm-node/cli/get/data.js +86 -0
  60. package/dist/esm-node/cli/get/index.js +13 -0
  61. package/dist/esm-node/cli/index.js +20 -0
  62. package/dist/esm-node/cli/is/config.js +43 -0
  63. package/dist/esm-node/cli/is/env.js +6 -0
  64. package/dist/esm-node/cli/is/index.js +5 -0
  65. package/dist/esm-node/cli/is/platform.js +2 -0
  66. package/dist/esm-node/cli/is/project.js +73 -0
  67. package/dist/esm-node/cli/is/type.js +25 -0
  68. package/dist/esm-node/cli/logger.js +103 -0
  69. package/dist/esm-node/cli/monorepo.js +70 -0
  70. package/dist/esm-node/cli/package.js +43 -0
  71. package/dist/esm-node/cli/path.js +49 -0
  72. package/dist/esm-node/cli/pathSerializer.js +46 -0
  73. package/dist/esm-node/cli/port.js +44 -0
  74. package/dist/esm-node/cli/prettyInstructions.js +78 -0
  75. package/dist/esm-node/cli/require.js +53 -0
  76. package/dist/esm-node/cli/runtimeExports.js +35 -0
  77. package/dist/esm-node/cli/watch.js +41 -0
  78. package/dist/esm-node/compiled.js +33 -0
  79. package/dist/esm-node/import.js +8 -0
  80. package/dist/esm-node/index.js +3 -0
  81. package/dist/esm-node/runtime/nestedRoutes.js +116 -0
  82. package/dist/esm-node/runtime/remixRouter.js +1 -0
  83. package/dist/esm-node/runtime/router.js +1 -0
  84. package/dist/esm-node/runtime-browser/index.js +1 -0
  85. package/dist/esm-node/runtime-browser/parsed.js +18 -0
  86. package/dist/esm-node/runtime-node/index.js +5 -0
  87. package/dist/esm-node/runtime-node/nestedRoutes.js +18 -0
  88. package/dist/esm-node/runtime-node/router.js +1 -0
  89. package/dist/esm-node/runtime-node/serialize.js +6 -0
  90. package/dist/esm-node/runtime-node/storage.js +38 -0
  91. package/dist/esm-node/universal/constants.js +3 -0
  92. package/dist/esm-node/universal/formatWebpack.js +99 -0
  93. package/dist/esm-node/universal/pluginDagSort.js +50 -0
  94. package/dist/types/cli/constants/chainId.d.ts +4 -0
  95. package/dist/types/universal/formatWebpack.d.ts +14 -1
  96. package/package.json +4 -4
@@ -1,21 +1,24 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
1
4
  import path from "path";
2
5
  import pkgUp from "../../../compiled/pkg-up";
3
6
  import { getArgv } from "../commands";
4
7
  import { fs, minimist, semver } from "../../compiled";
5
8
  import { createDebugger } from "../common";
6
9
  import { ensureArray } from "../ensure";
7
- const debug = createDebugger("judge-depExists");
8
- export const isDepExists = (appDirectory, name) => {
9
- const pkgPath = path.resolve(appDirectory, "./package.json");
10
+ var debug = createDebugger("judge-depExists");
11
+ export var isDepExists = function(appDirectory, name) {
12
+ var pkgPath = path.resolve(appDirectory, "./package.json");
10
13
  if (!fs.existsSync(pkgPath)) {
11
- debug(`can't find package.json under: %s`, appDirectory);
14
+ debug("can't find package.json under: %s", appDirectory);
12
15
  return false;
13
16
  }
14
- const json = require(pkgPath);
15
- const { dependencies = {}, devDependencies = {} } = json;
17
+ var json = require(pkgPath);
18
+ var _json_dependencies = json.dependencies, dependencies = _json_dependencies === void 0 ? {} : _json_dependencies, _json_devDependencies = json.devDependencies, devDependencies = _json_devDependencies === void 0 ? {} : _json_devDependencies;
16
19
  return dependencies.hasOwnProperty(name) || devDependencies.hasOwnProperty(name);
17
20
  };
18
- export const isPackageInstalled = (name, resolvePaths) => {
21
+ export var isPackageInstalled = function(name, resolvePaths) {
19
22
  try {
20
23
  require.resolve(name, {
21
24
  paths: ensureArray(resolvePaths)
@@ -25,49 +28,83 @@ export const isPackageInstalled = (name, resolvePaths) => {
25
28
  return false;
26
29
  }
27
30
  };
28
- export const isApiOnly = async (appDirectory, entryDir, apiDir) => {
29
- const existApi = await fs.pathExists(apiDir !== null && apiDir !== void 0 ? apiDir : path.join(appDirectory, "api"));
30
- const existSrc = await fs.pathExists(path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src"));
31
- const options = minimist(getArgv());
32
- if (options["api-only"]) {
33
- return true;
34
- }
35
- return existApi && !existSrc;
36
- };
37
- export const isWebOnly = async () => {
38
- const options = minimist(getArgv());
39
- return Boolean(options["web-only"]);
40
- };
41
- export const isBeyondReact17 = (cwd) => {
42
- const pkgPath = pkgUp.sync({
43
- cwd
31
+ export var isApiOnly = function() {
32
+ var _ref = _async_to_generator(function(appDirectory, entryDir, apiDir) {
33
+ var existApi, existSrc, options;
34
+ return _ts_generator(this, function(_state) {
35
+ switch (_state.label) {
36
+ case 0:
37
+ return [
38
+ 4,
39
+ fs.pathExists(apiDir !== null && apiDir !== void 0 ? apiDir : path.join(appDirectory, "api"))
40
+ ];
41
+ case 1:
42
+ existApi = _state.sent();
43
+ return [
44
+ 4,
45
+ fs.pathExists(path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src"))
46
+ ];
47
+ case 2:
48
+ existSrc = _state.sent();
49
+ options = minimist(getArgv());
50
+ if (options["api-only"]) {
51
+ return [
52
+ 2,
53
+ true
54
+ ];
55
+ }
56
+ return [
57
+ 2,
58
+ existApi && !existSrc
59
+ ];
60
+ }
61
+ });
62
+ });
63
+ return function isApiOnly2(appDirectory, entryDir, apiDir) {
64
+ return _ref.apply(this, arguments);
65
+ };
66
+ }();
67
+ export var isWebOnly = function() {
68
+ var _ref = _async_to_generator(function() {
69
+ var options;
70
+ return _ts_generator(this, function(_state) {
71
+ options = minimist(getArgv());
72
+ return [
73
+ 2,
74
+ Boolean(options["web-only"])
75
+ ];
76
+ });
77
+ });
78
+ return function isWebOnly2() {
79
+ return _ref.apply(this, arguments);
80
+ };
81
+ }();
82
+ export var isBeyondReact17 = function(cwd) {
83
+ var pkgPath = pkgUp.sync({
84
+ cwd: cwd
44
85
  });
45
86
  if (!pkgPath) {
46
87
  return false;
47
88
  }
48
- const pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
49
- const deps = {
50
- ...pkgInfo.devDependencies,
51
- ...pkgInfo.dependencies
52
- };
89
+ var pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
90
+ var deps = _object_spread({}, pkgInfo.devDependencies, pkgInfo.dependencies);
53
91
  if (typeof deps.react !== "string") {
54
92
  return false;
55
93
  }
56
94
  return semver.satisfies(semver.minVersion(deps.react), ">=17.0.0");
57
95
  };
58
- export const isReact18 = (cwd) => {
59
- const pkgPath = path.join(cwd, "package.json");
96
+ export var isReact18 = function(cwd) {
97
+ var pkgPath = path.join(cwd, "package.json");
60
98
  if (!fs.existsSync(pkgPath)) {
61
99
  return false;
62
100
  }
63
- const pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
64
- const deps = {
65
- ...pkgInfo.devDependencies,
66
- ...pkgInfo.dependencies
67
- };
101
+ var pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
102
+ var deps = _object_spread({}, pkgInfo.devDependencies, pkgInfo.dependencies);
68
103
  if (typeof deps.react !== "string") {
69
104
  return false;
70
105
  }
71
106
  return semver.satisfies(semver.minVersion(deps.react), ">=18.0.0");
72
107
  };
73
- export const isTypescript = (root) => fs.existsSync(path.resolve(root, "./tsconfig.json"));
108
+ export var isTypescript = function(root) {
109
+ return fs.existsSync(path.resolve(root, "./tsconfig.json"));
110
+ };
@@ -22,4 +22,6 @@ export function isPromise(obj) {
22
22
  export function isRegExp(obj) {
23
23
  return Object.prototype.toString.call(obj) === "[object RegExp]";
24
24
  }
25
- export const isEmpty = (o) => Object.entries(o).length === 0 && o.constructor === Object;
25
+ export var isEmpty = function(o) {
26
+ return Object.entries(o).length === 0 && o.constructor === Object;
27
+ };
@@ -1,12 +1,17 @@
1
+ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
2
+ import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
3
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
4
+ import { _ as _to_array } from "@swc/helpers/_/_to_array";
5
+ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
1
6
  import chalk from "../../compiled/chalk";
2
- const LOG_LEVEL = {
7
+ var LOG_LEVEL = {
3
8
  error: 0,
4
9
  warn: 1,
5
10
  info: 2,
6
11
  debug: 3,
7
12
  log: 4
8
13
  };
9
- const LOG_TYPES = {
14
+ var LOG_TYPES = {
10
15
  error: {
11
16
  color: "red",
12
17
  label: "error",
@@ -36,12 +41,30 @@ const LOG_TYPES = {
36
41
  level: "log"
37
42
  }
38
43
  };
39
- const DEFAULT_CONFIG = {
44
+ var DEFAULT_CONFIG = {
40
45
  displayLabel: true,
41
46
  uppercaseLabel: false
42
47
  };
43
- class Logger {
44
- _log(type, message, ...args) {
48
+ var Logger = /* @__PURE__ */ function() {
49
+ "use strict";
50
+ function Logger2() {
51
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
52
+ var _this = this;
53
+ _class_call_check(this, Logger2);
54
+ this.level = options.level || LOG_TYPES.log.level;
55
+ this.config = _object_spread({}, DEFAULT_CONFIG, options.config || {});
56
+ this.types = _object_spread({}, LOG_TYPES, options.types || {});
57
+ this.longestLabel = this.getLongestLabel();
58
+ Object.keys(this.types).forEach(function(type) {
59
+ _this[type] = _this._log.bind(_this, type);
60
+ });
61
+ }
62
+ var _proto = Logger2.prototype;
63
+ _proto._log = function _log(type, message) {
64
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
65
+ args[_key - 2] = arguments[_key];
66
+ }
67
+ var _console;
45
68
  if (message === void 0 || message === null) {
46
69
  console.log();
47
70
  return;
@@ -49,55 +72,43 @@ class Logger {
49
72
  if (LOG_LEVEL[type] > LOG_LEVEL[this.level]) {
50
73
  return;
51
74
  }
52
- let label = "";
53
- let text = "";
54
- const logType = this.types[type];
75
+ var label = "";
76
+ var text = "";
77
+ var logType = this.types[type];
55
78
  if (this.config.displayLabel && logType.label) {
56
79
  label = this.config.uppercaseLabel ? logType.label.toUpperCase() : logType.label;
57
80
  label = label.padEnd(this.longestLabel.length);
58
81
  label = chalk.bold(logType.color ? chalk[logType.color](label) : label);
59
82
  }
60
- if (message instanceof Error) {
83
+ if (_instanceof(message, Error)) {
61
84
  if (message.stack) {
62
- const [name, ...rest] = message.stack.split("\n");
63
- text = `${name}
64
- ${chalk.grey(rest.join("\n"))}`;
85
+ var _message_stack_split = _to_array(message.stack.split("\n")), name = _message_stack_split[0], rest = _message_stack_split.slice(1);
86
+ text = "".concat(name, "\n").concat(chalk.grey(rest.join("\n")));
65
87
  } else {
66
88
  text = message.message;
67
89
  }
68
90
  } else {
69
- text = `${message}`;
91
+ text = "".concat(message);
70
92
  }
71
- const log = label.length > 0 ? `${label} ${text}` : text;
72
- console.log(log, ...args);
73
- }
74
- getLongestLabel() {
75
- let longestLabel = "";
76
- Object.keys(this.types).forEach((type) => {
77
- const { label = "" } = this.types[type];
93
+ var log = label.length > 0 ? "".concat(label, " ").concat(text) : text;
94
+ (_console = console).log.apply(_console, [
95
+ log
96
+ ].concat(_to_consumable_array(args)));
97
+ };
98
+ _proto.getLongestLabel = function getLongestLabel() {
99
+ var _this = this;
100
+ var longestLabel = "";
101
+ Object.keys(this.types).forEach(function(type) {
102
+ var _this_types_type = _this.types[type], _this_types_type_label = _this_types_type.label, label = _this_types_type_label === void 0 ? "" : _this_types_type_label;
78
103
  if (label.length > longestLabel.length) {
79
104
  longestLabel = label;
80
105
  }
81
106
  });
82
107
  return longestLabel;
83
- }
84
- constructor(options = {}) {
85
- this.level = options.level || LOG_TYPES.log.level;
86
- this.config = {
87
- ...DEFAULT_CONFIG,
88
- ...options.config || {}
89
- };
90
- this.types = {
91
- ...LOG_TYPES,
92
- ...options.types || {}
93
- };
94
- this.longestLabel = this.getLongestLabel();
95
- Object.keys(this.types).forEach((type) => {
96
- this[type] = this._log.bind(this, type);
97
- });
98
- }
99
- }
100
- const logger = new Logger();
108
+ };
109
+ return Logger2;
110
+ }();
111
+ var logger = new Logger();
101
112
  logger.Logger = Logger;
102
113
  export { Logger };
103
114
  export { logger };
@@ -1,39 +1,44 @@
1
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
1
2
  import fs from "fs";
2
3
  import path from "path";
3
4
  import { glob, yaml } from "../compiled";
4
- const PACKAGE_MAX_DEPTH = 5;
5
- const WORKSPACE_FILES = {
5
+ var PACKAGE_MAX_DEPTH = 5;
6
+ var WORKSPACE_FILES = {
6
7
  YARN: "package.json",
7
8
  PNPM: "pnpm-workspace.yaml",
8
9
  LERNA: "lerna.json"
9
10
  };
10
- export const isLerna = (root) => fs.existsSync(path.join(root, WORKSPACE_FILES.LERNA));
11
- export const isYarnWorkspaces = (root) => {
11
+ export var isLerna = function(root) {
12
+ return fs.existsSync(path.join(root, WORKSPACE_FILES.LERNA));
13
+ };
14
+ export var isYarnWorkspaces = function(root) {
12
15
  var _json_workspaces;
13
- const pkg = path.join(root, WORKSPACE_FILES.YARN);
16
+ var pkg = path.join(root, WORKSPACE_FILES.YARN);
14
17
  if (!fs.existsSync(pkg)) {
15
18
  return false;
16
19
  }
17
- const json = JSON.parse(fs.readFileSync(pkg, "utf8"));
20
+ var json = JSON.parse(fs.readFileSync(pkg, "utf8"));
18
21
  return Boolean((_json_workspaces = json.workspaces) === null || _json_workspaces === void 0 ? void 0 : _json_workspaces.packages);
19
22
  };
20
- export const isPnpmWorkspaces = (root) => fs.existsSync(path.join(root, WORKSPACE_FILES.PNPM));
21
- export const isMonorepo = (root) => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
22
- export const isModernjsMonorepo = (root) => {
23
- const pkgJsonPath = path.join(root, "package.json");
23
+ export var isPnpmWorkspaces = function(root) {
24
+ return fs.existsSync(path.join(root, WORKSPACE_FILES.PNPM));
25
+ };
26
+ export var isMonorepo = function(root) {
27
+ return isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
28
+ };
29
+ export var isModernjsMonorepo = function(root) {
30
+ var pkgJsonPath = path.join(root, "package.json");
24
31
  if (!fs.existsSync(pkgJsonPath)) {
25
32
  return false;
26
33
  }
27
- const json = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
28
- const deps = {
29
- ...json.dependencies || {},
30
- ...json.devDependencies || {}
31
- };
34
+ var json = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
35
+ var deps = _object_spread({}, json.dependencies || {}, json.devDependencies || {});
32
36
  return Boolean(deps["@modern-js/monorepo-tools"]);
33
37
  };
34
- export const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
35
- let inMonorepo = false;
36
- for (let depth = 0; depth < maxDepth; depth++) {
38
+ export var findMonorepoRoot = function(appDirectory) {
39
+ var maxDepth = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : PACKAGE_MAX_DEPTH;
40
+ var inMonorepo = false;
41
+ for (var depth = 0; depth < maxDepth; depth++) {
37
42
  if (isMonorepo(appDirectory)) {
38
43
  inMonorepo = true;
39
44
  break;
@@ -42,29 +47,37 @@ export const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) =>
42
47
  }
43
48
  return inMonorepo ? appDirectory : void 0;
44
49
  };
45
- export const getMonorepoPackages = (root) => {
46
- let packages = [];
50
+ export var getMonorepoPackages = function(root) {
51
+ var packages = [];
47
52
  if (isYarnWorkspaces(root)) {
48
- const json = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
49
- ({ packages } = json.workspaces);
53
+ var json = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
54
+ packages = json.workspaces.packages;
50
55
  } else if (isLerna(root)) {
51
- const json = JSON.parse(fs.readFileSync(path.resolve(root, "lerna.json"), "utf8"));
52
- ({ packages } = json);
56
+ var json1 = JSON.parse(fs.readFileSync(path.resolve(root, "lerna.json"), "utf8"));
57
+ packages = json1.packages;
53
58
  } else {
54
- ({ packages } = yaml.load(fs.readFileSync(path.join(root, WORKSPACE_FILES.PNPM), "utf8")));
59
+ packages = yaml.load(fs.readFileSync(path.join(root, WORKSPACE_FILES.PNPM), "utf8")).packages;
55
60
  }
56
61
  if (packages) {
57
- return packages.map((name) => (
58
- // The trailing / ensures only dirs are picked up
59
- glob.sync(path.join(root, `${name}/`), {
60
- ignore: [
61
- "**/node_modules/**"
62
- ]
63
- })
64
- )).reduce((acc, val) => acc.concat(val), []).filter((filepath) => fs.existsSync(path.resolve(filepath, "package.json"))).map((filepath) => ({
65
- path: filepath,
66
- name: JSON.parse(fs.readFileSync(path.resolve(filepath, "package.json"), "utf8")).name
67
- }));
62
+ return packages.map(function(name) {
63
+ return (
64
+ // The trailing / ensures only dirs are picked up
65
+ glob.sync(path.join(root, "".concat(name, "/")), {
66
+ ignore: [
67
+ "**/node_modules/**"
68
+ ]
69
+ })
70
+ );
71
+ }).reduce(function(acc, val) {
72
+ return acc.concat(val);
73
+ }, []).filter(function(filepath) {
74
+ return fs.existsSync(path.resolve(filepath, "package.json"));
75
+ }).map(function(filepath) {
76
+ return {
77
+ path: filepath,
78
+ name: JSON.parse(fs.readFileSync(path.resolve(filepath, "package.json"), "utf8")).name
79
+ };
80
+ });
68
81
  }
69
82
  return [];
70
83
  };
@@ -1,43 +1,161 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
1
3
  import { execa } from "../compiled";
2
- export async function getPnpmVersion() {
3
- const { stdout } = await execa("pnpm", [
4
- "--version"
5
- ]);
6
- return stdout;
7
- }
8
- export async function canUseNpm() {
9
- try {
10
- await execa("npm", [
11
- "--version"
12
- ], {
13
- env: process.env
4
+ export function getPnpmVersion() {
5
+ return _getPnpmVersion.apply(this, arguments);
6
+ }
7
+ function _getPnpmVersion() {
8
+ _getPnpmVersion = _async_to_generator(function() {
9
+ var stdout;
10
+ return _ts_generator(this, function(_state) {
11
+ switch (_state.label) {
12
+ case 0:
13
+ return [
14
+ 4,
15
+ execa("pnpm", [
16
+ "--version"
17
+ ])
18
+ ];
19
+ case 1:
20
+ stdout = _state.sent().stdout;
21
+ return [
22
+ 2,
23
+ stdout
24
+ ];
25
+ }
26
+ });
27
+ });
28
+ return _getPnpmVersion.apply(this, arguments);
29
+ }
30
+ export function canUseNpm() {
31
+ return _canUseNpm.apply(this, arguments);
32
+ }
33
+ function _canUseNpm() {
34
+ _canUseNpm = _async_to_generator(function() {
35
+ var e;
36
+ return _ts_generator(this, function(_state) {
37
+ switch (_state.label) {
38
+ case 0:
39
+ _state.trys.push([
40
+ 0,
41
+ 2,
42
+ ,
43
+ 3
44
+ ]);
45
+ return [
46
+ 4,
47
+ execa("npm", [
48
+ "--version"
49
+ ], {
50
+ env: process.env
51
+ })
52
+ ];
53
+ case 1:
54
+ _state.sent();
55
+ return [
56
+ 2,
57
+ true
58
+ ];
59
+ case 2:
60
+ e = _state.sent();
61
+ return [
62
+ 2,
63
+ false
64
+ ];
65
+ case 3:
66
+ return [
67
+ 2
68
+ ];
69
+ }
14
70
  });
15
- return true;
16
- } catch (e) {
17
- return false;
18
- }
19
- }
20
- export async function canUseYarn() {
21
- try {
22
- await execa("yarn", [
23
- "--version"
24
- ], {
25
- env: process.env
71
+ });
72
+ return _canUseNpm.apply(this, arguments);
73
+ }
74
+ export function canUseYarn() {
75
+ return _canUseYarn.apply(this, arguments);
76
+ }
77
+ function _canUseYarn() {
78
+ _canUseYarn = _async_to_generator(function() {
79
+ var e;
80
+ return _ts_generator(this, function(_state) {
81
+ switch (_state.label) {
82
+ case 0:
83
+ _state.trys.push([
84
+ 0,
85
+ 2,
86
+ ,
87
+ 3
88
+ ]);
89
+ return [
90
+ 4,
91
+ execa("yarn", [
92
+ "--version"
93
+ ], {
94
+ env: process.env
95
+ })
96
+ ];
97
+ case 1:
98
+ _state.sent();
99
+ return [
100
+ 2,
101
+ true
102
+ ];
103
+ case 2:
104
+ e = _state.sent();
105
+ return [
106
+ 2,
107
+ false
108
+ ];
109
+ case 3:
110
+ return [
111
+ 2
112
+ ];
113
+ }
26
114
  });
27
- return true;
28
- } catch (e) {
29
- return false;
30
- }
31
- }
32
- export async function canUsePnpm() {
33
- try {
34
- await execa("pnpm", [
35
- "--version"
36
- ], {
37
- env: process.env
115
+ });
116
+ return _canUseYarn.apply(this, arguments);
117
+ }
118
+ export function canUsePnpm() {
119
+ return _canUsePnpm.apply(this, arguments);
120
+ }
121
+ function _canUsePnpm() {
122
+ _canUsePnpm = _async_to_generator(function() {
123
+ var e;
124
+ return _ts_generator(this, function(_state) {
125
+ switch (_state.label) {
126
+ case 0:
127
+ _state.trys.push([
128
+ 0,
129
+ 2,
130
+ ,
131
+ 3
132
+ ]);
133
+ return [
134
+ 4,
135
+ execa("pnpm", [
136
+ "--version"
137
+ ], {
138
+ env: process.env
139
+ })
140
+ ];
141
+ case 1:
142
+ _state.sent();
143
+ return [
144
+ 2,
145
+ true
146
+ ];
147
+ case 2:
148
+ e = _state.sent();
149
+ return [
150
+ 2,
151
+ false
152
+ ];
153
+ case 3:
154
+ return [
155
+ 2
156
+ ];
157
+ }
38
158
  });
39
- return true;
40
- } catch (e) {
41
- return false;
42
- }
159
+ });
160
+ return _canUsePnpm.apply(this, arguments);
43
161
  }