@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
|
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AG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;YAChD,gJAAgJ;QAClJ,CAAC;QAAC,MAAM,CAAC;YACP,+DAA+D;YAC/D,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IACE,MAAM,CAAC,WAAW,KAAK,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC;YAC1D,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAChC,CAAC;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,gB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AEF,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.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AAK,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,GAAG,CAAC,KAAgB,EAAE,OAAe,EAAE,GAAG,IAAe;QACvD,IAAI,KAAK,KAAK,SAAS,CAAC,KAAK,IAAI,KAAK,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC;YAC1D,OAAO;QACT,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAChC,CAAC;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"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TConstValue } from '@venizia/ignis-helpers';
|
|
2
|
+
import { ConstClass } from '@venizia/ignis-helpers/common';
|
|
2
3
|
/** Mirrors the kernel's `ArtifactTypes` values; boot must not depend on kernel (`{boot, kernel} -> core` in the build chain). */
|
|
3
|
-
export declare class ArtifactTypes {
|
|
4
|
+
export declare class ArtifactTypes extends ConstClass {
|
|
4
5
|
static readonly CONFIGURATION = "configuration";
|
|
5
6
|
static readonly COMPONENT = "component";
|
|
6
7
|
static readonly CONTROLLER = "controller";
|
|
@@ -8,21 +9,17 @@ export declare class ArtifactTypes {
|
|
|
8
9
|
static readonly REPOSITORY = "repository";
|
|
9
10
|
static readonly DATASOURCE = "datasource";
|
|
10
11
|
static readonly MODEL = "model";
|
|
11
|
-
static readonly SCHEME_SET: Set<string>;
|
|
12
|
-
static isValid(value: string): boolean;
|
|
13
12
|
}
|
|
14
13
|
/** One of the `ArtifactTypes` values. */
|
|
15
14
|
export type TArtifactType = TConstValue<typeof ArtifactTypes>;
|
|
16
15
|
/** Mirrors the kernel's `ArtifactIndexFields` - the keys of the object the emitter writes and `registerArtifacts` reads. */
|
|
17
|
-
export declare class ArtifactIndexFields {
|
|
16
|
+
export declare class ArtifactIndexFields extends ConstClass {
|
|
18
17
|
static readonly CONFIGURATIONS = "configurations";
|
|
19
18
|
static readonly DATA_SOURCES = "dataSources";
|
|
20
19
|
static readonly COMPONENTS = "components";
|
|
21
20
|
static readonly REPOSITORIES = "repositories";
|
|
22
21
|
static readonly SERVICES = "services";
|
|
23
22
|
static readonly CONTROLLERS = "controllers";
|
|
24
|
-
static readonly SCHEME_SET: Set<string>;
|
|
25
|
-
static isValid(value: string): boolean;
|
|
26
23
|
}
|
|
27
24
|
/** One of the `ArtifactIndexFields` values. */
|
|
28
25
|
export type TArtifactIndexField = TConstValue<typeof ArtifactIndexFields>;
|
|
@@ -38,6 +35,22 @@ export declare class ArtifactStereotypes {
|
|
|
38
35
|
static readonly SCHEME_SET: Set<string>;
|
|
39
36
|
static isValid(value: string): boolean;
|
|
40
37
|
static readonly SOURCE_MODULES: RegExp;
|
|
38
|
+
/** The index field that carries the classes of the application's own types (`ArtifactTypes.define`), by type name; mirrors the kernel's `IArtifactIndex.custom`. */
|
|
39
|
+
static readonly CUSTOM_FIELD = "custom";
|
|
40
|
+
/** Whether `type` is one of the built-in artifact types, `model` included. */
|
|
41
|
+
static isBuiltIn(opts: {
|
|
42
|
+
type: string;
|
|
43
|
+
}): boolean;
|
|
44
|
+
/** The classes of the custom types among `artifacts`, grouped by type name; types and classes in name order, so the output is stable. */
|
|
45
|
+
static groupCustom<Artifact extends {
|
|
46
|
+
type: string;
|
|
47
|
+
className: string;
|
|
48
|
+
}>(opts: {
|
|
49
|
+
artifacts: ReadonlyArray<Artifact>;
|
|
50
|
+
}): Array<{
|
|
51
|
+
type: string;
|
|
52
|
+
artifacts: Artifact[];
|
|
53
|
+
}>;
|
|
41
54
|
static readonly DEFAULT_IGNORE: string[];
|
|
42
55
|
/**
|
|
43
56
|
* The kernel's `registerArtifacts` order; `model` is never emitted. Configurations come first:
|
|
@@ -51,12 +64,12 @@ export declare class ArtifactStereotypes {
|
|
|
51
64
|
}>;
|
|
52
65
|
}
|
|
53
66
|
/** Why a decorated class was left out of the index - reported, never silent. */
|
|
54
|
-
export declare class ScanSkipReasons {
|
|
67
|
+
export declare class ScanSkipReasons extends ConstClass {
|
|
55
68
|
static readonly ABSTRACT = "abstract";
|
|
56
69
|
static readonly NOT_EXPORTED = "not-exported";
|
|
57
70
|
static readonly IGNORED = "ignored";
|
|
58
|
-
|
|
59
|
-
static
|
|
71
|
+
/** The decorator comes from an `ArtifactTypes.define` the scanner cannot read (a type that is not a literal, a built package, a barrel). */
|
|
72
|
+
static readonly UNREADABLE_TYPE = "unreadable-type";
|
|
60
73
|
}
|
|
61
74
|
/** One of the `ScanSkipReasons` values. */
|
|
62
75
|
export type TScanSkipReason = TConstValue<typeof ScanSkipReasons>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ConstClass } from '@venizia/ignis-helpers/common';
|
|
1
2
|
/** Mirrors the kernel's `ArtifactTypes` values; boot must not depend on kernel (`{boot, kernel} -> core` in the build chain). */
|
|
2
|
-
export class ArtifactTypes {
|
|
3
|
+
export class ArtifactTypes extends ConstClass {
|
|
3
4
|
static { this.CONFIGURATION = 'configuration'; }
|
|
4
5
|
static { this.COMPONENT = 'component'; }
|
|
5
6
|
static { this.CONTROLLER = 'controller'; }
|
|
@@ -7,38 +8,15 @@ export class ArtifactTypes {
|
|
|
7
8
|
static { this.REPOSITORY = 'repository'; }
|
|
8
9
|
static { this.DATASOURCE = 'datasource'; }
|
|
9
10
|
static { this.MODEL = 'model'; }
|
|
10
|
-
static { this.SCHEME_SET = new Set([
|
|
11
|
-
this.CONFIGURATION,
|
|
12
|
-
this.COMPONENT,
|
|
13
|
-
this.CONTROLLER,
|
|
14
|
-
this.SERVICE,
|
|
15
|
-
this.REPOSITORY,
|
|
16
|
-
this.DATASOURCE,
|
|
17
|
-
this.MODEL,
|
|
18
|
-
]); }
|
|
19
|
-
static isValid(value) {
|
|
20
|
-
return this.SCHEME_SET.has(value);
|
|
21
|
-
}
|
|
22
11
|
}
|
|
23
12
|
/** Mirrors the kernel's `ArtifactIndexFields` - the keys of the object the emitter writes and `registerArtifacts` reads. */
|
|
24
|
-
export class ArtifactIndexFields {
|
|
13
|
+
export class ArtifactIndexFields extends ConstClass {
|
|
25
14
|
static { this.CONFIGURATIONS = 'configurations'; }
|
|
26
15
|
static { this.DATA_SOURCES = 'dataSources'; }
|
|
27
16
|
static { this.COMPONENTS = 'components'; }
|
|
28
17
|
static { this.REPOSITORIES = 'repositories'; }
|
|
29
18
|
static { this.SERVICES = 'services'; }
|
|
30
19
|
static { this.CONTROLLERS = 'controllers'; }
|
|
31
|
-
static { this.SCHEME_SET = new Set([
|
|
32
|
-
this.CONFIGURATIONS,
|
|
33
|
-
this.DATA_SOURCES,
|
|
34
|
-
this.COMPONENTS,
|
|
35
|
-
this.REPOSITORIES,
|
|
36
|
-
this.SERVICES,
|
|
37
|
-
this.CONTROLLERS,
|
|
38
|
-
]); }
|
|
39
|
-
static isValid(value) {
|
|
40
|
-
return this.SCHEME_SET.has(value);
|
|
41
|
-
}
|
|
42
20
|
}
|
|
43
21
|
/** How the scanner recognises a decorated class: the source glob, decorator-to-type map, default ignore patterns and the emit order. */
|
|
44
22
|
export class ArtifactStereotypes {
|
|
@@ -62,6 +40,28 @@ export class ArtifactStereotypes {
|
|
|
62
40
|
return this.SCHEME_SET.has(value);
|
|
63
41
|
}
|
|
64
42
|
static { this.SOURCE_MODULES = /^@venizia\/ignis(?:-kernel)?(?:\/.+)?$/; }
|
|
43
|
+
/** The index field that carries the classes of the application's own types (`ArtifactTypes.define`), by type name; mirrors the kernel's `IArtifactIndex.custom`. */
|
|
44
|
+
static { this.CUSTOM_FIELD = 'custom'; }
|
|
45
|
+
/** Whether `type` is one of the built-in artifact types, `model` included. */
|
|
46
|
+
static isBuiltIn(opts) {
|
|
47
|
+
return ArtifactTypes.isValid(opts.type);
|
|
48
|
+
}
|
|
49
|
+
/** The classes of the custom types among `artifacts`, grouped by type name; types and classes in name order, so the output is stable. */
|
|
50
|
+
static groupCustom(opts) {
|
|
51
|
+
const byType = new Map();
|
|
52
|
+
for (const artifact of opts.artifacts) {
|
|
53
|
+
if (ArtifactStereotypes.isBuiltIn({ type: artifact.type })) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
byType.set(artifact.type, [...(byType.get(artifact.type) ?? []), artifact]);
|
|
57
|
+
}
|
|
58
|
+
return [...byType.entries()]
|
|
59
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
60
|
+
.map(([type, artifacts]) => ({
|
|
61
|
+
type,
|
|
62
|
+
artifacts: artifacts.sort((left, right) => left.className.localeCompare(right.className)),
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
65
|
static { this.DEFAULT_IGNORE = [
|
|
66
66
|
'**/__tests__/**',
|
|
67
67
|
'**/*.test.{ts,tsx}',
|
|
@@ -84,13 +84,11 @@ export class ArtifactStereotypes {
|
|
|
84
84
|
]; }
|
|
85
85
|
}
|
|
86
86
|
/** Why a decorated class was left out of the index - reported, never silent. */
|
|
87
|
-
export class ScanSkipReasons {
|
|
87
|
+
export class ScanSkipReasons extends ConstClass {
|
|
88
88
|
static { this.ABSTRACT = 'abstract'; }
|
|
89
89
|
static { this.NOT_EXPORTED = 'not-exported'; }
|
|
90
90
|
static { this.IGNORED = 'ignored'; }
|
|
91
|
-
|
|
92
|
-
static
|
|
93
|
-
return this.SCHEME_SET.has(value);
|
|
94
|
-
}
|
|
91
|
+
/** The decorator comes from an `ArtifactTypes.define` the scanner cannot read (a type that is not a literal, a built package, a barrel). */
|
|
92
|
+
static { this.UNREADABLE_TYPE = 'unreadable-type'; }
|
|
95
93
|
}
|
|
96
94
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/generator/common/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/generator/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,iIAAiI;AACjI,MAAM,OAAO,aAAc,SAAQ,UAAU;aAC3B,kBAAa,GAAG,eAAe,CAAC;aAChC,cAAS,GAAG,WAAW,CAAC;aACxB,eAAU,GAAG,YAAY,CAAC;aAC1B,YAAO,GAAG,SAAS,CAAC;aACpB,eAAU,GAAG,YAAY,CAAC;aAC1B,eAAU,GAAG,YAAY,CAAC;aAC1B,UAAK,GAAG,OAAO,CAAC;;AAMlC,4HAA4H;AAC5H,MAAM,OAAO,mBAAo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C,UAAU,EAAE,KAAK,EAAE,mBAAmB,CAAC,YAAY,EAAE;QAC3E,EAAE,IAAI,EAAE,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE;QACpE,EAAE,IAAI,EAAE,aAAa,CAAC,UAAU,EAAE,KAAK,EAAE,mBAAmB,CAAC,WAAW,EAAE;KAC3E,CAAC;;AAGJ,gFAAgF;AAChF,MAAM,OAAO,eAAgB,SAAQ,UAAU;aAC7B,aAAQ,GAAG,UAAU,CAAC;aACtB,iBAAY,GAAG,cAAc,CAAC;aAC9B,YAAO,GAAG,SAAS,CAAC;IACpC,4IAA4I;aAC5H,oBAAe,GAAG,iBAAiB,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers';\nimport { ConstClass } from '@venizia/ignis-helpers/common';\n\n/** Mirrors the kernel's `ArtifactTypes` values; boot must not depend on kernel (`{boot, kernel} -> core` in the build chain). */\nexport class ArtifactTypes extends ConstClass {\n static readonly CONFIGURATION = 'configuration';\n static readonly COMPONENT = 'component';\n static readonly CONTROLLER = 'controller';\n static readonly SERVICE = 'service';\n static readonly REPOSITORY = 'repository';\n static readonly DATASOURCE = 'datasource';\n static readonly MODEL = 'model';\n}\n\n/** One of the `ArtifactTypes` values. */\nexport type TArtifactType = TConstValue<typeof ArtifactTypes>;\n\n/** Mirrors the kernel's `ArtifactIndexFields` - the keys of the object the emitter writes and `registerArtifacts` reads. */\nexport class ArtifactIndexFields extends ConstClass {\n static readonly CONFIGURATIONS = 'configurations';\n static readonly DATA_SOURCES = 'dataSources';\n static readonly COMPONENTS = 'components';\n static readonly REPOSITORIES = 'repositories';\n static readonly SERVICES = 'services';\n static readonly CONTROLLERS = 'controllers';\n}\n\n/** One of the `ArtifactIndexFields` values. */\nexport type TArtifactIndexField = TConstValue<typeof ArtifactIndexFields>;\n\n/** How the scanner recognises a decorated class: the source glob, decorator-to-type map, default ignore patterns and the emit order. */\nexport class ArtifactStereotypes {\n /** The source files the scanner reads: TypeScript, with or without JSX. */\n static readonly SOURCE_GLOB = '**/*.{ts,tsx}';\n /** The extension of a source file - stripped for an import specifier, replaced by `.js` for its compiled copy. */\n static readonly SOURCE_EXTENSION = /\\.tsx?$/;\n /** Decorator name as imported from `@venizia/ignis` or `@venizia/ignis-kernel` -> artifact type. */\n static readonly BY_DECORATOR: Readonly<Record<string, TArtifactType>> = {\n configuration: ArtifactTypes.CONFIGURATION,\n component: ArtifactTypes.COMPONENT,\n controller: ArtifactTypes.CONTROLLER,\n service: ArtifactTypes.SERVICE,\n repository: ArtifactTypes.REPOSITORY,\n datasource: ArtifactTypes.DATASOURCE,\n model: ArtifactTypes.MODEL,\n };\n\n static readonly ROOT_DECORATOR = 'injectable';\n\n static readonly SCHEME_SET = new Set<string>(Object.values(ArtifactStereotypes.BY_DECORATOR));\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n\n static readonly SOURCE_MODULES = /^@venizia\\/ignis(?:-kernel)?(?:\\/.+)?$/;\n\n /** The index field that carries the classes of the application's own types (`ArtifactTypes.define`), by type name; mirrors the kernel's `IArtifactIndex.custom`. */\n static readonly CUSTOM_FIELD = 'custom';\n\n /** Whether `type` is one of the built-in artifact types, `model` included. */\n static isBuiltIn(opts: { type: string }): boolean {\n return ArtifactTypes.isValid(opts.type);\n }\n\n /** The classes of the custom types among `artifacts`, grouped by type name; types and classes in name order, so the output is stable. */\n static groupCustom<Artifact extends { type: string; className: string }>(opts: {\n artifacts: ReadonlyArray<Artifact>;\n }): Array<{ type: string; artifacts: Artifact[] }> {\n const byType = new Map<string, Artifact[]>();\n\n for (const artifact of opts.artifacts) {\n if (ArtifactStereotypes.isBuiltIn({ type: artifact.type })) {\n continue;\n }\n\n byType.set(artifact.type, [...(byType.get(artifact.type) ?? []), artifact]);\n }\n\n return [...byType.entries()]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([type, artifacts]) => ({\n type,\n artifacts: artifacts.sort((left, right) => left.className.localeCompare(right.className)),\n }));\n }\n\n static readonly DEFAULT_IGNORE = [\n '**/__tests__/**',\n '**/*.test.{ts,tsx}',\n '**/*.spec.{ts,tsx}',\n '**/generated/**',\n ];\n\n /**\n * The kernel's `registerArtifacts` order; `model` is never emitted. Configurations come first:\n * `registerConfigurations` runs before the datasource and component sweeps, so a `@configuration`\n * can shape what they read. The kernel sorts them among themselves by their `after` declarations\n * at boot, so the order within the field does not matter here.\n */\n static readonly EMIT_ORDER: ReadonlyArray<{ type: TArtifactType; field: TArtifactIndexField }> = [\n { type: ArtifactTypes.CONFIGURATION, field: ArtifactIndexFields.CONFIGURATIONS },\n { type: ArtifactTypes.DATASOURCE, field: ArtifactIndexFields.DATA_SOURCES },\n { type: ArtifactTypes.COMPONENT, field: ArtifactIndexFields.COMPONENTS },\n { type: ArtifactTypes.REPOSITORY, field: ArtifactIndexFields.REPOSITORIES },\n { type: ArtifactTypes.SERVICE, field: ArtifactIndexFields.SERVICES },\n { type: ArtifactTypes.CONTROLLER, field: ArtifactIndexFields.CONTROLLERS },\n ];\n}\n\n/** Why a decorated class was left out of the index - reported, never silent. */\nexport class ScanSkipReasons extends ConstClass {\n static readonly ABSTRACT = 'abstract';\n static readonly NOT_EXPORTED = 'not-exported';\n static readonly IGNORED = 'ignored';\n /** The decorator comes from an `ArtifactTypes.define` the scanner cannot read (a type that is not a literal, a built package, a barrel). */\n static readonly UNREADABLE_TYPE = 'unreadable-type';\n}\n\n/** One of the `ScanSkipReasons` values. */\nexport type TScanSkipReason = TConstValue<typeof ScanSkipReasons>;\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { TClass } from '@venizia/ignis-helpers';
|
|
2
|
-
import type { TArtifactIndexField,
|
|
2
|
+
import type { TArtifactIndexField, TScanSkipReason } from './constants.js';
|
|
3
3
|
/** A decorated class the scanner put in the index. */
|
|
4
4
|
export interface IScannedArtifact {
|
|
5
5
|
className: string;
|
|
6
6
|
/** Absolute path of the declaring file. */
|
|
7
7
|
filePath: string;
|
|
8
|
-
|
|
8
|
+
/** A built-in `TArtifactType`, or the name an `ArtifactTypes.define` gave. */
|
|
9
|
+
type: string;
|
|
9
10
|
}
|
|
10
11
|
/** Options for one scan of a source tree. */
|
|
11
12
|
export interface IScanOptions {
|
|
@@ -38,11 +39,15 @@ export interface IScanReport {
|
|
|
38
39
|
/**
|
|
39
40
|
* What an application may hand to an `AutoArtifactGroup` as its index: a list of classes per kind, with the same kinds as the kernel's `IArtifactIndex` (boot does not depend on the kernel, so it cannot name that type). The classes are `TClass<unknown>` so any real class is accepted; the group keeps the exact type the application passed.
|
|
40
41
|
*/
|
|
41
|
-
export type TGeneratedArtifactIndexInput = Partial<Record<TArtifactIndexField, ReadonlyArray<TClass<unknown
|
|
42
|
+
export type TGeneratedArtifactIndexInput = Partial<Record<TArtifactIndexField, ReadonlyArray<TClass<unknown>>>> & {
|
|
43
|
+
custom?: Readonly<Record<string, ReadonlyArray<TClass<unknown>>>>;
|
|
44
|
+
};
|
|
42
45
|
/**
|
|
43
46
|
* The index boot builds and moves around without knowing the application's classes: the object a generated index exports, and the default of `AutoArtifactGroup`.
|
|
44
47
|
*
|
|
45
48
|
* Each kind of the kernel's index names its own class type (`TClass<BaseConfiguration>`, `TClass<IService>`, ...), which boot cannot name. `TClass<never>` is the bottom of that family: it is assignable to every one of them, so a group that carries it is still the kernel's `IArtifactGroup`. Its instance type is `never`, so boot only passes the classes along and never constructs one.
|
|
46
49
|
*/
|
|
47
|
-
export type TGeneratedArtifactIndex = Partial<Record<TArtifactIndexField, ReadonlyArray<TClass<never
|
|
50
|
+
export type TGeneratedArtifactIndex = Partial<Record<TArtifactIndexField, ReadonlyArray<TClass<never>>>> & {
|
|
51
|
+
custom?: Readonly<Record<string, ReadonlyArray<TClass<never>>>>;
|
|
52
|
+
};
|
|
48
53
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/generator/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TClass } from '@venizia/ignis-helpers';\nimport type { TArtifactIndexField,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/generator/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TClass } from '@venizia/ignis-helpers';\nimport type { TArtifactIndexField, TScanSkipReason } from './constants';\n\n/** A decorated class the scanner put in the index. */\nexport interface IScannedArtifact {\n className: string;\n /** Absolute path of the declaring file. */\n filePath: string;\n /** A built-in `TArtifactType`, or the name an `ArtifactTypes.define` gave. */\n type: string;\n}\n\n/** Options for one scan of a source tree. */\nexport interface IScanOptions {\n root: string;\n /**\n * Glob patterns relative to `root`, ignored in addition to `ArtifactStereotypes.DEFAULT_IGNORE`,\n * which always apply.\n *\n * @default []\n */\n ignore?: string[];\n /** Module specifiers, matched exactly, whose stereotype imports also count - a package that re-exports the decorators. Adds to `ArtifactStereotypes.SOURCE_MODULES`. */\n sourceModules?: string[];\n /** Recognise a stereotype imported from any module whose exports lead, through `export *` and renaming re-exports, to a source module - a framework that re-exports the kernel's decorators. */\n followReexports?: boolean;\n}\n\n/** A decorated class the index leaves out, and why. */\nexport interface IScanSkipped {\n className: string;\n filePath: string;\n reason: TScanSkipReason;\n}\n\n/** The index content plus what a caller's `ignore` silently left out: decorated classes under a user pattern, never under a default one. */\nexport interface IScanReport {\n artifacts: IScannedArtifact[];\n ignored: IScannedArtifact[];\n /** Every decorated class left out - abstract, not a named export, or under a user ignore pattern. */\n skipped: IScanSkipped[];\n}\n\n/**\n * What an application may hand to an `AutoArtifactGroup` as its index: a list of classes per kind, with the same kinds as the kernel's `IArtifactIndex` (boot does not depend on the kernel, so it cannot name that type). The classes are `TClass<unknown>` so any real class is accepted; the group keeps the exact type the application passed.\n */\nexport type TGeneratedArtifactIndexInput = Partial<\n Record<TArtifactIndexField, ReadonlyArray<TClass<unknown>>>\n> & { custom?: Readonly<Record<string, ReadonlyArray<TClass<unknown>>>> };\n\n/**\n * The index boot builds and moves around without knowing the application's classes: the object a generated index exports, and the default of `AutoArtifactGroup`.\n *\n * Each kind of the kernel's index names its own class type (`TClass<BaseConfiguration>`, `TClass<IService>`, ...), which boot cannot name. `TClass<never>` is the bottom of that family: it is assignable to every one of them, so a group that carries it is still the kernel's `IArtifactGroup`. Its instance type is `never`, so boot only passes the classes along and never constructs one.\n */\nexport type TGeneratedArtifactIndex = Partial<\n Record<TArtifactIndexField, ReadonlyArray<TClass<never>>>\n> & { custom?: Readonly<Record<string, ReadonlyArray<TClass<never>>>> };\n"]}
|
|
@@ -34,6 +34,10 @@ export declare class ArtifactIndexEmitter {
|
|
|
34
34
|
sourceModules?: string[];
|
|
35
35
|
};
|
|
36
36
|
}): string;
|
|
37
|
+
/** `text` as a single-quoted string literal, with the backslash and the quote escaped, as the formatter writes it. */
|
|
38
|
+
private static quote;
|
|
39
|
+
/** The `custom` field: one list per type the application defined, nothing at all when it defined none. */
|
|
40
|
+
private static renderCustom;
|
|
37
41
|
/** One line while it fits the print width, else one name per line - so `bun fmt --check` on the generated file stays quiet. */
|
|
38
42
|
private static renderField;
|
|
39
43
|
private static importPath;
|
|
@@ -45,16 +45,39 @@ export class ArtifactIndexEmitter {
|
|
|
45
45
|
.sort((a, b) => a.localeCompare(b));
|
|
46
46
|
return ArtifactIndexEmitter.renderField({ field, names });
|
|
47
47
|
});
|
|
48
|
+
const custom = ArtifactStereotypes.groupCustom({ artifacts: emitted });
|
|
48
49
|
return [
|
|
49
50
|
ArtifactIndexEmitter.renderHeader({ ...command, exportName }),
|
|
50
51
|
...imports,
|
|
51
52
|
'',
|
|
52
53
|
`export const ${exportName} = {`,
|
|
53
54
|
...fields,
|
|
55
|
+
...ArtifactIndexEmitter.renderCustom({ custom }),
|
|
54
56
|
'};',
|
|
55
57
|
'',
|
|
56
58
|
].join('\n');
|
|
57
59
|
}
|
|
60
|
+
/** `text` as a single-quoted string literal, with the backslash and the quote escaped, as the formatter writes it. */
|
|
61
|
+
static quote(opts) {
|
|
62
|
+
return `'${opts.text.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`;
|
|
63
|
+
}
|
|
64
|
+
/** The `custom` field: one list per type the application defined, nothing at all when it defined none. */
|
|
65
|
+
static renderCustom(opts) {
|
|
66
|
+
if (opts.custom.length === 0) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
const lines = opts.custom.flatMap(({ type, artifacts }) => {
|
|
70
|
+
const key = /^[A-Za-z_$][\w$]*$/.test(type)
|
|
71
|
+
? type
|
|
72
|
+
: ArtifactIndexEmitter.quote({ text: type });
|
|
73
|
+
const names = artifacts.map((artifact) => artifact.className);
|
|
74
|
+
const singleLine = ` ${key}: [${names.join(', ')}],`;
|
|
75
|
+
return singleLine.length <= ArtifactIndexEmitter.PRINT_WIDTH
|
|
76
|
+
? [singleLine]
|
|
77
|
+
: [` ${key}: [`, ...names.map((name) => ` ${name},`), ' ],'];
|
|
78
|
+
});
|
|
79
|
+
return [` ${ArtifactStereotypes.CUSTOM_FIELD}: {`, ...lines, ' },'];
|
|
80
|
+
}
|
|
58
81
|
/** One line while it fits the print width, else one name per line - so `bun fmt --check` on the generated file stays quiet. */
|
|
59
82
|
static renderField(opts) {
|
|
60
83
|
const { field, names } = opts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../../src/generator/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAyB,MAAM,UAAU,CAAC;AAErF,iKAAiK;AACjK,MAAM,OAAO,oBAAoB;IAC/B,kEAAkE;aAClD,gBAAW,GAAG,GAAG,CAAC;aAElB,wBAAmB,GAAG,oBAAoB,CAAC;IAE3D,yHAAyH;IACzH,MAAM,CAAC,aAAa,CAAC,IAMpB;QACC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAA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AC,IAAwC;QACjE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC9B,MAAM,UAAU,GAAG,KAAK,KAAK,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAExD,IAAI,UAAU,CAAC,MAAM,IAAI,oBAAoB,CAAC,WAAW,EAAE,CAAC;YAC1D,OAAO,CAAC,UAAU,CAAC,CAAC;QACtB,CAAC;QAED,OAAO,CAAC,KAAK,KAAK,KAAK,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3E,CAAC;IAEO,MAAM,CAAC,UAAU,CAAC,IAAuD;QAC/E,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QACxF,CAAC;QAED,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;aAC9C,KAAK,CAAC,GAAG,CAAC;aACV,IAAI,CAAC,GAAG,CAAC;aACT,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAErD,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;IAChD,CAAC","sourcesContent":["import { dirname, relative, sep } from 'node:path';\nimport { ArtifactStereotypes, ArtifactTypes, type IScannedArtifact } from './common';\n\n/** Renders the generated index: deterministic text, plain static imports, no IGNIS import - the object is type-checked where `registerArtifacts` receives it. */\nexport class ArtifactIndexEmitter {\n /** Mirrors `printWidth` in the root bunfig.toml `[fmt]` table. */\n static readonly PRINT_WIDTH = 100;\n\n static readonly DEFAULT_EXPORT_NAME = 'GeneratedArtifacts';\n\n /** The `ignis-artifacts generate` command for these options - the header and the CLI's stale hint print the same one. */\n static renderCommand(opts: {\n root: string;\n out: string;\n ignore?: string[];\n exportName?: string;\n sourceModules?: string[];\n }): string {\n const { root, out, ignore = [], exportName, sourceModules = [] } = opts;\n const flags = [`--root ${root}`, `--out ${out}`];\n\n if (ignore.length > 0) {\n flags.push(`--ignore ${ignore.join(',')}`);\n }\n\n if (exportName && exportName !== ArtifactIndexEmitter.DEFAULT_EXPORT_NAME) {\n flags.push(`--export ${exportName}`);\n }\n\n for (const sourceModule of sourceModules) {\n flags.push(`--source-module ${sourceModule}`);\n }\n\n return `ignis-artifacts generate ${flags.join(' ')}`;\n }\n\n /** The exact command that regenerates the file, so the header never points at another path than the one the build used. */\n static renderHeader(opts: {\n root: string;\n out: string;\n ignore?: string[];\n exportName?: string;\n sourceModules?: string[];\n }): string {\n return `// AUTO-GENERATED by @venizia/ignis-boot - do not edit. Regenerate: ${ArtifactIndexEmitter.renderCommand(opts)}`;\n }\n\n static render(opts: {\n artifacts: IScannedArtifact[];\n outFile: string;\n exportName: string;\n /** Absolute import paths - for a virtual module, which has no directory to resolve a relative one from. */\n absoluteImports?: boolean;\n /** The CLI arguments as given, for the header; `outFile` above is the resolved path used for import specifiers. */\n command: { root: string; out: string; ignore?: string[]; sourceModules?: string[] };\n }): string {\n const { artifacts, outFile, exportName, command } = opts;\n const emitted = artifacts.filter((artifact) => artifact.type !== ArtifactTypes.MODEL);\n\n const imports = emitted\n .map((artifact) => ({\n name: artifact.className,\n path: ArtifactIndexEmitter.importPath({\n from: outFile,\n to: artifact.filePath,\n isAbsolute: opts.absoluteImports ?? false,\n }),\n }))\n .sort((a, b) => a.path.localeCompare(b.path) || a.name.localeCompare(b.name))\n .map((entry) => `import { ${entry.name} } from '${entry.path}';`);\n\n const fields = ArtifactStereotypes.EMIT_ORDER.flatMap(({ type, field }) => {\n const names = emitted\n .filter((artifact) => artifact.type === type)\n .map((artifact) => artifact.className)\n .sort((a, b) => a.localeCompare(b));\n\n return ArtifactIndexEmitter.renderField({ field, names });\n });\n\n return [\n ArtifactIndexEmitter.renderHeader({ ...command, exportName }),\n ...imports,\n '',\n `export const ${exportName} = {`,\n ...fields,\n '};',\n '',\n ].join('\\n');\n }\n\n /** One line while it fits the print width, else one name per line - so `bun fmt --check` on the generated file stays quiet. */\n private static renderField(opts: { field: string; names: string[] }): string[] {\n const { field, names } = opts;\n const singleLine = ` ${field}: [${names.join(', ')}],`;\n\n if (singleLine.length <= ArtifactIndexEmitter.PRINT_WIDTH) {\n return [singleLine];\n }\n\n return [` ${field}: [`, ...names.map((name) => ` ${name},`), ' ],'];\n }\n\n private static importPath(opts: { from: string; to: string; isAbsolute: boolean }): string {\n if (opts.isAbsolute) {\n return opts.to.split(sep).join('/').replace(ArtifactStereotypes.SOURCE_EXTENSION, '');\n }\n\n const raw = relative(dirname(opts.from), opts.to)\n .split(sep)\n .join('/')\n .replace(ArtifactStereotypes.SOURCE_EXTENSION, '');\n\n return raw.startsWith('.') ? raw : `./${raw}`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../../src/generator/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAyB,MAAM,UAAU,CAAC;AAErF,iKAAiK;AACjK,MAAM,OAAO,oBAAoB;IAC/B,kEAAkE;aAClD,gBAAW,GAAG,GAAG,CAAC;aAElB,wBAAmB,GAAG,oBAAoB,CAAC;IAE3D,yHAAyH;IACzH,MAAM,CAAC,aAAa,CAAC,IAMpB;QACC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,UAAU,EAAE,aAAa,GAAG,EAAE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E,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC;IAED,+HAA+H;IACvH,MAAM,CAAC,WAAW,CAAC,IAAwC;QACjE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC9B,MAAM,UAAU,GAAG,KAAK,KAAK,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAExD,IAAI,UAAU,CAAC,MAAM,IAAI,oBAAoB,CAAC,WAAW,EAAE,CAAC;YAC1D,OAAO,CAAC,UAAU,CAAC,CAAC;QACtB,CAAC;QAED,OAAO,CAAC,KAAK,KAAK,KAAK,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3E,CAAC;IAEO,MAAM,CAAC,UAAU,CAAC,IAAuD;QAC/E,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QACxF,CAAC;QAED,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;aAC9C,KAAK,CAAC,GAAG,CAAC;aACV,IAAI,CAAC,GAAG,CAAC;aACT,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAErD,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;IAChD,CAAC","sourcesContent":["import { dirname, relative, sep } from 'node:path';\nimport { ArtifactStereotypes, ArtifactTypes, type IScannedArtifact } from './common';\n\n/** Renders the generated index: deterministic text, plain static imports, no IGNIS import - the object is type-checked where `registerArtifacts` receives it. */\nexport class ArtifactIndexEmitter {\n /** Mirrors `printWidth` in the root bunfig.toml `[fmt]` table. */\n static readonly PRINT_WIDTH = 100;\n\n static readonly DEFAULT_EXPORT_NAME = 'GeneratedArtifacts';\n\n /** The `ignis-artifacts generate` command for these options - the header and the CLI's stale hint print the same one. */\n static renderCommand(opts: {\n root: string;\n out: string;\n ignore?: string[];\n exportName?: string;\n sourceModules?: string[];\n }): string {\n const { root, out, ignore = [], exportName, sourceModules = [] } = opts;\n const flags = [`--root ${root}`, `--out ${out}`];\n\n if (ignore.length > 0) {\n flags.push(`--ignore ${ignore.join(',')}`);\n }\n\n if (exportName && exportName !== ArtifactIndexEmitter.DEFAULT_EXPORT_NAME) {\n flags.push(`--export ${exportName}`);\n }\n\n for (const sourceModule of sourceModules) {\n flags.push(`--source-module ${sourceModule}`);\n }\n\n return `ignis-artifacts generate ${flags.join(' ')}`;\n }\n\n /** The exact command that regenerates the file, so the header never points at another path than the one the build used. */\n static renderHeader(opts: {\n root: string;\n out: string;\n ignore?: string[];\n exportName?: string;\n sourceModules?: string[];\n }): string {\n return `// AUTO-GENERATED by @venizia/ignis-boot - do not edit. Regenerate: ${ArtifactIndexEmitter.renderCommand(opts)}`;\n }\n\n static render(opts: {\n artifacts: IScannedArtifact[];\n outFile: string;\n exportName: string;\n /** Absolute import paths - for a virtual module, which has no directory to resolve a relative one from. */\n absoluteImports?: boolean;\n /** The CLI arguments as given, for the header; `outFile` above is the resolved path used for import specifiers. */\n command: { root: string; out: string; ignore?: string[]; sourceModules?: string[] };\n }): string {\n const { artifacts, outFile, exportName, command } = opts;\n const emitted = artifacts.filter((artifact) => artifact.type !== ArtifactTypes.MODEL);\n\n const imports = emitted\n .map((artifact) => ({\n name: artifact.className,\n path: ArtifactIndexEmitter.importPath({\n from: outFile,\n to: artifact.filePath,\n isAbsolute: opts.absoluteImports ?? false,\n }),\n }))\n .sort((a, b) => a.path.localeCompare(b.path) || a.name.localeCompare(b.name))\n .map((entry) => `import { ${entry.name} } from '${entry.path}';`);\n\n const fields = ArtifactStereotypes.EMIT_ORDER.flatMap(({ type, field }) => {\n const names = emitted\n .filter((artifact) => artifact.type === type)\n .map((artifact) => artifact.className)\n .sort((a, b) => a.localeCompare(b));\n\n return ArtifactIndexEmitter.renderField({ field, names });\n });\n const custom = ArtifactStereotypes.groupCustom({ artifacts: emitted });\n\n return [\n ArtifactIndexEmitter.renderHeader({ ...command, exportName }),\n ...imports,\n '',\n `export const ${exportName} = {`,\n ...fields,\n ...ArtifactIndexEmitter.renderCustom({ custom }),\n '};',\n '',\n ].join('\\n');\n }\n\n /** `text` as a single-quoted string literal, with the backslash and the quote escaped, as the formatter writes it. */\n private static quote(opts: { text: string }): string {\n return `'${opts.text.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n }\n\n /** The `custom` field: one list per type the application defined, nothing at all when it defined none. */\n private static renderCustom(opts: {\n custom: Array<{ type: string; artifacts: Array<{ className: string }> }>;\n }): string[] {\n if (opts.custom.length === 0) {\n return [];\n }\n\n const lines = opts.custom.flatMap(({ type, artifacts }) => {\n const key = /^[A-Za-z_$][\\w$]*$/.test(type)\n ? type\n : ArtifactIndexEmitter.quote({ text: type });\n const names = artifacts.map((artifact) => artifact.className);\n const singleLine = ` ${key}: [${names.join(', ')}],`;\n\n return singleLine.length <= ArtifactIndexEmitter.PRINT_WIDTH\n ? [singleLine]\n : [` ${key}: [`, ...names.map((name) => ` ${name},`), ' ],'];\n });\n\n return [` ${ArtifactStereotypes.CUSTOM_FIELD}: {`, ...lines, ' },'];\n }\n\n /** One line while it fits the print width, else one name per line - so `bun fmt --check` on the generated file stays quiet. */\n private static renderField(opts: { field: string; names: string[] }): string[] {\n const { field, names } = opts;\n const singleLine = ` ${field}: [${names.join(', ')}],`;\n\n if (singleLine.length <= ArtifactIndexEmitter.PRINT_WIDTH) {\n return [singleLine];\n }\n\n return [` ${field}: [`, ...names.map((name) => ` ${name},`), ' ],'];\n }\n\n private static importPath(opts: { from: string; to: string; isAbsolute: boolean }): string {\n if (opts.isAbsolute) {\n return opts.to.split(sep).join('/').replace(ArtifactStereotypes.SOURCE_EXTENSION, '');\n }\n\n const raw = relative(dirname(opts.from), opts.to)\n .split(sep)\n .join('/')\n .replace(ArtifactStereotypes.SOURCE_EXTENSION, '');\n\n return raw.startsWith('.') ? raw : `./${raw}`;\n }\n}\n"]}
|