@gadmin2n/cli 0.0.197 → 0.0.198

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.
@@ -85,7 +85,7 @@ class PrismaAction extends abstract_action_1.AbstractAction {
85
85
  return (0, sync_fs_1.writeFileIfChanged)('server/prisma/schema.prisma', generatorHead + merged);
86
86
  }
87
87
  handle(inputs, options) {
88
- var _a, _b, _c;
88
+ var _a, _b, _c, _d;
89
89
  return __awaiter(this, void 0, void 0, function* () {
90
90
  // 检查 prisma schema 配置是否存在
91
91
  const hasPrismaConfig = shell.test('-e', 'config/schema.prisma') ||
@@ -97,6 +97,12 @@ class PrismaAction extends abstract_action_1.AbstractAction {
97
97
  }
98
98
  const devMode = !!((_a = options.find((option) => option.name === 'dev')) === null || _a === void 0 ? void 0 : _a.value);
99
99
  const verbose = !!((_b = options.find((option) => option.name === 'verbose')) === null || _b === void 0 ? void 0 : _b.value);
100
+ // 非交互判定:stdin 非 TTY(CI/CD、管道、多数 AI agent 环境)时自动进入,
101
+ // 无需显式 --yes;--yes 用于强制(stdin 是 TTY 但无人值守的场景无法自动判断)。
102
+ // prisma migrate dev 的确认提示无自动确认参数可传,注入 CI=true 让 prisma 的
103
+ // canPrompt() 判定为非交互,遇确认直接报错退出(fail fast),而不是挂起等输入。
104
+ const yes = !!((_c = options.find((option) => option.name === 'yes')) === null || _c === void 0 ? void 0 : _c.value) ||
105
+ !process.stdin.isTTY;
100
106
  // 分发过程按类别记账,收尾统一打摘要 / --verbose 打完整清单
101
107
  const stats = {
102
108
  serverGeneratedIndex: [],
@@ -136,14 +142,18 @@ class PrismaAction extends abstract_action_1.AbstractAction {
136
142
  cwd: 'server',
137
143
  shell: true,
138
144
  stdio: 'inherit',
139
- env: Object.assign(Object.assign({}, process.env), { GADMIN_WEB_STAGING: WEB_STAGING, GADMIN_SERVER_STAGING: SERVER_STAGING, GADMIN_WEB_ROUTES_DIR: WEB_ROUTES_DIR }),
145
+ env: Object.assign(Object.assign(Object.assign({}, process.env), (yes ? { CI: 'true' } : {})), { GADMIN_WEB_STAGING: WEB_STAGING, GADMIN_SERVER_STAGING: SERVER_STAGING, GADMIN_WEB_ROUTES_DIR: WEB_ROUTES_DIR }),
140
146
  });
141
147
  if (result.error) {
142
148
  console.error(chalk.red(`Failed to run ${generateScript}: ${result.error.message}`));
143
149
  process.exit(1);
144
150
  }
145
151
  if (result.status !== 0) {
146
- process.exit((_c = result.status) !== null && _c !== void 0 ? _c : 1);
152
+ if (yes) {
153
+ console.log(chalk.yellow('Non-interactive mode: prisma migrate dev requires manual confirmation (e.g. data-loss warnings). ' +
154
+ 'Run `gadmin2 g prisma:dev` in an interactive terminal once to confirm the migration.'));
155
+ }
156
+ process.exit((_d = result.status) !== null && _d !== void 0 ? _d : 1);
147
157
  }
148
158
  // 分发策略:先集中写 server/,再集中写 web/。
149
159
  // 目的是把 nest --watch 的 2 波重启合成 1 波,把 Vite 的 4 波 HMR 合成 1 波。
@@ -288,7 +298,7 @@ class PrismaAction extends abstract_action_1.AbstractAction {
288
298
  this.printReport(stats, verbose);
289
299
  // 分发全部完成后,若 server/package.json 定义了 postgadminGenerate,
290
300
  // 触发它。项目侧可用来做 dev server 通知、缓存清理等自定义收尾。
291
- this.runProjectPostHook();
301
+ this.runProjectPostHook(yes);
292
302
  process.exit(0);
293
303
  });
294
304
  }
@@ -333,7 +343,7 @@ class PrismaAction extends abstract_action_1.AbstractAction {
333
343
  printGroup('web generated (unchanged)', stats.generatedUnchanged, chalk.gray);
334
344
  printGroup('web orphans removed', stats.orphansRemoved, chalk.red);
335
345
  }
336
- runProjectPostHook() {
346
+ runProjectPostHook(yes) {
337
347
  var _a;
338
348
  const pkgPath = 'server/package.json';
339
349
  let pkg;
@@ -350,7 +360,7 @@ class PrismaAction extends abstract_action_1.AbstractAction {
350
360
  cwd: 'server',
351
361
  shell: true,
352
362
  stdio: 'inherit',
353
- env: Object.assign({}, process.env),
363
+ env: Object.assign(Object.assign({}, process.env), (yes ? { CI: 'true' } : {})),
354
364
  });
355
365
  if (result.error) {
356
366
  console.log(chalk.yellow(`postgadminGenerate failed to spawn: ${result.error.message}; ignoring (non-fatal).`));
@@ -33,6 +33,8 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
33
33
  })
34
34
  .option('-c, --collection [collectionName]', 'Schematics collection to use.')
35
35
  .option('-v, --verbose', 'Print each affected src/ file (prisma).')
36
+ .option('-y, --yes', 'Force non-interactive mode: fail fast instead of hanging on prisma migrate dev confirmation prompts. ' +
37
+ 'Auto-enabled when stdin is not a TTY (CI/CD, pipes, AI agents); use this flag for unattended TTY sessions.')
36
38
  .action((schematic, name, path, command) => __awaiter(this, void 0, void 0, function* () {
37
39
  const options = [];
38
40
  options.push({ name: 'dry-run', value: !!command.dryRun });
@@ -66,6 +68,7 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
66
68
  },
67
69
  });
68
70
  options.push({ name: 'verbose', value: !!command.verbose });
71
+ options.push({ name: 'yes', value: !!command.yes });
69
72
  const inputs = [];
70
73
  inputs.push({ name: 'schematic', value: schematic });
71
74
  inputs.push({ name: 'name', value: name });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gadmin2n/cli",
3
- "version": "0.0.197",
3
+ "version": "0.0.198",
4
4
  "description": "Gadmin - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"