@silgi/module-builder 0.5.0 → 0.6.1
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/chunks/build.mjs
CHANGED
@@ -15,7 +15,7 @@ import { pkgDir } from 'silgi/runtime/meta';
|
|
15
15
|
import { parse } from 'tsconfck';
|
16
16
|
import { convertCompilerOptionsFromJson } from 'typescript';
|
17
17
|
import { scanExports } from 'unimport';
|
18
|
-
import { v as version, n as name } from '../shared/silgi-module-builder.
|
18
|
+
import { v as version, n as name } from '../shared/silgi-module-builder.CqQxaS-m.mjs';
|
19
19
|
|
20
20
|
const srcDir = fileURLToPath(new URL("src", import.meta.url));
|
21
21
|
const subpaths = [
|
@@ -218,7 +218,7 @@ const build = defineCommand({
|
|
218
218
|
};
|
219
219
|
const metaFile = resolve(ctx.options.outDir, "module.json");
|
220
220
|
await promises.writeFile(metaFile, JSON.stringify(moduleMeta, null, 2), "utf8");
|
221
|
-
await writeTypes(ctx.options
|
221
|
+
await writeTypes(ctx.options);
|
222
222
|
},
|
223
223
|
"build:done": async function(ctx) {
|
224
224
|
const logs = [...ctx.warnings].filter((l) => l.startsWith("Potential missing package.json files:"));
|
@@ -251,91 +251,53 @@ const build = defineCommand({
|
|
251
251
|
});
|
252
252
|
}
|
253
253
|
});
|
254
|
-
async function writeTypes(options,
|
254
|
+
async function writeTypes(options, _moduleMeta) {
|
255
255
|
const dtsFile = resolve(options.outDir, "moduleTypes.d.mts");
|
256
256
|
if (existsSync(dtsFile)) {
|
257
257
|
return;
|
258
258
|
}
|
259
259
|
const moduleReExports = [];
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
moduleReExports.push(e);
|
266
|
-
}
|
267
|
-
for (const i of findTypeExports(normalisedModuleTypes)) {
|
268
|
-
moduleReExports.push(i);
|
269
|
-
}
|
260
|
+
const moduleTypesFile = resolve(options.outDir, "module.d.mts");
|
261
|
+
const moduleTypes = await promises.readFile(moduleTypesFile, "utf8").catch(() => "");
|
262
|
+
const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
|
263
|
+
for (const e of findExports(normalisedModuleTypes)) {
|
264
|
+
moduleReExports.push(e);
|
270
265
|
}
|
271
|
-
const
|
272
|
-
|
273
|
-
const schemaImports = [];
|
274
|
-
const moduleExports = [];
|
275
|
-
const hasTypeExport = (name2) => isStub || moduleReExports.find((exp) => exp.names?.includes(name2));
|
276
|
-
if (!hasTypeExport("ModuleOptions")) {
|
277
|
-
schemaImports.push("SilgiModule");
|
278
|
-
moduleImports.push("default as Module");
|
279
|
-
moduleExports.push(`export type ModuleOptions = typeof Module extends SilgiModule<infer O> ? Partial<O> : Record<string, any>`);
|
266
|
+
for (const i of findTypeExports(normalisedModuleTypes)) {
|
267
|
+
moduleReExports.push(i);
|
280
268
|
}
|
269
|
+
const moduleImports = [];
|
270
|
+
const hasTypeExport = (name2) => moduleReExports.find((exp) => exp.names?.includes(name2));
|
281
271
|
if (hasTypeExport("ModuleOptions")) {
|
282
272
|
moduleImports.push("ModuleOptions");
|
283
|
-
schemaShims.push(` interface SilgiModuleOptions extends ModuleOptions {}`);
|
284
273
|
}
|
285
274
|
if (hasTypeExport("ModuleRuntimeOptions")) {
|
286
275
|
moduleImports.push("ModuleRuntimeOptions");
|
287
|
-
schemaShims.push(` interface SilgiRuntimeOptions extends ModuleRuntimeOptions {}`);
|
288
276
|
}
|
289
277
|
if (hasTypeExport("ModuleRuntimeShareds")) {
|
290
278
|
moduleImports.push("ModuleRuntimeShareds");
|
291
|
-
schemaShims.push(" interface SilgiRuntimeSharedsExtend extends ModuleRuntimeShareds {}");
|
292
279
|
}
|
293
280
|
if (hasTypeExport("ModuleEvents")) {
|
294
281
|
moduleImports.push("ModuleEvents");
|
295
|
-
schemaShims.push(" interface SilgiEvent extends ModuleEvents {}");
|
296
282
|
}
|
297
283
|
if (hasTypeExport("ModuleRuntimeContexts")) {
|
298
284
|
moduleImports.push("ModuleRuntimeContexts");
|
299
|
-
schemaShims.push(" interface SilgiRuntimeContext extends ModuleRuntimeContexts {}");
|
300
285
|
}
|
301
286
|
if (hasTypeExport("ModuleHooks")) {
|
302
287
|
moduleImports.push("ModuleHooks");
|
303
|
-
schemaShims.push(" interface SilgiHooks extends ModuleHooks {}");
|
304
288
|
}
|
305
289
|
if (hasTypeExport("ModuleRuntimeHooks")) {
|
306
290
|
moduleImports.push("ModuleRuntimeHooks");
|
307
|
-
schemaShims.push(" interface SilgiRuntimeHooks extends ModuleRuntimeHooks {}");
|
308
291
|
}
|
309
292
|
if (hasTypeExport("ModuleRuntimeActions")) {
|
310
293
|
moduleImports.push("ModuleRuntimeActions");
|
311
|
-
schemaShims.push(` interface SilgiRuntimeActions extends ModuleRuntimeActions {}`);
|
312
294
|
}
|
313
295
|
if (hasTypeExport("ModuleRuntimeMethods")) {
|
314
296
|
moduleImports.push("ModuleRuntimeMethods");
|
315
|
-
schemaShims.push(` interface SilgiRuntimeMethods extends ModuleRuntimeMethods {}`);
|
316
|
-
}
|
317
|
-
if (hasTypeExport("ModuleRuntimeRouteRules")) {
|
318
|
-
moduleImports.push("ModuleRuntimeRouteRules");
|
319
|
-
schemaShims.push(` interface SilgiRuntimeRouteRules extends ModuleRuntimeRouteRules {}`);
|
320
|
-
}
|
321
|
-
if (hasTypeExport("ModuleRuntimeRouteRulesConfig")) {
|
322
|
-
moduleImports.push("ModuleRuntimeRouteRulesConfig");
|
323
|
-
schemaShims.push(` interface SilgiRuntimeRouteRulesConfig extends ModuleRuntimeRouteRulesConfig {}`);
|
324
297
|
}
|
325
298
|
const dtsContents = `${`
|
326
|
-
${schemaImports.length ? `import type { ${schemaImports.join(", ")} } from 'silgi/types'` : ""}
|
327
|
-
|
328
299
|
${moduleImports.length ? `import type { ${moduleImports.join(", ")} } from './module.mjs'` : ""}
|
329
300
|
|
330
|
-
${schemaShims.length ? `declare module 'silgi/types' {
|
331
|
-
${schemaShims.join("\n")}
|
332
|
-
}
|
333
|
-
` : ""}
|
334
|
-
${moduleExports.length ? `
|
335
|
-
${moduleExports.join("\n")}` : ""}
|
336
|
-
${isStub ? 'export * from "./module.mjs"' : ""}
|
337
|
-
${moduleReExports.filter((e) => e.type === "named" || e.type === "default").map((e) => `
|
338
|
-
export { ${e.names.map((n) => (n === "default" ? "" : "type ") + n).join(", ")} } from '${e.specifier || "./module.mjs"}'`).join("\n")}
|
339
301
|
${moduleReExports.filter((e) => e.type === "star").map((e) => `
|
340
302
|
export * from '${e.specifier || "./module.mjs"}'`).join("\n")}
|
341
303
|
`.trim().replace(/[\n\r]{3,}/g, "\n\n")}
|
package/dist/cli.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import { defineCommand, runMain } from 'citty';
|
3
3
|
import { consola } from 'consola';
|
4
|
-
import { v as version, d as description, n as name } from './shared/silgi-module-builder.
|
4
|
+
import { v as version, d as description, n as name } from './shared/silgi-module-builder.CqQxaS-m.mjs';
|
5
5
|
|
6
6
|
const _rDefault = (r) => r && typeof r === "object" && "default" in r ? r.default : r;
|
7
7
|
const main = defineCommand({
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@silgi/module-builder",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.6.1",
|
5
5
|
"private": false,
|
6
6
|
"description": "Complete solution for building Silgi modules",
|
7
7
|
"exports": {
|
@@ -19,19 +19,19 @@
|
|
19
19
|
"consola": "^3.4.2",
|
20
20
|
"defu": "^6.1.4",
|
21
21
|
"dev-jiti": "^2.4.2",
|
22
|
-
"magic-regexp": "^0.
|
22
|
+
"magic-regexp": "^0.10.0",
|
23
23
|
"mlly": "^1.7.4",
|
24
24
|
"pathe": "^2.0.3",
|
25
25
|
"pkg-types": "^2.1.0",
|
26
|
-
"silgi": "^0.
|
26
|
+
"silgi": "^0.37.39",
|
27
27
|
"tsconfck": "^3.1.5",
|
28
28
|
"unbuild": "^3.5.0",
|
29
|
-
"unimport": "^5.0.
|
29
|
+
"unimport": "^5.0.1"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
|
-
"@antfu/eslint-config": "^4.
|
33
|
-
"@types/node": "^22.
|
34
|
-
"eslint": "^9.
|
32
|
+
"@antfu/eslint-config": "^4.13.0",
|
33
|
+
"@types/node": "^22.15.16",
|
34
|
+
"eslint": "^9.26.0",
|
35
35
|
"typescript": "^5.8.3"
|
36
36
|
},
|
37
37
|
"publishConfig": {
|