@venizia/ignis-boot 0.5.0-10 → 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/plugin.d.ts +1 -1
- package/dist/esm/bun/plugin.js +17 -19
- 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/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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,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"]}
|
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({
|
|
@@ -114,21 +115,18 @@ export class IgnisArtifactsPlugin {
|
|
|
114
115
|
return `{ ${fields.join(', ')} }`;
|
|
115
116
|
};
|
|
116
117
|
const visit = (node) => {
|
|
117
|
-
|
|
118
|
-
ts.isPropertyAccessExpression(node.expression)
|
|
119
|
-
(ts.isIdentifier(node.expression.expression) ||
|
|
120
|
-
ts.isPropertyAccessExpression(node.expression.expression))
|
|
121
|
-
(node.expression.name.text === 'define' || node.expression.name.text === 'application')
|
|
122
|
-
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')) {
|
|
123
123
|
ts.forEachChild(node, visit);
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
const call = node;
|
|
127
|
-
const access =
|
|
128
|
-
const target =
|
|
129
|
-
const callee = ts.isIdentifier(target)
|
|
130
|
-
? target.text
|
|
131
|
-
: 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;
|
|
132
130
|
const isApplication = access.name.text === 'application';
|
|
133
131
|
if (ts.isIdentifier(target) && aliases.has(callee)) {
|
|
134
132
|
refuse(call, `ArtifactGroup is imported as ${callee}`);
|
|
@@ -145,8 +143,7 @@ export class IgnisArtifactsPlugin {
|
|
|
145
143
|
if (!argument || !ts.isObjectLiteralExpression(argument)) {
|
|
146
144
|
refuse(call, 'the argument is not an object literal');
|
|
147
145
|
}
|
|
148
|
-
const
|
|
149
|
-
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);
|
|
150
147
|
if (named('content')) {
|
|
151
148
|
return;
|
|
152
149
|
}
|
|
@@ -163,18 +160,19 @@ export class IgnisArtifactsPlugin {
|
|
|
163
160
|
refuse(call, 'folder is not a string literal');
|
|
164
161
|
}
|
|
165
162
|
const ignoreProperty = named('ignore');
|
|
166
|
-
const
|
|
163
|
+
const ignored = ignoreProperty &&
|
|
167
164
|
ts.isPropertyAssignment(ignoreProperty) &&
|
|
168
|
-
ts.isArrayLiteralExpression(ignoreProperty.initializer)
|
|
169
|
-
ignoreProperty.initializer.elements
|
|
170
|
-
? ignoreProperty.initializer.elements.map((element) => element.text)
|
|
165
|
+
ts.isArrayLiteralExpression(ignoreProperty.initializer)
|
|
166
|
+
? ignoreProperty.initializer.elements
|
|
171
167
|
: undefined;
|
|
168
|
+
const names = ignored?.flatMap((element) => ts.isStringLiteral(element) ? [element.text] : []);
|
|
169
|
+
const ignoreList = names?.length === ignored?.length ? names : undefined;
|
|
172
170
|
if (ignoreProperty && ignoreList === undefined) {
|
|
173
171
|
refuse(call, 'ignore is not an array of string literals');
|
|
174
172
|
}
|
|
175
|
-
const last =
|
|
173
|
+
const last = argument.properties[argument.properties.length - 1];
|
|
176
174
|
edits.push({
|
|
177
|
-
at: last ? last.getEnd() :
|
|
175
|
+
at: last ? last.getEnd() : argument.getStart() + 1,
|
|
178
176
|
text: `${last ? ', ' : ''}content: ${contentLiteral(folderLiteral, ignoreList)}`,
|
|
179
177
|
});
|
|
180
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,CAAC,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AE,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 /** 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 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;IAE7G,oHAAoH;aACpG,gBAAW,GAAG,kDAAkD,CAAC;aAEzD,gBAAW,GAAG,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;IAEjG;QACE,eAAe,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,8GAA8G;IAC9G,MAAM,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,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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-cache.js","sourceRoot":"","sources":["../../../src/bun/scan-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,mBAAmB,E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AC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,MAAM,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,uIAAuI;IACvI,MAAM,CAAC,KAAK,CAAC,IAAqD;QAChE,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,SAAS,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,MAAM,CAAC;QAE/C,IAAI,CAAC;YACH,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9C,aAAa,CACX,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,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAE5B,OAAO,IAAI,CAAC;YACZ,wKAAwK;QAC1K,CAAC;QAAC,MAAM,CAAC;YACP,oGAAoG;YACpG,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC","sourcesContent":["import {\n existsSync,\n globSync,\n mkdirSync,\n readFileSync,\n renameSync,\n statSync,\n writeFileSync,\n} from 'node:fs';\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 /**\n * A 128-bit hash of `text` as 32 hex characters (cyrb128: four 32-bit lanes, public domain). It names a cache file and\n * tells a changed tree from an unchanged one; nothing here is a secret, so it needs no cryptographic strength. It is\n * plain arithmetic on purpose: this file runs under Vite, which runs under Node, where `Bun` and `node:crypto`\n * (removed from the sources) are not available, and under Bun alike. The same text gives the same string on both.\n */\n static digest(opts: { text: string }): string {\n let h1 = 1779033703;\n let h2 = 3144134277;\n let h3 = 1013904242;\n let h4 = 2773480762;\n\n for (let index = 0; index < opts.text.length; index++) {\n const code = opts.text.charCodeAt(index);\n h1 = h2 ^ Math.imul(h1 ^ code, 597399067);\n h2 = h3 ^ Math.imul(h2 ^ code, 2869860233);\n h3 = h4 ^ Math.imul(h3 ^ code, 951274213);\n h4 = h1 ^ Math.imul(h4 ^ code, 2716044179);\n }\n\n h1 = Math.imul(h3 ^ (h1 >>> 18), 597399067);\n h2 = Math.imul(h4 ^ (h2 >>> 22), 2869860233);\n h3 = Math.imul(h1 ^ (h3 >>> 17), 951274213);\n h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);\n h1 ^= h2 ^ h3 ^ h4;\n h2 ^= h1;\n h3 ^= h1;\n h4 ^= h1;\n\n return [h1, h2, h3, h4].map((lane) => (lane >>> 0).toString(16).padStart(8, '0')).join('');\n }\n\n static location(opts: { root: string }): string {\n const root = resolve(opts.root);\n const key = ArtifactScanCache.digest({ text: root }).slice(0, 16);\n\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\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\n entries.sort();\n\n const extras = [join(dirname(root), 'package.json')];\n let directory = dirname(root);\n\n while (true) {\n const lockfile = ['bun.lock', 'bun.lockb', 'package-lock.json']\n .map((name) => join(directory, name))\n .find(existsSync);\n\n if (lockfile) {\n extras.push(lockfile);\n break;\n }\n\n const parent = dirname(directory);\n\n if (parent === directory) {\n break;\n }\n\n directory = parent;\n }\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 ArtifactScanCache.digest({\n text: `${ArtifactScanCache.VERSION}\\n${entries.join('\\n')}`,\n });\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\n if (!existsSync(file)) {\n return undefined;\n }\n\n let stored: { fingerprint?: unknown; artifacts?: unknown };\n\n try {\n stored = JSON.parse(readFileSync(file, 'utf8'));\n // 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\n } catch {\n // A corrupt cache is a miss: the caller scans and rewrites it.\n return undefined;\n }\n\n if (\n stored.fingerprint !== ArtifactScanCache.fingerprint(opts) ||\n !Array.isArray(stored.artifacts)\n ) {\n return undefined;\n }\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\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\n return true;\n // 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\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"]}
|
|
@@ -3,6 +3,7 @@ import '../common/install-quiet-logger.js';
|
|
|
3
3
|
import { relative } from 'node:path';
|
|
4
4
|
import { parseArgs } from 'node:util';
|
|
5
5
|
import { ArtifactIndexEmitter, ArtifactIndexGenerator } from '../generator/index.js';
|
|
6
|
+
import { writeLine } from './write-line.js';
|
|
6
7
|
const USAGE = 'ignis-artifacts <generate|check> [--root src] [--out src/generated/artifacts.ts] [--ignore a,b] [--export GeneratedArtifacts] [--source-module <specifier>]...';
|
|
7
8
|
const { positionals, values } = parseArgs({
|
|
8
9
|
args: process.argv.slice(2),
|
|
@@ -28,7 +29,10 @@ const options = {
|
|
|
28
29
|
/** One stderr line per decorated class a user `--ignore` pattern hid; silence when nothing is hidden. */
|
|
29
30
|
const warnIgnored = (opts) => {
|
|
30
31
|
for (const artifact of opts.ignored) {
|
|
31
|
-
|
|
32
|
+
writeLine({
|
|
33
|
+
fd: 2,
|
|
34
|
+
line: `warning: ${artifact.className} (${artifact.type}) in ${relative(opts.root, artifact.filePath)} matches --ignore and is left out of the index`,
|
|
35
|
+
});
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
/** Exit code of the command, so the process exits in exactly one place. */
|
|
@@ -36,7 +40,10 @@ const run = () => {
|
|
|
36
40
|
switch (positionals[0]) {
|
|
37
41
|
case 'generate': {
|
|
38
42
|
const result = ArtifactIndexGenerator.generate(options);
|
|
39
|
-
|
|
43
|
+
writeLine({
|
|
44
|
+
fd: 1,
|
|
45
|
+
line: `${result.written ? 'wrote' : 'up to date'} ${options.out} | ${result.artifacts.length} artifact(s)`,
|
|
46
|
+
});
|
|
40
47
|
warnIgnored({ ignored: result.ignored, root: options.root });
|
|
41
48
|
return 0;
|
|
42
49
|
}
|
|
@@ -44,14 +51,17 @@ const run = () => {
|
|
|
44
51
|
const result = ArtifactIndexGenerator.check(options);
|
|
45
52
|
warnIgnored({ ignored: result.ignored, root: options.root });
|
|
46
53
|
if (result.isFresh) {
|
|
47
|
-
|
|
54
|
+
writeLine({ fd: 1, line: `fresh ${options.out}` });
|
|
48
55
|
return 0;
|
|
49
56
|
}
|
|
50
|
-
|
|
57
|
+
writeLine({
|
|
58
|
+
fd: 2,
|
|
59
|
+
line: `stale ${options.out} - run: ${ArtifactIndexEmitter.renderCommand(options)}`,
|
|
60
|
+
});
|
|
51
61
|
return 1;
|
|
52
62
|
}
|
|
53
63
|
default: {
|
|
54
|
-
|
|
64
|
+
writeLine({ fd: 2, line: USAGE });
|
|
55
65
|
return 2;
|
|
56
66
|
}
|
|
57
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../../src/clis/artifacts.ts"],"names":[],"mappings":";AACA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../../src/clis/artifacts.ts"],"names":[],"mappings":";AACA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,KAAK,GACT,gKAAgK,CAAC;AAEnK,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;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,EAAE;QAC9D,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,oBAAoB,EAAE;QACz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AAC,CAAC;YACH,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAE7D,OAAO,CAAC,CAAC;QACX,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,MAAM,GAAG,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACrD,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAE7D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBAEnD,OAAO,CAAC,CAAC;YACX,CAAC;YAED,SAAS,CAAC;gBACR,EAAE,EAAE,CAAC;gBACL,IAAI,EAAE,SAAS,OAAO,CAAC,GAAG,WAAW,oBAAoB,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;aACnF,CAAC,CAAC;YAEH,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAElC,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, ArtifactIndexGenerator } from '../generator';\nimport type { IScannedArtifact } from '../generator';\nimport { writeLine } from './write-line';\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 writeLine({\n fd: 2,\n line: `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 = ArtifactIndexGenerator.generate(options);\n writeLine({\n fd: 1,\n line: `${result.written ? 'wrote' : 'up to date'} ${options.out} | ${result.artifacts.length} artifact(s)`,\n });\n warnIgnored({ ignored: result.ignored, root: options.root });\n\n return 0;\n }\n case 'check': {\n const result = ArtifactIndexGenerator.check(options);\n warnIgnored({ ignored: result.ignored, root: options.root });\n\n if (result.isFresh) {\n writeLine({ fd: 1, line: `fresh ${options.out}` });\n\n return 0;\n }\n\n writeLine({\n fd: 2,\n line: `stale ${options.out} - run: ${ArtifactIndexEmitter.renderCommand(options)}`,\n });\n\n return 1;\n }\n default: {\n writeLine({ fd: 2, line: USAGE });\n\n return 2;\n }\n }\n};\n\nprocess.exit(run());\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One line of the CLI's own output on file descriptor `1` (stdout) or `2` (stderr), written in full before the call
|
|
3
|
+
* returns: `process.stdout.write` queues on a pipe in Bun, and what is still queued at `process.exit` is lost.
|
|
4
|
+
*/
|
|
5
|
+
export declare const writeLine: (opts: {
|
|
6
|
+
fd: 1 | 2;
|
|
7
|
+
line: string;
|
|
8
|
+
}) => void;
|
|
9
|
+
//# sourceMappingURL=write-line.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { writeSync } from 'node:fs';
|
|
2
|
+
const pause = new Int32Array(new SharedArrayBuffer(4));
|
|
3
|
+
/**
|
|
4
|
+
* One line of the CLI's own output on file descriptor `1` (stdout) or `2` (stderr), written in full before the call
|
|
5
|
+
* returns: `process.stdout.write` queues on a pipe in Bun, and what is still queued at `process.exit` is lost.
|
|
6
|
+
*/
|
|
7
|
+
export const writeLine = (opts) => {
|
|
8
|
+
const bytes = Buffer.from(`${opts.line}\n`);
|
|
9
|
+
let written = 0;
|
|
10
|
+
while (written < bytes.length) {
|
|
11
|
+
try {
|
|
12
|
+
// A pipe another writer made non-blocking takes only what fits its buffer.
|
|
13
|
+
written += writeSync(opts.fd, bytes, written);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
const code = error instanceof Error && 'code' in error ? error.code : undefined;
|
|
17
|
+
// The reader closed the pipe: there is nobody left to tell.
|
|
18
|
+
if (code === 'EPIPE') {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (code !== 'EAGAIN') {
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
// The buffer is full: wait a millisecond for the reader.
|
|
25
|
+
Atomics.wait(pause, 0, 0, 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=write-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-line.js","sourceRoot":"","sources":["../../../src/clis/write-line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAiC,EAAQ,EAAE;IACnE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;IAC5C,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,OAAO,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,2EAA2E;YAC3E,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,GAAG,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;YAEhF,4DAA4D;YAC5D,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;gBACrB,OAAO;YACT,CAAC;YAED,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtB,MAAM,KAAK,CAAC;YACd,CAAC;YAED,yDAAyD;YACzD,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { writeSync } from 'node:fs';\n\nconst pause = new Int32Array(new SharedArrayBuffer(4));\n\n/**\n * One line of the CLI's own output on file descriptor `1` (stdout) or `2` (stderr), written in full before the call\n * returns: `process.stdout.write` queues on a pipe in Bun, and what is still queued at `process.exit` is lost.\n */\nexport const writeLine = (opts: { fd: 1 | 2; line: string }): void => {\n const bytes = Buffer.from(`${opts.line}\\n`);\n let written = 0;\n\n while (written < bytes.length) {\n try {\n // A pipe another writer made non-blocking takes only what fits its buffer.\n written += writeSync(opts.fd, bytes, written);\n } catch (error) {\n const code = error instanceof Error && 'code' in error ? error.code : undefined;\n\n // The reader closed the pipe: there is nobody left to tell.\n if (code === 'EPIPE') {\n return;\n }\n\n if (code !== 'EAGAIN') {\n throw error;\n }\n\n // The buffer is full: wait a millisecond for the reader.\n Atomics.wait(pause, 0, 0, 1);\n }\n }\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ILogger, TLogLevel } from '@venizia/ignis-helpers/core';
|
|
2
|
-
/** The generator's own output goes
|
|
2
|
+
/** The generator's own output goes to stdout; framework diagnostics below `warn` are dropped and the rest land on stderr, so a codegen run prints nothing but its result on stdout. */
|
|
3
3
|
export declare class QuietLogger implements ILogger {
|
|
4
4
|
private readonly scope;
|
|
5
5
|
private static readonly cache;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LogLevels } from '@venizia/ignis-helpers/core';
|
|
2
|
-
/** The generator's own output goes
|
|
2
|
+
/** The generator's own output goes to stdout; framework diagnostics below `warn` are dropped and the rest land on stderr, so a codegen run prints nothing but its result on stdout. */
|
|
3
3
|
export class QuietLogger {
|
|
4
4
|
static { this.cache = new Map(); }
|
|
5
5
|
constructor(scope) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quiet-logger.js","sourceRoot":"","sources":["../../../src/common/quiet-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,
|
|
1
|
+
{"version":3,"file":"quiet-logger.js","sourceRoot":"","sources":["../../../src/common/quiet-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,uLAAuL;AACvL,MAAM,OAAO,WAAW;aACE,UAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;IAG/D,YAAqC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QAChD,IAAI,CAAC,MAAM,GAAG,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CA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;IAED,GAAG,CAAC,UAAkB;QACpB,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,EAAE,CAAC,CAAC;IACzF,CAAC","sourcesContent":["import type { ILogger, TLogLevel } from '@venizia/ignis-helpers/core';\nimport { LogLevels } from '@venizia/ignis-helpers/core';\n\n/** The generator's own output goes to stdout; framework diagnostics below `warn` are dropped and the rest land on stderr, so a codegen run prints nothing but its result on stdout. */\nexport class QuietLogger implements ILogger {\n private static readonly cache = new Map<string, QuietLogger>();\n private readonly prefix: string;\n\n private constructor(private readonly scope: string) {\n this.prefix = scope === '' ? '' : `[${scope}] `;\n }\n\n static get(scope: string): ILogger {\n const cached = this.cache.get(scope);\n\n if (cached) {\n return cached;\n }\n\n const created = new QuietLogger(scope);\n this.cache.set(scope, created);\n\n return created;\n }\n\n private write(opts: { message: string; args: unknown[] }): void {\n console.error(`${this.prefix}${opts.message}`, ...opts.args);\n }\n\n debug(): void {}\n\n info(): void {}\n\n warn(message: string, ...args: unknown[]): void {\n this.write({ message, args });\n }\n\n error(message: string, ...args: unknown[]): void {\n this.write({ message, args });\n }\n\n emerg(message: string, ...args: unknown[]): void {\n this.write({ message, args });\n }\n\n log(level: TLogLevel, message: string, ...args: unknown[]): void {\n if (level === LogLevels.DEBUG || level === LogLevels.INFO) {\n return;\n }\n\n this.write({ message, args });\n }\n\n for(methodName: string): ILogger {\n return QuietLogger.get(this.scope === '' ? methodName : `${this.scope}-${methodName}`);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ignis-boot",
|
|
3
|
-
"version": "0.5.0-
|
|
3
|
+
"version": "0.5.0-11",
|
|
4
4
|
"description": "Build-time artifact index generator for IGNIS applications: scans decorated classes with the TypeScript AST and emits one static registration file per package, so bun build --compile sees plain imports.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"artifact-index",
|
|
@@ -77,19 +77,19 @@
|
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"force-update": "sh ../../scripts/build/force-update.sh",
|
|
80
|
-
"test": "bun test ./src"
|
|
80
|
+
"test": "bun test --max-concurrency=6 ./src"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@venizia/ignis-helpers": "0.5.0-
|
|
84
|
-
"@venizia/ignis-inversion": "0.5.0-
|
|
83
|
+
"@venizia/ignis-helpers": "0.5.0-11",
|
|
84
|
+
"@venizia/ignis-inversion": "0.5.0-5"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@types/bun": "^1.4.5",
|
|
88
|
-
"@venizia/dev-configs": "0.5.0-
|
|
89
|
-
"eslint": "^10.
|
|
90
|
-
"oxlint": "1.
|
|
91
|
-
"oxlint-tsgolint": "7.0.
|
|
92
|
-
"tsc-alias": "1.9.
|
|
88
|
+
"@venizia/dev-configs": "0.5.0-9",
|
|
89
|
+
"eslint": "^10.15.0",
|
|
90
|
+
"oxlint": "1.95.0",
|
|
91
|
+
"oxlint-tsgolint": "7.0.2009",
|
|
92
|
+
"tsc-alias": "1.9.12",
|
|
93
93
|
"typescript": "^6.0.3"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|