@lark-apaas/miaoda-cli 0.1.39-alpha.8eeaf6e → 0.1.39-alpha.a18a150

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.
@@ -76,6 +76,22 @@ exports.MIGRATE_CONFIG = {
76
76
  // 不带过去 shadcn 组件会被 lint,组件里引用新版 react-hooks 规则的 disable 注释报"规则不存在"。
77
77
  { type: 'file', from: 'eslint.config.js', to: 'eslint.config.js', overwrite: false },
78
78
  { type: 'carry-eslint-ignores', from: 'eslint.config.mjs', to: 'eslint.config.js' },
79
+ // 新 preset(fullstack-presets simple client)比旧 preset(coding-presets-react)新增 / 加严的 error 级规则,
80
+ // 旧代码按旧规则合规、迁移后才违规,降为 warn,不让平台规范的增量拦下整次转换
81
+ {
82
+ type: 'relax-eslint-rules',
83
+ to: 'eslint.config.js',
84
+ files: ['client/**/*.{ts,tsx}', 'shared/**/*.{ts,tsx}'],
85
+ rules: [
86
+ '@lark-apaas/require-app-container',
87
+ '@lark-apaas/no-direct-capability-api',
88
+ '@lark-apaas/no-multiline-styled-jsx-classname',
89
+ '@lark-apaas/no-nested-styled-jsx',
90
+ '@lark-apaas/no-styled-jsx-data-uri-url-ref',
91
+ 'import/no-unresolved',
92
+ 'no-restricted-syntax',
93
+ ],
94
+ },
79
95
  // 旧配置用户改过则冲突
80
96
  {
81
97
  type: 'remove-known-default',
@@ -39,6 +39,7 @@ var __importStar = (this && this.__importStar) || (function () {
39
39
  };
40
40
  })();
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.RELAX_ESLINT_MARKER = void 0;
42
43
  exports.parseJsoncObject = parseJsoncObject;
43
44
  exports.rewriteSrcPath = rewriteSrcPath;
44
45
  exports.adaptTsconfig = adaptTsconfig;
@@ -49,6 +50,7 @@ exports.normalizeConfigSource = normalizeConfigSource;
49
50
  exports.matchesKnownDefault = matchesKnownDefault;
50
51
  exports.rewriteLegacyLayoutGlob = rewriteLegacyLayoutGlob;
51
52
  exports.carryEslintIgnores = carryEslintIgnores;
53
+ exports.relaxEslintRules = relaxEslintRules;
52
54
  const jsonc = __importStar(require("jsonc-parser"));
53
55
  const JSONC_FORMAT = {
54
56
  formattingOptions: { insertSpaces: true, tabSize: 2, eol: '\n' },
@@ -596,3 +598,37 @@ function carryEslintIgnores(opts) {
596
598
  const text = opts.targetText.slice(0, start) + nextBody + opts.targetText.slice(start + body.length);
597
599
  return { ok: true, text, changed: true, detail: `carried ${missing.join(', ')}` };
598
600
  }
601
+ /** relax-eslint-rules 追加段的标识注释 */
602
+ exports.RELAX_ESLINT_MARKER = 'miaoda-migrate: relax rules added by the vite-react → fullstack migration';
603
+ const CONFIG_CALL_END_RE = /\n\);?\s*$/;
604
+ /**
605
+ * 在 `module.exports = tseslint.config(...)` 收尾前追加一段覆盖:files 范围内 rules 降为 warn。
606
+ * 已有 marker → 不变;找不到 `tseslint.config(` 或收尾的 `)` → 冲突原因(调用方记 kept,不阻断)。
607
+ */
608
+ function relaxEslintRules(opts) {
609
+ if (opts.text.includes(exports.RELAX_ESLINT_MARKER)) {
610
+ return { ok: true, text: opts.text, changed: false, detail: 'already relaxed' };
611
+ }
612
+ const end = CONFIG_CALL_END_RE.exec(opts.text);
613
+ if (!/\btseslint\.config\(/.test(opts.text) || end === null) {
614
+ return { ok: false, conflict: 'not a `tseslint.config(...)` config; rules not relaxed' };
615
+ }
616
+ const before = opts.text.slice(0, end.index).replace(/,?\s*$/, ',');
617
+ const block = [
618
+ ` // ${exports.RELAX_ESLINT_MARKER}`,
619
+ ' // 新 preset 新增 / 加严的平台规范先降为 warn(lint 以 --quiet 运行不阻断提交),按提示逐步修复后可删除本段',
620
+ ' {',
621
+ ` files: [${opts.files.map(quote).join(', ')}],`,
622
+ ' rules: {',
623
+ ...opts.rules.map((r) => ` ${quote(r)}: 'warn',`),
624
+ ' },',
625
+ ' },',
626
+ ].join('\n');
627
+ const text = `${before}\n${block}${opts.text.slice(end.index)}`;
628
+ return {
629
+ ok: true,
630
+ text,
631
+ changed: true,
632
+ detail: `${opts.rules.length.toString()} rule(s) relaxed`,
633
+ };
634
+ }
@@ -90,6 +90,9 @@ function applyOne(rule, opts) {
90
90
  if (rule.type === 'carry-eslint-ignores') {
91
91
  return applyCarryEslintIgnores(rule, opts);
92
92
  }
93
+ if (rule.type === 'relax-eslint-rules') {
94
+ return applyRelaxEslintRules(rule, opts);
95
+ }
93
96
  if (rule.type === 'move-directory' || rule.type === 'move-file') {
94
97
  return applyMove(rule, opts);
95
98
  }
@@ -769,6 +772,36 @@ function applyCarryEslintIgnores(rule, opts) {
769
772
  (0, logger_1.log)(logPrefix, ` ✓ ${rule.to} (${result.detail ?? 'ignores carried'})`);
770
773
  return { rule, action: 'patched', path: rule.to, detail: result.detail };
771
774
  }
775
+ function applyRelaxEslintRules(rule, opts) {
776
+ const logPrefix = opts.logPrefix ?? 'migrate';
777
+ const abs = node_path_1.default.join(opts.targetDir, rule.to);
778
+ if (!node_fs_1.default.existsSync(abs)) {
779
+ (0, logger_1.log)(logPrefix, ` ○ ${rule.to} (not found, skip relaxing rules)`);
780
+ return { rule, action: 'skipped', path: rule.to };
781
+ }
782
+ const result = (0, migrate_adapters_1.relaxEslintRules)({
783
+ text: node_fs_1.default.readFileSync(abs, 'utf-8'),
784
+ files: rule.files,
785
+ rules: rule.rules,
786
+ });
787
+ if (!result.ok) {
788
+ // 用户自己的配置形态:不改,记 kept;规则仍按 preset 生效,交给提交 hooks 判定
789
+ (0, logger_1.log)(logPrefix, ` ○ ${rule.to} (${result.conflict}, kept)`);
790
+ return {
791
+ rule,
792
+ action: 'skipped',
793
+ path: rule.to,
794
+ kept: [{ path: rule.to, reason: result.conflict }],
795
+ };
796
+ }
797
+ if (!result.changed) {
798
+ (0, logger_1.log)(logPrefix, ` ○ ${rule.to} (${result.detail ?? 'unchanged'})`);
799
+ return { rule, action: 'noop', path: rule.to, detail: result.detail };
800
+ }
801
+ node_fs_1.default.writeFileSync(abs, result.text);
802
+ (0, logger_1.log)(logPrefix, ` ✓ ${rule.to} (${result.detail ?? 'rules relaxed'})`);
803
+ return { rule, action: 'patched', path: rule.to, detail: result.detail };
804
+ }
772
805
  function applySetStack(rule, opts) {
773
806
  const logPrefix = opts.logPrefix ?? 'migrate';
774
807
  (0, spark_meta_1.writeSparkMeta)(opts.targetDir, { stack: rule.stack });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-cli",
3
- "version": "0.1.39-alpha.8eeaf6e",
3
+ "version": "0.1.39-alpha.a18a150",
4
4
  "description": "Miaoda 平台命令行工具,面向 Agent 调用",
5
5
  "type": "commonjs",
6
6
  "bin": {