@venizia/ignis-boot 0.3.6 → 0.4.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/LICENSE.md +1 -1
- package/dist/cjs/bun/auto-loader.js +3 -3
- package/dist/cjs/bun/auto-loader.js.map +1 -1
- package/dist/cjs/bun/group-resolver.js +1 -1
- package/dist/cjs/bun/group-resolver.js.map +1 -1
- package/dist/cjs/bun/plugin.js +10 -10
- package/dist/cjs/bun/plugin.js.map +1 -1
- package/dist/cjs/bun/scan-cache.js +1 -1
- package/dist/cjs/bun/scan-cache.js.map +1 -1
- package/dist/cjs/bun/sources.js +4 -4
- package/dist/cjs/bun/sources.js.map +1 -1
- package/dist/cjs/clis/artifacts.js +1 -1
- package/dist/cjs/clis/artifacts.js.map +1 -1
- package/dist/cjs/generator/emitter.d.ts +2 -2
- package/dist/cjs/generator/emitter.d.ts.map +1 -1
- package/dist/cjs/generator/emitter.js +8 -8
- package/dist/cjs/generator/emitter.js.map +1 -1
- package/dist/cjs/generator/scanner.d.ts.map +1 -1
- package/dist/cjs/generator/scanner.js +10 -8
- package/dist/cjs/generator/scanner.js.map +1 -1
- package/dist/cjs/vite/plugin.js +3 -3
- package/dist/cjs/vite/plugin.js.map +1 -1
- package/dist/esm/bun/auto-loader.js +3 -3
- package/dist/esm/bun/auto-loader.js.map +1 -1
- package/dist/esm/bun/group-resolver.js +1 -1
- package/dist/esm/bun/group-resolver.js.map +1 -1
- package/dist/esm/bun/plugin.js +10 -10
- package/dist/esm/bun/plugin.js.map +1 -1
- package/dist/esm/bun/scan-cache.js +1 -1
- package/dist/esm/bun/scan-cache.js.map +1 -1
- package/dist/esm/bun/sources.js +4 -4
- package/dist/esm/bun/sources.js.map +1 -1
- package/dist/esm/clis/artifacts.js +1 -1
- package/dist/esm/clis/artifacts.js.map +1 -1
- package/dist/esm/generator/emitter.d.ts +2 -2
- package/dist/esm/generator/emitter.d.ts.map +1 -1
- package/dist/esm/generator/emitter.js +8 -8
- package/dist/esm/generator/emitter.js.map +1 -1
- package/dist/esm/generator/scanner.d.ts.map +1 -1
- package/dist/esm/generator/scanner.js +10 -8
- package/dist/esm/generator/scanner.js.map +1 -1
- package/dist/esm/vite/plugin.js +3 -3
- package/dist/esm/vite/plugin.js.map +1 -1
- package/package.json +26 -27
package/LICENSE.md
CHANGED
|
@@ -62,7 +62,7 @@ Part of the Ignis monorepo:
|
|
|
62
62
|
| `@venizia/ignis-boot` | **This package** - Application bootstrapping |
|
|
63
63
|
| `@venizia/ignis-helpers` | Utility helpers - logging, cron, Redis, queues, storage |
|
|
64
64
|
| `@venizia/ignis-inversion` | Dependency Injection & IoC container |
|
|
65
|
-
| `@venizia/dev-configs` | Shared
|
|
65
|
+
| `@venizia/dev-configs` | Shared oxlint, ESLint, TypeScript configurations |
|
|
66
66
|
| `@venizia/ignis-docs` | Documentation and MCP Server |
|
|
67
67
|
|
|
68
68
|
---
|
|
@@ -38,7 +38,7 @@ class AutoArtifactsLoader {
|
|
|
38
38
|
/** The index the emitter would render for `artifacts`: modules imported in path order, each field sorted by class name. */
|
|
39
39
|
static async importIndex(opts) {
|
|
40
40
|
const emitted = opts.artifacts
|
|
41
|
-
.filter(artifact => artifact.type !== common_1.ArtifactTypes.MODEL)
|
|
41
|
+
.filter((artifact) => artifact.type !== common_1.ArtifactTypes.MODEL)
|
|
42
42
|
.sort((left, right) => left.filePath.localeCompare(right.filePath) ||
|
|
43
43
|
left.className.localeCompare(right.className));
|
|
44
44
|
const loaded = new Map();
|
|
@@ -49,9 +49,9 @@ class AutoArtifactsLoader {
|
|
|
49
49
|
const index = {};
|
|
50
50
|
for (const { type, field } of common_1.ArtifactStereotypes.EMIT_ORDER) {
|
|
51
51
|
const classes = emitted
|
|
52
|
-
.filter(artifact => artifact.type === type)
|
|
52
|
+
.filter((artifact) => artifact.type === type)
|
|
53
53
|
.sort((left, right) => left.className.localeCompare(right.className))
|
|
54
|
-
.flatMap(artifact => loaded.get(artifact) ?? []);
|
|
54
|
+
.flatMap((artifact) => loaded.get(artifact) ?? []);
|
|
55
55
|
if (classes.length > 0) {
|
|
56
56
|
index[field] = classes;
|
|
57
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-loader.js","sourceRoot":"","sources":["../../../src/bun/auto-loader.ts"],"names":[],"mappings":";;;AAAA,0DAAkD;AAElD,yCAAoC;AACpC,gDAK6B;AAC7B,uCAA4C;AAE5C,0MAA0M;AAC1M,MAAa,mBAAmB;IAC9B,MAAM,CAAC,aAAa,CAAC,IAAyB;QAC5C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAA,wBAAQ,EAAC;gBACb,OAAO,EACL,sNAAsN;aACzN,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI;QACf,mBAAmB,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,KAAK,WAAW,EAAE,CAAC,CAAC;QAE1E,iGAAiG;QACjG,MAAM,KAAK,GAAG,yBAAe,CAAC,KAAK,EAAE,CAAC;QACtC,MAAM,aAAa,GAAG,yBAAe,CAAC,aAAa,CAAC;YAClD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,IAAA,mBAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;SAC7C,CAAC,CAAC;QACH,IAAI,yBAAe,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;YAChD,MAAM,SAAS,GAAG,yBAAe,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC;YAC1D,OAAO,mBAAmB,CAAC,WAAW,CAAC;gBACrC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,yBAAe,CAAC,gBAAgB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;aAC5F,CAA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C,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,KAAK,GAA2C,EAAE,CAAC;QACzD,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,4BAAmB,CAAC,UAAU,EAAE,CAAC;YAC7D,MAAM,OAAO,GAAG,OAAO;iBACpB,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC;iBAC5C,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;iBACpE,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YACrD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;YACzB,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAjED,kDAiEC","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport type { AnyType, TClass } from '@venizia/ignis-helpers';\nimport { dirname } from 'node:path';\nimport {\n ArtifactStereotypes,\n ArtifactTypes,\n type IScannedArtifact,\n type TGeneratedArtifactIndex,\n} from '../generator/common';\nimport { ArtifactSources } from './sources';\n\n/** Loads the application's index for `@venizia/ignis-boot/auto` from source: registers the run-time plugin, then imports the virtual module. A binary never runs this - the build replaces the module. */\nexport class AutoArtifactsLoader {\n static assertRuntime(opts: { hasBun: boolean }): void {\n if (!opts.hasBun) {\n throw getError({\n message:\n '[@venizia/ignis-boot/auto] Auto artifacts need Bun (a Bun plugin builds the index) | On Node, generate the index with `ignis-artifacts generate --root src --out src/_artifacts.ts` and pass it to configs.artifacts',\n });\n }\n }\n\n static async load(): Promise<TGeneratedArtifactIndex> {\n AutoArtifactsLoader.assertRuntime({ hasBun: typeof Bun !== 'undefined' });\n\n // A warm scan cache needs neither the plugin nor TypeScript: import the listed classes directly.\n const entry = ArtifactSources.entry();\n const packageSource = ArtifactSources.packageSource({\n from: entry ? dirname(entry) : process.cwd(),\n });\n if (ArtifactSources.isCached({ packageSource })) {\n const artifacts = ArtifactSources.scan({ packageSource });\n return AutoArtifactsLoader.importIndex({\n artifacts: entry ? ArtifactSources.runningArtifacts({ artifacts, from: entry }) : artifacts,\n });\n }\n\n // A non-static specifier: a bundler must not pull the scanner (and TypeScript) into a binary.\n const pluginModule = './plugin';\n const { IgnisArtifactsPlugin } = await import(pluginModule);\n await IgnisArtifactsPlugin.registerRuntime();\n\n // A static specifier on purpose: a build without IgnisArtifactsPlugin then fails to resolve it, instead of shipping a binary with no classes.\n const { GeneratedArtifacts } = await import('ignis:artifacts');\n return GeneratedArtifacts;\n }\n\n /** The index the emitter would render for `artifacts`: modules imported in path order, each field sorted by class name. */\n static async importIndex(opts: {\n artifacts: IScannedArtifact[];\n }): Promise<TGeneratedArtifactIndex> {\n const emitted = opts.artifacts\n .filter((artifact) => artifact.type !== ArtifactTypes.MODEL)\n .sort(\n (left, right) =>\n left.filePath.localeCompare(right.filePath) ||\n left.className.localeCompare(right.className),\n );\n\n const loaded = new Map<IScannedArtifact, TClass<AnyType>>();\n for (const artifact of emitted) {\n const module = await import(artifact.filePath);\n loaded.set(artifact, module[artifact.className]);\n }\n\n const index: Record<string, Array<TClass<AnyType>>> = {};\n for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {\n const classes = emitted\n .filter((artifact) => artifact.type === type)\n .sort((left, right) => left.className.localeCompare(right.className))\n .flatMap((artifact) => loaded.get(artifact) ?? []);\n if (classes.length > 0) {\n index[field] = classes;\n }\n }\n return index;\n }\n}\n"]}
|
|
@@ -23,7 +23,7 @@ class GroupArtifactsResolver {
|
|
|
23
23
|
}
|
|
24
24
|
const index = {};
|
|
25
25
|
for (const artifact of sources_1.ArtifactSources.folderArtifacts({ folder, site, ignore })) {
|
|
26
|
-
const field = common_1.ArtifactStereotypes.EMIT_ORDER.find(entry => entry.type === artifact.type)?.field;
|
|
26
|
+
const field = common_1.ArtifactStereotypes.EMIT_ORDER.find((entry) => entry.type === artifact.type)?.field;
|
|
27
27
|
if (!field) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-resolver.js","sourceRoot":"","sources":["../../../src/bun/group-resolver.ts"],"names":[],"mappings":";;;AAAA,0DAAkD;AAElD,gDAAwF;AACxF,yCAAoC;AACpC,uCAA4C;AAE5C,2OAA2O;AAC3O,MAAa,sBAAsB;IACjC,uGAAuG;aACvF,eAAU,GAAG,MAAM,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;IAEzF,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAMpB;QACC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAA,wBAAQ,EAAC;gBACb,OAAO,EAAE,oBAAoB,MAAM,IAAI,eAAe,6GAA6G;aACpK,CAAC,CAAC;QACL,CAAC;QAED,IACE,CAAC,yBAAe,CAAC,QAAQ,CAAC;YACxB,aAAa,EAAE,yBAAe,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,IAAA,mBAAO,EAAC,IAAI,CAAC,EAAE,CAAC;SACtE,CAAC,EACF,CAAC;YACD,MAAM,yBAAe,CAAC,WAAW,EAAE,CAAC;QACtC,CAAC;QAED,MAAM,KAAK,GAA2C,EAAE,CAAC;QACzD,KAAK,MAAM,QAAQ,IAAI,yBAAe,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;YACjF,MAAM,KAAK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,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC/C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,mIAAmI;IACnI,MAAM,CAAC,OAAO;QACZ,MAAM,QAAQ,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;QACrF,MAAM,MAAM,GACV,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,MAAM,CAAC,OAAO,GAAG,CAAC,WAMjB,EAAE,EAAE,CAAC,sBAAsB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,sBAAsB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC;;AArDH,wDAsDC","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport type { AnyType, TClass } from '@venizia/ignis-helpers';\nimport { ArtifactStereotypes, type TGeneratedArtifactIndex } from '../generator/common';\nimport { dirname } from 'node:path';\nimport { ArtifactSources } from './sources';\n\n/** Fills an `ArtifactGroup` defined without content, from source: the defining package is the nearest `package.json` above the group's call site, and the group is every decorated class under a directory named `folder` in its `src`. */\nexport class GroupArtifactsResolver {\n /** The kernel's `SingletonRealm` slot for the group resolver (`ArtifactGroup.SINGLETON_REALM_KEY`). */\n static readonly REALM_SLOT = Symbol.for('@venizia/ignis-kernel:artifact-group-resolver');\n\n static async resolve(opts: {\n group: {\n folder: string | undefined;\n site: string | undefined;\n ignore?: ReadonlyArray<string>;\n };\n }): Promise<TGeneratedArtifactIndex> {\n const { folder, site, ignore } = opts.group;\n if (!site) {\n throw getError({\n message: `[ArtifactGroup] '${folder ?? '<application>'}' has no call site to resolve from | Define it with ArtifactGroup.define in the shared package's own source`,\n });\n }\n\n if (\n !ArtifactSources.isCached({\n packageSource: ArtifactSources.packageSource({ from: dirname(site) }),\n })\n ) {\n await ArtifactSources.loadScanner();\n }\n\n const index: Record<string, Array<TClass<AnyType>>> = {};\n for (const artifact of ArtifactSources.folderArtifacts({ folder, site, ignore })) {\n const field = ArtifactStereotypes.EMIT_ORDER.find(\n (entry) => entry.type === artifact.type,\n )?.field;\n if (!field) {\n continue;\n }\n const loaded = await import(artifact.filePath);\n index[field] = [...(index[field] ?? []), loaded[artifact.className]];\n }\n return index;\n }\n\n /** Fills the kernel's realm slot; the holder may already exist (the kernel created it empty), so it is mutated, never replaced. */\n static install(): void {\n const existing: unknown = Reflect.get(globalThis, GroupArtifactsResolver.REALM_SLOT);\n const holder: { resolve?: unknown } =\n typeof existing === 'object' && existing !== null ? existing : {};\n holder.resolve = (resolveOpts: {\n group: {\n folder: string | undefined;\n site: string | undefined;\n ignore?: ReadonlyArray<string>;\n };\n }) => GroupArtifactsResolver.resolve(resolveOpts);\n Reflect.set(globalThis, GroupArtifactsResolver.REALM_SLOT, holder);\n }\n}\n"]}
|
package/dist/cjs/bun/plugin.js
CHANGED
|
@@ -90,8 +90,8 @@ class IgnisArtifactsPlugin {
|
|
|
90
90
|
const fields = [];
|
|
91
91
|
for (const { type, field } of generator_1.ArtifactStereotypes.EMIT_ORDER) {
|
|
92
92
|
const locals = artifacts
|
|
93
|
-
.filter(artifact => artifact.type === type)
|
|
94
|
-
.map(artifact => {
|
|
93
|
+
.filter((artifact) => artifact.type === type)
|
|
94
|
+
.map((artifact) => {
|
|
95
95
|
if (isCompiled) {
|
|
96
96
|
return `require(${JSON.stringify(artifact.filePath)}).${artifact.className}`;
|
|
97
97
|
}
|
|
@@ -143,7 +143,7 @@ class IgnisArtifactsPlugin {
|
|
|
143
143
|
refuse(call, 'the argument is not an object literal');
|
|
144
144
|
}
|
|
145
145
|
const literal = argument;
|
|
146
|
-
const named = (name) => literal.properties.find(entry => entry.name !== undefined && typescript_1.default.isIdentifier(entry.name) && entry.name.text === name);
|
|
146
|
+
const named = (name) => literal.properties.find((entry) => entry.name !== undefined && typescript_1.default.isIdentifier(entry.name) && entry.name.text === name);
|
|
147
147
|
if (named('content')) {
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
@@ -163,8 +163,8 @@ class IgnisArtifactsPlugin {
|
|
|
163
163
|
const ignoreList = ignoreProperty &&
|
|
164
164
|
typescript_1.default.isPropertyAssignment(ignoreProperty) &&
|
|
165
165
|
typescript_1.default.isArrayLiteralExpression(ignoreProperty.initializer) &&
|
|
166
|
-
ignoreProperty.initializer.elements.every(element => typescript_1.default.isStringLiteral(element))
|
|
167
|
-
? ignoreProperty.initializer.elements.map(element => element.text)
|
|
166
|
+
ignoreProperty.initializer.elements.every((element) => typescript_1.default.isStringLiteral(element))
|
|
167
|
+
? ignoreProperty.initializer.elements.map((element) => element.text)
|
|
168
168
|
: undefined;
|
|
169
169
|
if (ignoreProperty && ignoreList === undefined) {
|
|
170
170
|
refuse(call, 'ignore is not an array of string literals');
|
|
@@ -194,7 +194,7 @@ class IgnisArtifactsPlugin {
|
|
|
194
194
|
const found = [];
|
|
195
195
|
const visit = (node) => {
|
|
196
196
|
if (typescript_1.default.isClassDeclaration(node) && node.name) {
|
|
197
|
-
const isDecorated = (typescript_1.default.getDecorators(node) ?? []).some(decorator => {
|
|
197
|
+
const isDecorated = (typescript_1.default.getDecorators(node) ?? []).some((decorator) => {
|
|
198
198
|
const expression = typescript_1.default.isCallExpression(decorator.expression)
|
|
199
199
|
? decorator.expression.expression
|
|
200
200
|
: decorator.expression;
|
|
@@ -246,7 +246,7 @@ class IgnisArtifactsPlugin {
|
|
|
246
246
|
if (!IgnisArtifactsPlugin.DECORATED.test(source)) {
|
|
247
247
|
continue;
|
|
248
248
|
}
|
|
249
|
-
add(IgnisArtifactsPlugin.decoratedClasses({ filePath: file, source }).map(className => ({
|
|
249
|
+
add(IgnisArtifactsPlugin.decoratedClasses({ filePath: file, source }).map((className) => ({
|
|
250
250
|
filePath: file,
|
|
251
251
|
className,
|
|
252
252
|
})));
|
|
@@ -265,7 +265,7 @@ class IgnisArtifactsPlugin {
|
|
|
265
265
|
}
|
|
266
266
|
/** The source files that define groups: the application's own `src` and the `src` of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does. */
|
|
267
267
|
static groupDefinitionFiles(opts) {
|
|
268
|
-
return IgnisArtifactsPlugin.workspaceSourceFiles(opts).filter(file => IgnisArtifactsPlugin.DEFINE_CALL.test((0, node_fs_1.readFileSync)(file, 'utf8')));
|
|
268
|
+
return IgnisArtifactsPlugin.workspaceSourceFiles(opts).filter((file) => IgnisArtifactsPlugin.DEFINE_CALL.test((0, node_fs_1.readFileSync)(file, 'utf8')));
|
|
269
269
|
}
|
|
270
270
|
/** The source files of the application and of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does - plus the compiled trees beside each `src`, for a package that runs from `dist`. Tests excluded. */
|
|
271
271
|
static workspaceSourceFiles(opts) {
|
|
@@ -351,8 +351,8 @@ class IgnisArtifactsPlugin {
|
|
|
351
351
|
const pinned = IgnisArtifactsPlugin.pinnedClasses({ root, groupFiles, entry });
|
|
352
352
|
const loaded = [...new Set([...groupFiles, ...pinned.keys()])];
|
|
353
353
|
if (loaded.length > 0) {
|
|
354
|
-
const escaped = loaded.map(file => file.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&'));
|
|
355
|
-
build.onLoad({ filter: new RegExp(`^(?:${escaped.join('|')})$`) }, args => {
|
|
354
|
+
const escaped = loaded.map((file) => file.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&'));
|
|
355
|
+
build.onLoad({ filter: new RegExp(`^(?:${escaped.join('|')})$`) }, (args) => {
|
|
356
356
|
const source = (0, node_fs_1.readFileSync)(args.path, 'utf8');
|
|
357
357
|
const grouped = groupFileSet.has(args.path)
|
|
358
358
|
? IgnisArtifactsPlugin.rewriteGroups({ filePath: args.path, source })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/bun/plugin.ts"],"names":[],"mappings":";;;;;;AACA,0DAAkD;AAClD,qCAAwF;AACxF,yCAAwD;AACxD,4DAA4B;AAC5B,4CAA0F;AAC1F,uCAA4C;AAE5C,6QAA6Q;AAC7Q,MAAa,oBAAoB;aACf,SAAI,GAAG,iBAAiB,CAAC;aACzB,YAAO,GAAG,iBAAiB,CAAC;aAC5B,gBAAW,GAAG,oBAAoB,CAAC;IAEnD,+IAA+I;aAC/H,gBAAW,GACzB,kHAAkH,CAAC;IAErH,oHAAoH;aACpG,gBAAW,GAAG,kDAAkD,CAAC;aAEzD,gBAAW,GAAG,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;IAEjG;QACE,yBAAe,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,2BAAe,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,8GAA8G;IAC9G,MAAM,CAAC,WAAW,CAAC,OAA0B,EAAE;QAC7C,OAAO,yBAAe,CAAC,aAAa,CAAC;YACnC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,oBAAoB,CAAC,cAAc,EAAE;SACzD,CAAC,CAAC;IACL,CAAC;IAED,wLAAwL;IACxL,MAAM,CAAC,cAAc;QACnB,MAAM,KAAK,GAAG,yBAAe,CAAC,KAAK,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC,CAAC,CAAC,IAAA,mBAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IAChD,CAAC;IAED,+NAA+N;IAC/N,MAAM,CAAC,MAAM,CAAC,IAAsC;QAClD,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAA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O,0GAA0G,oBAAoB,CAAC,WAAW,QAAQ,CAAC;gBAC3O,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;oBAChE,QAAQ,EAAE,UAAU;oBACpB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAC,CAAC;YACN,CAAC;SACF,CAAC;IACJ,CAAC;IAED,gFAAgF;IAChF,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAA0B,EAAE;QACvD,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,oBAAoB,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,CAAC;YACvE,OAAO;QACT,CAAC;QACD,MAAM,GAAG,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,oBAAoB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;;AArcH,oDAscC","sourcesContent":["import type { BunPlugin } from 'bun';\nimport { getError } from '@venizia/ignis-helpers';\nimport { existsSync, globSync, readdirSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join, resolve, sep } from 'node:path';\nimport ts from 'typescript';\nimport { ArtifactIndexEmitter, ArtifactScanner, ArtifactStereotypes } from '../generator';\nimport { ArtifactSources } from './sources';\n\n/** Serves `ignis:artifacts` - the application's generated index, rendered in memory from the scanner. At run time it is a virtual module (`build.module`); in `Bun.build` it is resolved and loaded (`onResolve`/`onLoad`), so a binary carries the list and never scans. */\nexport class IgnisArtifactsPlugin {\n static readonly NAME = 'ignis-artifacts';\n static readonly VIRTUAL = 'ignis:artifacts';\n static readonly EXPORT_NAME = 'GeneratedArtifacts';\n\n /** `@venizia/ignis-boot/auto`, from source or from either dist format - replaced at build time by a static re-export of the virtual module. */\n static readonly AUTO_MODULE =\n /[\\\\/](?:@venizia[\\\\/]ignis-boot|packages[\\\\/]boot)[\\\\/](?:dist[\\\\/](?:esm|cjs)|src)[\\\\/]bun[\\\\/]auto\\.(?:ts|js)$/;\n\n /** A text test for a file worth parsing: `ArtifactGroup.define(`, with any spacing or line break around the dot. */\n static readonly DEFINE_CALL = /ArtifactGroup\\s*\\.\\s*(?:define|application)\\s*\\(/;\n\n private static readonly RUNTIME_KEY = Symbol.for('@venizia/ignis-boot:artifacts-runtime-plugin');\n\n static {\n ArtifactSources.useScanner({ scanner: ArtifactScanner.getInstance() });\n }\n\n /** The `src` beside the nearest `package.json` at or above `from` (default: the entry module's directory). */\n static defaultRoot(opts: { from?: string } = {}): string {\n return ArtifactSources.packageSource({\n from: opts.from ?? IgnisArtifactsPlugin.entryDirectory(),\n });\n }\n\n /** The entry module's directory (`Bun.main`), so the root never depends on where the process was started; the working directory only when there is no entry file (`bun -e`, a REPL). */\n static entryDirectory(): string {\n const entry = ArtifactSources.entry();\n return entry ? dirname(entry) : process.cwd();\n }\n\n /** The index as module source: every import absolute, since a virtual module has no directory to resolve from. With `entry` in a compiled tree, each class is imported from that tree (`ArtifactSources.runningArtifacts`). */\n static render(opts: { root: string; entry?: string }): string {\n const root = resolve(opts.root);\n if (!existsSync(root)) {\n throw getError({\n message: `[IgnisArtifactsPlugin] ${dirname(root)} has no src directory (${root}) | Auto artifacts scan the src beside the package.json of the entry module; pass IgnisArtifactsPlugin.create({ root }), or use ArtifactGroup.application() in the application's own source`,\n });\n }\n const outFile = join(root, '__ignis_artifacts__.ts');\n const artifacts = ArtifactSources.scan({ packageSource: root });\n return ArtifactIndexEmitter.render({\n artifacts: opts.entry\n ? ArtifactSources.runningArtifacts({ artifacts, from: opts.entry })\n : artifacts,\n outFile,\n exportName: IgnisArtifactsPlugin.EXPORT_NAME,\n command: { root, out: outFile },\n absoluteImports: true,\n });\n }\n\n /** Rewrites every `ArtifactGroup.define({ folder: '<literal>' })` and `ArtifactGroup.application()` in a source file to carry its classes as `content`, imported by absolute path - a binary then holds each group's list and never scans. A group with no decorated class, or a call the plugin cannot read (an aliased `ArtifactGroup`, a folder that is not a string literal), fails the build. */\n static rewriteGroups(opts: { filePath: string; source: string }): string {\n const { filePath, source } = opts;\n const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true);\n const aliases = new Set<string>();\n for (const statement of sourceFile.statements) {\n const bindings = ts.isImportDeclaration(statement)\n ? statement.importClause?.namedBindings\n : undefined;\n for (const element of bindings && ts.isNamedImports(bindings) ? bindings.elements : []) {\n if (\n (element.propertyName ?? element.name).text === 'ArtifactGroup' &&\n element.name.text !== 'ArtifactGroup'\n ) {\n aliases.add(element.name.text);\n }\n }\n }\n\n const edits: Array<{ at: number; text: string }> = [];\n const imports: string[] = [];\n let counter = 0;\n\n const refuse = (node: ts.Node, reason: string): never => {\n const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n throw getError({\n message: `[IgnisArtifactsPlugin] An ArtifactGroup call at ${filePath}:${line + 1} cannot be rewritten | ${reason} - write ArtifactGroup.define({ folder: '<name>' }) or ArtifactGroup.application() with the class imported under its own name`,\n });\n };\n\n const isCompiled = !ArtifactStereotypes.SOURCE_EXTENSION.test(filePath);\n const contentLiteral = (folder: string | undefined, ignore?: string[]): string => {\n const artifacts = ArtifactSources.folderArtifacts({ folder, site: filePath, ignore });\n if (artifacts.length === 0) {\n throw getError({\n message: `[IgnisArtifactsPlugin] ArtifactGroup '${folder ?? '<application>'}' resolved to no class | ${filePath} - check the folder name and that its classes carry a stereotype decorator`,\n });\n }\n\n const fields: string[] = [];\n for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {\n const locals = artifacts\n .filter(artifact => artifact.type === type)\n .map(artifact => {\n if (isCompiled) {\n return `require(${JSON.stringify(artifact.filePath)}).${artifact.className}`;\n }\n counter += 1;\n const local = `__ignis_group_${counter}`;\n const path = artifact.filePath\n .split(sep)\n .join('/')\n .replace(ArtifactStereotypes.SOURCE_EXTENSION, '');\n imports.push(`import { ${artifact.className} as ${local} } from '${path}';`);\n return local;\n });\n if (locals.length > 0) {\n fields.push(`${field}: [${locals.join(', ')}]`);\n }\n }\n return `{ ${fields.join(', ')} }`;\n };\n\n const visit = (node: ts.Node): void => {\n const isGroupCall =\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n (ts.isIdentifier(node.expression.expression) ||\n ts.isPropertyAccessExpression(node.expression.expression)) &&\n (node.expression.name.text === 'define' || node.expression.name.text === 'application');\n if (!isGroupCall) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const call = node as ts.CallExpression;\n const access = call.expression as ts.PropertyAccessExpression;\n const target = access.expression;\n const callee = ts.isIdentifier(target)\n ? target.text\n : (target as ts.PropertyAccessExpression).name.text;\n const isApplication = access.name.text === 'application';\n if (ts.isIdentifier(target) && aliases.has(callee)) {\n refuse(call, `ArtifactGroup is imported as ${callee}`);\n }\n if (callee !== 'ArtifactGroup') {\n ts.forEachChild(node, visit);\n return;\n }\n\n const [argument] = call.arguments;\n if (isApplication && !argument) {\n edits.push({ at: call.arguments.pos, text: `{ content: ${contentLiteral(undefined)} }` });\n return;\n }\n if (!argument || !ts.isObjectLiteralExpression(argument)) {\n refuse(call, 'the argument is not an object literal');\n }\n\n const literal = argument as ts.ObjectLiteralExpression;\n const named = (name: string): ts.ObjectLiteralElementLike | undefined =>\n literal.properties.find(\n entry =>\n entry.name !== undefined && ts.isIdentifier(entry.name) && entry.name.text === name,\n );\n if (named('content')) {\n return;\n }\n\n const folderProperty = named('folder');\n if (isApplication && folderProperty) {\n refuse(call, 'ArtifactGroup.application() takes no folder');\n }\n const folderLiteral =\n folderProperty &&\n ts.isPropertyAssignment(folderProperty) &&\n ts.isStringLiteral(folderProperty.initializer)\n ? folderProperty.initializer.text\n : undefined;\n if (!isApplication && folderLiteral === undefined) {\n refuse(call, 'folder is not a string literal');\n }\n\n const ignoreProperty = named('ignore');\n const ignoreList =\n ignoreProperty &&\n ts.isPropertyAssignment(ignoreProperty) &&\n ts.isArrayLiteralExpression(ignoreProperty.initializer) &&\n ignoreProperty.initializer.elements.every(element => ts.isStringLiteral(element))\n ? ignoreProperty.initializer.elements.map(element => (element as ts.StringLiteral).text)\n : undefined;\n if (ignoreProperty && ignoreList === undefined) {\n refuse(call, 'ignore is not an array of string literals');\n }\n\n const last = literal.properties[literal.properties.length - 1];\n edits.push({\n at: last ? last.getEnd() : literal.getStart() + 1,\n text: `${last ? ', ' : ''}content: ${contentLiteral(folderLiteral, ignoreList)}`,\n });\n };\n visit(sourceFile);\n\n let rewritten = source;\n for (const edit of [...edits].sort((left, right) => right.at - left.at)) {\n rewritten = rewritten.slice(0, edit.at) + edit.text + rewritten.slice(edit.at);\n }\n return imports.length > 0 ? `${imports.join('\\n')}\\n${rewritten}` : rewritten;\n }\n\n /** A text test for a file worth parsing for decorated classes: an IGNIS stereotype decorator call. */\n static readonly DECORATED =\n /@(?:configuration|component|controller|service|repository|datasource|model|injectable)\\s*\\(/;\n\n /** The classes of a source file that carry an IGNIS stereotype decorator (`@service()`, `@repository(...)`, `@injectable(...)`...). */\n static decoratedClasses(opts: { filePath: string; source: string }): string[] {\n const names = new Set([\n ...Object.keys(ArtifactStereotypes.BY_DECORATOR),\n ArtifactStereotypes.ROOT_DECORATOR,\n ]);\n const sourceFile = ts.createSourceFile(\n opts.filePath,\n opts.source,\n ts.ScriptTarget.Latest,\n true,\n );\n const found: string[] = [];\n const visit = (node: ts.Node): void => {\n if (ts.isClassDeclaration(node) && node.name) {\n const isDecorated = (ts.getDecorators(node) ?? []).some(decorator => {\n const expression = ts.isCallExpression(decorator.expression)\n ? decorator.expression.expression\n : decorator.expression;\n return ts.isIdentifier(expression) && names.has(expression.text);\n });\n if (isDecorated) {\n found.push(node.name.text);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return found;\n }\n\n /** Opens each named class with `static { Object.defineProperty(this, 'name', ...) }`. Binding keys are built from `Class.name`, and a bundler renames classes - a minifier, or Bun's scope hoisting when a registered class shadows a same-name class it extends (`StockService` becomes `StockService2`). A string literal survives both, and a static block runs before the class's decorators. Only these classes are touched; the rest of the bundle is left alone. */\n static pinClassNames(opts: {\n filePath: string;\n source: string;\n classNames: ReadonlySet<string>;\n }): string {\n const sourceFile = ts.createSourceFile(\n opts.filePath,\n opts.source,\n ts.ScriptTarget.Latest,\n true,\n );\n const positions: Array<{ at: number; name: string }> = [];\n const visit = (node: ts.Node): void => {\n if (ts.isClassDeclaration(node) && node.name && opts.classNames.has(node.name.text)) {\n positions.push({ at: node.members.pos, name: node.name.text });\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n\n let pinned = opts.source;\n for (const { at, name } of positions.sort((left, right) => right.at - left.at)) {\n const block = ` static { Object.defineProperty(this, 'name', { value: ${JSON.stringify(name)} }); }`;\n pinned = pinned.slice(0, at) + block + pinned.slice(at);\n }\n return pinned;\n }\n\n /** The classes whose names a build must pin, by the file the build loads: the app's own (from the tree `entry` runs, see `runningArtifacts`) and those of every package that defines a group the app can borrow (from the tree the group file sits in). */\n static pinnedClasses(opts: {\n root: string;\n groupFiles?: ReadonlyArray<string>;\n entry?: string;\n }): Map<string, Set<string>> {\n const byFile = new Map<string, Set<string>>();\n const add = (artifacts: ReadonlyArray<{ filePath: string; className: string }>): void => {\n for (const { filePath, className } of artifacts) {\n byFile.set(filePath, (byFile.get(filePath) ?? new Set()).add(className));\n }\n };\n const own = ArtifactSources.scan({ packageSource: opts.root });\n add(opts.entry ? ArtifactSources.runningArtifacts({ artifacts: own, from: opts.entry }) : own);\n // Every class carrying an IGNIS decorator in the workspace sources: a class nothing scans (a library that defines no group) is still an injection target, and still renamed by a bundler when its name collides.\n for (const file of IgnisArtifactsPlugin.workspaceSourceFiles({ root: opts.root })) {\n if (!ArtifactStereotypes.SOURCE_EXTENSION.test(file)) {\n continue;\n }\n const source = readFileSync(file, 'utf8');\n if (!IgnisArtifactsPlugin.DECORATED.test(source)) {\n continue;\n }\n add(\n IgnisArtifactsPlugin.decoratedClasses({ filePath: file, source }).map(className => ({\n filePath: file,\n className,\n })),\n );\n }\n for (const groupFile of opts.groupFiles ?? []) {\n const packageSource = ArtifactSources.packageSource({ from: dirname(groupFile) });\n if (packageSource === opts.root || !existsSync(packageSource)) {\n continue;\n }\n add(\n ArtifactSources.runningArtifacts({\n artifacts: ArtifactSources.scan({ packageSource }),\n from: groupFile,\n }),\n );\n }\n return byFile;\n }\n\n /** The source files that define groups: the application's own `src` and the `src` of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does. */\n static groupDefinitionFiles(opts: { root: string }): string[] {\n return IgnisArtifactsPlugin.workspaceSourceFiles(opts).filter(file =>\n IgnisArtifactsPlugin.DEFINE_CALL.test(readFileSync(file, 'utf8')),\n );\n }\n\n /** The source files of the application and of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does - plus the compiled trees beside each `src`, for a package that runs from `dist`. Tests excluded. */\n static workspaceSourceFiles(opts: { root: string }): string[] {\n const root = resolve(opts.root);\n const packageDirectory = dirname(root);\n const manifestPath = join(packageDirectory, 'package.json');\n const manifest = existsSync(manifestPath) ? JSON.parse(readFileSync(manifestPath, 'utf8')) : {};\n const names = Object.keys({\n ...manifest.dependencies,\n ...manifest.devDependencies,\n ...manifest.peerDependencies,\n });\n\n const sources = new Set<string>([root]);\n for (const name of names) {\n let directory = packageDirectory;\n while (true) {\n const linked = join(directory, 'node_modules', name);\n if (existsSync(linked)) {\n const real = realpathSync(linked);\n if (!real.split(sep).includes('node_modules') && existsSync(join(real, 'src'))) {\n sources.add(join(real, 'src'));\n }\n break;\n }\n const parent = dirname(directory);\n if (parent === directory) {\n break;\n }\n directory = parent;\n }\n }\n\n // A package that runs from its compiled tree (`main` in dist) defines its groups there too.\n const trees: Array<{ directory: string; pattern: string }> = [];\n for (const source of sources) {\n if (!existsSync(source)) {\n continue;\n }\n trees.push({ directory: source, pattern: ArtifactStereotypes.SOURCE_GLOB });\n for (const entry of readdirSync(dirname(source), { withFileTypes: true })) {\n if (\n entry.isDirectory() &&\n !['src', 'node_modules'].includes(entry.name) &&\n !entry.name.startsWith('.')\n ) {\n trees.push({ directory: join(dirname(source), entry.name), pattern: '**/*.js' });\n }\n }\n }\n\n const files: string[] = [];\n for (const { directory, pattern } of trees) {\n for (const relativePath of globSync(pattern, { cwd: directory })) {\n if (!relativePath.includes('__tests__')) {\n files.push(join(directory, relativePath));\n }\n }\n }\n return files;\n }\n\n /** For `Bun.build({ plugins: [IgnisArtifactsPlugin.create()] })`; `isRuntime` is set by `registerRuntime`, which serves a virtual module instead. `entry` (default: the build's first entrypoint, or `Bun.main` at run time) decides which tree the classes are imported from. */\n static create(\n opts: { root?: string; entry?: string; isRuntime?: boolean; lazyIndex?: boolean } = {},\n ): BunPlugin {\n const isRuntime = opts.isRuntime ?? false;\n\n return {\n name: IgnisArtifactsPlugin.NAME,\n setup(build) {\n const [entrypoint] = isRuntime ? [] : build.config.entrypoints;\n const entry = opts.entry ?? (entrypoint ? resolve(entrypoint) : ArtifactSources.entry());\n const root =\n opts.root ??\n ArtifactSources.packageSource({ from: entry ? dirname(entry) : process.cwd() });\n const contents = (): string => IgnisArtifactsPlugin.render({ root, entry });\n\n if (isRuntime) {\n build.module(IgnisArtifactsPlugin.VIRTUAL, () => ({\n contents: contents(),\n loader: 'ts',\n }));\n return;\n }\n\n const virtualPath = join(resolve(root), '__ignis_artifacts__.ts');\n build.onResolve({ filter: /^ignis:artifacts$/ }, () => ({ path: virtualPath }));\n build.onLoad({ filter: /__ignis_artifacts__\\.ts$/ }, () => ({\n contents: contents(),\n loader: 'ts',\n }));\n const groupFiles = IgnisArtifactsPlugin.groupDefinitionFiles({ root });\n const groupFileSet = new Set(groupFiles);\n const pinned = IgnisArtifactsPlugin.pinnedClasses({ root, groupFiles, entry });\n const loaded = [...new Set([...groupFiles, ...pinned.keys()])];\n if (loaded.length > 0) {\n const escaped = loaded.map(file => file.replace(/[.*+?^${}()|[\\]\\\\/]/g, '\\\\$&'));\n build.onLoad({ filter: new RegExp(`^(?:${escaped.join('|')})$`) }, args => {\n const source = readFileSync(args.path, 'utf8');\n const grouped = groupFileSet.has(args.path)\n ? IgnisArtifactsPlugin.rewriteGroups({ filePath: args.path, source })\n : source;\n const classNames = pinned.get(args.path);\n return {\n contents: classNames\n ? IgnisArtifactsPlugin.pinClassNames({\n filePath: args.path,\n source: grouped,\n classNames,\n })\n : grouped,\n loader: args.path.endsWith('.tsx') ? 'tsx' : args.path.endsWith('.ts') ? 'ts' : 'js',\n };\n });\n }\n // Lazy (a dynamic import on the first resolve) for a server: a library importing this module must not evaluate the app's classes inside its own half-loaded graph. Eager for a browser bundle: a lazily evaluated graph is not tree-shaken, which doubled a measured frontend bundle.\n const isLazy = opts.lazyIndex ?? build.config.target !== 'browser';\n const autoModule = isLazy\n ? `import { AutoArtifactGroup } from './auto-group';\\nexport default new AutoArtifactGroup({ resolve: async () => (await import('${IgnisArtifactsPlugin.VIRTUAL}')).${IgnisArtifactsPlugin.EXPORT_NAME} });\\n`\n : `import { ${IgnisArtifactsPlugin.EXPORT_NAME} } from '${IgnisArtifactsPlugin.VIRTUAL}';\\nimport { AutoArtifactGroup } from './auto-group';\\nexport default new AutoArtifactGroup({ content: ${IgnisArtifactsPlugin.EXPORT_NAME} });\\n`;\n build.onLoad({ filter: IgnisArtifactsPlugin.AUTO_MODULE }, () => ({\n contents: autoModule,\n loader: 'ts',\n }));\n },\n };\n }\n\n /** Registers the run-time plugin once per process; a second call is a no-op. */\n static async registerRuntime(opts: { root?: string } = {}): Promise<void> {\n if (Reflect.get(globalThis, IgnisArtifactsPlugin.RUNTIME_KEY) === true) {\n return;\n }\n await Bun.plugin(IgnisArtifactsPlugin.create({ ...opts, isRuntime: true }));\n Reflect.set(globalThis, IgnisArtifactsPlugin.RUNTIME_KEY, true);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../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oBAAoB,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;oBAChE,QAAQ,EAAE,UAAU;oBACpB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAC,CAAC;YACN,CAAC;SACF,CAAC;IACJ,CAAC;IAED,gFAAgF;IAChF,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAA0B,EAAE;QACvD,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,oBAAoB,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,CAAC;YACvE,OAAO;QACT,CAAC;QACD,MAAM,GAAG,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,oBAAoB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;;AArcH,oDAscC","sourcesContent":["import type { BunPlugin } from 'bun';\nimport { getError } from '@venizia/ignis-helpers';\nimport { existsSync, globSync, readdirSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join, resolve, sep } from 'node:path';\nimport ts from 'typescript';\nimport { ArtifactIndexEmitter, ArtifactScanner, ArtifactStereotypes } from '../generator';\nimport { ArtifactSources } from './sources';\n\n/** Serves `ignis:artifacts` - the application's generated index, rendered in memory from the scanner. At run time it is a virtual module (`build.module`); in `Bun.build` it is resolved and loaded (`onResolve`/`onLoad`), so a binary carries the list and never scans. */\nexport class IgnisArtifactsPlugin {\n static readonly NAME = 'ignis-artifacts';\n static readonly VIRTUAL = 'ignis:artifacts';\n static readonly EXPORT_NAME = 'GeneratedArtifacts';\n\n /** `@venizia/ignis-boot/auto`, from source or from either dist format - replaced at build time by a static re-export of the virtual module. */\n static readonly AUTO_MODULE =\n /[\\\\/](?:@venizia[\\\\/]ignis-boot|packages[\\\\/]boot)[\\\\/](?:dist[\\\\/](?:esm|cjs)|src)[\\\\/]bun[\\\\/]auto\\.(?:ts|js)$/;\n\n /** A text test for a file worth parsing: `ArtifactGroup.define(`, with any spacing or line break around the dot. */\n static readonly DEFINE_CALL = /ArtifactGroup\\s*\\.\\s*(?:define|application)\\s*\\(/;\n\n private static readonly RUNTIME_KEY = Symbol.for('@venizia/ignis-boot:artifacts-runtime-plugin');\n\n static {\n ArtifactSources.useScanner({ scanner: ArtifactScanner.getInstance() });\n }\n\n /** The `src` beside the nearest `package.json` at or above `from` (default: the entry module's directory). */\n static defaultRoot(opts: { from?: string } = {}): string {\n return ArtifactSources.packageSource({\n from: opts.from ?? IgnisArtifactsPlugin.entryDirectory(),\n });\n }\n\n /** The entry module's directory (`Bun.main`), so the root never depends on where the process was started; the working directory only when there is no entry file (`bun -e`, a REPL). */\n static entryDirectory(): string {\n const entry = ArtifactSources.entry();\n return entry ? dirname(entry) : process.cwd();\n }\n\n /** The index as module source: every import absolute, since a virtual module has no directory to resolve from. With `entry` in a compiled tree, each class is imported from that tree (`ArtifactSources.runningArtifacts`). */\n static render(opts: { root: string; entry?: string }): string {\n const root = resolve(opts.root);\n if (!existsSync(root)) {\n throw getError({\n message: `[IgnisArtifactsPlugin] ${dirname(root)} has no src directory (${root}) | Auto artifacts scan the src beside the package.json of the entry module; pass IgnisArtifactsPlugin.create({ root }), or use ArtifactGroup.application() in the application's own source`,\n });\n }\n const outFile = join(root, '__ignis_artifacts__.ts');\n const artifacts = ArtifactSources.scan({ packageSource: root });\n return ArtifactIndexEmitter.render({\n artifacts: opts.entry\n ? ArtifactSources.runningArtifacts({ artifacts, from: opts.entry })\n : artifacts,\n outFile,\n exportName: IgnisArtifactsPlugin.EXPORT_NAME,\n command: { root, out: outFile },\n absoluteImports: true,\n });\n }\n\n /** Rewrites every `ArtifactGroup.define({ folder: '<literal>' })` and `ArtifactGroup.application()` in a source file to carry its classes as `content`, imported by absolute path - a binary then holds each group's list and never scans. A group with no decorated class, or a call the plugin cannot read (an aliased `ArtifactGroup`, a folder that is not a string literal), fails the build. */\n static rewriteGroups(opts: { filePath: string; source: string }): string {\n const { filePath, source } = opts;\n const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true);\n const aliases = new Set<string>();\n for (const statement of sourceFile.statements) {\n const bindings = ts.isImportDeclaration(statement)\n ? statement.importClause?.namedBindings\n : undefined;\n for (const element of bindings && ts.isNamedImports(bindings) ? bindings.elements : []) {\n if (\n (element.propertyName ?? element.name).text === 'ArtifactGroup' &&\n element.name.text !== 'ArtifactGroup'\n ) {\n aliases.add(element.name.text);\n }\n }\n }\n\n const edits: Array<{ at: number; text: string }> = [];\n const imports: string[] = [];\n let counter = 0;\n\n const refuse = (node: ts.Node, reason: string): never => {\n const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n throw getError({\n message: `[IgnisArtifactsPlugin] An ArtifactGroup call at ${filePath}:${line + 1} cannot be rewritten | ${reason} - write ArtifactGroup.define({ folder: '<name>' }) or ArtifactGroup.application() with the class imported under its own name`,\n });\n };\n\n const isCompiled = !ArtifactStereotypes.SOURCE_EXTENSION.test(filePath);\n const contentLiteral = (folder: string | undefined, ignore?: string[]): string => {\n const artifacts = ArtifactSources.folderArtifacts({ folder, site: filePath, ignore });\n if (artifacts.length === 0) {\n throw getError({\n message: `[IgnisArtifactsPlugin] ArtifactGroup '${folder ?? '<application>'}' resolved to no class | ${filePath} - check the folder name and that its classes carry a stereotype decorator`,\n });\n }\n\n const fields: string[] = [];\n for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {\n const locals = artifacts\n .filter((artifact) => artifact.type === type)\n .map((artifact) => {\n if (isCompiled) {\n return `require(${JSON.stringify(artifact.filePath)}).${artifact.className}`;\n }\n counter += 1;\n const local = `__ignis_group_${counter}`;\n const path = artifact.filePath\n .split(sep)\n .join('/')\n .replace(ArtifactStereotypes.SOURCE_EXTENSION, '');\n imports.push(`import { ${artifact.className} as ${local} } from '${path}';`);\n return local;\n });\n if (locals.length > 0) {\n fields.push(`${field}: [${locals.join(', ')}]`);\n }\n }\n return `{ ${fields.join(', ')} }`;\n };\n\n const visit = (node: ts.Node): void => {\n const isGroupCall =\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n (ts.isIdentifier(node.expression.expression) ||\n ts.isPropertyAccessExpression(node.expression.expression)) &&\n (node.expression.name.text === 'define' || node.expression.name.text === 'application');\n if (!isGroupCall) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const call = node as ts.CallExpression;\n const access = call.expression as ts.PropertyAccessExpression;\n const target = access.expression;\n const callee = ts.isIdentifier(target)\n ? target.text\n : (target as ts.PropertyAccessExpression).name.text;\n const isApplication = access.name.text === 'application';\n if (ts.isIdentifier(target) && aliases.has(callee)) {\n refuse(call, `ArtifactGroup is imported as ${callee}`);\n }\n if (callee !== 'ArtifactGroup') {\n ts.forEachChild(node, visit);\n return;\n }\n\n const [argument] = call.arguments;\n if (isApplication && !argument) {\n edits.push({ at: call.arguments.pos, text: `{ content: ${contentLiteral(undefined)} }` });\n return;\n }\n if (!argument || !ts.isObjectLiteralExpression(argument)) {\n refuse(call, 'the argument is not an object literal');\n }\n\n const literal = argument as ts.ObjectLiteralExpression;\n const named = (name: string): ts.ObjectLiteralElementLike | undefined =>\n literal.properties.find(\n (entry) =>\n entry.name !== undefined && ts.isIdentifier(entry.name) && entry.name.text === name,\n );\n if (named('content')) {\n return;\n }\n\n const folderProperty = named('folder');\n if (isApplication && folderProperty) {\n refuse(call, 'ArtifactGroup.application() takes no folder');\n }\n const folderLiteral =\n folderProperty &&\n ts.isPropertyAssignment(folderProperty) &&\n ts.isStringLiteral(folderProperty.initializer)\n ? folderProperty.initializer.text\n : undefined;\n if (!isApplication && folderLiteral === undefined) {\n refuse(call, 'folder is not a string literal');\n }\n\n const ignoreProperty = named('ignore');\n const ignoreList =\n ignoreProperty &&\n ts.isPropertyAssignment(ignoreProperty) &&\n ts.isArrayLiteralExpression(ignoreProperty.initializer) &&\n ignoreProperty.initializer.elements.every((element) => ts.isStringLiteral(element))\n ? ignoreProperty.initializer.elements.map((element) => (element as ts.StringLiteral).text)\n : undefined;\n if (ignoreProperty && ignoreList === undefined) {\n refuse(call, 'ignore is not an array of string literals');\n }\n\n const last = literal.properties[literal.properties.length - 1];\n edits.push({\n at: last ? last.getEnd() : literal.getStart() + 1,\n text: `${last ? ', ' : ''}content: ${contentLiteral(folderLiteral, ignoreList)}`,\n });\n };\n visit(sourceFile);\n\n let rewritten = source;\n for (const edit of [...edits].sort((left, right) => right.at - left.at)) {\n rewritten = rewritten.slice(0, edit.at) + edit.text + rewritten.slice(edit.at);\n }\n return imports.length > 0 ? `${imports.join('\\n')}\\n${rewritten}` : rewritten;\n }\n\n /** A text test for a file worth parsing for decorated classes: an IGNIS stereotype decorator call. */\n static readonly DECORATED =\n /@(?:configuration|component|controller|service|repository|datasource|model|injectable)\\s*\\(/;\n\n /** The classes of a source file that carry an IGNIS stereotype decorator (`@service()`, `@repository(...)`, `@injectable(...)`...). */\n static decoratedClasses(opts: { filePath: string; source: string }): string[] {\n const names = new Set([\n ...Object.keys(ArtifactStereotypes.BY_DECORATOR),\n ArtifactStereotypes.ROOT_DECORATOR,\n ]);\n const sourceFile = ts.createSourceFile(\n opts.filePath,\n opts.source,\n ts.ScriptTarget.Latest,\n true,\n );\n const found: string[] = [];\n const visit = (node: ts.Node): void => {\n if (ts.isClassDeclaration(node) && node.name) {\n const isDecorated = (ts.getDecorators(node) ?? []).some((decorator) => {\n const expression = ts.isCallExpression(decorator.expression)\n ? decorator.expression.expression\n : decorator.expression;\n return ts.isIdentifier(expression) && names.has(expression.text);\n });\n if (isDecorated) {\n found.push(node.name.text);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return found;\n }\n\n /** Opens each named class with `static { Object.defineProperty(this, 'name', ...) }`. Binding keys are built from `Class.name`, and a bundler renames classes - a minifier, or Bun's scope hoisting when a registered class shadows a same-name class it extends (`StockService` becomes `StockService2`). A string literal survives both, and a static block runs before the class's decorators. Only these classes are touched; the rest of the bundle is left alone. */\n static pinClassNames(opts: {\n filePath: string;\n source: string;\n classNames: ReadonlySet<string>;\n }): string {\n const sourceFile = ts.createSourceFile(\n opts.filePath,\n opts.source,\n ts.ScriptTarget.Latest,\n true,\n );\n const positions: Array<{ at: number; name: string }> = [];\n const visit = (node: ts.Node): void => {\n if (ts.isClassDeclaration(node) && node.name && opts.classNames.has(node.name.text)) {\n positions.push({ at: node.members.pos, name: node.name.text });\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n\n let pinned = opts.source;\n for (const { at, name } of positions.sort((left, right) => right.at - left.at)) {\n const block = ` static { Object.defineProperty(this, 'name', { value: ${JSON.stringify(name)} }); }`;\n pinned = pinned.slice(0, at) + block + pinned.slice(at);\n }\n return pinned;\n }\n\n /** The classes whose names a build must pin, by the file the build loads: the app's own (from the tree `entry` runs, see `runningArtifacts`) and those of every package that defines a group the app can borrow (from the tree the group file sits in). */\n static pinnedClasses(opts: {\n root: string;\n groupFiles?: ReadonlyArray<string>;\n entry?: string;\n }): Map<string, Set<string>> {\n const byFile = new Map<string, Set<string>>();\n const add = (artifacts: ReadonlyArray<{ filePath: string; className: string }>): void => {\n for (const { filePath, className } of artifacts) {\n byFile.set(filePath, (byFile.get(filePath) ?? new Set()).add(className));\n }\n };\n const own = ArtifactSources.scan({ packageSource: opts.root });\n add(opts.entry ? ArtifactSources.runningArtifacts({ artifacts: own, from: opts.entry }) : own);\n // Every class carrying an IGNIS decorator in the workspace sources: a class nothing scans (a library that defines no group) is still an injection target, and still renamed by a bundler when its name collides.\n for (const file of IgnisArtifactsPlugin.workspaceSourceFiles({ root: opts.root })) {\n if (!ArtifactStereotypes.SOURCE_EXTENSION.test(file)) {\n continue;\n }\n const source = readFileSync(file, 'utf8');\n if (!IgnisArtifactsPlugin.DECORATED.test(source)) {\n continue;\n }\n add(\n IgnisArtifactsPlugin.decoratedClasses({ filePath: file, source }).map((className) => ({\n filePath: file,\n className,\n })),\n );\n }\n for (const groupFile of opts.groupFiles ?? []) {\n const packageSource = ArtifactSources.packageSource({ from: dirname(groupFile) });\n if (packageSource === opts.root || !existsSync(packageSource)) {\n continue;\n }\n add(\n ArtifactSources.runningArtifacts({\n artifacts: ArtifactSources.scan({ packageSource }),\n from: groupFile,\n }),\n );\n }\n return byFile;\n }\n\n /** The source files that define groups: the application's own `src` and the `src` of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does. */\n static groupDefinitionFiles(opts: { root: string }): string[] {\n return IgnisArtifactsPlugin.workspaceSourceFiles(opts).filter((file) =>\n IgnisArtifactsPlugin.DEFINE_CALL.test(readFileSync(file, 'utf8')),\n );\n }\n\n /** The source files of the application and of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does - plus the compiled trees beside each `src`, for a package that runs from `dist`. Tests excluded. */\n static workspaceSourceFiles(opts: { root: string }): string[] {\n const root = resolve(opts.root);\n const packageDirectory = dirname(root);\n const manifestPath = join(packageDirectory, 'package.json');\n const manifest = existsSync(manifestPath) ? JSON.parse(readFileSync(manifestPath, 'utf8')) : {};\n const names = Object.keys({\n ...manifest.dependencies,\n ...manifest.devDependencies,\n ...manifest.peerDependencies,\n });\n\n const sources = new Set<string>([root]);\n for (const name of names) {\n let directory = packageDirectory;\n while (true) {\n const linked = join(directory, 'node_modules', name);\n if (existsSync(linked)) {\n const real = realpathSync(linked);\n if (!real.split(sep).includes('node_modules') && existsSync(join(real, 'src'))) {\n sources.add(join(real, 'src'));\n }\n break;\n }\n const parent = dirname(directory);\n if (parent === directory) {\n break;\n }\n directory = parent;\n }\n }\n\n // A package that runs from its compiled tree (`main` in dist) defines its groups there too.\n const trees: Array<{ directory: string; pattern: string }> = [];\n for (const source of sources) {\n if (!existsSync(source)) {\n continue;\n }\n trees.push({ directory: source, pattern: ArtifactStereotypes.SOURCE_GLOB });\n for (const entry of readdirSync(dirname(source), { withFileTypes: true })) {\n if (\n entry.isDirectory() &&\n !['src', 'node_modules'].includes(entry.name) &&\n !entry.name.startsWith('.')\n ) {\n trees.push({ directory: join(dirname(source), entry.name), pattern: '**/*.js' });\n }\n }\n }\n\n const files: string[] = [];\n for (const { directory, pattern } of trees) {\n for (const relativePath of globSync(pattern, { cwd: directory })) {\n if (!relativePath.includes('__tests__')) {\n files.push(join(directory, relativePath));\n }\n }\n }\n return files;\n }\n\n /** For `Bun.build({ plugins: [IgnisArtifactsPlugin.create()] })`; `isRuntime` is set by `registerRuntime`, which serves a virtual module instead. `entry` (default: the build's first entrypoint, or `Bun.main` at run time) decides which tree the classes are imported from. */\n static create(\n opts: { root?: string; entry?: string; isRuntime?: boolean; lazyIndex?: boolean } = {},\n ): BunPlugin {\n const isRuntime = opts.isRuntime ?? false;\n\n return {\n name: IgnisArtifactsPlugin.NAME,\n setup(build) {\n const [entrypoint] = isRuntime ? [] : build.config.entrypoints;\n const entry = opts.entry ?? (entrypoint ? resolve(entrypoint) : ArtifactSources.entry());\n const root =\n opts.root ??\n ArtifactSources.packageSource({ from: entry ? dirname(entry) : process.cwd() });\n const contents = (): string => IgnisArtifactsPlugin.render({ root, entry });\n\n if (isRuntime) {\n build.module(IgnisArtifactsPlugin.VIRTUAL, () => ({\n contents: contents(),\n loader: 'ts',\n }));\n return;\n }\n\n const virtualPath = join(resolve(root), '__ignis_artifacts__.ts');\n build.onResolve({ filter: /^ignis:artifacts$/ }, () => ({ path: virtualPath }));\n build.onLoad({ filter: /__ignis_artifacts__\\.ts$/ }, () => ({\n contents: contents(),\n loader: 'ts',\n }));\n const groupFiles = IgnisArtifactsPlugin.groupDefinitionFiles({ root });\n const groupFileSet = new Set(groupFiles);\n const pinned = IgnisArtifactsPlugin.pinnedClasses({ root, groupFiles, entry });\n const loaded = [...new Set([...groupFiles, ...pinned.keys()])];\n if (loaded.length > 0) {\n const escaped = loaded.map((file) => file.replace(/[.*+?^${}()|[\\]\\\\/]/g, '\\\\$&'));\n build.onLoad({ filter: new RegExp(`^(?:${escaped.join('|')})$`) }, (args) => {\n const source = readFileSync(args.path, 'utf8');\n const grouped = groupFileSet.has(args.path)\n ? IgnisArtifactsPlugin.rewriteGroups({ filePath: args.path, source })\n : source;\n const classNames = pinned.get(args.path);\n return {\n contents: classNames\n ? IgnisArtifactsPlugin.pinClassNames({\n filePath: args.path,\n source: grouped,\n classNames,\n })\n : grouped,\n loader: args.path.endsWith('.tsx') ? 'tsx' : args.path.endsWith('.ts') ? 'ts' : 'js',\n };\n });\n }\n // Lazy (a dynamic import on the first resolve) for a server: a library importing this module must not evaluate the app's classes inside its own half-loaded graph. Eager for a browser bundle: a lazily evaluated graph is not tree-shaken, which doubled a measured frontend bundle.\n const isLazy = opts.lazyIndex ?? build.config.target !== 'browser';\n const autoModule = isLazy\n ? `import { AutoArtifactGroup } from './auto-group';\\nexport default new AutoArtifactGroup({ resolve: async () => (await import('${IgnisArtifactsPlugin.VIRTUAL}')).${IgnisArtifactsPlugin.EXPORT_NAME} });\\n`\n : `import { ${IgnisArtifactsPlugin.EXPORT_NAME} } from '${IgnisArtifactsPlugin.VIRTUAL}';\\nimport { AutoArtifactGroup } from './auto-group';\\nexport default new AutoArtifactGroup({ content: ${IgnisArtifactsPlugin.EXPORT_NAME} });\\n`;\n build.onLoad({ filter: IgnisArtifactsPlugin.AUTO_MODULE }, () => ({\n contents: autoModule,\n loader: 'ts',\n }));\n },\n };\n }\n\n /** Registers the run-time plugin once per process; a second call is a no-op. */\n static async registerRuntime(opts: { root?: string } = {}): Promise<void> {\n if (Reflect.get(globalThis, IgnisArtifactsPlugin.RUNTIME_KEY) === true) {\n return;\n }\n await Bun.plugin(IgnisArtifactsPlugin.create({ ...opts, isRuntime: true }));\n Reflect.set(globalThis, IgnisArtifactsPlugin.RUNTIME_KEY, true);\n }\n}\n"]}
|
|
@@ -26,7 +26,7 @@ class ArtifactScanCache {
|
|
|
26
26
|
let directory = (0, node_path_1.dirname)(root);
|
|
27
27
|
while (true) {
|
|
28
28
|
const lockfile = ['bun.lock', 'bun.lockb', 'package-lock.json']
|
|
29
|
-
.map(name => (0, node_path_1.join)(directory, name))
|
|
29
|
+
.map((name) => (0, node_path_1.join)(directory, name))
|
|
30
30
|
.find(node_fs_1.existsSync);
|
|
31
31
|
if (lockfile) {
|
|
32
32
|
extras.push(lockfile);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-cache.js","sourceRoot":"","sources":["../../../src/bun/scan-cache.ts"],"names":[],"mappings":";;;AAAA,qCAQiB;AACjB,6CAAyC;AACzC,yCAAmD;AACnD,gDAAiF;AAEjF,oNAAoN;AACpN,MAAa,iBAAiB;aACZ,YAAO,GAAG,CAAC,CAAC;IAE5B,MAAM,CAAC,QAAQ,CAAC,IAAsB;QACpC,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,MAAM,GAAG,GAAG,IAAA,wBAAU,EAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvE,OAAO,IAAA,gBAAI,EAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC;IACzF,CAAC;IAED,4KAA4K;IAC5K,MAAM,CAAC,WAAW,CAAC,IAAsB;QACvC,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,MAAM,YAAY,IAAI,IAAA,kBAAQ,EAAC,4BAAmB,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YACpF,MAAM,KAAK,GAAG,IAAA,kBAAQ,EAAC,IAAA,gBAAI,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;YACjD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I,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9C,IAAA,uBAAa,EACX,SAAS,EACT,IAAI,CAAC,SAAS,CAAC;gBACb,WAAW,EAAE,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC;gBAChD,SAAS,EAAE,IAAI,CAAC,SAAS;aAC1B,CAAC,CACH,CAAC;YACF,IAAA,oBAAU,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,oGAAoG;YACpG,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;;AAtFH,8CAuFC","sourcesContent":["import {\n existsSync,\n globSync,\n mkdirSync,\n readFileSync,\n renameSync,\n statSync,\n writeFileSync,\n} from 'node:fs';\nimport { createHash } from 'node:crypto';\nimport { dirname, join, resolve } from 'node:path';\nimport { ArtifactStereotypes, type IScannedArtifact } from '../generator/common';\n\n/** The scanner's answer for one `src`, kept under the package's `node_modules/.cache` and valid while no `.ts` file under `src`, the package manifest or the lockfile changed - a hit skips TypeScript entirely. */\nexport class ArtifactScanCache {\n static readonly VERSION = 2;\n\n static location(opts: { root: string }): string {\n const root = resolve(opts.root);\n const key = createHash('sha1').update(root).digest('hex').slice(0, 16);\n return join(dirname(root), 'node_modules', '.cache', 'ignis-artifacts', `${key}.json`);\n }\n\n /** Path, size and mtime of every `.ts`/`.tsx` under `root`, plus the package manifest and the nearest lockfile (a dependency upgrade can change which decorators count). */\n static fingerprint(opts: { root: string }): string {\n const root = resolve(opts.root);\n const entries: string[] = [];\n for (const relativePath of globSync(ArtifactStereotypes.SOURCE_GLOB, { cwd: root })) {\n const stats = statSync(join(root, relativePath));\n entries.push(`${relativePath}:${stats.size}:${stats.mtimeMs}`);\n }\n entries.sort();\n\n const extras = [join(dirname(root), 'package.json')];\n let directory = dirname(root);\n while (true) {\n const lockfile = ['bun.lock', 'bun.lockb', 'package-lock.json']\n .map((name) => join(directory, name))\n .find(existsSync);\n if (lockfile) {\n extras.push(lockfile);\n break;\n }\n const parent = dirname(directory);\n if (parent === directory) {\n break;\n }\n directory = parent;\n }\n for (const file of extras.filter(existsSync)) {\n const stats = statSync(file);\n entries.push(`${file}:${stats.size}:${stats.mtimeMs}`);\n }\n\n return createHash('sha1')\n .update(`${ArtifactScanCache.VERSION}\\n${entries.join('\\n')}`)\n .digest('hex');\n }\n\n /** The cached scan, or `undefined` for a missing, stale or unreadable cache - never an error. */\n static read(opts: { root: string }): IScannedArtifact[] | undefined {\n const file = ArtifactScanCache.location(opts);\n if (!existsSync(file)) {\n return undefined;\n }\n let stored: { fingerprint?: unknown; artifacts?: unknown };\n try {\n stored = JSON.parse(readFileSync(file, 'utf8'));\n } catch {\n // A corrupt cache is a miss: the caller scans and rewrites it.\n return undefined;\n }\n if (\n stored.fingerprint !== ArtifactScanCache.fingerprint(opts) ||\n !Array.isArray(stored.artifacts)\n ) {\n return undefined;\n }\n return stored.artifacts;\n }\n\n /** Stores a scan; `false` when the cache directory cannot be written (a read-only install), which only costs the next start a scan. */\n static write(opts: { root: string; artifacts: IScannedArtifact[] }): boolean {\n const file = ArtifactScanCache.location(opts);\n const temporary = `${file}.${process.pid}.tmp`;\n try {\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(\n temporary,\n JSON.stringify({\n fingerprint: ArtifactScanCache.fingerprint(opts),\n artifacts: opts.artifacts,\n }),\n );\n renameSync(temporary, file);\n return true;\n } catch {\n // Caching is an optimisation; reporting `false` lets the caller go on with the scan it already has.\n return false;\n }\n }\n}\n"]}
|
package/dist/cjs/bun/sources.js
CHANGED
|
@@ -75,10 +75,10 @@ class ArtifactSources {
|
|
|
75
75
|
const artifacts = ArtifactSources.scan({ packageSource });
|
|
76
76
|
const { folder } = opts;
|
|
77
77
|
const ignored = opts.ignore ?? [];
|
|
78
|
-
const picked = artifacts.filter(artifact => {
|
|
78
|
+
const picked = artifacts.filter((artifact) => {
|
|
79
79
|
const path = (0, node_path_1.relative)(packageSource, artifact.filePath);
|
|
80
80
|
return ((folder === undefined || path.split(node_path_1.sep).slice(0, -1).includes(folder)) &&
|
|
81
|
-
!ignored.some(pattern => (0, node_path_1.matchesGlob)(path, pattern)));
|
|
81
|
+
!ignored.some((pattern) => (0, node_path_1.matchesGlob)(path, pattern)));
|
|
82
82
|
});
|
|
83
83
|
return ArtifactSources.runningArtifacts({ artifacts: picked, from: opts.site });
|
|
84
84
|
}
|
|
@@ -95,8 +95,8 @@ class ArtifactSources {
|
|
|
95
95
|
const segments = (0, node_path_1.relative)(packageRoot, (0, node_path_1.dirname)(from)).split(node_path_1.sep);
|
|
96
96
|
const tree = segments
|
|
97
97
|
.map((_segment, index) => (0, node_path_1.join)(packageRoot, ...segments.slice(0, index + 1)))
|
|
98
|
-
.find(candidate => (0, node_fs_1.existsSync)(compiledPath({ tree: candidate, artifact: probe })));
|
|
99
|
-
return opts.artifacts.map(artifact => {
|
|
98
|
+
.find((candidate) => (0, node_fs_1.existsSync)(compiledPath({ tree: candidate, artifact: probe })));
|
|
99
|
+
return opts.artifacts.map((artifact) => {
|
|
100
100
|
const compiled = tree ? compiledPath({ tree, artifact }) : undefined;
|
|
101
101
|
if (!compiled || !(0, node_fs_1.existsSync)(compiled)) {
|
|
102
102
|
throw (0, ignis_helpers_1.getError)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sources.js","sourceRoot":"","sources":["../../../src/bun/sources.ts"],"names":[],"mappings":";;;AAAA,0DAAkD;AAClD,qCAAqC;AACrC,yCAA+E;AAC/E,gDAAiF;AACjF,6CAAiD;AAQjD,mSAAmS;AACnS,MAAa,eAAe;aACF,UAAK,GAAG,IAAI,GAAG,EAA8B,CAAC;IAGtE,8EAA8E;IAC9E,MAAM,CAAC,UAAU,CAAC,IAAmC;QACnD,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IACzC,CAAC;IAED,+GAA+G;IAC/G,MAAM,CAAC,KAAK,CAAC,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,CAAC,CAAC,CAAC;IACL,CAAC;IAED,yFAAyF;IACzF,MAAM,CAAC,KAAK;QACV,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;;AApIH,0CAqIC","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport { existsSync } from 'node:fs';\nimport { dirname, join, matchesGlob, relative, resolve, sep } from 'node:path';\nimport { ArtifactStereotypes, type IScannedArtifact } from '../generator/common';\nimport { ArtifactScanCache } from './scan-cache';\n\ninterface IArtifactScanner {\n scanWithReport(opts: { root: string; followReexports: boolean }): {\n artifacts: IScannedArtifact[];\n };\n}\n\n/** Where a package's artifacts live: the `src` beside its nearest `package.json`, and the classes under one of its directories. One scan per package per process, served from `ArtifactScanCache` when no source file changed - so this module never loads the scanner (and TypeScript) itself. */\nexport class ArtifactSources {\n private static readonly scans = new Map<string, IScannedArtifact[]>();\n private static scanner: IArtifactScanner | undefined;\n\n /** Called by the modules that already hold the scanner (the build plugin). */\n static useScanner(opts: { scanner: IArtifactScanner }): void {\n ArtifactSources.scanner = opts.scanner;\n }\n\n /** Loads the scanner - only on a cache miss. A non-static specifier, so a bundle never pulls TypeScript in. */\n static async loadScanner(): Promise<void> {\n if (ArtifactSources.scanner) {\n return;\n }\n const generatorModule = '../generator';\n const { ArtifactScanner } = await import(generatorModule);\n ArtifactSources.scanner = ArtifactScanner.getInstance();\n }\n\n /** Whether `packageSource` can be listed without the scanner: scanned in this process, or a valid disk cache. */\n static isCached(opts: { packageSource: string }): boolean {\n if (ArtifactSources.scans.has(opts.packageSource)) {\n return true;\n }\n const cached = ArtifactScanCache.read({ root: opts.packageSource });\n if (cached) {\n ArtifactSources.scans.set(opts.packageSource, cached);\n }\n return cached !== undefined;\n }\n\n /** Every decorated class under `packageSource`: this process's scan, else the disk cache, else the scanner (which must be loaded), written back to the cache. */\n static scan(opts: { packageSource: string }): IScannedArtifact[] {\n const { packageSource } = opts;\n if (ArtifactSources.isCached({ packageSource })) {\n return ArtifactSources.scans.get(packageSource) ?? [];\n }\n if (!ArtifactSources.scanner) {\n throw getError({\n message: `[ArtifactSources] ${packageSource} is not cached and the scanner is not loaded | Call ArtifactSources.loadScanner() first`,\n });\n }\n const { artifacts } = ArtifactSources.scanner.scanWithReport({\n root: packageSource,\n followReexports: true,\n });\n ArtifactSources.scans.set(packageSource, artifacts);\n ArtifactScanCache.write({ root: packageSource, artifacts });\n return artifacts;\n }\n\n /** The entry module (`Bun.main`), or `undefined` when there is no entry file (`bun -e`, a REPL). */\n static entry(): string | undefined {\n return typeof Bun !== 'undefined' && existsSync(Bun.main) ? Bun.main : undefined;\n }\n\n /** The `src` beside the nearest `package.json` at or above `from` (default: the working directory). */\n static packageSource(opts: { from?: string } = {}): string {\n const start = resolve(opts.from ?? process.cwd());\n let directory = start;\n while (!existsSync(join(directory, 'package.json'))) {\n const parent = dirname(directory);\n if (parent === directory) {\n return join(start, 'src');\n }\n directory = parent;\n }\n return join(directory, 'src');\n }\n\n /** The decorated classes under a directory named `folder` in the package whose source holds `site`, less those under an `ignore` glob (relative to `src`), each pointing at the copy that runs beside `site` (see `runningArtifacts`). */\n static folderArtifacts(opts: {\n folder: string | undefined;\n site: string;\n ignore?: ReadonlyArray<string>;\n }): IScannedArtifact[] {\n const packageSource = ArtifactSources.packageSource({ from: dirname(opts.site) });\n\n const artifacts = ArtifactSources.scan({ packageSource });\n\n const { folder } = opts;\n const ignored = opts.ignore ?? [];\n const picked = artifacts.filter(artifact => {\n const path = relative(packageSource, artifact.filePath);\n return (\n (folder === undefined || path.split(sep).slice(0, -1).includes(folder)) &&\n !ignored.some(pattern => matchesGlob(path, pattern))\n );\n });\n return ArtifactSources.runningArtifacts({ artifacts: picked, from: opts.site });\n }\n\n /** The scanned classes as the code at `from` runs them: unchanged when `from` is in `src`; otherwise each `src/<path>.ts` becomes `<tree>/<path>.js` in the compiled tree `from` sits in (`dist`, `dist/esm`), so an application registers the very class its code uses, never a second copy loaded from `src`. */\n static runningArtifacts(opts: {\n artifacts: IScannedArtifact[];\n from: string;\n }): IScannedArtifact[] {\n const from = resolve(opts.from);\n const packageSource = ArtifactSources.packageSource({ from: dirname(from) });\n const [probe] = opts.artifacts;\n if (!probe || from.startsWith(`${packageSource}${sep}`)) {\n return opts.artifacts;\n }\n\n const packageRoot = dirname(packageSource);\n const compiledPath = (target: { tree: string; artifact: IScannedArtifact }): string =>\n join(\n target.tree,\n relative(packageSource, target.artifact.filePath).replace(\n ArtifactStereotypes.SOURCE_EXTENSION,\n '.js',\n ),\n );\n const segments = relative(packageRoot, dirname(from)).split(sep);\n const tree = segments\n .map((_segment, index) => join(packageRoot, ...segments.slice(0, index + 1)))\n .find(candidate => existsSync(compiledPath({ tree: candidate, artifact: probe })));\n\n return opts.artifacts.map(artifact => {\n const compiled = tree ? compiledPath({ tree, artifact }) : undefined;\n if (!compiled || !existsSync(compiled)) {\n throw getError({\n message: `[ArtifactSources] ${artifact.filePath} has no compiled copy beside ${from} | The package runs from a compiled tree that is older than its src - rebuild it (or run it from src)`,\n });\n }\n return { ...artifact, filePath: compiled };\n });\n }\n\n /** Forgets every cached scan - for a long-lived process that rebuilds (a watch mode). */\n static clear(): void {\n ArtifactSources.scans.clear();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sources.js","sourceRoot":"","sources":["../../../src/bun/sources.ts"],"names":[],"mappings":";;;AAAA,0DAAkD;AAClD,qCAAqC;AACrC,yCAA+E;AAC/E,gDAAiF;AACjF,6CAAiD;AAQjD,mSAAmS;AACnS,MAAa,eAAe;aACF,UAAK,GAAG,IAAI,GAAG,EAA8B,CAAC;IAGtE,8EAA8E;IAC9E,MAAM,CAAC,UAAU,CAAC,IAAmC;QACnD,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IACzC,CAAC;IAED,+GAA+G;IAC/G,MAAM,CAAC,KAAK,CAAC,WAAW;QACtB,IAAI,eAAe,CAAC,OAAO,EAAE,CAAC;YAC5B,OAAO;QACT,CAAC;QACD,MAA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,CAAC,KAAK;QACV,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;;AApIH,0CAqIC","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport { existsSync } from 'node:fs';\nimport { dirname, join, matchesGlob, relative, resolve, sep } from 'node:path';\nimport { ArtifactStereotypes, type IScannedArtifact } from '../generator/common';\nimport { ArtifactScanCache } from './scan-cache';\n\ninterface IArtifactScanner {\n scanWithReport(opts: { root: string; followReexports: boolean }): {\n artifacts: IScannedArtifact[];\n };\n}\n\n/** Where a package's artifacts live: the `src` beside its nearest `package.json`, and the classes under one of its directories. One scan per package per process, served from `ArtifactScanCache` when no source file changed - so this module never loads the scanner (and TypeScript) itself. */\nexport class ArtifactSources {\n private static readonly scans = new Map<string, IScannedArtifact[]>();\n private static scanner: IArtifactScanner | undefined;\n\n /** Called by the modules that already hold the scanner (the build plugin). */\n static useScanner(opts: { scanner: IArtifactScanner }): void {\n ArtifactSources.scanner = opts.scanner;\n }\n\n /** Loads the scanner - only on a cache miss. A non-static specifier, so a bundle never pulls TypeScript in. */\n static async loadScanner(): Promise<void> {\n if (ArtifactSources.scanner) {\n return;\n }\n const generatorModule = '../generator';\n const { ArtifactScanner } = await import(generatorModule);\n ArtifactSources.scanner = ArtifactScanner.getInstance();\n }\n\n /** Whether `packageSource` can be listed without the scanner: scanned in this process, or a valid disk cache. */\n static isCached(opts: { packageSource: string }): boolean {\n if (ArtifactSources.scans.has(opts.packageSource)) {\n return true;\n }\n const cached = ArtifactScanCache.read({ root: opts.packageSource });\n if (cached) {\n ArtifactSources.scans.set(opts.packageSource, cached);\n }\n return cached !== undefined;\n }\n\n /** Every decorated class under `packageSource`: this process's scan, else the disk cache, else the scanner (which must be loaded), written back to the cache. */\n static scan(opts: { packageSource: string }): IScannedArtifact[] {\n const { packageSource } = opts;\n if (ArtifactSources.isCached({ packageSource })) {\n return ArtifactSources.scans.get(packageSource) ?? [];\n }\n if (!ArtifactSources.scanner) {\n throw getError({\n message: `[ArtifactSources] ${packageSource} is not cached and the scanner is not loaded | Call ArtifactSources.loadScanner() first`,\n });\n }\n const { artifacts } = ArtifactSources.scanner.scanWithReport({\n root: packageSource,\n followReexports: true,\n });\n ArtifactSources.scans.set(packageSource, artifacts);\n ArtifactScanCache.write({ root: packageSource, artifacts });\n return artifacts;\n }\n\n /** The entry module (`Bun.main`), or `undefined` when there is no entry file (`bun -e`, a REPL). */\n static entry(): string | undefined {\n return typeof Bun !== 'undefined' && existsSync(Bun.main) ? Bun.main : undefined;\n }\n\n /** The `src` beside the nearest `package.json` at or above `from` (default: the working directory). */\n static packageSource(opts: { from?: string } = {}): string {\n const start = resolve(opts.from ?? process.cwd());\n let directory = start;\n while (!existsSync(join(directory, 'package.json'))) {\n const parent = dirname(directory);\n if (parent === directory) {\n return join(start, 'src');\n }\n directory = parent;\n }\n return join(directory, 'src');\n }\n\n /** The decorated classes under a directory named `folder` in the package whose source holds `site`, less those under an `ignore` glob (relative to `src`), each pointing at the copy that runs beside `site` (see `runningArtifacts`). */\n static folderArtifacts(opts: {\n folder: string | undefined;\n site: string;\n ignore?: ReadonlyArray<string>;\n }): IScannedArtifact[] {\n const packageSource = ArtifactSources.packageSource({ from: dirname(opts.site) });\n\n const artifacts = ArtifactSources.scan({ packageSource });\n\n const { folder } = opts;\n const ignored = opts.ignore ?? [];\n const picked = artifacts.filter((artifact) => {\n const path = relative(packageSource, artifact.filePath);\n return (\n (folder === undefined || path.split(sep).slice(0, -1).includes(folder)) &&\n !ignored.some((pattern) => matchesGlob(path, pattern))\n );\n });\n return ArtifactSources.runningArtifacts({ artifacts: picked, from: opts.site });\n }\n\n /** The scanned classes as the code at `from` runs them: unchanged when `from` is in `src`; otherwise each `src/<path>.ts` becomes `<tree>/<path>.js` in the compiled tree `from` sits in (`dist`, `dist/esm`), so an application registers the very class its code uses, never a second copy loaded from `src`. */\n static runningArtifacts(opts: {\n artifacts: IScannedArtifact[];\n from: string;\n }): IScannedArtifact[] {\n const from = resolve(opts.from);\n const packageSource = ArtifactSources.packageSource({ from: dirname(from) });\n const [probe] = opts.artifacts;\n if (!probe || from.startsWith(`${packageSource}${sep}`)) {\n return opts.artifacts;\n }\n\n const packageRoot = dirname(packageSource);\n const compiledPath = (target: { tree: string; artifact: IScannedArtifact }): string =>\n join(\n target.tree,\n relative(packageSource, target.artifact.filePath).replace(\n ArtifactStereotypes.SOURCE_EXTENSION,\n '.js',\n ),\n );\n const segments = relative(packageRoot, dirname(from)).split(sep);\n const tree = segments\n .map((_segment, index) => join(packageRoot, ...segments.slice(0, index + 1)))\n .find((candidate) => existsSync(compiledPath({ tree: candidate, artifact: probe })));\n\n return opts.artifacts.map((artifact) => {\n const compiled = tree ? compiledPath({ tree, artifact }) : undefined;\n if (!compiled || !existsSync(compiled)) {\n throw getError({\n message: `[ArtifactSources] ${artifact.filePath} has no compiled copy beside ${from} | The package runs from a compiled tree that is older than its src - rebuild it (or run it from src)`,\n });\n }\n return { ...artifact, filePath: compiled };\n });\n }\n\n /** Forgets every cached scan - for a long-lived process that rebuilds (a watch mode). */\n static clear(): void {\n ArtifactSources.scans.clear();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../../src/clis/artifacts.ts"],"names":[],"mappings":";;;AACA,0CAAwC;AACxC,yCAAqC;AACrC,yCAAsC;AACtC,4CAA+F;AAG/F,MAAM,KAAK,GACT,gKAAgK,CAAC;AAEnK,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAA,qBAAS,EAAC;IACxC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3B,gBAAgB,EAAE,IAAI;IACtB,OAAO,EAAE;QACP,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE;QACxC,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,4BAA4B,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,CAAC;YAC3C,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,CAAC,GAAG,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;gBACpC,OAAO,CAAC,CAAC;YACX,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,SAAS,OAAO,CAAC,GAAG,WAAW,gCAAoB,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC5F,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC","sourcesContent":["#!/usr/bin/env bun\nimport '../common/install-quiet-logger';\nimport { relative } from 'node:path';\nimport { parseArgs } from 'node:util';\nimport { ArtifactIndexEmitter, checkArtifactIndex, generateArtifactIndex } from '../generator';\nimport type { IScannedArtifact } from '../generator';\n\nconst USAGE =\n 'ignis-artifacts <generate|check> [--root src] [--out src/generated/artifacts.ts] [--ignore a,b] [--export GeneratedArtifacts] [--source-module <specifier>]...';\n\nconst { positionals, values } = parseArgs({\n args: process.argv.slice(2),\n allowPositionals: true,\n options: {\n root: { type: 'string', default: 'src' },\n out: { type: 'string', default: 'src/generated/artifacts.ts' },\n ignore: { type: 'string' },\n export: { type: 'string', default: 'GeneratedArtifacts' },\n 'source-module': { type: 'string', multiple: true },\n },\n});\n\nconst options = {\n root: values.root,\n out: values.out,\n ignore: values.ignore\n ?.split(',')\n .map((pattern) => pattern.trim())\n .filter(Boolean),\n exportName: values.export,\n sourceModules: values['source-module'],\n};\n\n/** One stderr line per decorated class a user `--ignore` pattern hid; silence when nothing is hidden. */\nconst warnIgnored = (opts: { ignored: IScannedArtifact[]; root: string }): void => {\n for (const artifact of opts.ignored) {\n console.error(\n `warning: ${artifact.className} (${artifact.type}) in ${relative(opts.root, artifact.filePath)} matches --ignore and is left out of the index`,\n );\n }\n};\n\n/** Exit code of the command, so the process exits in exactly one place. */\nconst run = (): number => {\n switch (positionals[0]) {\n case 'generate': {\n const result = generateArtifactIndex(options);\n console.log(\n `${result.written ? 'wrote' : 'up to date'} ${options.out} | ${result.artifacts.length} artifact(s)`,\n );\n warnIgnored({ ignored: result.ignored, root: options.root });\n return 0;\n }\n case 'check': {\n const result = checkArtifactIndex(options);\n warnIgnored({ ignored: result.ignored, root: options.root });\n if (result.isFresh) {\n console.log(`fresh ${options.out}`);\n return 0;\n }\n console.error(`stale ${options.out} - run: ${ArtifactIndexEmitter.renderCommand(options)}`);\n return 1;\n }\n default: {\n console.error(USAGE);\n return 2;\n }\n }\n};\n\nprocess.exit(run());\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type IScannedArtifact } from './common';
|
|
2
2
|
/** Renders the generated index: deterministic text, plain static imports, no IGNIS import - the object is type-checked where `registerArtifacts` receives it. */
|
|
3
3
|
export declare class ArtifactIndexEmitter {
|
|
4
|
-
/** Mirrors `printWidth` in
|
|
4
|
+
/** Mirrors `printWidth` in the root bunfig.toml `[fmt]` table. */
|
|
5
5
|
static readonly PRINT_WIDTH = 100;
|
|
6
6
|
static readonly DEFAULT_EXPORT_NAME = "GeneratedArtifacts";
|
|
7
7
|
/** The `ignis-artifacts generate` command for these options - the header and the CLI's stale hint print the same one. */
|
|
@@ -34,7 +34,7 @@ export declare class ArtifactIndexEmitter {
|
|
|
34
34
|
sourceModules?: string[];
|
|
35
35
|
};
|
|
36
36
|
}): string;
|
|
37
|
-
/** One line while it fits the
|
|
37
|
+
/** One line while it fits the print width, else one name per line - so `bun fmt --check` on the generated file stays quiet. */
|
|
38
38
|
private static renderField;
|
|
39
39
|
private static importPath;
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../../src/generator/emitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAErF,iKAAiK;AACjK,qBAAa,oBAAoB;IAC/B,
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../../src/generator/emitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAErF,iKAAiK;AACjK,qBAAa,oBAAoB;IAC/B,kEAAkE;IAClE,MAAM,CAAC,QAAQ,CAAC,WAAW,OAAO;IAElC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,wBAAwB;IAE3D,yHAAyH;IACzH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B,GAAG,MAAM;IAeV,2HAA2H;IAC3H,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B,GAAG,MAAM;IAIV,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAClB,SAAS,EAAE,gBAAgB,EAAE,CAAC;QAC9B,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,2GAA2G;QAC3G,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,mHAAmH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