@venizia/ignis-boot 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +17 -4
- package/dist/esm/build-info/resolver.d.ts +2 -2
- package/dist/esm/build-info/resolver.d.ts.map +1 -1
- package/dist/esm/build-info/resolver.js +17 -11
- package/dist/esm/build-info/resolver.js.map +1 -1
- package/dist/esm/bun/plugin.d.ts +1 -1
- package/dist/esm/bun/plugin.d.ts.map +1 -1
- package/dist/esm/bun/plugin.js +2 -2
- package/dist/esm/bun/plugin.js.map +1 -1
- package/dist/esm/clis/artifacts.js +0 -0
- package/package.json +19 -33
- package/dist/cjs/build-info/common/constants.d.ts +0 -12
- package/dist/cjs/build-info/common/constants.d.ts.map +0 -1
- package/dist/cjs/build-info/common/constants.js +0 -32
- package/dist/cjs/build-info/common/constants.js.map +0 -1
- package/dist/cjs/build-info/common/index.d.ts +0 -2
- package/dist/cjs/build-info/common/index.d.ts.map +0 -1
- package/dist/cjs/build-info/common/index.js +0 -18
- package/dist/cjs/build-info/common/index.js.map +0 -1
- package/dist/cjs/build-info/index.d.ts +0 -4
- package/dist/cjs/build-info/index.d.ts.map +0 -1
- package/dist/cjs/build-info/index.js +0 -20
- package/dist/cjs/build-info/index.js.map +0 -1
- package/dist/cjs/build-info/resolver.d.ts +0 -25
- package/dist/cjs/build-info/resolver.d.ts.map +0 -1
- package/dist/cjs/build-info/resolver.js +0 -105
- package/dist/cjs/build-info/resolver.js.map +0 -1
- package/dist/cjs/build-info/stamp.d.ts +0 -22
- package/dist/cjs/build-info/stamp.d.ts.map +0 -1
- package/dist/cjs/build-info/stamp.js +0 -36
- package/dist/cjs/build-info/stamp.js.map +0 -1
- package/dist/cjs/bun/auto-group.d.ts +0 -22
- package/dist/cjs/bun/auto-group.d.ts.map +0 -1
- package/dist/cjs/bun/auto-group.js +0 -51
- package/dist/cjs/bun/auto-group.js.map +0 -1
- package/dist/cjs/bun/auto-loader.d.ts +0 -13
- package/dist/cjs/bun/auto-loader.d.ts.map +0 -1
- package/dist/cjs/bun/auto-loader.js +0 -63
- package/dist/cjs/bun/auto-loader.js.map +0 -1
- package/dist/cjs/bun/auto.d.ts +0 -5
- package/dist/cjs/bun/auto.d.ts.map +0 -1
- package/dist/cjs/bun/auto.js +0 -11
- package/dist/cjs/bun/auto.js.map +0 -1
- package/dist/cjs/bun/group-resolver.d.ts +0 -16
- package/dist/cjs/bun/group-resolver.d.ts.map +0 -1
- package/dist/cjs/bun/group-resolver.js +0 -44
- package/dist/cjs/bun/group-resolver.js.map +0 -1
- package/dist/cjs/bun/index.d.ts +0 -7
- package/dist/cjs/bun/index.d.ts.map +0 -1
- package/dist/cjs/bun/index.js +0 -23
- package/dist/cjs/bun/index.js.map +0 -1
- package/dist/cjs/bun/plugin.d.ts +0 -67
- package/dist/cjs/bun/plugin.d.ts.map +0 -1
- package/dist/cjs/bun/plugin.js +0 -395
- package/dist/cjs/bun/plugin.js.map +0 -1
- package/dist/cjs/bun/scan-cache.d.ts +0 -22
- package/dist/cjs/bun/scan-cache.d.ts.map +0 -1
- package/dist/cjs/bun/scan-cache.js +0 -89
- package/dist/cjs/bun/scan-cache.js.map +0 -1
- package/dist/cjs/bun/sources.d.ts +0 -49
- package/dist/cjs/bun/sources.d.ts.map +0 -1
- package/dist/cjs/bun/sources.js +0 -115
- package/dist/cjs/bun/sources.js.map +0 -1
- package/dist/cjs/clis/artifacts.d.ts +0 -3
- package/dist/cjs/clis/artifacts.d.ts.map +0 -1
- package/dist/cjs/clis/artifacts.js +0 -62
- package/dist/cjs/clis/artifacts.js.map +0 -1
- package/dist/cjs/common/install-quiet-logger.d.ts +0 -2
- package/dist/cjs/common/install-quiet-logger.d.ts.map +0 -1
- package/dist/cjs/common/install-quiet-logger.js +0 -7
- package/dist/cjs/common/install-quiet-logger.js.map +0 -1
- package/dist/cjs/common/quiet-logger.d.ts +0 -18
- package/dist/cjs/common/quiet-logger.d.ts.map +0 -1
- package/dist/cjs/common/quiet-logger.js +0 -46
- package/dist/cjs/common/quiet-logger.js.map +0 -1
- package/dist/cjs/generator/common/constants.d.ts +0 -59
- package/dist/cjs/generator/common/constants.d.ts.map +0 -1
- package/dist/cjs/generator/common/constants.js +0 -102
- package/dist/cjs/generator/common/constants.js.map +0 -1
- package/dist/cjs/generator/common/index.d.ts +0 -3
- package/dist/cjs/generator/common/index.d.ts.map +0 -1
- package/dist/cjs/generator/common/index.js +0 -19
- package/dist/cjs/generator/common/index.js.map +0 -1
- package/dist/cjs/generator/common/types.d.ts +0 -33
- package/dist/cjs/generator/common/types.d.ts.map +0 -1
- package/dist/cjs/generator/common/types.js +0 -3
- package/dist/cjs/generator/common/types.js.map +0 -1
- package/dist/cjs/generator/emitter.d.ts +0 -41
- package/dist/cjs/generator/emitter.d.ts.map +0 -1
- package/dist/cjs/generator/emitter.js +0 -82
- package/dist/cjs/generator/emitter.js.map +0 -1
- package/dist/cjs/generator/index.d.ts +0 -26
- package/dist/cjs/generator/index.d.ts.map +0 -1
- package/dist/cjs/generator/index.js +0 -68
- package/dist/cjs/generator/index.js.map +0 -1
- package/dist/cjs/generator/reexport.d.ts +0 -28
- package/dist/cjs/generator/reexport.d.ts.map +0 -1
- package/dist/cjs/generator/reexport.js +0 -131
- package/dist/cjs/generator/reexport.js.map +0 -1
- package/dist/cjs/generator/scanner.d.ts +0 -26
- package/dist/cjs/generator/scanner.d.ts.map +0 -1
- package/dist/cjs/generator/scanner.js +0 -258
- package/dist/cjs/generator/scanner.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -3
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -19
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/vite/index.d.ts +0 -2
- package/dist/cjs/vite/index.d.ts.map +0 -1
- package/dist/cjs/vite/index.js +0 -18
- package/dist/cjs/vite/index.js.map +0 -1
- package/dist/cjs/vite/plugin.d.ts +0 -29
- package/dist/cjs/vite/plugin.d.ts.map +0 -1
- package/dist/cjs/vite/plugin.js +0 -61
- package/dist/cjs/vite/plugin.js.map +0 -1
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArtifactScanCache = void 0;
|
|
4
|
-
const node_fs_1 = require("node:fs");
|
|
5
|
-
const node_crypto_1 = require("node:crypto");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
|
-
const common_1 = require("../generator/common");
|
|
8
|
-
/** 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. */
|
|
9
|
-
class ArtifactScanCache {
|
|
10
|
-
static { this.VERSION = 2; }
|
|
11
|
-
static location(opts) {
|
|
12
|
-
const root = (0, node_path_1.resolve)(opts.root);
|
|
13
|
-
const key = (0, node_crypto_1.createHash)('sha1').update(root).digest('hex').slice(0, 16);
|
|
14
|
-
return (0, node_path_1.join)((0, node_path_1.dirname)(root), 'node_modules', '.cache', 'ignis-artifacts', `${key}.json`);
|
|
15
|
-
}
|
|
16
|
-
/** 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). */
|
|
17
|
-
static fingerprint(opts) {
|
|
18
|
-
const root = (0, node_path_1.resolve)(opts.root);
|
|
19
|
-
const entries = [];
|
|
20
|
-
for (const relativePath of (0, node_fs_1.globSync)(common_1.ArtifactStereotypes.SOURCE_GLOB, { cwd: root })) {
|
|
21
|
-
const stats = (0, node_fs_1.statSync)((0, node_path_1.join)(root, relativePath));
|
|
22
|
-
entries.push(`${relativePath}:${stats.size}:${stats.mtimeMs}`);
|
|
23
|
-
}
|
|
24
|
-
entries.sort();
|
|
25
|
-
const extras = [(0, node_path_1.join)((0, node_path_1.dirname)(root), 'package.json')];
|
|
26
|
-
let directory = (0, node_path_1.dirname)(root);
|
|
27
|
-
while (true) {
|
|
28
|
-
const lockfile = ['bun.lock', 'bun.lockb', 'package-lock.json']
|
|
29
|
-
.map((name) => (0, node_path_1.join)(directory, name))
|
|
30
|
-
.find(node_fs_1.existsSync);
|
|
31
|
-
if (lockfile) {
|
|
32
|
-
extras.push(lockfile);
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
const parent = (0, node_path_1.dirname)(directory);
|
|
36
|
-
if (parent === directory) {
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
directory = parent;
|
|
40
|
-
}
|
|
41
|
-
for (const file of extras.filter(node_fs_1.existsSync)) {
|
|
42
|
-
const stats = (0, node_fs_1.statSync)(file);
|
|
43
|
-
entries.push(`${file}:${stats.size}:${stats.mtimeMs}`);
|
|
44
|
-
}
|
|
45
|
-
return (0, node_crypto_1.createHash)('sha1')
|
|
46
|
-
.update(`${ArtifactScanCache.VERSION}\n${entries.join('\n')}`)
|
|
47
|
-
.digest('hex');
|
|
48
|
-
}
|
|
49
|
-
/** The cached scan, or `undefined` for a missing, stale or unreadable cache - never an error. */
|
|
50
|
-
static read(opts) {
|
|
51
|
-
const file = ArtifactScanCache.location(opts);
|
|
52
|
-
if (!(0, node_fs_1.existsSync)(file)) {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
let stored;
|
|
56
|
-
try {
|
|
57
|
-
stored = JSON.parse((0, node_fs_1.readFileSync)(file, 'utf8'));
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
// A corrupt cache is a miss: the caller scans and rewrites it.
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
if (stored.fingerprint !== ArtifactScanCache.fingerprint(opts) ||
|
|
64
|
-
!Array.isArray(stored.artifacts)) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
return stored.artifacts;
|
|
68
|
-
}
|
|
69
|
-
/** Stores a scan; `false` when the cache directory cannot be written (a read-only install), which only costs the next start a scan. */
|
|
70
|
-
static write(opts) {
|
|
71
|
-
const file = ArtifactScanCache.location(opts);
|
|
72
|
-
const temporary = `${file}.${process.pid}.tmp`;
|
|
73
|
-
try {
|
|
74
|
-
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(file), { recursive: true });
|
|
75
|
-
(0, node_fs_1.writeFileSync)(temporary, JSON.stringify({
|
|
76
|
-
fingerprint: ArtifactScanCache.fingerprint(opts),
|
|
77
|
-
artifacts: opts.artifacts,
|
|
78
|
-
}));
|
|
79
|
-
(0, node_fs_1.renameSync)(temporary, file);
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
// Caching is an optimisation; reporting `false` lets the caller go on with the scan it already has.
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.ArtifactScanCache = ArtifactScanCache;
|
|
89
|
-
//# sourceMappingURL=scan-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scan-cache.js","sourceRoot":"","sources":["../../../src/bun/scan-cache.ts"],"names":[],"mappings":";;;AAAA,qCAQiB;AACjB,6CAAyC;AACzC,yCAAmD;AACnD,gDAAiF;AAEjF,oNAAoN;AACpN,MAAa,iBAAiB;aACZ,YAAO,GAAG,CAAC,CAAC;IAE5B,MAAM,CAAC,QAAQ,CAAC,IAAsB;QACpC,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,MAAM,GAAG,GAAG,IAAA,wBAAU,EAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvE,OAAO,IAAA,gBAAI,EAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC;IACzF,CA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,CAAC;QAC9C,MAAM,SAAS,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,MAAM,CAAC;QAC/C,IAAI,CAAC;YACH,IAAA,mBAAS,EAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9C,IAAA,uBAAa,EACX,SAAS,EACT,IAAI,CAAC,SAAS,CAAC;gBACb,WAAW,EAAE,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC;gBAChD,SAAS,EAAE,IAAI,CAAC,SAAS;aAC1B,CAAC,CACH,CAAC;YACF,IAAA,oBAAU,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,oGAAoG;YACpG,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;;AAtFH,8CAuFC","sourcesContent":["import {\n existsSync,\n globSync,\n mkdirSync,\n readFileSync,\n renameSync,\n statSync,\n writeFileSync,\n} from 'node:fs';\nimport { createHash } from 'node:crypto';\nimport { dirname, join, resolve } from 'node:path';\nimport { ArtifactStereotypes, type IScannedArtifact } from '../generator/common';\n\n/** The scanner's answer for one `src`, kept under the package's `node_modules/.cache` and valid while no `.ts` file under `src`, the package manifest or the lockfile changed - a hit skips TypeScript entirely. */\nexport class ArtifactScanCache {\n static readonly VERSION = 2;\n\n static location(opts: { root: string }): string {\n const root = resolve(opts.root);\n const key = createHash('sha1').update(root).digest('hex').slice(0, 16);\n return join(dirname(root), 'node_modules', '.cache', 'ignis-artifacts', `${key}.json`);\n }\n\n /** Path, size and mtime of every `.ts`/`.tsx` under `root`, plus the package manifest and the nearest lockfile (a dependency upgrade can change which decorators count). */\n static fingerprint(opts: { root: string }): string {\n const root = resolve(opts.root);\n const entries: string[] = [];\n for (const relativePath of globSync(ArtifactStereotypes.SOURCE_GLOB, { cwd: root })) {\n const stats = statSync(join(root, relativePath));\n entries.push(`${relativePath}:${stats.size}:${stats.mtimeMs}`);\n }\n entries.sort();\n\n const extras = [join(dirname(root), 'package.json')];\n let directory = dirname(root);\n while (true) {\n const lockfile = ['bun.lock', 'bun.lockb', 'package-lock.json']\n .map((name) => join(directory, name))\n .find(existsSync);\n if (lockfile) {\n extras.push(lockfile);\n break;\n }\n const parent = dirname(directory);\n if (parent === directory) {\n break;\n }\n directory = parent;\n }\n for (const file of extras.filter(existsSync)) {\n const stats = statSync(file);\n entries.push(`${file}:${stats.size}:${stats.mtimeMs}`);\n }\n\n return createHash('sha1')\n .update(`${ArtifactScanCache.VERSION}\\n${entries.join('\\n')}`)\n .digest('hex');\n }\n\n /** The cached scan, or `undefined` for a missing, stale or unreadable cache - never an error. */\n static read(opts: { root: string }): IScannedArtifact[] | undefined {\n const file = ArtifactScanCache.location(opts);\n if (!existsSync(file)) {\n return undefined;\n }\n let stored: { fingerprint?: unknown; artifacts?: unknown };\n try {\n stored = JSON.parse(readFileSync(file, 'utf8'));\n } catch {\n // A corrupt cache is a miss: the caller scans and rewrites it.\n return undefined;\n }\n if (\n stored.fingerprint !== ArtifactScanCache.fingerprint(opts) ||\n !Array.isArray(stored.artifacts)\n ) {\n return undefined;\n }\n return stored.artifacts;\n }\n\n /** Stores a scan; `false` when the cache directory cannot be written (a read-only install), which only costs the next start a scan. */\n static write(opts: { root: string; artifacts: IScannedArtifact[] }): boolean {\n const file = ArtifactScanCache.location(opts);\n const temporary = `${file}.${process.pid}.tmp`;\n try {\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(\n temporary,\n JSON.stringify({\n fingerprint: ArtifactScanCache.fingerprint(opts),\n artifacts: opts.artifacts,\n }),\n );\n renameSync(temporary, file);\n return true;\n } catch {\n // Caching is an optimisation; reporting `false` lets the caller go on with the scan it already has.\n return false;\n }\n }\n}\n"]}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type IScannedArtifact } from '../generator/common';
|
|
2
|
-
interface IArtifactScanner {
|
|
3
|
-
scanWithReport(opts: {
|
|
4
|
-
root: string;
|
|
5
|
-
followReexports: boolean;
|
|
6
|
-
}): {
|
|
7
|
-
artifacts: IScannedArtifact[];
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
/** Where a package's artifacts live: the `src` beside its nearest `package.json`, and the classes under one of its directories. One scan per package per process, served from `ArtifactScanCache` when no source file changed - so this module never loads the scanner (and TypeScript) itself. */
|
|
11
|
-
export declare class ArtifactSources {
|
|
12
|
-
private static readonly scans;
|
|
13
|
-
private static scanner;
|
|
14
|
-
/** Called by the modules that already hold the scanner (the build plugin). */
|
|
15
|
-
static useScanner(opts: {
|
|
16
|
-
scanner: IArtifactScanner;
|
|
17
|
-
}): void;
|
|
18
|
-
/** Loads the scanner - only on a cache miss. A non-static specifier, so a bundle never pulls TypeScript in. */
|
|
19
|
-
static loadScanner(): Promise<void>;
|
|
20
|
-
/** Whether `packageSource` can be listed without the scanner: scanned in this process, or a valid disk cache. */
|
|
21
|
-
static isCached(opts: {
|
|
22
|
-
packageSource: string;
|
|
23
|
-
}): boolean;
|
|
24
|
-
/** Every decorated class under `packageSource`: this process's scan, else the disk cache, else the scanner (which must be loaded), written back to the cache. */
|
|
25
|
-
static scan(opts: {
|
|
26
|
-
packageSource: string;
|
|
27
|
-
}): IScannedArtifact[];
|
|
28
|
-
/** The entry module (`Bun.main`), or `undefined` when there is no entry file (`bun -e`, a REPL). */
|
|
29
|
-
static entry(): string | undefined;
|
|
30
|
-
/** The `src` beside the nearest `package.json` at or above `from` (default: the working directory). */
|
|
31
|
-
static packageSource(opts?: {
|
|
32
|
-
from?: string;
|
|
33
|
-
}): string;
|
|
34
|
-
/** The decorated classes under a directory named `folder` in the package whose source holds `site`, less those under an `ignore` glob (relative to `src`), each pointing at the copy that runs beside `site` (see `runningArtifacts`). */
|
|
35
|
-
static folderArtifacts(opts: {
|
|
36
|
-
folder: string | undefined;
|
|
37
|
-
site: string;
|
|
38
|
-
ignore?: ReadonlyArray<string>;
|
|
39
|
-
}): IScannedArtifact[];
|
|
40
|
-
/** The scanned classes as the code at `from` runs them: unchanged when `from` is in `src`; otherwise each `src/<path>.ts` becomes `<tree>/<path>.js` in the compiled tree `from` sits in (`dist`, `dist/esm`), so an application registers the very class its code uses, never a second copy loaded from `src`. */
|
|
41
|
-
static runningArtifacts(opts: {
|
|
42
|
-
artifacts: IScannedArtifact[];
|
|
43
|
-
from: string;
|
|
44
|
-
}): IScannedArtifact[];
|
|
45
|
-
/** Forgets every cached scan - for a long-lived process that rebuilds (a watch mode). */
|
|
46
|
-
static clear(): void;
|
|
47
|
-
}
|
|
48
|
-
export {};
|
|
49
|
-
//# sourceMappingURL=sources.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../src/bun/sources.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGjF,UAAU,gBAAgB;IACxB,cAAc,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,OAAO,CAAA;KAAE,GAAG;QAChE,SAAS,EAAE,gBAAgB,EAAE,CAAC;KAC/B,CAAC;CACH;AAED,mSAAmS;AACnS,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAyC;IACtE,OAAO,CAAC,MAAM,CAAC,OAAO,CAA+B;IAErD,8EAA8E;IAC9E,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,gBAAgB,CAAA;KAAE,GAAG,IAAI;IAI5D,+GAA+G;WAClG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IASzC,iHAAiH;IACjH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;IAWzD,iKAAiK;IACjK,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,GAAG,gBAAgB,EAAE;IAmBhE,oGAAoG;IACpG,MAAM,CAAC,KAAK,IAAI,MAAM,GAAG,SAAS;IAIlC,uGAAuG;IACvG,MAAM,CAAC,aAAa,CAAC,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,MAAM;IAa1D,0OAA0O;IAC1O,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE;QAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KAChC,GAAG,gBAAgB,EAAE;IAiBtB,mTAAmT;IACnT,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE;QAC5B,SAAS,EAAE,gBAAgB,EAAE,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,gBAAgB,EAAE;IAiCtB,yFAAyF;IACzF,MAAM,CAAC,KAAK,IAAI,IAAI;CAGrB"}
|
package/dist/cjs/bun/sources.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArtifactSources = void 0;
|
|
4
|
-
const ignis_helpers_1 = require("@venizia/ignis-helpers");
|
|
5
|
-
const node_fs_1 = require("node:fs");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
|
-
const common_1 = require("../generator/common");
|
|
8
|
-
const scan_cache_1 = require("./scan-cache");
|
|
9
|
-
/** Where a package's artifacts live: the `src` beside its nearest `package.json`, and the classes under one of its directories. One scan per package per process, served from `ArtifactScanCache` when no source file changed - so this module never loads the scanner (and TypeScript) itself. */
|
|
10
|
-
class ArtifactSources {
|
|
11
|
-
static { this.scans = new Map(); }
|
|
12
|
-
/** Called by the modules that already hold the scanner (the build plugin). */
|
|
13
|
-
static useScanner(opts) {
|
|
14
|
-
ArtifactSources.scanner = opts.scanner;
|
|
15
|
-
}
|
|
16
|
-
/** Loads the scanner - only on a cache miss. A non-static specifier, so a bundle never pulls TypeScript in. */
|
|
17
|
-
static async loadScanner() {
|
|
18
|
-
if (ArtifactSources.scanner) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const generatorModule = '../generator';
|
|
22
|
-
const { ArtifactScanner } = await import(generatorModule);
|
|
23
|
-
ArtifactSources.scanner = ArtifactScanner.getInstance();
|
|
24
|
-
}
|
|
25
|
-
/** Whether `packageSource` can be listed without the scanner: scanned in this process, or a valid disk cache. */
|
|
26
|
-
static isCached(opts) {
|
|
27
|
-
if (ArtifactSources.scans.has(opts.packageSource)) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
const cached = scan_cache_1.ArtifactScanCache.read({ root: opts.packageSource });
|
|
31
|
-
if (cached) {
|
|
32
|
-
ArtifactSources.scans.set(opts.packageSource, cached);
|
|
33
|
-
}
|
|
34
|
-
return cached !== undefined;
|
|
35
|
-
}
|
|
36
|
-
/** Every decorated class under `packageSource`: this process's scan, else the disk cache, else the scanner (which must be loaded), written back to the cache. */
|
|
37
|
-
static scan(opts) {
|
|
38
|
-
const { packageSource } = opts;
|
|
39
|
-
if (ArtifactSources.isCached({ packageSource })) {
|
|
40
|
-
return ArtifactSources.scans.get(packageSource) ?? [];
|
|
41
|
-
}
|
|
42
|
-
if (!ArtifactSources.scanner) {
|
|
43
|
-
throw (0, ignis_helpers_1.getError)({
|
|
44
|
-
message: `[ArtifactSources] ${packageSource} is not cached and the scanner is not loaded | Call ArtifactSources.loadScanner() first`,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
const { artifacts } = ArtifactSources.scanner.scanWithReport({
|
|
48
|
-
root: packageSource,
|
|
49
|
-
followReexports: true,
|
|
50
|
-
});
|
|
51
|
-
ArtifactSources.scans.set(packageSource, artifacts);
|
|
52
|
-
scan_cache_1.ArtifactScanCache.write({ root: packageSource, artifacts });
|
|
53
|
-
return artifacts;
|
|
54
|
-
}
|
|
55
|
-
/** The entry module (`Bun.main`), or `undefined` when there is no entry file (`bun -e`, a REPL). */
|
|
56
|
-
static entry() {
|
|
57
|
-
return typeof Bun !== 'undefined' && (0, node_fs_1.existsSync)(Bun.main) ? Bun.main : undefined;
|
|
58
|
-
}
|
|
59
|
-
/** The `src` beside the nearest `package.json` at or above `from` (default: the working directory). */
|
|
60
|
-
static packageSource(opts = {}) {
|
|
61
|
-
const start = (0, node_path_1.resolve)(opts.from ?? process.cwd());
|
|
62
|
-
let directory = start;
|
|
63
|
-
while (!(0, node_fs_1.existsSync)((0, node_path_1.join)(directory, 'package.json'))) {
|
|
64
|
-
const parent = (0, node_path_1.dirname)(directory);
|
|
65
|
-
if (parent === directory) {
|
|
66
|
-
return (0, node_path_1.join)(start, 'src');
|
|
67
|
-
}
|
|
68
|
-
directory = parent;
|
|
69
|
-
}
|
|
70
|
-
return (0, node_path_1.join)(directory, 'src');
|
|
71
|
-
}
|
|
72
|
-
/** The decorated classes under a directory named `folder` in the package whose source holds `site`, less those under an `ignore` glob (relative to `src`), each pointing at the copy that runs beside `site` (see `runningArtifacts`). */
|
|
73
|
-
static folderArtifacts(opts) {
|
|
74
|
-
const packageSource = ArtifactSources.packageSource({ from: (0, node_path_1.dirname)(opts.site) });
|
|
75
|
-
const artifacts = ArtifactSources.scan({ packageSource });
|
|
76
|
-
const { folder } = opts;
|
|
77
|
-
const ignored = opts.ignore ?? [];
|
|
78
|
-
const picked = artifacts.filter((artifact) => {
|
|
79
|
-
const path = (0, node_path_1.relative)(packageSource, artifact.filePath);
|
|
80
|
-
return ((folder === undefined || path.split(node_path_1.sep).slice(0, -1).includes(folder)) &&
|
|
81
|
-
!ignored.some((pattern) => (0, node_path_1.matchesGlob)(path, pattern)));
|
|
82
|
-
});
|
|
83
|
-
return ArtifactSources.runningArtifacts({ artifacts: picked, from: opts.site });
|
|
84
|
-
}
|
|
85
|
-
/** The scanned classes as the code at `from` runs them: unchanged when `from` is in `src`; otherwise each `src/<path>.ts` becomes `<tree>/<path>.js` in the compiled tree `from` sits in (`dist`, `dist/esm`), so an application registers the very class its code uses, never a second copy loaded from `src`. */
|
|
86
|
-
static runningArtifacts(opts) {
|
|
87
|
-
const from = (0, node_path_1.resolve)(opts.from);
|
|
88
|
-
const packageSource = ArtifactSources.packageSource({ from: (0, node_path_1.dirname)(from) });
|
|
89
|
-
const [probe] = opts.artifacts;
|
|
90
|
-
if (!probe || from.startsWith(`${packageSource}${node_path_1.sep}`)) {
|
|
91
|
-
return opts.artifacts;
|
|
92
|
-
}
|
|
93
|
-
const packageRoot = (0, node_path_1.dirname)(packageSource);
|
|
94
|
-
const compiledPath = (target) => (0, node_path_1.join)(target.tree, (0, node_path_1.relative)(packageSource, target.artifact.filePath).replace(common_1.ArtifactStereotypes.SOURCE_EXTENSION, '.js'));
|
|
95
|
-
const segments = (0, node_path_1.relative)(packageRoot, (0, node_path_1.dirname)(from)).split(node_path_1.sep);
|
|
96
|
-
const tree = segments
|
|
97
|
-
.map((_segment, index) => (0, node_path_1.join)(packageRoot, ...segments.slice(0, index + 1)))
|
|
98
|
-
.find((candidate) => (0, node_fs_1.existsSync)(compiledPath({ tree: candidate, artifact: probe })));
|
|
99
|
-
return opts.artifacts.map((artifact) => {
|
|
100
|
-
const compiled = tree ? compiledPath({ tree, artifact }) : undefined;
|
|
101
|
-
if (!compiled || !(0, node_fs_1.existsSync)(compiled)) {
|
|
102
|
-
throw (0, ignis_helpers_1.getError)({
|
|
103
|
-
message: `[ArtifactSources] ${artifact.filePath} has no compiled copy beside ${from} | The package runs from a compiled tree that is older than its src - rebuild it (or run it from src)`,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return { ...artifact, filePath: compiled };
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
/** Forgets every cached scan - for a long-lived process that rebuilds (a watch mode). */
|
|
110
|
-
static clear() {
|
|
111
|
-
ArtifactSources.scans.clear();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
exports.ArtifactSources = ArtifactSources;
|
|
115
|
-
//# sourceMappingURL=sources.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sources.js","sourceRoot":"","sources":["../../../src/bun/sources.ts"],"names":[],"mappings":";;;AAAA,0DAAkD;AAClD,qCAAqC;AACrC,yCAA+E;AAC/E,gDAAiF;AACjF,6CAAiD;AAQjD,mSAAmS;AACnS,MAAa,eAAe;aACF,UAAK,GAAG,IAAI,GAAG,EAA8B,CAAC;IAGtE,8EAA8E;IAC9E,MAAM,CAAC,UAAU,CAAC,IAAmC;QACnD,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IACzC,CAAC;IAED,+GAA+G;IAC/G,MAAM,CAAC,KAAK,CAAC,WAAW;QACtB,IAAI,eAAe,CAAC,OAAO,EAAE,CAAC;YAC5B,OAAO;QACT,CAAC;QACD,MAAM,eAAe,GAAG,cAAc,CAAC;QACvC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;QAC1D,eAAe,CAAC,OAAO,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IAC1D,CAAC;IAED,iHAAiH;IACjH,MAAM,CAAC,QAAQ,CAAC,IAA+B;QAC7C,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YAClD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,8BAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QACpE,IAAI,MAAM,EAAE,CAAC;YACX,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,MAAM,KAAK,SAAS,CAAC;IAC9B,CAAC;IAED,iKAAiK;IACjK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,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QAEvF,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACrE,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAA,oBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;gBACvC,MAAM,IAAA,wBAAQ,EAAC;oBACb,OAAO,EAAE,qBAAqB,QAAQ,CAAC,QAAQ,gCAAgC,IAAI,uGAAuG;iBAC3L,CAAC,CAAC;YACL,CAAC;YACD,OAAO,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,yFAAyF;IACzF,MAAM,CAAC,KAAK;QACV,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;;AApIH,0CAqIC","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport { existsSync } from 'node:fs';\nimport { dirname, join, matchesGlob, relative, resolve, sep } from 'node:path';\nimport { ArtifactStereotypes, type IScannedArtifact } from '../generator/common';\nimport { ArtifactScanCache } from './scan-cache';\n\ninterface IArtifactScanner {\n scanWithReport(opts: { root: string; followReexports: boolean }): {\n artifacts: IScannedArtifact[];\n };\n}\n\n/** Where a package's artifacts live: the `src` beside its nearest `package.json`, and the classes under one of its directories. One scan per package per process, served from `ArtifactScanCache` when no source file changed - so this module never loads the scanner (and TypeScript) itself. */\nexport class ArtifactSources {\n private static readonly scans = new Map<string, IScannedArtifact[]>();\n private static scanner: IArtifactScanner | undefined;\n\n /** Called by the modules that already hold the scanner (the build plugin). */\n static useScanner(opts: { scanner: IArtifactScanner }): void {\n ArtifactSources.scanner = opts.scanner;\n }\n\n /** Loads the scanner - only on a cache miss. A non-static specifier, so a bundle never pulls TypeScript in. */\n static async loadScanner(): Promise<void> {\n if (ArtifactSources.scanner) {\n return;\n }\n const generatorModule = '../generator';\n const { ArtifactScanner } = await import(generatorModule);\n ArtifactSources.scanner = ArtifactScanner.getInstance();\n }\n\n /** Whether `packageSource` can be listed without the scanner: scanned in this process, or a valid disk cache. */\n static isCached(opts: { packageSource: string }): boolean {\n if (ArtifactSources.scans.has(opts.packageSource)) {\n return true;\n }\n const cached = ArtifactScanCache.read({ root: opts.packageSource });\n if (cached) {\n ArtifactSources.scans.set(opts.packageSource, cached);\n }\n return cached !== undefined;\n }\n\n /** Every decorated class under `packageSource`: this process's scan, else the disk cache, else the scanner (which must be loaded), written back to the cache. */\n static scan(opts: { packageSource: string }): IScannedArtifact[] {\n const { packageSource } = opts;\n if (ArtifactSources.isCached({ packageSource })) {\n return ArtifactSources.scans.get(packageSource) ?? [];\n }\n if (!ArtifactSources.scanner) {\n throw getError({\n message: `[ArtifactSources] ${packageSource} is not cached and the scanner is not loaded | Call ArtifactSources.loadScanner() first`,\n });\n }\n const { artifacts } = ArtifactSources.scanner.scanWithReport({\n root: packageSource,\n followReexports: true,\n });\n ArtifactSources.scans.set(packageSource, artifacts);\n ArtifactScanCache.write({ root: packageSource, artifacts });\n return artifacts;\n }\n\n /** The entry module (`Bun.main`), or `undefined` when there is no entry file (`bun -e`, a REPL). */\n static entry(): string | undefined {\n return typeof Bun !== 'undefined' && existsSync(Bun.main) ? Bun.main : undefined;\n }\n\n /** The `src` beside the nearest `package.json` at or above `from` (default: the working directory). */\n static packageSource(opts: { from?: string } = {}): string {\n const start = resolve(opts.from ?? process.cwd());\n let directory = start;\n while (!existsSync(join(directory, 'package.json'))) {\n const parent = dirname(directory);\n if (parent === directory) {\n return join(start, 'src');\n }\n directory = parent;\n }\n return join(directory, 'src');\n }\n\n /** The decorated classes under a directory named `folder` in the package whose source holds `site`, less those under an `ignore` glob (relative to `src`), each pointing at the copy that runs beside `site` (see `runningArtifacts`). */\n static folderArtifacts(opts: {\n folder: string | undefined;\n site: string;\n ignore?: ReadonlyArray<string>;\n }): IScannedArtifact[] {\n const packageSource = ArtifactSources.packageSource({ from: dirname(opts.site) });\n\n const artifacts = ArtifactSources.scan({ packageSource });\n\n const { folder } = opts;\n const ignored = opts.ignore ?? [];\n const picked = artifacts.filter((artifact) => {\n const path = relative(packageSource, artifact.filePath);\n return (\n (folder === undefined || path.split(sep).slice(0, -1).includes(folder)) &&\n !ignored.some((pattern) => matchesGlob(path, pattern))\n );\n });\n return ArtifactSources.runningArtifacts({ artifacts: picked, from: opts.site });\n }\n\n /** The scanned classes as the code at `from` runs them: unchanged when `from` is in `src`; otherwise each `src/<path>.ts` becomes `<tree>/<path>.js` in the compiled tree `from` sits in (`dist`, `dist/esm`), so an application registers the very class its code uses, never a second copy loaded from `src`. */\n static runningArtifacts(opts: {\n artifacts: IScannedArtifact[];\n from: string;\n }): IScannedArtifact[] {\n const from = resolve(opts.from);\n const packageSource = ArtifactSources.packageSource({ from: dirname(from) });\n const [probe] = opts.artifacts;\n if (!probe || from.startsWith(`${packageSource}${sep}`)) {\n return opts.artifacts;\n }\n\n const packageRoot = dirname(packageSource);\n const compiledPath = (target: { tree: string; artifact: IScannedArtifact }): string =>\n join(\n target.tree,\n relative(packageSource, target.artifact.filePath).replace(\n ArtifactStereotypes.SOURCE_EXTENSION,\n '.js',\n ),\n );\n const segments = relative(packageRoot, dirname(from)).split(sep);\n const tree = segments\n .map((_segment, index) => join(packageRoot, ...segments.slice(0, index + 1)))\n .find((candidate) => existsSync(compiledPath({ tree: candidate, artifact: probe })));\n\n return opts.artifacts.map((artifact) => {\n const compiled = tree ? compiledPath({ tree, artifact }) : undefined;\n if (!compiled || !existsSync(compiled)) {\n throw getError({\n message: `[ArtifactSources] ${artifact.filePath} has no compiled copy beside ${from} | The package runs from a compiled tree that is older than its src - rebuild it (or run it from src)`,\n });\n }\n return { ...artifact, filePath: compiled };\n });\n }\n\n /** Forgets every cached scan - for a long-lived process that rebuilds (a watch mode). */\n static clear(): void {\n ArtifactSources.scans.clear();\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../../../src/clis/artifacts.ts"],"names":[],"mappings":";AACA,OAAO,gCAAgC,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
require("../common/install-quiet-logger");
|
|
5
|
-
const node_path_1 = require("node:path");
|
|
6
|
-
const node_util_1 = require("node:util");
|
|
7
|
-
const generator_1 = require("../generator");
|
|
8
|
-
const USAGE = 'ignis-artifacts <generate|check> [--root src] [--out src/generated/artifacts.ts] [--ignore a,b] [--export GeneratedArtifacts] [--source-module <specifier>]...';
|
|
9
|
-
const { positionals, values } = (0, node_util_1.parseArgs)({
|
|
10
|
-
args: process.argv.slice(2),
|
|
11
|
-
allowPositionals: true,
|
|
12
|
-
options: {
|
|
13
|
-
root: { type: 'string', default: 'src' },
|
|
14
|
-
out: { type: 'string', default: 'src/generated/artifacts.ts' },
|
|
15
|
-
ignore: { type: 'string' },
|
|
16
|
-
export: { type: 'string', default: 'GeneratedArtifacts' },
|
|
17
|
-
'source-module': { type: 'string', multiple: true },
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
const options = {
|
|
21
|
-
root: values.root,
|
|
22
|
-
out: values.out,
|
|
23
|
-
ignore: values.ignore
|
|
24
|
-
?.split(',')
|
|
25
|
-
.map((pattern) => pattern.trim())
|
|
26
|
-
.filter(Boolean),
|
|
27
|
-
exportName: values.export,
|
|
28
|
-
sourceModules: values['source-module'],
|
|
29
|
-
};
|
|
30
|
-
/** One stderr line per decorated class a user `--ignore` pattern hid; silence when nothing is hidden. */
|
|
31
|
-
const warnIgnored = (opts) => {
|
|
32
|
-
for (const artifact of opts.ignored) {
|
|
33
|
-
console.error(`warning: ${artifact.className} (${artifact.type}) in ${(0, node_path_1.relative)(opts.root, artifact.filePath)} matches --ignore and is left out of the index`);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
/** Exit code of the command, so the process exits in exactly one place. */
|
|
37
|
-
const run = () => {
|
|
38
|
-
switch (positionals[0]) {
|
|
39
|
-
case 'generate': {
|
|
40
|
-
const result = (0, generator_1.generateArtifactIndex)(options);
|
|
41
|
-
console.log(`${result.written ? 'wrote' : 'up to date'} ${options.out} | ${result.artifacts.length} artifact(s)`);
|
|
42
|
-
warnIgnored({ ignored: result.ignored, root: options.root });
|
|
43
|
-
return 0;
|
|
44
|
-
}
|
|
45
|
-
case 'check': {
|
|
46
|
-
const result = (0, generator_1.checkArtifactIndex)(options);
|
|
47
|
-
warnIgnored({ ignored: result.ignored, root: options.root });
|
|
48
|
-
if (result.isFresh) {
|
|
49
|
-
console.log(`fresh ${options.out}`);
|
|
50
|
-
return 0;
|
|
51
|
-
}
|
|
52
|
-
console.error(`stale ${options.out} - run: ${generator_1.ArtifactIndexEmitter.renderCommand(options)}`);
|
|
53
|
-
return 1;
|
|
54
|
-
}
|
|
55
|
-
default: {
|
|
56
|
-
console.error(USAGE);
|
|
57
|
-
return 2;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
process.exit(run());
|
|
62
|
-
//# sourceMappingURL=artifacts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../../src/clis/artifacts.ts"],"names":[],"mappings":";;;AACA,0CAAwC;AACxC,yCAAqC;AACrC,yCAAsC;AACtC,4CAA+F;AAG/F,MAAM,KAAK,GACT,gKAAgK,CAAC;AAEnK,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAA,qBAAS,EAAC;IACxC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3B,gBAAgB,EAAE,IA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ChB,MAAM,MAAM,GAAG,IAAA,iCAAqB,EAAC,OAAO,CAAC,CAAC;YAC9C,OAAO,CAAC,GAAG,CACT,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,cAAc,CACrG,CAAC;YACF,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7D,OAAO,CAAC,CAAC;QACX,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,MAAM,GAAG,IAAA,8BAAkB,EAAC,OAAO,CAAC,CAAC;YAC3C,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,CAAC,GAAG,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;gBACpC,OAAO,CAAC,CAAC;YACX,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,SAAS,OAAO,CAAC,GAAG,WAAW,gCAAoB,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC5F,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC","sourcesContent":["#!/usr/bin/env bun\nimport '../common/install-quiet-logger';\nimport { relative } from 'node:path';\nimport { parseArgs } from 'node:util';\nimport { ArtifactIndexEmitter, checkArtifactIndex, generateArtifactIndex } from '../generator';\nimport type { IScannedArtifact } from '../generator';\n\nconst USAGE =\n 'ignis-artifacts <generate|check> [--root src] [--out src/generated/artifacts.ts] [--ignore a,b] [--export GeneratedArtifacts] [--source-module <specifier>]...';\n\nconst { positionals, values } = parseArgs({\n args: process.argv.slice(2),\n allowPositionals: true,\n options: {\n root: { type: 'string', default: 'src' },\n out: { type: 'string', default: 'src/generated/artifacts.ts' },\n ignore: { type: 'string' },\n export: { type: 'string', default: 'GeneratedArtifacts' },\n 'source-module': { type: 'string', multiple: true },\n },\n});\n\nconst options = {\n root: values.root,\n out: values.out,\n ignore: values.ignore\n ?.split(',')\n .map((pattern) => pattern.trim())\n .filter(Boolean),\n exportName: values.export,\n sourceModules: values['source-module'],\n};\n\n/** One stderr line per decorated class a user `--ignore` pattern hid; silence when nothing is hidden. */\nconst warnIgnored = (opts: { ignored: IScannedArtifact[]; root: string }): void => {\n for (const artifact of opts.ignored) {\n console.error(\n `warning: ${artifact.className} (${artifact.type}) in ${relative(opts.root, artifact.filePath)} matches --ignore and is left out of the index`,\n );\n }\n};\n\n/** Exit code of the command, so the process exits in exactly one place. */\nconst run = (): number => {\n switch (positionals[0]) {\n case 'generate': {\n const result = generateArtifactIndex(options);\n console.log(\n `${result.written ? 'wrote' : 'up to date'} ${options.out} | ${result.artifacts.length} artifact(s)`,\n );\n warnIgnored({ ignored: result.ignored, root: options.root });\n return 0;\n }\n case 'check': {\n const result = checkArtifactIndex(options);\n warnIgnored({ ignored: result.ignored, root: options.root });\n if (result.isFresh) {\n console.log(`fresh ${options.out}`);\n return 0;\n }\n console.error(`stale ${options.out} - run: ${ArtifactIndexEmitter.renderCommand(options)}`);\n return 1;\n }\n default: {\n console.error(USAGE);\n return 2;\n }\n }\n};\n\nprocess.exit(run());\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"install-quiet-logger.d.ts","sourceRoot":"","sources":["../../../src/common/install-quiet-logger.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ignis_helpers_1 = require("@venizia/ignis-helpers");
|
|
4
|
-
const quiet_logger_1 = require("./quiet-logger");
|
|
5
|
-
// Imported first by the CLI: a provider registered after another module resolved its logger would still see the console fallback and its warning.
|
|
6
|
-
ignis_helpers_1.LoggerFactory.use({ provider: quiet_logger_1.QuietLogger });
|
|
7
|
-
//# sourceMappingURL=install-quiet-logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"install-quiet-logger.js","sourceRoot":"","sources":["../../../src/common/install-quiet-logger.ts"],"names":[],"mappings":";;AAAA,0DAAuD;AACvD,iDAA6C;AAE7C,kJAAkJ;AAClJ,6BAAa,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,0BAAW,EAAE,CAAC,CAAC","sourcesContent":["import { LoggerFactory } from '@venizia/ignis-helpers';\nimport { QuietLogger } from './quiet-logger';\n\n// Imported first by the CLI: a provider registered after another module resolved its logger would still see the console fallback and its warning.\nLoggerFactory.use({ provider: QuietLogger });\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ILogger, TLogLevel } from '@venizia/ignis-helpers/core';
|
|
2
|
-
/** The generator's own output goes through `console.log`; framework diagnostics below `warn` are dropped and the rest land on stderr, so a codegen run prints nothing but its result on stdout. */
|
|
3
|
-
export declare class QuietLogger implements ILogger {
|
|
4
|
-
private readonly scope;
|
|
5
|
-
private static readonly cache;
|
|
6
|
-
private readonly prefix;
|
|
7
|
-
private constructor();
|
|
8
|
-
static get(scope: string): ILogger;
|
|
9
|
-
private write;
|
|
10
|
-
debug(): void;
|
|
11
|
-
info(): void;
|
|
12
|
-
warn(message: string, ...args: unknown[]): void;
|
|
13
|
-
error(message: string, ...args: unknown[]): void;
|
|
14
|
-
emerg(message: string, ...args: unknown[]): void;
|
|
15
|
-
log(level: TLogLevel, message: string, ...args: unknown[]): void;
|
|
16
|
-
for(methodName: string): ILogger;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=quiet-logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quiet-logger.d.ts","sourceRoot":"","sources":["../../../src/common/quiet-logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAGtE,mMAAmM;AACnM,qBAAa,WAAY,YAAW,OAAO;IAIrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAH1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAkC;IAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO;IAIP,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAWlC,OAAO,CAAC,KAAK;IAIb,KAAK,IAAI,IAAI;IAEb,IAAI,IAAI,IAAI;IAEZ,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIhD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIhD,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAQhE,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAGjC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QuietLogger = void 0;
|
|
4
|
-
const core_1 = require("@venizia/ignis-helpers/core");
|
|
5
|
-
/** The generator's own output goes through `console.log`; framework diagnostics below `warn` are dropped and the rest land on stderr, so a codegen run prints nothing but its result on stdout. */
|
|
6
|
-
class QuietLogger {
|
|
7
|
-
static { this.cache = new Map(); }
|
|
8
|
-
constructor(scope) {
|
|
9
|
-
this.scope = scope;
|
|
10
|
-
this.prefix = scope === '' ? '' : `[${scope}] `;
|
|
11
|
-
}
|
|
12
|
-
static get(scope) {
|
|
13
|
-
const cached = this.cache.get(scope);
|
|
14
|
-
if (cached) {
|
|
15
|
-
return cached;
|
|
16
|
-
}
|
|
17
|
-
const created = new QuietLogger(scope);
|
|
18
|
-
this.cache.set(scope, created);
|
|
19
|
-
return created;
|
|
20
|
-
}
|
|
21
|
-
write(opts) {
|
|
22
|
-
console.error(`${this.prefix}${opts.message}`, ...opts.args);
|
|
23
|
-
}
|
|
24
|
-
debug() { }
|
|
25
|
-
info() { }
|
|
26
|
-
warn(message, ...args) {
|
|
27
|
-
this.write({ message, args });
|
|
28
|
-
}
|
|
29
|
-
error(message, ...args) {
|
|
30
|
-
this.write({ message, args });
|
|
31
|
-
}
|
|
32
|
-
emerg(message, ...args) {
|
|
33
|
-
this.write({ message, args });
|
|
34
|
-
}
|
|
35
|
-
log(level, message, ...args) {
|
|
36
|
-
if (level === core_1.LogLevels.DEBUG || level === core_1.LogLevels.INFO) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
this.write({ message, args });
|
|
40
|
-
}
|
|
41
|
-
for(methodName) {
|
|
42
|
-
return QuietLogger.get(this.scope === '' ? methodName : `${this.scope}-${methodName}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.QuietLogger = QuietLogger;
|
|
46
|
-
//# sourceMappingURL=quiet-logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quiet-logger.js","sourceRoot":"","sources":["../../../src/common/quiet-logger.ts"],"names":[],"mappings":";;;AACA,sDAAwD;AAExD,mMAAmM;AACnM,MAAa,WAAW;aACE,UAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;IAG/D,YAAq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AAI,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;;AAjDH,kCAkDC","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 through `console.log`; 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 if (cached) {\n return cached;\n }\n\n const created = new QuietLogger(scope);\n this.cache.set(scope, created);\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,59 +0,0 @@
|
|
|
1
|
-
import type { TConstValue } from '@venizia/ignis-helpers';
|
|
2
|
-
/** 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
|
-
static readonly CONFIGURATION = "configuration";
|
|
5
|
-
static readonly COMPONENT = "component";
|
|
6
|
-
static readonly CONTROLLER = "controller";
|
|
7
|
-
static readonly SERVICE = "service";
|
|
8
|
-
static readonly REPOSITORY = "repository";
|
|
9
|
-
static readonly DATASOURCE = "datasource";
|
|
10
|
-
static readonly MODEL = "model";
|
|
11
|
-
static readonly SCHEME_SET: Set<string>;
|
|
12
|
-
static isValid(value: string): boolean;
|
|
13
|
-
}
|
|
14
|
-
export type TArtifactType = TConstValue<typeof ArtifactTypes>;
|
|
15
|
-
/** Mirrors the kernel's `ArtifactIndexFields` - the keys of the object the emitter writes and `registerArtifacts` reads. */
|
|
16
|
-
export declare class ArtifactIndexFields {
|
|
17
|
-
static readonly CONFIGURATIONS = "configurations";
|
|
18
|
-
static readonly DATA_SOURCES = "dataSources";
|
|
19
|
-
static readonly COMPONENTS = "components";
|
|
20
|
-
static readonly REPOSITORIES = "repositories";
|
|
21
|
-
static readonly SERVICES = "services";
|
|
22
|
-
static readonly CONTROLLERS = "controllers";
|
|
23
|
-
static readonly SCHEME_SET: Set<string>;
|
|
24
|
-
static isValid(value: string): boolean;
|
|
25
|
-
}
|
|
26
|
-
export type TArtifactIndexField = TConstValue<typeof ArtifactIndexFields>;
|
|
27
|
-
export declare class ArtifactStereotypes {
|
|
28
|
-
/** The source files the scanner reads: TypeScript, with or without JSX. */
|
|
29
|
-
static readonly SOURCE_GLOB = "**/*.{ts,tsx}";
|
|
30
|
-
/** The extension of a source file - stripped for an import specifier, replaced by `.js` for its compiled copy. */
|
|
31
|
-
static readonly SOURCE_EXTENSION: RegExp;
|
|
32
|
-
/** Decorator name as imported from `@venizia/ignis` or `@venizia/ignis-kernel` -> artifact type. */
|
|
33
|
-
static readonly BY_DECORATOR: Readonly<Record<string, TArtifactType>>;
|
|
34
|
-
static readonly ROOT_DECORATOR = "injectable";
|
|
35
|
-
static readonly SCHEME_SET: Set<string>;
|
|
36
|
-
static isValid(value: string): boolean;
|
|
37
|
-
static readonly SOURCE_MODULES: RegExp;
|
|
38
|
-
static readonly DEFAULT_IGNORE: string[];
|
|
39
|
-
/**
|
|
40
|
-
* The kernel's `registerArtifacts` order; `model` is never emitted. Configurations come first:
|
|
41
|
-
* `registerConfigurations` runs before the datasource and component sweeps, so a `@configuration`
|
|
42
|
-
* can shape what they read. The kernel sorts them among themselves by their `after` declarations
|
|
43
|
-
* at boot, so the order within the field does not matter here.
|
|
44
|
-
*/
|
|
45
|
-
static readonly EMIT_ORDER: ReadonlyArray<{
|
|
46
|
-
type: TArtifactType;
|
|
47
|
-
field: TArtifactIndexField;
|
|
48
|
-
}>;
|
|
49
|
-
}
|
|
50
|
-
/** Why a decorated class was left out of the index - reported, never silent. */
|
|
51
|
-
export declare class ScanSkipReasons {
|
|
52
|
-
static readonly ABSTRACT = "abstract";
|
|
53
|
-
static readonly NOT_EXPORTED = "not-exported";
|
|
54
|
-
static readonly IGNORED = "ignored";
|
|
55
|
-
static readonly SCHEME_SET: Set<string>;
|
|
56
|
-
static isValid(value: string): boolean;
|
|
57
|
-
}
|
|
58
|
-
export type TScanSkipReason = TConstValue<typeof ScanSkipReasons>;
|
|
59
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/generator/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,iIAAiI;AACjI,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,aAAa,mBAAmB;IAChD,MAAM,CAAC,QAAQ,CAAC,SAAS,eAAe;IACxC,MAAM,CAAC,QAAQ,CAAC,UAAU,gBAAgB;IAC1C,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;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