@venizia/ignis-boot 0.5.0-1 → 0.5.0-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/build-info/resolver.js +3 -3
- package/dist/esm/build-info/resolver.js.map +1 -1
- package/dist/esm/bun/auto-group.d.ts +1 -1
- package/dist/esm/bun/auto-group.js +8 -8
- package/dist/esm/bun/auto-group.js.map +1 -1
- package/dist/esm/bun/auto-loader.js +7 -0
- package/dist/esm/bun/auto-loader.js.map +1 -1
- package/dist/esm/bun/group-resolver.js +12 -2
- package/dist/esm/bun/group-resolver.js.map +1 -1
- package/dist/esm/bun/plugin.d.ts +1 -1
- package/dist/esm/bun/plugin.js +39 -32
- package/dist/esm/bun/plugin.js.map +1 -1
- package/dist/esm/bun/scan-cache.js +2 -2
- package/dist/esm/bun/scan-cache.js.map +1 -1
- package/dist/esm/clis/artifacts.js +15 -5
- package/dist/esm/clis/artifacts.js.map +1 -1
- package/dist/esm/clis/write-line.d.ts +9 -0
- package/dist/esm/clis/write-line.js +29 -0
- package/dist/esm/clis/write-line.js.map +1 -0
- package/dist/esm/common/quiet-logger.d.ts +1 -1
- package/dist/esm/common/quiet-logger.js +1 -1
- package/dist/esm/common/quiet-logger.js.map +1 -1
- package/dist/esm/generator/common/constants.d.ts +22 -9
- package/dist/esm/generator/common/constants.js +28 -30
- package/dist/esm/generator/common/constants.js.map +1 -1
- package/dist/esm/generator/common/types.d.ts +9 -4
- package/dist/esm/generator/common/types.js.map +1 -1
- package/dist/esm/generator/emitter.d.ts +4 -0
- package/dist/esm/generator/emitter.js +23 -0
- package/dist/esm/generator/emitter.js.map +1 -1
- package/dist/esm/generator/reexport.d.ts +33 -1
- package/dist/esm/generator/reexport.js +135 -5
- package/dist/esm/generator/reexport.js.map +1 -1
- package/dist/esm/generator/scanner.d.ts +5 -0
- package/dist/esm/generator/scanner.js +73 -10
- package/dist/esm/generator/scanner.js.map +1 -1
- package/package.json +9 -9
|
@@ -69,9 +69,9 @@ export class BuildInfoResolver extends BaseHelper {
|
|
|
69
69
|
// `rev-parse --abbrev-ref HEAD` in a repository with no commit prints the literal `HEAD` on
|
|
70
70
|
// stdout while exiting 128, so the exit code decides and stdout alone never does: a nonzero
|
|
71
71
|
// exit rejects here whatever it printed.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.logger.debug('git %s | exit: %d | %s', args.join(' '), code,
|
|
72
|
+
if (error instanceof Error && 'code' in error && typeof error.code === 'number') {
|
|
73
|
+
const stderr = 'stderr' in error && typeof error.stderr === 'string' ? error.stderr : '';
|
|
74
|
+
this.logger.debug('git %s | exit: %d | %s', args.join(' '), error.code, stderr.trim());
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
77
|
this.logger.debug('git %s | unavailable: %s', args.join(' '), error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/build-info/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,yEAAyE;AACzE,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAG/C;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC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YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;YAEnE,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBAClD,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,MAAM,IAAI,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;YACxD,MAAM,OAAO,GAAG,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;YAEjE,OAAO;gBACL,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;gBACjD,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;aAC3D,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YAEzE,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF","sourcesContent":["import { BaseHelper } from '@venizia/ignis-helpers';\nimport { BuildInfoRegistry, type TBuildInfoRecord } from '@venizia/ignis-helpers/core';\nimport { execFile } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { promisify } from 'node:util';\nimport { BuildInfoEnvironmentKeys } from './common';\n\nconst execFileAsync = promisify(execFile);\n\n/** Length of a short SHA; an env value already shorter is left alone. */\nconst COMMIT_LENGTH = 12;\n\n/**\n * Resolves the stamp: environment first (CI knows the release tag), then `git`, then the\n * manifest. Every miss is logged with its reason and degrades one field to\n * {@link BuildInfoRegistry.UNSPECIFIED} - a Distroless image has no `git` and an exported tarball\n * has no manifest, and a build must not die over a stamp.\n */\nexport class BuildInfoResolver extends BaseHelper {\n private static instance?: BuildInfoResolver;\n\n private constructor() {\n super({ scope: BuildInfoResolver.name });\n }\n\n static getInstance(): BuildInfoResolver {\n return (this.instance ??= new BuildInfoResolver());\n }\n\n async resolve(opts?: { root?: string }): Promise<TBuildInfoRecord> {\n const root = resolve(opts?.root ?? process.cwd());\n const manifest = this.resolveManifest({ root });\n\n // Independent processes; sequencing them would double the latency of the common case for nothing.\n const [gitCommit, gitBranch] = await Promise.all([\n this.resolveGitValue({ args: ['rev-parse', `--short=${COMMIT_LENGTH}`, 'HEAD'], root }),\n this.resolveGitValue({ args: ['rev-parse', '--abbrev-ref', 'HEAD'], root }),\n ]);\n\n const unspecified = BuildInfoRegistry.UNSPECIFIED;\n\n return {\n service: manifest.name ?? unspecified,\n version:\n this.resolveEnvironmentValue({ keys: BuildInfoEnvironmentKeys.VERSION }) ??\n manifest.version ??\n unspecified,\n commit:\n this.resolveEnvironmentValue({ keys: BuildInfoEnvironmentKeys.COMMIT })?.slice(\n 0,\n COMMIT_LENGTH,\n ) ??\n gitCommit ??\n unspecified,\n branch:\n this.resolveEnvironmentValue({ keys: BuildInfoEnvironmentKeys.BRANCH }) ??\n gitBranch ??\n unspecified,\n builtAt:\n this.resolveEnvironmentValue({ keys: BuildInfoEnvironmentKeys.BUILT_AT }) ??\n new Date().toISOString(),\n };\n }\n\n private resolveEnvironmentValue(opts: { keys: readonly string[] }): string | undefined {\n for (const key of opts.keys) {\n const value = process.env[key];\n\n if (value !== undefined && value.trim().length > 0) {\n return value.trim();\n }\n }\n\n return undefined;\n }\n\n /**\n * `execFile` runs `git` without a shell, so no argument is ever parsed by one. A nonzero exit and\n * `git` being absent are both a miss, logged and degraded to one field.\n */\n private async resolveGitValue(opts: {\n args: string[];\n root: string;\n }): Promise<string | undefined> {\n const { args, root } = opts;\n\n try {\n const { stdout } = await execFileAsync('git', args, { cwd: root, windowsHide: true });\n const value = stdout.trim();\n\n return value.length > 0 ? value : undefined;\n } catch (error) {\n // `rev-parse --abbrev-ref HEAD` in a repository with no commit prints the literal `HEAD` on\n // stdout while exiting 128, so the exit code decides and stdout alone never does: a nonzero\n // exit rejects here whatever it printed.\n if (error instanceof Error && 'code' in error && typeof error.code === 'number') {\n const stderr = 'stderr' in error && typeof error.stderr === 'string' ? error.stderr : '';\n this.logger.debug('git %s | exit: %d | %s', args.join(' '), error.code, stderr.trim());\n } else {\n this.logger.debug('git %s | unavailable: %s', args.join(' '), error);\n }\n\n return undefined;\n }\n }\n\n /** `JSON.parse` promises nothing about the shape, so a manifest holding `{ \"name\": 42 }` must not become a numeric `service`. */\n private resolveManifest(opts: { root: string }): { name?: string; version?: string } {\n const manifest = resolve(opts.root, 'package.json');\n\n if (!existsSync(manifest)) {\n this.logger.debug('No package.json at %s', opts.root);\n\n return {};\n }\n\n try {\n const parsed: unknown = JSON.parse(readFileSync(manifest, 'utf8'));\n\n if (typeof parsed !== 'object' || parsed === null) {\n return {};\n }\n\n const name = 'name' in parsed ? parsed.name : undefined;\n const version = 'version' in parsed ? parsed.version : undefined;\n\n return {\n name: typeof name === 'string' ? name : undefined,\n version: typeof version === 'string' ? version : undefined,\n };\n } catch (error) {\n this.logger.debug('Unreadable package.json at %s | %s', manifest, error);\n\n return {};\n }\n }\n}\n"]}
|
|
@@ -11,7 +11,7 @@ export declare class AutoArtifactGroup<TIndex extends TGeneratedArtifactIndexInp
|
|
|
11
11
|
resolve?: () => Promise<TIndex>;
|
|
12
12
|
});
|
|
13
13
|
resolve(): Promise<TIndex>;
|
|
14
|
-
private static
|
|
14
|
+
private static unreadCategory;
|
|
15
15
|
get configurations(): never;
|
|
16
16
|
get dataSources(): never;
|
|
17
17
|
get components(): never;
|
|
@@ -20,28 +20,28 @@ export class AutoArtifactGroup {
|
|
|
20
20
|
}
|
|
21
21
|
return this.resolver();
|
|
22
22
|
}
|
|
23
|
-
static
|
|
23
|
+
static unreadCategory() {
|
|
24
24
|
throw getError({
|
|
25
|
-
message: '[@venizia/ignis-boot/auto] The application artifacts are resolved when artifacts are registered | A function that walks configs.artifacts must pass a group through untouched (check `isArtifactGroup`) instead of reading its
|
|
25
|
+
message: '[@venizia/ignis-boot/auto] The application artifacts are resolved when artifacts are registered | A function that walks configs.artifacts must pass a group through untouched (check `isArtifactGroup`) instead of reading its categories',
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
get configurations() {
|
|
29
|
-
return AutoArtifactGroup.
|
|
29
|
+
return AutoArtifactGroup.unreadCategory();
|
|
30
30
|
}
|
|
31
31
|
get dataSources() {
|
|
32
|
-
return AutoArtifactGroup.
|
|
32
|
+
return AutoArtifactGroup.unreadCategory();
|
|
33
33
|
}
|
|
34
34
|
get components() {
|
|
35
|
-
return AutoArtifactGroup.
|
|
35
|
+
return AutoArtifactGroup.unreadCategory();
|
|
36
36
|
}
|
|
37
37
|
get repositories() {
|
|
38
|
-
return AutoArtifactGroup.
|
|
38
|
+
return AutoArtifactGroup.unreadCategory();
|
|
39
39
|
}
|
|
40
40
|
get services() {
|
|
41
|
-
return AutoArtifactGroup.
|
|
41
|
+
return AutoArtifactGroup.unreadCategory();
|
|
42
42
|
}
|
|
43
43
|
get controllers() {
|
|
44
|
-
return AutoArtifactGroup.
|
|
44
|
+
return AutoArtifactGroup.unreadCategory();
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
//# sourceMappingURL=auto-group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-group.js","sourceRoot":"","sources":["../../../src/bun/auto-group.ts"],"names":[],"mappings":"AAAA,2HAA2H;AAC3H,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,wdAAwd;AACxd,MAAM,OAAO,iBAAiB;IAS5B,YAAY,IAA2D;QAN9D,oBAAe,GAAG,IAAa,CAAC;QAChC,WAAM,GAAG,SAAS,CAAC;QACnB,SAAI,GAAG,SAAS,CAAC;QAKxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QA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,OAAO,iBAAiB,CAAC,cAAc,EAAE,CAAC;IAC5C,CAAC;IAED,IAAI,WAAW;QACb,OAAO,iBAAiB,CAAC,cAAc,EAAE,CAAC;IAC5C,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,iBAAiB,CAAC,cAAc,EAAE,CAAC;IAC5C,CAAC;IAED,IAAI,YAAY;QACd,OAAO,iBAAiB,CAAC,cAAc,EAAE,CAAC;IAC5C,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,iBAAiB,CAAC,cAAc,EAAE,CAAC;IAC5C,CAAC;IAED,IAAI,WAAW;QACb,OAAO,iBAAiB,CAAC,cAAc,EAAE,CAAC;IAC5C,CAAC;CACF","sourcesContent":["// The inversion package, not the helpers barrel: a browser bundle reaches this module, and the barrel loads node builtins.\nimport { getError } from '@venizia/ignis-inversion';\nimport type { TGeneratedArtifactIndex, TGeneratedArtifactIndexInput } from '../generator';\n\n/** The application's own artifacts as the kernel's group protocol (`isArtifactGroup`), built without depending on the kernel: inlined `content` in a binary, `resolve()` from source. Reading a kind throws, so a function that walks `configs.artifacts` cannot drop it as an empty index. `TIndex` is the index type the content carries: it is inferred from what the application passes, and defaults to the bottom `TGeneratedArtifactIndex` when boot builds the group itself. */\nexport class AutoArtifactGroup<\n TIndex extends TGeneratedArtifactIndexInput = TGeneratedArtifactIndex,\n> {\n readonly isArtifactGroup = true as const;\n readonly folder = undefined;\n readonly site = undefined;\n readonly content: TIndex | undefined;\n private readonly resolver: (() => Promise<TIndex>) | undefined;\n\n constructor(opts: { content?: TIndex; resolve?: () => Promise<TIndex> }) {\n this.content = opts.content;\n this.resolver = opts.resolve;\n }\n\n async resolve(): Promise<TIndex> {\n if (this.content) {\n return this.content;\n }\n\n if (!this.resolver) {\n throw getError({\n message: '[@venizia/ignis-boot/auto] The auto group has neither content nor a resolver',\n });\n }\n\n return this.resolver();\n }\n\n private static unreadCategory(): never {\n throw getError({\n message:\n '[@venizia/ignis-boot/auto] The application artifacts are resolved when artifacts are registered | A function that walks configs.artifacts must pass a group through untouched (check `isArtifactGroup`) instead of reading its categories',\n });\n }\n\n get configurations(): never {\n return AutoArtifactGroup.unreadCategory();\n }\n\n get dataSources(): never {\n return AutoArtifactGroup.unreadCategory();\n }\n\n get components(): never {\n return AutoArtifactGroup.unreadCategory();\n }\n\n get repositories(): never {\n return AutoArtifactGroup.unreadCategory();\n }\n\n get services(): never {\n return AutoArtifactGroup.unreadCategory();\n }\n\n get controllers(): never {\n return AutoArtifactGroup.unreadCategory();\n }\n}\n"]}
|
|
@@ -53,6 +53,13 @@ export class AutoArtifactsLoader {
|
|
|
53
53
|
index[field] = classes;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
const custom = {};
|
|
57
|
+
for (const group of ArtifactStereotypes.groupCustom({ artifacts: emitted })) {
|
|
58
|
+
custom[group.type] = group.artifacts.flatMap((artifact) => loaded.get(artifact) ?? []);
|
|
59
|
+
}
|
|
60
|
+
if (Object.keys(custom).length > 0) {
|
|
61
|
+
index.custom = custom;
|
|
62
|
+
}
|
|
56
63
|
return index;
|
|
57
64
|
}
|
|
58
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-loader.js","sourceRoot":"","sources":["../../../src/bun/auto-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,mBAAmB,EACnB,aAAa,GAGd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,0MAA0M;AAC1M,MAAM,OAAO,mBAAmB;IAC9B,MAAM,CAAC,aAAa,CAAC,IAAyB;QAC5C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,QAAQ,CAAC;gBACb,OAAO,EACL,sNAAsN;aACzN,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IA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,CAAC,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,KAAK,GAA4B,EAAE,CAAC;QAE1C,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,mBAAmB,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;YAErD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;YACzB,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAyC,EAAE,CAAC;QAExD,KAAK,MAAM,KAAK,IAAI,mBAAmB,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;YAC5E,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QACzF,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;QACxB,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport type { 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\n if (ArtifactSources.isCached({ packageSource })) {\n const artifacts = ArtifactSources.scan({ packageSource });\n\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\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<never>>();\n\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: TGeneratedArtifactIndex = {};\n\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\n if (classes.length > 0) {\n index[field] = classes;\n }\n }\n\n const custom: Record<string, Array<TClass<never>>> = {};\n\n for (const group of ArtifactStereotypes.groupCustom({ artifacts: emitted })) {\n custom[group.type] = group.artifacts.flatMap((artifact) => loaded.get(artifact) ?? []);\n }\n\n if (Object.keys(custom).length > 0) {\n index.custom = custom;\n }\n\n return index;\n }\n}\n"]}
|
|
@@ -19,13 +19,23 @@ export class GroupArtifactsResolver {
|
|
|
19
19
|
await ArtifactSources.loadScanner();
|
|
20
20
|
}
|
|
21
21
|
const index = {};
|
|
22
|
+
const custom = {};
|
|
22
23
|
for (const artifact of ArtifactSources.folderArtifacts({ folder, site, ignore })) {
|
|
23
24
|
const field = ArtifactStereotypes.EMIT_ORDER.find((entry) => entry.type === artifact.type)?.field;
|
|
24
|
-
|
|
25
|
+
const isCustom = !field && !ArtifactStereotypes.isBuiltIn({ type: artifact.type });
|
|
26
|
+
if (!field && !isCustom) {
|
|
25
27
|
continue;
|
|
26
28
|
}
|
|
27
29
|
const loaded = await import(artifact.filePath);
|
|
28
|
-
|
|
30
|
+
if (field) {
|
|
31
|
+
index[field] = [...(index[field] ?? []), loaded[artifact.className]];
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
custom[artifact.type] = [...(custom[artifact.type] ?? []), loaded[artifact.className]];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (Object.keys(custom).length > 0) {
|
|
38
|
+
index.custom = custom;
|
|
29
39
|
}
|
|
30
40
|
return index;
|
|
31
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-resolver.js","sourceRoot":"","sources":["../../../src/bun/group-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAgC,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,2OAA2O;AAC3O,MAAM,OAAO,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;QAE5C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,oBAAoB,MAAM,IAAI,eAAe,6GAA6G;aACpK,CAAC,CAAC;QACL,CAAC;QAED,IACE,CAAC,eAAe,CAAC,QAAQ,CAAC;YACxB,aAAa,EAAE,eAAe,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;SACtE,CAAC,EACF,CAAC;YACD,MAAM,eAAe,CAAC,WAAW,EAAE,CAAC;QACtC,CAAC;QAED,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"group-resolver.js","sourceRoot":"","sources":["../../../src/bun/group-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAgC,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,2OAA2O;AAC3O,MAAM,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AK,EAAE,CAAC;gBACV,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;YACvE,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;YACzF,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;QACxB,CAAC;QAED,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","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport type { 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\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: TGeneratedArtifactIndex = {};\n const custom: Record<string, Array<TClass<never>>> = {};\n\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 const isCustom = !field && !ArtifactStereotypes.isBuiltIn({ type: artifact.type });\n\n if (!field && !isCustom) {\n continue;\n }\n\n const loaded = await import(artifact.filePath);\n\n if (field) {\n index[field] = [...(index[field] ?? []), loaded[artifact.className]];\n } else {\n custom[artifact.type] = [...(custom[artifact.type] ?? []), loaded[artifact.className]];\n }\n }\n\n if (Object.keys(custom).length > 0) {\n index.custom = custom;\n }\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/esm/bun/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BunPlugin } from 'bun';
|
|
1
|
+
import type { BunPlugin } from '../bun/index.js';
|
|
2
2
|
/** 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. */
|
|
3
3
|
export declare class IgnisArtifactsPlugin {
|
|
4
4
|
static readonly NAME = "ignis-artifacts";
|
package/dist/esm/bun/plugin.js
CHANGED
|
@@ -67,6 +67,7 @@ export class IgnisArtifactsPlugin {
|
|
|
67
67
|
const edits = [];
|
|
68
68
|
const imports = [];
|
|
69
69
|
let counter = 0;
|
|
70
|
+
// Annotated: only a declared `never` narrows the code after a call.
|
|
70
71
|
const refuse = (node, reason) => {
|
|
71
72
|
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
72
73
|
throw getError({
|
|
@@ -82,44 +83,50 @@ export class IgnisArtifactsPlugin {
|
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
85
|
const fields = [];
|
|
86
|
+
/** How the generated literal names one class: a `require` in a compiled file, else an import of its own. */
|
|
87
|
+
const reference = (artifact) => {
|
|
88
|
+
if (isCompiled) {
|
|
89
|
+
return `require(${JSON.stringify(artifact.filePath)}).${artifact.className}`;
|
|
90
|
+
}
|
|
91
|
+
counter += 1;
|
|
92
|
+
const local = `__ignis_group_${counter}`;
|
|
93
|
+
const path = artifact.filePath
|
|
94
|
+
.split(sep)
|
|
95
|
+
.join('/')
|
|
96
|
+
.replace(ArtifactStereotypes.SOURCE_EXTENSION, '');
|
|
97
|
+
imports.push(`import { ${artifact.className} as ${local} } from '${path}';`);
|
|
98
|
+
return local;
|
|
99
|
+
};
|
|
85
100
|
for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {
|
|
86
101
|
const locals = artifacts
|
|
87
102
|
.filter((artifact) => artifact.type === type)
|
|
88
|
-
.map((artifact) =>
|
|
89
|
-
if (isCompiled) {
|
|
90
|
-
return `require(${JSON.stringify(artifact.filePath)}).${artifact.className}`;
|
|
91
|
-
}
|
|
92
|
-
counter += 1;
|
|
93
|
-
const local = `__ignis_group_${counter}`;
|
|
94
|
-
const path = artifact.filePath
|
|
95
|
-
.split(sep)
|
|
96
|
-
.join('/')
|
|
97
|
-
.replace(ArtifactStereotypes.SOURCE_EXTENSION, '');
|
|
98
|
-
imports.push(`import { ${artifact.className} as ${local} } from '${path}';`);
|
|
99
|
-
return local;
|
|
100
|
-
});
|
|
103
|
+
.map((artifact) => reference(artifact));
|
|
101
104
|
if (locals.length > 0) {
|
|
102
105
|
fields.push(`${field}: [${locals.join(', ')}]`);
|
|
103
106
|
}
|
|
104
107
|
}
|
|
108
|
+
const custom = ArtifactStereotypes.groupCustom({ artifacts }).map(({ type, artifacts: group }) => {
|
|
109
|
+
const locals = group.map((artifact) => reference(artifact));
|
|
110
|
+
return `${JSON.stringify(type)}: [${locals.join(', ')}]`;
|
|
111
|
+
});
|
|
112
|
+
if (custom.length > 0) {
|
|
113
|
+
fields.push(`${ArtifactStereotypes.CUSTOM_FIELD}: { ${custom.join(', ')} }`);
|
|
114
|
+
}
|
|
105
115
|
return `{ ${fields.join(', ')} }`;
|
|
106
116
|
};
|
|
107
117
|
const visit = (node) => {
|
|
108
|
-
|
|
109
|
-
ts.isPropertyAccessExpression(node.expression)
|
|
110
|
-
(ts.isIdentifier(node.expression.expression) ||
|
|
111
|
-
ts.isPropertyAccessExpression(node.expression.expression))
|
|
112
|
-
(node.expression.name.text === 'define' || node.expression.name.text === 'application')
|
|
113
|
-
if (!isGroupCall) {
|
|
118
|
+
if (!ts.isCallExpression(node) ||
|
|
119
|
+
!ts.isPropertyAccessExpression(node.expression) ||
|
|
120
|
+
!(ts.isIdentifier(node.expression.expression) ||
|
|
121
|
+
ts.isPropertyAccessExpression(node.expression.expression)) ||
|
|
122
|
+
!(node.expression.name.text === 'define' || node.expression.name.text === 'application')) {
|
|
114
123
|
ts.forEachChild(node, visit);
|
|
115
124
|
return;
|
|
116
125
|
}
|
|
117
126
|
const call = node;
|
|
118
|
-
const access =
|
|
119
|
-
const target =
|
|
120
|
-
const callee = ts.isIdentifier(target)
|
|
121
|
-
? target.text
|
|
122
|
-
: target.name.text;
|
|
127
|
+
const access = node.expression;
|
|
128
|
+
const target = node.expression.expression;
|
|
129
|
+
const callee = ts.isIdentifier(target) ? target.text : target.name.text;
|
|
123
130
|
const isApplication = access.name.text === 'application';
|
|
124
131
|
if (ts.isIdentifier(target) && aliases.has(callee)) {
|
|
125
132
|
refuse(call, `ArtifactGroup is imported as ${callee}`);
|
|
@@ -136,8 +143,7 @@ export class IgnisArtifactsPlugin {
|
|
|
136
143
|
if (!argument || !ts.isObjectLiteralExpression(argument)) {
|
|
137
144
|
refuse(call, 'the argument is not an object literal');
|
|
138
145
|
}
|
|
139
|
-
const
|
|
140
|
-
const named = (name) => literal.properties.find((entry) => entry.name !== undefined && ts.isIdentifier(entry.name) && entry.name.text === name);
|
|
146
|
+
const named = (name) => argument.properties.find((entry) => entry.name !== undefined && ts.isIdentifier(entry.name) && entry.name.text === name);
|
|
141
147
|
if (named('content')) {
|
|
142
148
|
return;
|
|
143
149
|
}
|
|
@@ -154,18 +160,19 @@ export class IgnisArtifactsPlugin {
|
|
|
154
160
|
refuse(call, 'folder is not a string literal');
|
|
155
161
|
}
|
|
156
162
|
const ignoreProperty = named('ignore');
|
|
157
|
-
const
|
|
163
|
+
const ignored = ignoreProperty &&
|
|
158
164
|
ts.isPropertyAssignment(ignoreProperty) &&
|
|
159
|
-
ts.isArrayLiteralExpression(ignoreProperty.initializer)
|
|
160
|
-
ignoreProperty.initializer.elements
|
|
161
|
-
? ignoreProperty.initializer.elements.map((element) => element.text)
|
|
165
|
+
ts.isArrayLiteralExpression(ignoreProperty.initializer)
|
|
166
|
+
? ignoreProperty.initializer.elements
|
|
162
167
|
: undefined;
|
|
168
|
+
const names = ignored?.flatMap((element) => ts.isStringLiteral(element) ? [element.text] : []);
|
|
169
|
+
const ignoreList = names?.length === ignored?.length ? names : undefined;
|
|
163
170
|
if (ignoreProperty && ignoreList === undefined) {
|
|
164
171
|
refuse(call, 'ignore is not an array of string literals');
|
|
165
172
|
}
|
|
166
|
-
const last =
|
|
173
|
+
const last = argument.properties[argument.properties.length - 1];
|
|
167
174
|
edits.push({
|
|
168
|
-
at: last ? last.getEnd() :
|
|
175
|
+
at: last ? last.getEnd() : argument.getStart() + 1,
|
|
169
176
|
text: `${last ? ', ' : ''}content: ${contentLiteral(folderLiteral, ignoreList)}`,
|
|
170
177
|
});
|
|
171
178
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/bun/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,6QAA6Q;AAC7Q,MAAM,OAAO,oBAAoB;aACf,SAAI,GAAG,iBAAiB,CAAC;aACzB,YAAO,GAAG,iBAAiB,CAAC;aAC5B,gBAAW,GAAG,oBAAoB,CAAC;IAEnD,uIAAuI;aACvH,gBAAW,GACzB,0GAA0G,CAAC;IAE7G,oHAAoH;aACpG,gBAAW,GAAG,kDAAkD,CAAC;aAEzD,gBAAW,GAAG,MAAM,CAAC,GAAG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C,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;yBACrF,CAAC;oBACJ,CAAC,CAAC,CAAC;gBACL,CAAC;gBAED,sRAAsR;gBACtR,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC;gBACnE,MAAM,UAAU,GAAG,MAAM;oBACvB,CAAC,CAAC,iIAAiI,oBAAoB,CAAC,OAAO,OAAO,oBAAoB,CAAC,WAAW,QAAQ;oBAC9M,CAAC,CAAC,YAAY,oBAAoB,CAAC,WAAW,YAAY,oBAAoB,CAAC,OAAO,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;QAED,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","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 `dist/esm` - 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|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\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\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\n const outFile = join(root, '__ignis_artifacts__.ts');\n const artifacts = ArtifactSources.scan({ packageSource: root });\n\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\n for (const statement of sourceFile.statements) {\n const bindings = ts.isImportDeclaration(statement)\n ? statement.importClause?.namedBindings\n : undefined;\n\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\n const contentLiteral = (folder: string | undefined, ignore?: string[]): string => {\n const artifacts = ArtifactSources.folderArtifacts({ folder, site: filePath, ignore });\n\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\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\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\n return local;\n });\n\n if (locals.length > 0) {\n fields.push(`${field}: [${locals.join(', ')}]`);\n }\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\n if (!isGroupCall) {\n ts.forEachChild(node, visit);\n\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\n if (ts.isIdentifier(target) && aliases.has(callee)) {\n refuse(call, `ArtifactGroup is imported as ${callee}`);\n }\n\n if (callee !== 'ArtifactGroup') {\n ts.forEachChild(node, visit);\n\n return;\n }\n\n const [argument] = call.arguments;\n\n if (isApplication && !argument) {\n edits.push({ at: call.arguments.pos, text: `{ content: ${contentLiteral(undefined)} }` });\n\n return;\n }\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\n if (named('content')) {\n return;\n }\n\n const folderProperty = named('folder');\n\n if (isApplication && folderProperty) {\n refuse(call, 'ArtifactGroup.application() takes no folder');\n }\n\n const folderLiteral =\n folderProperty &&\n ts.isPropertyAssignment(folderProperty) &&\n ts.isStringLiteral(folderProperty.initializer)\n ? folderProperty.initializer.text\n : undefined;\n\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\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\n visit(sourceFile);\n\n let rewritten = source;\n\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\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\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\n return ts.isIdentifier(expression) && names.has(expression.text);\n });\n\n if (isDecorated) {\n found.push(node.name.text);\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n\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\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\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n\n let pinned = opts.source;\n\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\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\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\n const own = ArtifactSources.scan({ packageSource: opts.root });\n add(opts.entry ? ArtifactSources.runningArtifacts({ artifacts: own, from: opts.entry }) : own);\n\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\n const source = readFileSync(file, 'utf8');\n\n if (!IgnisArtifactsPlugin.DECORATED.test(source)) {\n continue;\n }\n\n add(\n IgnisArtifactsPlugin.decoratedClasses({ filePath: file, source }).map((className) => ({\n filePath: file,\n className,\n })),\n );\n }\n\n for (const groupFile of opts.groupFiles ?? []) {\n const packageSource = ArtifactSources.packageSource({ from: dirname(groupFile) });\n\n if (packageSource === opts.root || !existsSync(packageSource)) {\n continue;\n }\n\n add(\n ArtifactSources.runningArtifacts({\n artifacts: ArtifactSources.scan({ packageSource }),\n from: groupFile,\n }),\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\n for (const name of names) {\n let directory = packageDirectory;\n\n while (true) {\n const linked = join(directory, 'node_modules', name);\n\n if (existsSync(linked)) {\n const real = realpathSync(linked);\n\n if (!real.split(sep).includes('node_modules') && existsSync(join(real, 'src'))) {\n sources.add(join(real, 'src'));\n }\n\n break;\n }\n\n const parent = dirname(directory);\n\n if (parent === directory) {\n break;\n }\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\n for (const source of sources) {\n if (!existsSync(source)) {\n continue;\n }\n\n trees.push({ directory: source, pattern: ArtifactStereotypes.SOURCE_GLOB });\n\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\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\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\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\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\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\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\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":["../../../src/bun/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,6QAA6Q;AAC7Q,MAAM,OAAO,oBAAoB;aACf,SAAI,GAAG,iBAAiB,CAAC;aACzB,YAAO,GAAG,iBAAiB,CAAC;aAC5B,gBAAW,GAAG,oBAAoB,CAAC;IAEnD,uIAAuI;aACvH,gBAAW,GACzB,0GAA0G,CAAC;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,WAAW,QAAQ;oBAC9M,CAAC,CAAC,YAAY,oBAAoB,CAAC,WAAW,YAAY,oBAAoB,CAAC,OAAO,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;QAED,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","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 `dist/esm` - 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|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\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\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\n const outFile = join(root, '__ignis_artifacts__.ts');\n const artifacts = ArtifactSources.scan({ packageSource: root });\n\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\n for (const statement of sourceFile.statements) {\n const bindings = ts.isImportDeclaration(statement)\n ? statement.importClause?.namedBindings\n : undefined;\n\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 // Annotated: only a declared `never` narrows the code after a call.\n const refuse: (node: ts.Node, reason: string) => never = (node, reason) => {\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\n const contentLiteral = (folder: string | undefined, ignore?: string[]): string => {\n const artifacts = ArtifactSources.folderArtifacts({ folder, site: filePath, ignore });\n\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\n /** How the generated literal names one class: a `require` in a compiled file, else an import of its own. */\n const reference = (artifact: { filePath: string; className: string }): string => {\n if (isCompiled) {\n return `require(${JSON.stringify(artifact.filePath)}).${artifact.className}`;\n }\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\n return local;\n };\n\n for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {\n const locals = artifacts\n .filter((artifact) => artifact.type === type)\n .map((artifact) => reference(artifact));\n\n if (locals.length > 0) {\n fields.push(`${field}: [${locals.join(', ')}]`);\n }\n }\n\n const custom = ArtifactStereotypes.groupCustom({ artifacts }).map(\n ({ type, artifacts: group }) => {\n const locals = group.map((artifact) => reference(artifact));\n\n return `${JSON.stringify(type)}: [${locals.join(', ')}]`;\n },\n );\n\n if (custom.length > 0) {\n fields.push(`${ArtifactStereotypes.CUSTOM_FIELD}: { ${custom.join(', ')} }`);\n }\n\n return `{ ${fields.join(', ')} }`;\n };\n\n const visit = (node: ts.Node): void => {\n if (\n !ts.isCallExpression(node) ||\n !ts.isPropertyAccessExpression(node.expression) ||\n !(\n ts.isIdentifier(node.expression.expression) ||\n ts.isPropertyAccessExpression(node.expression.expression)\n ) ||\n !(node.expression.name.text === 'define' || node.expression.name.text === 'application')\n ) {\n ts.forEachChild(node, visit);\n\n return;\n }\n\n const call = node;\n const access = node.expression;\n const target = node.expression.expression;\n const callee = ts.isIdentifier(target) ? target.text : target.name.text;\n const isApplication = access.name.text === 'application';\n\n if (ts.isIdentifier(target) && aliases.has(callee)) {\n refuse(call, `ArtifactGroup is imported as ${callee}`);\n }\n\n if (callee !== 'ArtifactGroup') {\n ts.forEachChild(node, visit);\n\n return;\n }\n\n const [argument] = call.arguments;\n\n if (isApplication && !argument) {\n edits.push({ at: call.arguments.pos, text: `{ content: ${contentLiteral(undefined)} }` });\n\n return;\n }\n\n if (!argument || !ts.isObjectLiteralExpression(argument)) {\n refuse(call, 'the argument is not an object literal');\n }\n\n const named = (name: string): ts.ObjectLiteralElementLike | undefined =>\n argument.properties.find(\n (entry) =>\n entry.name !== undefined && ts.isIdentifier(entry.name) && entry.name.text === name,\n );\n\n if (named('content')) {\n return;\n }\n\n const folderProperty = named('folder');\n\n if (isApplication && folderProperty) {\n refuse(call, 'ArtifactGroup.application() takes no folder');\n }\n\n const folderLiteral =\n folderProperty &&\n ts.isPropertyAssignment(folderProperty) &&\n ts.isStringLiteral(folderProperty.initializer)\n ? folderProperty.initializer.text\n : undefined;\n\n if (!isApplication && folderLiteral === undefined) {\n refuse(call, 'folder is not a string literal');\n }\n\n const ignoreProperty = named('ignore');\n const ignored =\n ignoreProperty &&\n ts.isPropertyAssignment(ignoreProperty) &&\n ts.isArrayLiteralExpression(ignoreProperty.initializer)\n ? ignoreProperty.initializer.elements\n : undefined;\n const names = ignored?.flatMap((element) =>\n ts.isStringLiteral(element) ? [element.text] : [],\n );\n const ignoreList = names?.length === ignored?.length ? names : undefined;\n\n if (ignoreProperty && ignoreList === undefined) {\n refuse(call, 'ignore is not an array of string literals');\n }\n\n const last = argument.properties[argument.properties.length - 1];\n edits.push({\n at: last ? last.getEnd() : argument.getStart() + 1,\n text: `${last ? ', ' : ''}content: ${contentLiteral(folderLiteral, ignoreList)}`,\n });\n };\n\n visit(sourceFile);\n\n let rewritten = source;\n\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\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\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\n return ts.isIdentifier(expression) && names.has(expression.text);\n });\n\n if (isDecorated) {\n found.push(node.name.text);\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n\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\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\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n\n let pinned = opts.source;\n\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\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\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\n const own = ArtifactSources.scan({ packageSource: opts.root });\n add(opts.entry ? ArtifactSources.runningArtifacts({ artifacts: own, from: opts.entry }) : own);\n\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\n const source = readFileSync(file, 'utf8');\n\n if (!IgnisArtifactsPlugin.DECORATED.test(source)) {\n continue;\n }\n\n add(\n IgnisArtifactsPlugin.decoratedClasses({ filePath: file, source }).map((className) => ({\n filePath: file,\n className,\n })),\n );\n }\n\n for (const groupFile of opts.groupFiles ?? []) {\n const packageSource = ArtifactSources.packageSource({ from: dirname(groupFile) });\n\n if (packageSource === opts.root || !existsSync(packageSource)) {\n continue;\n }\n\n add(\n ArtifactSources.runningArtifacts({\n artifacts: ArtifactSources.scan({ packageSource }),\n from: groupFile,\n }),\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\n for (const name of names) {\n let directory = packageDirectory;\n\n while (true) {\n const linked = join(directory, 'node_modules', name);\n\n if (existsSync(linked)) {\n const real = realpathSync(linked);\n\n if (!real.split(sep).includes('node_modules') && existsSync(join(real, 'src'))) {\n sources.add(join(real, 'src'));\n }\n\n break;\n }\n\n const parent = dirname(directory);\n\n if (parent === directory) {\n break;\n }\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\n for (const source of sources) {\n if (!existsSync(source)) {\n continue;\n }\n\n trees.push({ directory: source, pattern: ArtifactStereotypes.SOURCE_GLOB });\n\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\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\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\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\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\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\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\n await Bun.plugin(IgnisArtifactsPlugin.create({ ...opts, isRuntime: true }));\n Reflect.set(globalThis, IgnisArtifactsPlugin.RUNTIME_KEY, true);\n }\n}\n"]}
|
|
@@ -79,7 +79,7 @@ export class ArtifactScanCache {
|
|
|
79
79
|
let stored;
|
|
80
80
|
try {
|
|
81
81
|
stored = JSON.parse(readFileSync(file, 'utf8'));
|
|
82
|
-
// eslint-disable-next-line venizia/no-silent-catch -- a corrupt cache is a miss; the cause is not reported and the only cost is one fresh scan
|
|
82
|
+
// eslint-disable-next-line @venizia/no-silent-catch -- a corrupt cache is a miss; the cause is not reported and the only cost is one fresh scan
|
|
83
83
|
}
|
|
84
84
|
catch {
|
|
85
85
|
// A corrupt cache is a miss: the caller scans and rewrites it.
|
|
@@ -103,7 +103,7 @@ export class ArtifactScanCache {
|
|
|
103
103
|
}));
|
|
104
104
|
renameSync(temporary, file);
|
|
105
105
|
return true;
|
|
106
|
-
// eslint-disable-next-line venizia/no-silent-catch -- the `false` returned below is the report; the cause of the failed write is lost and the next start pays one scan
|
|
106
|
+
// eslint-disable-next-line @venizia/no-silent-catch -- the `false` returned below is the report; the cause of the failed write is lost and the next start pays one scan
|
|
107
107
|
}
|
|
108
108
|
catch {
|
|
109
109
|
// Caching is an optimisation; reporting `false` lets the caller go on with the scan it already has.
|