@aomex/console 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @aomex/console
2
2
 
3
+ ## 0.0.28
4
+
5
+ ### Patch Changes
6
+
7
+ - [`95fd705`](https://github.com/aomex/aomex/commit/95fd705d2ac24f4a3c14446ccb9de6eb6817d0cd) Thanks [@geekact](https://github.com/geekact)! - refactor(console): 命令行入口直接引入ts-node执行ts文件,废弃子进程模式
8
+
9
+ - Updated dependencies [[`7b09277`](https://github.com/aomex/aomex/commit/7b09277136910966f500c8132303c7ddee84340c), [`9c78999`](https://github.com/aomex/aomex/commit/9c78999ebcb2962f30344acfbf6de0733d6fdd41), [`f4b012d`](https://github.com/aomex/aomex/commit/f4b012d98cddb2918479ea05df6c266dd914e53a)]:
10
+ - @aomex/core@0.0.23
11
+
3
12
  ## 0.0.27
4
13
 
5
14
  ### Patch Changes
package/dist/bin.js CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  // src/bin.ts
4
4
  import path, { basename } from "node:path";
5
- import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import { pathToFileURL } from "node:url";
6
6
  import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
7
7
  import { hideBin } from "yargs/helpers";
8
- import { spawnSync } from "node:child_process";
9
8
  import { chalk } from "@aomex/core";
9
+ import tsNode from "ts-node/dist/bin";
10
10
  var configFile = path.resolve("aomex.json");
11
11
  {
12
12
  const defaultConfig = {
@@ -19,27 +19,21 @@ var configFile = path.resolve("aomex.json");
19
19
  const args = hideBin(process.argv);
20
20
  if (args.length === 1 && args[0] === "--init") {
21
21
  if (existsSync(configFile)) {
22
- console.warn(
23
- chalk.yellow("Your configuration file had been generated already!")
24
- );
22
+ console.warn(chalk.yellow("\u914D\u7F6E\u6587\u4EF6aomex.json\u5DF2\u7ECF\u5B58\u5728\uFF0C\u8BF7\u52FF\u91CD\u590D\u64CD\u4F5C"));
25
23
  process.exit(0);
26
24
  }
27
25
  writeFileSync(configFile, JSON.stringify(defaultConfig, null, 2) + "\n");
28
- console.info(
29
- "Configuration file has been generated successfully: " + chalk.blueBright(configFile)
30
- );
26
+ console.info("\u914D\u7F6E\u6587\u4EF6\u5DF2\u7ECF\u751F\u6210\uFF1A" + chalk.blueBright(configFile));
31
27
  process.exit(0);
32
28
  }
33
29
  }
34
30
  if (!existsSync(configFile)) {
35
31
  console.error(
36
- `Unable to find configuration file "${chalk.bold(
32
+ `\u627E\u4E0D\u5230\u914D\u7F6E\u6587\u4EF6"${chalk.bold(
37
33
  basename(configFile)
38
- )}", consider to execute the command below to initialize it.
34
+ )}"\u8BF7\u5148\u6267\u884C\u4E0B\u9762\u7684\u547D\u4EE4\uFF1A
39
35
 
40
- ${chalk.greenBright(
41
- "npx aomex --init"
42
- )}
36
+ ${chalk.greenBright("npx aomex --init")}
43
37
  `
44
38
  );
45
39
  process.exit(1);
@@ -58,32 +52,16 @@ var parseEnv = (sub) => {
58
52
  var cliEntry = parseEnv(config.cliEntry) || "";
59
53
  cliEntry &&= path.resolve(cliEntry);
60
54
  if (!cliEntry || !statSync(cliEntry).isFile()) {
61
- console.error(`Given entry file "${cliEntry}" is empty or not a file.`);
55
+ console.error(`\u63A7\u5236\u53F0\u5165\u53E3\u6587\u4EF6"${cliEntry}"\u4E0D\u5B58\u5728`);
62
56
  process.exit(1);
63
57
  }
64
58
  if (cliEntry.endsWith("js")) {
65
59
  await import(pathToFileURL(cliEntry).toString());
66
60
  } else {
67
- let tsNodeEsm = path.join(
68
- path.dirname(fileURLToPath(import.meta.url)),
69
- "../node_modules/.bin/ts-node-esm"
70
- );
71
- if (!existsSync(tsNodeEsm)) {
72
- tsNodeEsm = "ts-node-esm";
73
- }
74
- spawnSync(
75
- tsNodeEsm,
76
- [
77
- "--transpileOnly",
78
- "--experimentalSpecifierResolution",
79
- "node",
80
- cliEntry,
81
- ...hideBin(process.argv)
82
- ],
83
- {
84
- stdio: "inherit",
85
- env: process.env
86
- }
87
- );
61
+ tsNode.main([cliEntry, ...hideBin(process.argv)], {
62
+ "--esm": true,
63
+ "--transpileOnly": true,
64
+ "--experimentalSpecifierResolution": "node"
65
+ });
88
66
  }
89
67
  //# sourceMappingURL=bin.js.map
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env -S node --experimental-specifier-resolution=node --no-warnings\n\nimport path, { basename } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { hideBin } from 'yargs/helpers';\nimport { spawnSync } from 'node:child_process';\nimport { chalk } from '@aomex/core';\n\nconst configFile = path.resolve('aomex.json');\n{\n const defaultConfig = {\n $schema: './node_modules/@aomex/console/config.json',\n cliEntry: {\n production: './src/cli.js',\n default: './src/cli.ts',\n },\n };\n\n const args = hideBin(process.argv);\n if (args.length === 1 && args[0] === '--init') {\n if (existsSync(configFile)) {\n console.warn(\n chalk.yellow('Your configuration file had been generated already!'),\n );\n process.exit(0);\n }\n\n writeFileSync(configFile, JSON.stringify(defaultConfig, null, 2) + '\\n');\n console.info(\n 'Configuration file has been generated successfully: ' +\n chalk.blueBright(configFile),\n );\n process.exit(0);\n }\n}\n\nif (!existsSync(configFile)) {\n console.error(\n `Unable to find configuration file \"${chalk.bold(\n basename(configFile),\n )}\", consider to execute the command below to initialize it.\\n\\n${chalk.greenBright(\n 'npx aomex --init',\n )}\\n`,\n );\n process.exit(1);\n}\n\nconst config: AomexConfig = JSON.parse(readFileSync(configFile, 'utf8'));\nconst env = process.env['NODE_ENV'] || 'development';\nconst parseEnv = (sub: any) => {\n if (!sub) return null;\n if (Object.hasOwn(sub, env)) return sub[env];\n if (Object.hasOwn(sub, 'default')) return sub['default'];\n return null;\n};\n\nlet cliEntry: string = parseEnv(config.cliEntry) || '';\ncliEntry &&= path.resolve(cliEntry);\nif (!cliEntry || !statSync(cliEntry).isFile()) {\n console.error(`Given entry file \"${cliEntry}\" is empty or not a file.`);\n process.exit(1);\n}\n\nif (cliEntry.endsWith('js')) {\n await import(pathToFileURL(cliEntry).toString());\n} else {\n let tsNodeEsm = path.join(\n path.dirname(fileURLToPath(import.meta.url)),\n '../node_modules/.bin/ts-node-esm',\n );\n if (!existsSync(tsNodeEsm)) {\n tsNodeEsm = 'ts-node-esm';\n }\n\n spawnSync(\n tsNodeEsm,\n [\n '--transpileOnly',\n '--experimentalSpecifierResolution',\n 'node',\n cliEntry,\n ...hideBin(process.argv),\n ],\n {\n stdio: 'inherit',\n env: process.env,\n },\n );\n}\n"],"mappings":";;;AAEA,OAAO,QAAQ,gBAAgB;AAC/B,SAAS,eAAe,qBAAqB;AAC7C,SAAS,YAAY,cAAc,UAAU,qBAAqB;AAClE,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AAEtB,IAAM,aAAa,KAAK,QAAQ,YAAY;AAC5C;AACE,QAAM,gBAAgB;AAAA,IACpB,SAAS;AAAA,IACT,UAAU;AAAA,MACR,YAAY;AAAA,MACZ,SAAS;AAAA,IACX;AAAA,EACF;AAEA,QAAM,OAAO,QAAQ,QAAQ,IAAI;AACjC,MAAI,KAAK,WAAW,KAAK,KAAK,CAAC,MAAM,UAAU;AAC7C,QAAI,WAAW,UAAU,GAAG;AAC1B,cAAQ;AAAA,QACN,MAAM,OAAO,qDAAqD;AAAA,MACpE;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,kBAAc,YAAY,KAAK,UAAU,eAAe,MAAM,CAAC,IAAI,IAAI;AACvE,YAAQ;AAAA,MACN,yDACE,MAAM,WAAW,UAAU;AAAA,IAC/B;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,IAAI,CAAC,WAAW,UAAU,GAAG;AAC3B,UAAQ;AAAA,IACN,sCAAsC,MAAM;AAAA,MAC1C,SAAS,UAAU;AAAA,IACrB,CAAC;AAAA;AAAA,EAAiE,MAAM;AAAA,MACtE;AAAA,IACF,CAAC;AAAA;AAAA,EACH;AACA,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,SAAsB,KAAK,MAAM,aAAa,YAAY,MAAM,CAAC;AACvE,IAAM,MAAM,QAAQ,IAAI,UAAU,KAAK;AACvC,IAAM,WAAW,CAAC,QAAa;AAC7B,MAAI,CAAC;AAAK,WAAO;AACjB,MAAI,OAAO,OAAO,KAAK,GAAG;AAAG,WAAO,IAAI,GAAG;AAC3C,MAAI,OAAO,OAAO,KAAK,SAAS;AAAG,WAAO,IAAI,SAAS;AACvD,SAAO;AACT;AAEA,IAAI,WAAmB,SAAS,OAAO,QAAQ,KAAK;AACpD,aAAa,KAAK,QAAQ,QAAQ;AAClC,IAAI,CAAC,YAAY,CAAC,SAAS,QAAQ,EAAE,OAAO,GAAG;AAC7C,UAAQ,MAAM,qBAAqB,QAAQ,2BAA2B;AACtE,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAI,SAAS,SAAS,IAAI,GAAG;AAC3B,QAAM,OAAO,cAAc,QAAQ,EAAE,SAAS;AAChD,OAAO;AACL,MAAI,YAAY,KAAK;AAAA,IACnB,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAAA,IAC3C;AAAA,EACF;AACA,MAAI,CAAC,WAAW,SAAS,GAAG;AAC1B,gBAAY;AAAA,EACd;AAEA;AAAA,IACE;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG,QAAQ,QAAQ,IAAI;AAAA,IACzB;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,KAAK,QAAQ;AAAA,IACf;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env -S node --experimental-specifier-resolution=node --no-warnings\n\nimport path, { basename } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { hideBin } from 'yargs/helpers';\nimport { chalk } from '@aomex/core';\nimport tsNode from 'ts-node/dist/bin';\n\nconst configFile = path.resolve('aomex.json');\n{\n const defaultConfig = {\n $schema: './node_modules/@aomex/console/config.json',\n cliEntry: {\n production: './src/cli.js',\n default: './src/cli.ts',\n },\n };\n\n const args = hideBin(process.argv);\n if (args.length === 1 && args[0] === '--init') {\n if (existsSync(configFile)) {\n console.warn(chalk.yellow('配置文件aomex.json已经存在,请勿重复操作'));\n process.exit(0);\n }\n\n writeFileSync(configFile, JSON.stringify(defaultConfig, null, 2) + '\\n');\n console.info('配置文件已经生成:' + chalk.blueBright(configFile));\n process.exit(0);\n }\n}\n\nif (!existsSync(configFile)) {\n console.error(\n `找不到配置文件\"${chalk.bold(\n basename(configFile),\n )}\"请先执行下面的命令:\\n\\n${chalk.greenBright('npx aomex --init')}\\n`,\n );\n process.exit(1);\n}\n\nconst config: AomexConfig = JSON.parse(readFileSync(configFile, 'utf8'));\nconst env = process.env['NODE_ENV'] || 'development';\nconst parseEnv = (sub: any) => {\n if (!sub) return null;\n if (Object.hasOwn(sub, env)) return sub[env];\n if (Object.hasOwn(sub, 'default')) return sub['default'];\n return null;\n};\n\nlet cliEntry: string = parseEnv(config.cliEntry) || '';\ncliEntry &&= path.resolve(cliEntry);\nif (!cliEntry || !statSync(cliEntry).isFile()) {\n console.error(`控制台入口文件\"${cliEntry}\"不存在`);\n process.exit(1);\n}\n\nif (cliEntry.endsWith('js')) {\n await import(pathToFileURL(cliEntry).toString());\n} else {\n tsNode.main([cliEntry, ...hideBin(process.argv)], {\n '--esm': true,\n '--transpileOnly': true,\n '--experimentalSpecifierResolution': 'node',\n });\n}\n"],"mappings":";;;AAEA,OAAO,QAAQ,gBAAgB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,YAAY,cAAc,UAAU,qBAAqB;AAClE,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,OAAO,YAAY;AAE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ChB;AAEA,IAAI,SAAS,SAAS,IAAI,GAAG;AAC3B,QAAM,OAAO,cAAc,QAAQ,EAAE,SAAS;AAChD,OAAO;AACL,SAAO,KAAK,CAAC,UAAU,GAAG,QAAQ,QAAQ,IAAI,CAAC,GAAG;AAAA,IAChD,SAAS;AAAA,IACT,mBAAmB;AAAA,IACnB,qCAAqC;AAAA,EACvC,CAAC;AACH;","names":[]}
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { compose, middleware } from "@aomex/core";
7
7
  import yargs from "yargs";
8
8
 
9
9
  // src/meta.ts
10
- var version = "0.0.27";
10
+ var version = "0.0.28";
11
11
  var scriptName = "aomex";
12
12
 
13
13
  // src/middleware/showHelp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aomex/console",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "控制台应用",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "homepage": "https://aomex.js.org",
31
31
  "license": "MIT",
32
32
  "peerDependencies": {
33
- "@aomex/core": "^0.0.22"
33
+ "@aomex/core": "^0.0.23"
34
34
  },
35
35
  "dependencies": {
36
36
  "@types/yargs": "^17.0.23",
@@ -39,7 +39,7 @@
39
39
  "yargs-parser": "^21.1.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@aomex/core": "^0.0.22",
42
+ "@aomex/core": "^0.0.23",
43
43
  "@types/yargs-parser": "^21.0.0",
44
44
  "read-pkg-up": "^10.0.0"
45
45
  },
package/src/bin-dev.mjs CHANGED
@@ -2,23 +2,13 @@
2
2
 
3
3
  import { dirname, join } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
- import { spawnSync } from 'node:child_process';
6
5
  import { hideBin } from 'yargs/helpers';
6
+ import tsNode from 'ts-node/dist/bin';
7
7
 
8
8
  const src = dirname(fileURLToPath(import.meta.url));
9
- const tsNodeEsm = join(src, '../node_modules/.bin/ts-node-esm');
10
9
 
11
- spawnSync(
12
- tsNodeEsm,
13
- [
14
- '--transpileOnly',
15
- '--experimentalSpecifierResolution',
16
- 'node',
17
- join(src, 'bin.ts'),
18
- ...hideBin(process.argv),
19
- ],
20
- {
21
- stdio: 'inherit',
22
- env: process.env,
23
- },
24
- );
10
+ tsNode.main([join(src, 'bin.ts'), ...hideBin(process.argv)], {
11
+ '--esm': true,
12
+ '--transpileOnly': true,
13
+ '--experimentalSpecifierResolution': 'node',
14
+ });