@lark-apaas/miaoda-cli 0.1.7 → 0.1.8-alpha.0

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.
@@ -19,6 +19,9 @@ function nodeStatusText(v) {
19
19
  return v;
20
20
  if (typeof v !== 'number')
21
21
  return undefined;
22
+ // `number` 不在 `NodeStatus` 枚举键集时,TS Partial<Record<NodeStatus,_>> 推断
23
+ // 出来类型不友好(eslint 报 unsafe-return);cast 到 Record<number,string|undefined>
24
+ // 等价安全访问。
22
25
  return NODE_STATUS_TEXT[v];
23
26
  }
24
27
  /** NodeStatus 文本(CLI flag 字符串)→ 枚举数值 */
@@ -15,6 +15,7 @@ const sync_configs_1 = require("../../../config/sync-configs");
15
15
  const sync_rule_1 = require("../../../utils/sync-rule");
16
16
  const platform_sync_1 = require("../../../utils/platform-sync");
17
17
  const githooks_1 = require("../../../utils/githooks");
18
+ const install_1 = require("../../../services/app/init/install");
18
19
  const spark_meta_1 = require("../../../utils/spark-meta");
19
20
  const error_1 = require("../../../utils/error");
20
21
  const output_1 = require("../../../utils/output");
@@ -88,7 +89,16 @@ async function handleAppSync(opts) {
88
89
  // package.json 写了 latest 但实际还是装 alpha。显式 `npm install foo@latest bar@latest`
89
90
  // 会重新解析这些包,lockfile 跟着更新。没变化的包不动,避免 noisy lockfile diff。
90
91
  // --ignore-scripts 绕开 action-plugin postinstall 在缺平台 env 时的 ENOENT。
91
- const installArgs = ['install', '--no-audit', '--no-fund', '--ignore-scripts'];
92
+ // --registry init 钉同一份 npmmirror,避免 user 全局 ~/.npmrc 把 sync 拉到 ~~一个~~
93
+ // 另一个源(详见 services/app/init/install.ts 上的注释)。MIAODA_NPM_REGISTRY env 兜底。
94
+ const installArgs = [
95
+ 'install',
96
+ '--no-audit',
97
+ '--no-fund',
98
+ '--ignore-scripts',
99
+ '--registry',
100
+ (0, install_1.resolveNpmInstallRegistry)(),
101
+ ];
92
102
  for (const bump of upgradedPackages) {
93
103
  installArgs.push(`${bump.name}@${bump.to}`);
94
104
  }
@@ -76,7 +76,7 @@ function parsePluginName(input) {
76
76
  if (!match) {
77
77
  throw new error_1.AppError('INVALID_PLUGIN_NAME', `Invalid plugin name format: ${input}. Expected: @scope/name or @scope/name@version`, { next_actions: ['示例:@demo/example-plugin 或 @demo/example-plugin@1.2.3'] });
78
78
  }
79
- return { name: match[1], version: match[2] ?? 'latest' };
79
+ return { name: match[1], version: match[2] || 'latest' };
80
80
  }
81
81
  // ── package.json actionPlugins CRUD ──
82
82
  function readPackageJson() {
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.installDependencies = installDependencies;
7
+ exports.resolveNpmInstallRegistry = resolveNpmInstallRegistry;
7
8
  const node_child_process_1 = require("node:child_process");
8
9
  const node_crypto_1 = __importDefault(require("node:crypto"));
9
10
  const node_fs_1 = __importDefault(require("node:fs"));
@@ -111,12 +112,20 @@ function extractZip(zipPath, targetDir, stdio) {
111
112
  * - 字节内网 DNS 会把 npmmirror 域名透明指向公司镜像,外网就是公网阿里源;同一行配置
112
113
  * 在两套环境都拉得到 @lark-apaas/* 私包(内网经公司镜像,外网经阿里同步过去的副本)。
113
114
  * - 留 `MIAODA_NPM_REGISTRY` env 应急覆盖。
115
+ *
116
+ * `miaoda app sync` 也用同款规则,通过 resolveNpmInstallRegistry() 共享。
114
117
  */
115
118
  const NPM_INSTALL_REGISTRY_DEFAULT = 'https://registry.npmmirror.com/';
119
+ /**
120
+ * 解析 miaoda 内部 npm install 命令使用的 registry。init / sync 共用。
121
+ * 优先级:`MIAODA_NPM_REGISTRY` env > `NPM_INSTALL_REGISTRY_DEFAULT`。
122
+ */
123
+ function resolveNpmInstallRegistry() {
124
+ return process.env.MIAODA_NPM_REGISTRY ?? NPM_INSTALL_REGISTRY_DEFAULT;
125
+ }
116
126
  function runNpmInstall(targetDir, stdio) {
117
127
  (0, logger_1.log)('init', `npm install in ${targetDir}...`);
118
- const registry = process.env.MIAODA_NPM_REGISTRY ?? NPM_INSTALL_REGISTRY_DEFAULT;
119
- (0, node_child_process_1.execFileSync)('npm', ['install', '--no-audit', '--no-fund', '--registry', registry], {
128
+ (0, node_child_process_1.execFileSync)('npm', ['install', '--no-audit', '--no-fund', '--registry', resolveNpmInstallRegistry()], {
120
129
  cwd: targetDir,
121
130
  stdio,
122
131
  });
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8-alpha.0",
4
4
  "description": "Miaoda 平台命令行工具,面向 Agent 调用",
5
5
  "type": "commonjs",
6
6
  "bin": {
7
7
  "miaoda": "bin/miaoda.js"
8
8
  },
9
9
  "publishConfig": {
10
- "access": "public"
10
+ "access": "public",
11
+ "registry": "https://registry.npmjs.org/"
11
12
  },
12
13
  "files": [
13
14
  "LICENSE",
@@ -16,6 +17,20 @@
16
17
  "dist",
17
18
  "upgrade"
18
19
  ],
20
+ "scripts": {
21
+ "build": "bash scripts/build.sh",
22
+ "typecheck": "tsc --noEmit -p tsconfig.json",
23
+ "lint": "eslint src/ --max-warnings 0",
24
+ "format": "prettier --write src/",
25
+ "format:check": "prettier --check src/",
26
+ "test": "vitest run --project=unit",
27
+ "test:watch": "vitest --project=unit",
28
+ "test:integration": "vitest run --project=integration",
29
+ "dev": "node --import tsx src/main.ts",
30
+ "cli": "node --env-file-if-exists=integration/.env --import tsx src/main.ts",
31
+ "prepare": "husky",
32
+ "prepublishOnly": "pnpm format:check && pnpm lint && pnpm build && pnpm test"
33
+ },
19
34
  "keywords": [
20
35
  "miaoda",
21
36
  "cli",
@@ -50,16 +65,5 @@
50
65
  "vitest": "^4.1.4",
51
66
  "xml2js": "^0.6.2"
52
67
  },
53
- "scripts": {
54
- "build": "bash scripts/build.sh",
55
- "typecheck": "tsc --noEmit -p tsconfig.json",
56
- "lint": "eslint src/ --max-warnings 0",
57
- "format": "prettier --write src/",
58
- "format:check": "prettier --check src/",
59
- "test": "vitest run --project=unit",
60
- "test:watch": "vitest --project=unit",
61
- "test:integration": "vitest run --project=integration",
62
- "dev": "node --import tsx src/main.ts",
63
- "cli": "node --env-file-if-exists=integration/.env --import tsx src/main.ts"
64
- }
65
- }
68
+ "packageManager": "pnpm@10.16.1+sha512.0e155aa2629db8672b49e8475da6226aa4bdea85fdcdfdc15350874946d4f3c91faaf64cbdc4a5d1ab8002f473d5c3fcedcd197989cf0390f9badd3c04678706"
69
+ }