@silgi/module-builder 0.4.11 → 0.6.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.
@@ -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.Bpzy2kWP.mjs';
18
+ import { v as version, n as name } from '../shared/silgi-module-builder.C7f-yJv1.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, ctx.options.stub);
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,28 +251,25 @@ const build = defineCommand({
251
251
  });
252
252
  }
253
253
  });
254
- async function writeTypes(options, isStub, _moduleMeta) {
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
- if (!isStub) {
261
- const moduleTypesFile = resolve(options.outDir, "module.d.mts");
262
- const moduleTypes = await promises.readFile(moduleTypesFile, "utf8").catch(() => "");
263
- const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
264
- for (const e of findExports(normalisedModuleTypes)) {
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);
265
+ }
266
+ for (const i of findTypeExports(normalisedModuleTypes)) {
267
+ moduleReExports.push(i);
270
268
  }
271
- const schemaShims = [];
272
269
  const moduleImports = [];
273
270
  const schemaImports = [];
274
271
  const moduleExports = [];
275
- const hasTypeExport = (name2) => isStub || moduleReExports.find((exp) => exp.names?.includes(name2));
272
+ const hasTypeExport = (name2) => moduleReExports.find((exp) => exp.names?.includes(name2));
276
273
  if (!hasTypeExport("ModuleOptions")) {
277
274
  schemaImports.push("SilgiModule");
278
275
  moduleImports.push("default as Module");
@@ -280,60 +277,38 @@ async function writeTypes(options, isStub, _moduleMeta) {
280
277
  }
281
278
  if (hasTypeExport("ModuleOptions")) {
282
279
  moduleImports.push("ModuleOptions");
283
- schemaShims.push(` interface SilgiModuleOptions extends ModuleOptions {}`);
284
280
  }
285
281
  if (hasTypeExport("ModuleRuntimeOptions")) {
286
282
  moduleImports.push("ModuleRuntimeOptions");
287
- schemaShims.push(` interface SilgiRuntimeOptions extends ModuleRuntimeOptions {}`);
288
283
  }
289
284
  if (hasTypeExport("ModuleRuntimeShareds")) {
290
285
  moduleImports.push("ModuleRuntimeShareds");
291
- schemaShims.push(" interface SilgiRuntimeSharedsExtend extends ModuleRuntimeShareds {}");
292
286
  }
293
287
  if (hasTypeExport("ModuleEvents")) {
294
288
  moduleImports.push("ModuleEvents");
295
- schemaShims.push(" interface SilgiEvent extends ModuleEvents {}");
296
289
  }
297
290
  if (hasTypeExport("ModuleRuntimeContexts")) {
298
291
  moduleImports.push("ModuleRuntimeContexts");
299
- schemaShims.push(" interface SilgiRuntimeContext extends ModuleRuntimeContexts {}");
300
292
  }
301
293
  if (hasTypeExport("ModuleHooks")) {
302
294
  moduleImports.push("ModuleHooks");
303
- schemaShims.push(" interface SilgiHooks extends ModuleHooks {}");
304
295
  }
305
296
  if (hasTypeExport("ModuleRuntimeHooks")) {
306
297
  moduleImports.push("ModuleRuntimeHooks");
307
- schemaShims.push(" interface SilgiRuntimeHooks extends ModuleRuntimeHooks {}");
308
298
  }
309
299
  if (hasTypeExport("ModuleRuntimeActions")) {
310
300
  moduleImports.push("ModuleRuntimeActions");
311
- schemaShims.push(` interface SilgiRuntimeActions extends ModuleRuntimeActions {}`);
312
301
  }
313
302
  if (hasTypeExport("ModuleRuntimeMethods")) {
314
303
  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
304
  }
325
305
  const dtsContents = `${`
326
306
  ${schemaImports.length ? `import type { ${schemaImports.join(", ")} } from 'silgi/types'` : ""}
327
307
 
328
308
  ${moduleImports.length ? `import type { ${moduleImports.join(", ")} } from './module.mjs'` : ""}
329
309
 
330
- ${schemaShims.length ? `declare module 'silgi/types' {
331
- ${schemaShims.join("\n")}
332
- }
333
- ` : ""}
334
310
  ${moduleExports.length ? `
335
311
  ${moduleExports.join("\n")}` : ""}
336
- ${isStub ? 'export * from "./module.mjs"' : ""}
337
312
  ${moduleReExports.filter((e) => e.type === "named" || e.type === "default").map((e) => `
338
313
  export { ${e.names.map((n) => (n === "default" ? "" : "type ") + n).join(", ")} } from '${e.specifier || "./module.mjs"}'`).join("\n")}
339
314
  ${moduleReExports.filter((e) => e.type === "star").map((e) => `
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.Bpzy2kWP.mjs';
4
+ import { v as version, d as description, n as name } from './shared/silgi-module-builder.C7f-yJv1.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
@@ -16,4 +16,4 @@ import 'silgi/runtime/meta';
16
16
  import 'tsconfck';
17
17
  import 'typescript';
18
18
  import 'unimport';
19
- import './shared/silgi-module-builder.Bpzy2kWP.mjs';
19
+ import './shared/silgi-module-builder.C7f-yJv1.mjs';
@@ -1,5 +1,5 @@
1
1
  const name = "@silgi/module-builder";
2
- const version = "0.4.11";
2
+ const version = "0.6.0";
3
3
  const description = "Complete solution for building Silgi modules";
4
4
 
5
5
  export { description as d, name as n, version as v };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silgi/module-builder",
3
3
  "type": "module",
4
- "version": "0.4.11",
4
+ "version": "0.6.0",
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.9.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.28.1",
26
+ "silgi": "^0.37.39",
27
27
  "tsconfck": "^3.1.5",
28
28
  "unbuild": "^3.5.0",
29
- "unimport": "^5.0.0"
29
+ "unimport": "^5.0.1"
30
30
  },
31
31
  "devDependencies": {
32
- "@antfu/eslint-config": "^4.12.0",
33
- "@types/node": "^22.14.1",
34
- "eslint": "^9.25.0",
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": {
package/dist/cli.d.ts DELETED
@@ -1 +0,0 @@
1
-
package/dist/index.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import * as citty from 'citty';
2
-
3
- declare const _default: citty.CommandDef<{
4
- cwd: {
5
- type: "string";
6
- description: string;
7
- };
8
- rootDir: {
9
- type: "positional";
10
- description: string;
11
- required: false;
12
- };
13
- outDir: {
14
- type: "string";
15
- };
16
- sourcemap: {
17
- type: "boolean";
18
- };
19
- stub: {
20
- type: "boolean";
21
- };
22
- check: {
23
- type: "boolean";
24
- };
25
- }>;
26
-
27
- export { _default as build };