@wzyjs/next 0.3.28 → 0.3.29
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/dist/Base.zmodel +1 -1
- package/dist/index.js +21 -66
- package/dist/plugin/crud/index.js +27 -66
- package/dist/plugin/no-check/index.js +38 -0
- package/dist/plugin/tags/index.js +53 -78
- package/package.json +7 -3
package/dist/Base.zmodel
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,71 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.name = void 0;
|
|
40
4
|
exports.default = run;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (!generateActions.includes('tags')) return [3 /*break*/, 4];
|
|
63
|
-
return [4 /*yield*/, (0, tags_1.generateTags)(model, outputPath)];
|
|
64
|
-
case 3:
|
|
65
|
-
_a.sent();
|
|
66
|
-
_a.label = 4;
|
|
67
|
-
case 4: return [2 /*return*/];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
5
|
+
const crud_1 = require("./plugin/crud");
|
|
6
|
+
const tags_1 = require("./plugin/tags");
|
|
7
|
+
const no_check_1 = require("./plugin/no-check");
|
|
8
|
+
exports.name = 'Generate CRUD, Tags and Generated File Banners';
|
|
9
|
+
async function run(model, options) {
|
|
10
|
+
// 检查配置
|
|
11
|
+
if (!options.output) {
|
|
12
|
+
throw new Error('output is required');
|
|
13
|
+
}
|
|
14
|
+
const outputPath = String(options.output);
|
|
15
|
+
const generateActions = String(options.generateActions || 'crud, tags, noCheck').replace(/\s/g, '').toLowerCase().split(',');
|
|
16
|
+
// 根据配置执行相应功能
|
|
17
|
+
if (generateActions.includes('crud')) {
|
|
18
|
+
await (0, crud_1.generateCRUD)(model, outputPath);
|
|
19
|
+
}
|
|
20
|
+
if (generateActions.includes('tags')) {
|
|
21
|
+
await (0, tags_1.generateTags)(model, outputPath);
|
|
22
|
+
}
|
|
23
|
+
if (generateActions.includes('nocheck')) {
|
|
24
|
+
await (0, no_check_1.markGeneratedNoCheck)(outputPath);
|
|
25
|
+
}
|
|
71
26
|
}
|
|
@@ -1,76 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.generateCRUD = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const crudConfig = {
|
|
43
7
|
template: {
|
|
44
8
|
content: fs.readFileSync(path.resolve(__dirname, './useHabitGroupCRUD.ts'), 'utf-8'),
|
|
45
9
|
},
|
|
46
10
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
fs.mkdirSync(crudDirPath, { recursive: true });
|
|
56
|
-
}
|
|
11
|
+
const generateCRUD = async (model, outputPath) => {
|
|
12
|
+
const crudDirPath = path.join(outputPath, 'crud');
|
|
13
|
+
// 过滤出来 model
|
|
14
|
+
const modelNames = model.declarations.filter(item => item.$type === 'DataModel');
|
|
15
|
+
// 创建目录
|
|
16
|
+
if (modelNames.length) {
|
|
17
|
+
if (!fs.existsSync(crudDirPath)) {
|
|
18
|
+
fs.mkdirSync(crudDirPath, { recursive: true });
|
|
57
19
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
indexContent = modelNames.map(function (_a) {
|
|
68
|
-
var ModelName = _a.name;
|
|
69
|
-
return "export * from './use".concat(ModelName, "CRUD'");
|
|
70
|
-
}).join('\n');
|
|
71
|
-
fs.writeFileSync(path.join(crudDirPath, 'index.ts'), indexContent + '\n');
|
|
72
|
-
console.log("\u2705 CRUD \u529F\u80FD\u751F\u6210\u5B8C\u6210\uFF0C\u5171\u5904\u7406 ".concat(modelNames.length, " \u4E2A\u6A21\u578B"));
|
|
73
|
-
return [2 /*return*/];
|
|
20
|
+
}
|
|
21
|
+
// 生成模板
|
|
22
|
+
modelNames.forEach(({ name: ModelName }) => {
|
|
23
|
+
let templateContent = crudConfig.template.content;
|
|
24
|
+
const modelName = String(ModelName).replace(/^./, (s) => s.toLowerCase());
|
|
25
|
+
templateContent = templateContent.replace(/habitGroup/g, modelName);
|
|
26
|
+
templateContent = templateContent.replace(/HabitGroup/g, String(ModelName));
|
|
27
|
+
fs.writeFileSync(path.join(crudDirPath, `use${ModelName}CRUD.ts`), templateContent);
|
|
74
28
|
});
|
|
75
|
-
|
|
29
|
+
// 创建 index.ts 导出所有代理
|
|
30
|
+
const indexContent = modelNames.map(({ name: ModelName }) => {
|
|
31
|
+
return `export * from './use${ModelName}CRUD'`;
|
|
32
|
+
}).join('\n');
|
|
33
|
+
fs.writeFileSync(path.join(crudDirPath, 'index.ts'), indexContent + '\n');
|
|
34
|
+
console.log('\n');
|
|
35
|
+
console.log(`✅ CRUD 功能生成完成,共处理 ${modelNames.length} 个模型`);
|
|
36
|
+
};
|
|
76
37
|
exports.generateCRUD = generateCRUD;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.markGeneratedNoCheck = void 0;
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const noCheckBanner = '// @ts-nocheck';
|
|
7
|
+
const walkTsFiles = (dirPath) => {
|
|
8
|
+
if (!fs.existsSync(dirPath)) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const files = [];
|
|
12
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
const entryPath = path.join(dirPath, entry.name);
|
|
15
|
+
if (entry.isDirectory()) {
|
|
16
|
+
files.push(...walkTsFiles(entryPath));
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (entry.isFile() && entry.name.endsWith('.ts')) {
|
|
20
|
+
files.push(entryPath);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return files;
|
|
24
|
+
};
|
|
25
|
+
const markFile = (filePath) => {
|
|
26
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
27
|
+
if (content.includes(noCheckBanner)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
fs.writeFileSync(filePath, `${noCheckBanner}\n${content}`, 'utf-8');
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
const markGeneratedNoCheck = async (outputPath) => {
|
|
34
|
+
const files = walkTsFiles(outputPath);
|
|
35
|
+
const changedCount = files.filter(markFile).length;
|
|
36
|
+
console.log(`✅ Generated 文件 no-check 标记完成,共处理 ${changedCount}/${files.length} 个 TS 文件`);
|
|
37
|
+
};
|
|
38
|
+
exports.markGeneratedNoCheck = markGeneratedNoCheck;
|
|
@@ -1,84 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.generateTags = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const generateTags = async (model, outputPath) => {
|
|
7
|
+
// 过滤出来有 tags 字段的 DataModel
|
|
8
|
+
const modelsWithTags = model.declarations.filter(item => item.$type === 'DataModel');
|
|
9
|
+
// .filter(dataModel => {
|
|
10
|
+
// return dataModel.fields.some(field => field.name === 'tags')
|
|
11
|
+
// })
|
|
12
|
+
if (modelsWithTags.length === 0) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
// 为每个有 tags 字段的模型添加 getAllTags 接口
|
|
16
|
+
for (const dataModel of modelsWithTags) {
|
|
17
|
+
const modelName = String(dataModel.name);
|
|
18
|
+
const routerFilePath = path.join(outputPath, 'trpc', 'routers', `${modelName}.router.ts`);
|
|
19
|
+
// 检查文件是否存在
|
|
20
|
+
if (!fs.existsSync(routerFilePath)) {
|
|
21
|
+
continue;
|
|
51
22
|
}
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// 检查文件是否存在
|
|
58
|
-
if (!fs.existsSync(routerFilePath)) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
fileContent = fs.readFileSync(routerFilePath, 'utf-8');
|
|
62
|
-
// 检查是否已经添加了 getAllTags 接口
|
|
63
|
-
if (fileContent.includes('getAllTags:')) {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
delegateName = modelName.charAt(0).toLowerCase() + modelName.slice(1);
|
|
67
|
-
getAllTagsInterface = "\n getAllTags: procedure\n .query(async ({ ctx, input }) => {\n const records = await checkRead(db(ctx).".concat(delegateName, ".findMany({\n ...(input?.where ? { where: input.where } : {}),\n select: { tags: true },\n }))\n\n // \u6241\u5E73\u5316 + \u53BB\u91CD\n const uniqueTags = Array.from(new Set(records.flatMap(record => record.tags || [])))\n\n return uniqueTags\n }),");
|
|
68
|
-
lastCommaIndex = fileContent.lastIndexOf(',');
|
|
69
|
-
closingBraceIndex = fileContent.indexOf('\n }\n );', lastCommaIndex);
|
|
70
|
-
if (closingBraceIndex === -1) {
|
|
71
|
-
console.warn("\u26A0\uFE0F Could not find insertion point in ".concat(modelName, ".router.ts"));
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
beforeInsertion = fileContent.substring(0, closingBraceIndex);
|
|
75
|
-
afterInsertion = fileContent.substring(closingBraceIndex);
|
|
76
|
-
newContent = beforeInsertion + getAllTagsInterface + afterInsertion;
|
|
77
|
-
// 写入文件
|
|
78
|
-
fs.writeFileSync(routerFilePath, newContent, 'utf-8');
|
|
23
|
+
// 读取文件内容
|
|
24
|
+
let fileContent = fs.readFileSync(routerFilePath, 'utf-8');
|
|
25
|
+
// 检查是否已经添加了 getAllTags 接口
|
|
26
|
+
if (fileContent.includes('getAllTags:')) {
|
|
27
|
+
continue;
|
|
79
28
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
29
|
+
const delegateName = modelName.charAt(0).toLowerCase() + modelName.slice(1);
|
|
30
|
+
const getAllTagsInterface = `
|
|
31
|
+
getAllTags: procedure
|
|
32
|
+
.query(async ({ ctx, input }) => {
|
|
33
|
+
const records = await checkRead(db(ctx).${delegateName}.findMany({
|
|
34
|
+
...(input?.where ? { where: input.where } : {}),
|
|
35
|
+
select: { tags: true },
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
// 扁平化 + 去重
|
|
39
|
+
const uniqueTags = Array.from(new Set(records.flatMap(record => record.tags || [])))
|
|
40
|
+
|
|
41
|
+
return uniqueTags
|
|
42
|
+
}),`;
|
|
43
|
+
// 找到最后一个接口的位置,在其后添加新接口
|
|
44
|
+
const lastCommaIndex = fileContent.lastIndexOf(',');
|
|
45
|
+
const closingBraceIndex = fileContent.indexOf('\n }\n );', lastCommaIndex);
|
|
46
|
+
if (closingBraceIndex === -1) {
|
|
47
|
+
console.warn(`⚠️ Could not find insertion point in ${modelName}.router.ts`);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
// 插入新接口
|
|
51
|
+
const beforeInsertion = fileContent.substring(0, closingBraceIndex);
|
|
52
|
+
const afterInsertion = fileContent.substring(closingBraceIndex);
|
|
53
|
+
const newContent = beforeInsertion + getAllTagsInterface + afterInsertion;
|
|
54
|
+
// 写入文件
|
|
55
|
+
fs.writeFileSync(routerFilePath, newContent, 'utf-8');
|
|
56
|
+
}
|
|
57
|
+
console.log(`✅ Tags 功能生成完成,共处理 ${modelsWithTags.length} 个模型`);
|
|
58
|
+
};
|
|
84
59
|
exports.generateTags = generateTags;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzyjs/next",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.29",
|
|
4
4
|
"description": "description",
|
|
5
5
|
"author": "wzy",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"rm": "rm -rf dist",
|
|
10
10
|
"cp1": "cp src/prisma/Base.zmodel dist/Base.zmodel",
|
|
11
11
|
"cp2": "cp src/plugin/crud/useHabitGroupCRUD.ts dist/plugin/crud/useHabitGroupCRUD.ts",
|
|
12
|
-
"build": "
|
|
12
|
+
"build": "bun run rm && bun run build:plugin && bun run cp1 && bun run cp2"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@zenstackhq/sdk": "^2.12.3"
|
|
19
19
|
},
|
|
20
|
-
"
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^20.19.23",
|
|
22
|
+
"typescript": "^5.9.3"
|
|
23
|
+
},
|
|
24
|
+
"gitHead": "a78702bb9367a10779eaa376ed70834d8b42b5a8",
|
|
21
25
|
"publishConfig": {
|
|
22
26
|
"access": "public"
|
|
23
27
|
}
|