@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,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./common"), exports);
|
|
18
|
-
__exportStar(require("./resolver"), exports);
|
|
19
|
-
__exportStar(require("./stamp"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/build-info/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,6CAA2B;AAC3B,0CAAwB","sourcesContent":["export * from './common';\nexport * from './resolver';\nexport * from './stamp';\n"]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { BaseHelper } from '@venizia/ignis-helpers';
|
|
2
|
-
import { type TBuildInfoRecord } from '@venizia/ignis-helpers/core';
|
|
3
|
-
/**
|
|
4
|
-
* Resolves the stamp: environment first (CI knows the release tag), then `git`, then the
|
|
5
|
-
* manifest. Every miss is logged with its reason and degrades one field to
|
|
6
|
-
* {@link BuildInfoRegistry.UNSPECIFIED} - a Distroless image has no `git` and an exported tarball
|
|
7
|
-
* has no manifest, and a build must not die over a stamp.
|
|
8
|
-
*/
|
|
9
|
-
export declare class BuildInfoResolver extends BaseHelper {
|
|
10
|
-
private static instance?;
|
|
11
|
-
private constructor();
|
|
12
|
-
static getInstance(): BuildInfoResolver;
|
|
13
|
-
resolve(opts?: {
|
|
14
|
-
root?: string;
|
|
15
|
-
}): Promise<TBuildInfoRecord>;
|
|
16
|
-
private resolveEnvironmentValue;
|
|
17
|
-
/**
|
|
18
|
-
* `nothrow()` covers a nonzero exit; the `catch` covers `git` being absent and also `Bun` being
|
|
19
|
-
* absent - under plain Node the `ReferenceError` degrades the field instead of killing the build.
|
|
20
|
-
*/
|
|
21
|
-
private resolveGitValue;
|
|
22
|
-
/** `JSON.parse` promises nothing about the shape, so a manifest holding `{ "name": 42 }` must not become a numeric `service`. */
|
|
23
|
-
private resolveManifest;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/build-info/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAQvF;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,UAAU;IAC/C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAoB;IAE5C,OAAO;IAIP,MAAM,CAAC,WAAW,IAAI,iBAAiB;IAIjC,OAAO,CAAC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkClE,OAAO,CAAC,uBAAuB;IAW/B;;;OAGG;YACW,eAAe;IA4B7B,iIAAiI;IACjI,OAAO,CAAC,eAAe;CAyBxB"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BuildInfoResolver = void 0;
|
|
4
|
-
const ignis_helpers_1 = require("@venizia/ignis-helpers");
|
|
5
|
-
const core_1 = require("@venizia/ignis-helpers/core");
|
|
6
|
-
const node_fs_1 = require("node:fs");
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
8
|
-
const common_1 = require("./common");
|
|
9
|
-
/** Length of a short SHA; an env value already shorter is left alone. */
|
|
10
|
-
const COMMIT_LENGTH = 12;
|
|
11
|
-
/**
|
|
12
|
-
* Resolves the stamp: environment first (CI knows the release tag), then `git`, then the
|
|
13
|
-
* manifest. Every miss is logged with its reason and degrades one field to
|
|
14
|
-
* {@link BuildInfoRegistry.UNSPECIFIED} - a Distroless image has no `git` and an exported tarball
|
|
15
|
-
* has no manifest, and a build must not die over a stamp.
|
|
16
|
-
*/
|
|
17
|
-
class BuildInfoResolver extends ignis_helpers_1.BaseHelper {
|
|
18
|
-
constructor() {
|
|
19
|
-
super({ scope: BuildInfoResolver.name });
|
|
20
|
-
}
|
|
21
|
-
static getInstance() {
|
|
22
|
-
return (this.instance ??= new BuildInfoResolver());
|
|
23
|
-
}
|
|
24
|
-
async resolve(opts) {
|
|
25
|
-
const root = (0, node_path_1.resolve)(opts?.root ?? process.cwd());
|
|
26
|
-
const manifest = this.resolveManifest({ root });
|
|
27
|
-
// Independent processes; sequencing them would double the latency of the common case for nothing.
|
|
28
|
-
const [gitCommit, gitBranch] = await Promise.all([
|
|
29
|
-
this.resolveGitValue({ args: ['rev-parse', `--short=${COMMIT_LENGTH}`, 'HEAD'], root }),
|
|
30
|
-
this.resolveGitValue({ args: ['rev-parse', '--abbrev-ref', 'HEAD'], root }),
|
|
31
|
-
]);
|
|
32
|
-
const unspecified = core_1.BuildInfoRegistry.UNSPECIFIED;
|
|
33
|
-
return {
|
|
34
|
-
service: manifest.name ?? unspecified,
|
|
35
|
-
version: this.resolveEnvironmentValue({ keys: common_1.BuildInfoEnvironmentKeys.VERSION }) ??
|
|
36
|
-
manifest.version ??
|
|
37
|
-
unspecified,
|
|
38
|
-
commit: this.resolveEnvironmentValue({ keys: common_1.BuildInfoEnvironmentKeys.COMMIT })?.slice(0, COMMIT_LENGTH) ??
|
|
39
|
-
gitCommit ??
|
|
40
|
-
unspecified,
|
|
41
|
-
branch: this.resolveEnvironmentValue({ keys: common_1.BuildInfoEnvironmentKeys.BRANCH }) ??
|
|
42
|
-
gitBranch ??
|
|
43
|
-
unspecified,
|
|
44
|
-
builtAt: this.resolveEnvironmentValue({ keys: common_1.BuildInfoEnvironmentKeys.BUILT_AT }) ??
|
|
45
|
-
new Date().toISOString(),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
resolveEnvironmentValue(opts) {
|
|
49
|
-
for (const key of opts.keys) {
|
|
50
|
-
const value = process.env[key];
|
|
51
|
-
if (value !== undefined && value.trim().length > 0) {
|
|
52
|
-
return value.trim();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* `nothrow()` covers a nonzero exit; the `catch` covers `git` being absent and also `Bun` being
|
|
59
|
-
* absent - under plain Node the `ReferenceError` degrades the field instead of killing the build.
|
|
60
|
-
*/
|
|
61
|
-
async resolveGitValue(opts) {
|
|
62
|
-
const { args, root } = opts;
|
|
63
|
-
try {
|
|
64
|
-
const result = await Bun.$ `git ${args}`.cwd(root).quiet().nothrow();
|
|
65
|
-
// `rev-parse --abbrev-ref HEAD` in a repository with no commit prints the literal `HEAD` on
|
|
66
|
-
// stdout while exiting 128, so the exit code decides and stdout alone never does.
|
|
67
|
-
if (result.exitCode !== 0) {
|
|
68
|
-
this.logger.debug('git %s | exit: %d | %s', args.join(' '), result.exitCode, result.stderr.toString().trim());
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
const value = result.stdout.toString().trim();
|
|
72
|
-
return value.length > 0 ? value : undefined;
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
this.logger.debug('git %s | unavailable: %s', args.join(' '), error);
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/** `JSON.parse` promises nothing about the shape, so a manifest holding `{ "name": 42 }` must not become a numeric `service`. */
|
|
80
|
-
resolveManifest(opts) {
|
|
81
|
-
const manifest = (0, node_path_1.resolve)(opts.root, 'package.json');
|
|
82
|
-
if (!(0, node_fs_1.existsSync)(manifest)) {
|
|
83
|
-
this.logger.debug('No package.json at %s', opts.root);
|
|
84
|
-
return {};
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
const parsed = JSON.parse((0, node_fs_1.readFileSync)(manifest, 'utf8'));
|
|
88
|
-
if (typeof parsed !== 'object' || parsed === null) {
|
|
89
|
-
return {};
|
|
90
|
-
}
|
|
91
|
-
const name = 'name' in parsed ? parsed.name : undefined;
|
|
92
|
-
const version = 'version' in parsed ? parsed.version : undefined;
|
|
93
|
-
return {
|
|
94
|
-
name: typeof name === 'string' ? name : undefined,
|
|
95
|
-
version: typeof version === 'string' ? version : undefined,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
this.logger.debug('Unreadable package.json at %s | %s', manifest, error);
|
|
100
|
-
return {};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.BuildInfoResolver = BuildInfoResolver;
|
|
105
|
-
//# sourceMappingURL=resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/build-info/resolver.ts"],"names":[],"mappings":";;;AAAA,0DAAoD;AACpD,sDAAuF;AACvF,qCAAmD;AACnD,yCAAoC;AACpC,qCAAoD;AAEpD,yEAAyE;AACzE,M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CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;gBACjD,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;aAC3D,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YACzE,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAlHD,8CAkHC","sourcesContent":["import { BaseHelper } from '@venizia/ignis-helpers';\nimport { BuildInfoRegistry, type TBuildInfoRecord } from '@venizia/ignis-helpers/core';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { BuildInfoEnvironmentKeys } from './common';\n\n/** Length of a short SHA; an env value already shorter is left alone. */\nconst COMMIT_LENGTH = 12;\n\n/**\n * Resolves the stamp: environment first (CI knows the release tag), then `git`, then the\n * manifest. Every miss is logged with its reason and degrades one field to\n * {@link BuildInfoRegistry.UNSPECIFIED} - a Distroless image has no `git` and an exported tarball\n * has no manifest, and a build must not die over a stamp.\n */\nexport class BuildInfoResolver extends BaseHelper {\n private static instance?: BuildInfoResolver;\n\n private constructor() {\n super({ scope: BuildInfoResolver.name });\n }\n\n static getInstance(): BuildInfoResolver {\n return (this.instance ??= new BuildInfoResolver());\n }\n\n async resolve(opts?: { root?: string }): Promise<TBuildInfoRecord> {\n const root = resolve(opts?.root ?? process.cwd());\n const manifest = this.resolveManifest({ root });\n\n // Independent processes; sequencing them would double the latency of the common case for nothing.\n const [gitCommit, gitBranch] = await Promise.all([\n this.resolveGitValue({ args: ['rev-parse', `--short=${COMMIT_LENGTH}`, 'HEAD'], root }),\n this.resolveGitValue({ args: ['rev-parse', '--abbrev-ref', 'HEAD'], root }),\n ]);\n\n const unspecified = BuildInfoRegistry.UNSPECIFIED;\n return {\n service: manifest.name ?? unspecified,\n version:\n this.resolveEnvironmentValue({ keys: BuildInfoEnvironmentKeys.VERSION }) ??\n manifest.version ??\n unspecified,\n commit:\n this.resolveEnvironmentValue({ keys: BuildInfoEnvironmentKeys.COMMIT })?.slice(\n 0,\n COMMIT_LENGTH,\n ) ??\n gitCommit ??\n unspecified,\n branch:\n this.resolveEnvironmentValue({ keys: BuildInfoEnvironmentKeys.BRANCH }) ??\n gitBranch ??\n unspecified,\n builtAt:\n this.resolveEnvironmentValue({ keys: BuildInfoEnvironmentKeys.BUILT_AT }) ??\n new Date().toISOString(),\n };\n }\n\n private resolveEnvironmentValue(opts: { keys: readonly string[] }): string | undefined {\n for (const key of opts.keys) {\n const value = process.env[key];\n if (value !== undefined && value.trim().length > 0) {\n return value.trim();\n }\n }\n\n return undefined;\n }\n\n /**\n * `nothrow()` covers a nonzero exit; the `catch` covers `git` being absent and also `Bun` being\n * absent - under plain Node the `ReferenceError` degrades the field instead of killing the build.\n */\n private async resolveGitValue(opts: {\n args: string[];\n root: string;\n }): Promise<string | undefined> {\n const { args, root } = opts;\n\n try {\n const result = await Bun.$`git ${args}`.cwd(root).quiet().nothrow();\n // `rev-parse --abbrev-ref HEAD` in a repository with no commit prints the literal `HEAD` on\n // stdout while exiting 128, so the exit code decides and stdout alone never does.\n if (result.exitCode !== 0) {\n this.logger.debug(\n 'git %s | exit: %d | %s',\n args.join(' '),\n result.exitCode,\n result.stderr.toString().trim(),\n );\n return undefined;\n }\n\n const value = result.stdout.toString().trim();\n return value.length > 0 ? value : undefined;\n } catch (error) {\n this.logger.debug('git %s | unavailable: %s', args.join(' '), error);\n return undefined;\n }\n }\n\n /** `JSON.parse` promises nothing about the shape, so a manifest holding `{ \"name\": 42 }` must not become a numeric `service`. */\n private resolveManifest(opts: { root: string }): { name?: string; version?: string } {\n const manifest = resolve(opts.root, 'package.json');\n if (!existsSync(manifest)) {\n this.logger.debug('No package.json at %s', opts.root);\n return {};\n }\n\n try {\n const parsed: unknown = JSON.parse(readFileSync(manifest, 'utf8'));\n if (typeof parsed !== 'object' || parsed === null) {\n return {};\n }\n\n const name = 'name' in parsed ? parsed.name : undefined;\n const version = 'version' in parsed ? parsed.version : undefined;\n\n return {\n name: typeof name === 'string' ? name : undefined,\n version: typeof version === 'string' ? version : undefined,\n };\n } catch (error) {\n this.logger.debug('Unreadable package.json at %s | %s', manifest, error);\n return {};\n }\n }\n}\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The build stamp, decided where it is cheap: a compile bakes it into the binary, a run from
|
|
3
|
-
* source resolves it from git when the application starts.
|
|
4
|
-
*
|
|
5
|
-
* `define()` is for the compile script, `register()` for the entrypoint. A binary that carries the
|
|
6
|
-
* stamp never runs git; the resolver is the only code here, and it needs no TypeScript scanner.
|
|
7
|
-
*/
|
|
8
|
-
export declare class BuildInfoStamp {
|
|
9
|
-
/** The identifier `define()` replaces in the bundle and `register()` reads. */
|
|
10
|
-
static readonly GLOBAL_NAME = "IGNIS_BUILD_INFO";
|
|
11
|
-
/** The `define` record for a compile: resolves the stamp now and returns it under {@link BuildInfoStamp.GLOBAL_NAME}. */
|
|
12
|
-
static define(opts?: {
|
|
13
|
-
root?: string;
|
|
14
|
-
}): Promise<Record<string, string>>;
|
|
15
|
-
/**
|
|
16
|
-
* Registers the stamp in {@link BuildInfoRegistry}: the baked value when the compile defined it,
|
|
17
|
-
* else the resolver's. Only `commit`, `branch` and `builtAt` are set - `service` and `version`
|
|
18
|
-
* stay with the application's `getAppInfo()`, which the health reporter reads when they are absent.
|
|
19
|
-
*/
|
|
20
|
-
static register(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=stamp.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stamp.d.ts","sourceRoot":"","sources":["../../../src/build-info/stamp.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,qBAAa,cAAc;IACzB,+EAA+E;IAC/E,MAAM,CAAC,QAAQ,CAAC,WAAW,sBAAsB;IAEjD,yHAAyH;WAC5G,MAAM,CAAC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAK9E;;;;OAIG;WACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAUvC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BuildInfoStamp = void 0;
|
|
4
|
-
const core_1 = require("@venizia/ignis-helpers/core");
|
|
5
|
-
const resolver_1 = require("./resolver");
|
|
6
|
-
/**
|
|
7
|
-
* The build stamp, decided where it is cheap: a compile bakes it into the binary, a run from
|
|
8
|
-
* source resolves it from git when the application starts.
|
|
9
|
-
*
|
|
10
|
-
* `define()` is for the compile script, `register()` for the entrypoint. A binary that carries the
|
|
11
|
-
* stamp never runs git; the resolver is the only code here, and it needs no TypeScript scanner.
|
|
12
|
-
*/
|
|
13
|
-
class BuildInfoStamp {
|
|
14
|
-
/** The identifier `define()` replaces in the bundle and `register()` reads. */
|
|
15
|
-
static { this.GLOBAL_NAME = 'IGNIS_BUILD_INFO'; }
|
|
16
|
-
/** The `define` record for a compile: resolves the stamp now and returns it under {@link BuildInfoStamp.GLOBAL_NAME}. */
|
|
17
|
-
static async define(opts) {
|
|
18
|
-
const stamp = await resolver_1.BuildInfoResolver.getInstance().resolve(opts);
|
|
19
|
-
return { [BuildInfoStamp.GLOBAL_NAME]: JSON.stringify(stamp) };
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Registers the stamp in {@link BuildInfoRegistry}: the baked value when the compile defined it,
|
|
23
|
-
* else the resolver's. Only `commit`, `branch` and `builtAt` are set - `service` and `version`
|
|
24
|
-
* stay with the application's `getAppInfo()`, which the health reporter reads when they are absent.
|
|
25
|
-
*/
|
|
26
|
-
static async register() {
|
|
27
|
-
const stamp = typeof IGNIS_BUILD_INFO !== 'undefined'
|
|
28
|
-
? IGNIS_BUILD_INFO
|
|
29
|
-
: await resolver_1.BuildInfoResolver.getInstance().resolve();
|
|
30
|
-
core_1.BuildInfoRegistry.set({
|
|
31
|
-
buildInfo: { commit: stamp.commit, branch: stamp.branch, builtAt: stamp.builtAt },
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.BuildInfoStamp = BuildInfoStamp;
|
|
36
|
-
//# sourceMappingURL=stamp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stamp.js","sourceRoot":"","sources":["../../../src/build-info/stamp.ts"],"names":[],"mappings":";;;AAAA,sDAAuF;AACvF,yCAA+C;AAM/C;;;;;;GAMG;AACH,MAAa,cAAc;IACzB,+EAA+E;aAC/D,gBAAW,GAAG,kBAAkB,CAAC;IAEjD,yHAAyH;IACzH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAwB;QAC1C,MAAM,KAAK,GAAG,MAAM,4BAAiB,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClE,OAAO,EAAE,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ;QACnB,MAAM,KAAK,GACT,OAAO,gBAAgB,KAAK,WAAW;YACrC,CAAC,CAAC,gBAAgB;YAClB,CAAC,CAAC,MAAM,4BAAiB,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;QAEtD,wBAAiB,CAAC,GAAG,CAAC;YACpB,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;SAClF,CAAC,CAAC;IACL,CAAC;;AAxBH,wCAyBC","sourcesContent":["import { BuildInfoRegistry, type TBuildInfoRecord } from '@venizia/ignis-helpers/core';\nimport { BuildInfoResolver } from './resolver';\n\n// A compile bakes the stamp in under this name (`define`); a run from source has no such name.\n// The identifier below must spell the same as `BuildInfoStamp.GLOBAL_NAME`.\ndeclare const IGNIS_BUILD_INFO: TBuildInfoRecord | undefined;\n\n/**\n * The build stamp, decided where it is cheap: a compile bakes it into the binary, a run from\n * source resolves it from git when the application starts.\n *\n * `define()` is for the compile script, `register()` for the entrypoint. A binary that carries the\n * stamp never runs git; the resolver is the only code here, and it needs no TypeScript scanner.\n */\nexport class BuildInfoStamp {\n /** The identifier `define()` replaces in the bundle and `register()` reads. */\n static readonly GLOBAL_NAME = 'IGNIS_BUILD_INFO';\n\n /** The `define` record for a compile: resolves the stamp now and returns it under {@link BuildInfoStamp.GLOBAL_NAME}. */\n static async define(opts?: { root?: string }): Promise<Record<string, string>> {\n const stamp = await BuildInfoResolver.getInstance().resolve(opts);\n return { [BuildInfoStamp.GLOBAL_NAME]: JSON.stringify(stamp) };\n }\n\n /**\n * Registers the stamp in {@link BuildInfoRegistry}: the baked value when the compile defined it,\n * else the resolver's. Only `commit`, `branch` and `builtAt` are set - `service` and `version`\n * stay with the application's `getAppInfo()`, which the health reporter reads when they are absent.\n */\n static async register(): Promise<void> {\n const stamp =\n typeof IGNIS_BUILD_INFO !== 'undefined'\n ? IGNIS_BUILD_INFO\n : await BuildInfoResolver.getInstance().resolve();\n\n BuildInfoRegistry.set({\n buildInfo: { commit: stamp.commit, branch: stamp.branch, builtAt: stamp.builtAt },\n });\n }\n}\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { TGeneratedArtifactIndex } from '../generator';
|
|
2
|
-
/** The application's own artifacts as the kernel's group protocol (`isArtifactGroup`), built without depending on the kernel: inlined `content` in a binary, `resolve()` from source. Reading a kind throws, so a function that walks `configs.artifacts` cannot drop it as an empty index. */
|
|
3
|
-
export declare class AutoArtifactGroup {
|
|
4
|
-
readonly isArtifactGroup: true;
|
|
5
|
-
readonly folder: undefined;
|
|
6
|
-
readonly site: undefined;
|
|
7
|
-
readonly content: TGeneratedArtifactIndex | undefined;
|
|
8
|
-
private readonly resolver;
|
|
9
|
-
constructor(opts: {
|
|
10
|
-
content?: TGeneratedArtifactIndex;
|
|
11
|
-
resolve?: () => Promise<TGeneratedArtifactIndex>;
|
|
12
|
-
});
|
|
13
|
-
resolve(): Promise<TGeneratedArtifactIndex>;
|
|
14
|
-
private static unreadKind;
|
|
15
|
-
get configurations(): never;
|
|
16
|
-
get dataSources(): never;
|
|
17
|
-
get components(): never;
|
|
18
|
-
get repositories(): never;
|
|
19
|
-
get services(): never;
|
|
20
|
-
get controllers(): never;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=auto-group.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-group.d.ts","sourceRoot":"","sources":["../../../src/bun/auto-group.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D,+RAA+R;AAC/R,qBAAa,iBAAiB;IAC5B,QAAQ,CAAC,eAAe,EAAG,IAAI,CAAU;IACzC,QAAQ,CAAC,MAAM,YAAa;IAC5B,QAAQ,CAAC,IAAI,YAAa;IAC1B,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,SAAS,CAAC;IACtD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuD;gBAEpE,IAAI,EAAE;QAChB,OAAO,CAAC,EAAE,uBAAuB,CAAC;QAClC,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,CAAC;KAClD;IAKK,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAYjD,OAAO,CAAC,MAAM,CAAC,UAAU;IAOzB,IAAI,cAAc,IAAI,KAAK,CAE1B;IAED,IAAI,WAAW,IAAI,KAAK,CAEvB;IAED,IAAI,UAAU,IAAI,KAAK,CAEtB;IAED,IAAI,YAAY,IAAI,KAAK,CAExB;IAED,IAAI,QAAQ,IAAI,KAAK,CAEpB;IAED,IAAI,WAAW,IAAI,KAAK,CAEvB;CACF"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AutoArtifactGroup = void 0;
|
|
4
|
-
// The inversion package, not the helpers barrel: a browser bundle reaches this module, and the barrel loads node builtins.
|
|
5
|
-
const ignis_inversion_1 = require("@venizia/ignis-inversion");
|
|
6
|
-
/** The application's own artifacts as the kernel's group protocol (`isArtifactGroup`), built without depending on the kernel: inlined `content` in a binary, `resolve()` from source. Reading a kind throws, so a function that walks `configs.artifacts` cannot drop it as an empty index. */
|
|
7
|
-
class AutoArtifactGroup {
|
|
8
|
-
constructor(opts) {
|
|
9
|
-
this.isArtifactGroup = true;
|
|
10
|
-
this.folder = undefined;
|
|
11
|
-
this.site = undefined;
|
|
12
|
-
this.content = opts.content;
|
|
13
|
-
this.resolver = opts.resolve;
|
|
14
|
-
}
|
|
15
|
-
async resolve() {
|
|
16
|
-
if (this.content) {
|
|
17
|
-
return this.content;
|
|
18
|
-
}
|
|
19
|
-
if (!this.resolver) {
|
|
20
|
-
throw (0, ignis_inversion_1.getError)({
|
|
21
|
-
message: '[@venizia/ignis-boot/auto] The auto group has neither content nor a resolver',
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return this.resolver();
|
|
25
|
-
}
|
|
26
|
-
static unreadKind() {
|
|
27
|
-
throw (0, ignis_inversion_1.getError)({
|
|
28
|
-
message: '[@venizia/ignis-boot/auto] The application artifacts are resolved when artifacts are registered | A function that walks configs.artifacts must pass a group through untouched (check `isArtifactGroup`) instead of reading its kinds',
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
get configurations() {
|
|
32
|
-
return AutoArtifactGroup.unreadKind();
|
|
33
|
-
}
|
|
34
|
-
get dataSources() {
|
|
35
|
-
return AutoArtifactGroup.unreadKind();
|
|
36
|
-
}
|
|
37
|
-
get components() {
|
|
38
|
-
return AutoArtifactGroup.unreadKind();
|
|
39
|
-
}
|
|
40
|
-
get repositories() {
|
|
41
|
-
return AutoArtifactGroup.unreadKind();
|
|
42
|
-
}
|
|
43
|
-
get services() {
|
|
44
|
-
return AutoArtifactGroup.unreadKind();
|
|
45
|
-
}
|
|
46
|
-
get controllers() {
|
|
47
|
-
return AutoArtifactGroup.unreadKind();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.AutoArtifactGroup = AutoArtifactGroup;
|
|
51
|
-
//# sourceMappingURL=auto-group.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-group.js","sourceRoot":"","sources":["../../../src/bun/auto-group.ts"],"names":[],"mappings":";;;AAAA,2HAA2H;AAC3H,8DAAoD;AAGpD,+RAA+R;AAC/R,MAAa,iBAAiB;IAO5B,YAAY,IAGX;QATQ,oBAAe,GAAG,IAAa,CAAC;QAChC,WAAM,GAAG,SAAS,CAAC;QACnB,SAAI,GAAG,SAAS,CAAC;QAQxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAA,0BAAQ,EAAC;gBACb,OAAO,EAAE,8EAA8E;aACxF,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,UAAU;QACvB,MAAM,IAAA,0BAAQ,EAAC;YACb,OAAO,EACL,sOAAsO;SACzO,CAAC,CAAC;IACL,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,iBAAiB,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,WAAW;QACb,OAAO,iBAAiB,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,iBAAiB,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,YAAY;QACd,OAAO,iBAAiB,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,iBAAiB,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,WAAW;QACb,OAAO,iBAAiB,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;CACF;AAzDD,8CAyDC","sourcesContent":["// The inversion package, not the helpers barrel: a browser bundle reaches this module, and the barrel loads node builtins.\nimport { getError } from '@venizia/ignis-inversion';\nimport type { TGeneratedArtifactIndex } from '../generator';\n\n/** The application's own artifacts as the kernel's group protocol (`isArtifactGroup`), built without depending on the kernel: inlined `content` in a binary, `resolve()` from source. Reading a kind throws, so a function that walks `configs.artifacts` cannot drop it as an empty index. */\nexport class AutoArtifactGroup {\n readonly isArtifactGroup = true as const;\n readonly folder = undefined;\n readonly site = undefined;\n readonly content: TGeneratedArtifactIndex | undefined;\n private readonly resolver: (() => Promise<TGeneratedArtifactIndex>) | undefined;\n\n constructor(opts: {\n content?: TGeneratedArtifactIndex;\n resolve?: () => Promise<TGeneratedArtifactIndex>;\n }) {\n this.content = opts.content;\n this.resolver = opts.resolve;\n }\n\n async resolve(): Promise<TGeneratedArtifactIndex> {\n if (this.content) {\n return this.content;\n }\n if (!this.resolver) {\n throw getError({\n message: '[@venizia/ignis-boot/auto] The auto group has neither content nor a resolver',\n });\n }\n return this.resolver();\n }\n\n private static unreadKind(): never {\n throw getError({\n message:\n '[@venizia/ignis-boot/auto] The application artifacts are resolved when artifacts are registered | A function that walks configs.artifacts must pass a group through untouched (check `isArtifactGroup`) instead of reading its kinds',\n });\n }\n\n get configurations(): never {\n return AutoArtifactGroup.unreadKind();\n }\n\n get dataSources(): never {\n return AutoArtifactGroup.unreadKind();\n }\n\n get components(): never {\n return AutoArtifactGroup.unreadKind();\n }\n\n get repositories(): never {\n return AutoArtifactGroup.unreadKind();\n }\n\n get services(): never {\n return AutoArtifactGroup.unreadKind();\n }\n\n get controllers(): never {\n return AutoArtifactGroup.unreadKind();\n }\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type IScannedArtifact, type TGeneratedArtifactIndex } from '../generator/common';
|
|
2
|
-
/** Loads the application's index for `@venizia/ignis-boot/auto` from source: registers the run-time plugin, then imports the virtual module. A binary never runs this - the build replaces the module. */
|
|
3
|
-
export declare class AutoArtifactsLoader {
|
|
4
|
-
static assertRuntime(opts: {
|
|
5
|
-
hasBun: boolean;
|
|
6
|
-
}): void;
|
|
7
|
-
static load(): Promise<TGeneratedArtifactIndex>;
|
|
8
|
-
/** The index the emitter would render for `artifacts`: modules imported in path order, each field sorted by class name. */
|
|
9
|
-
static importIndex(opts: {
|
|
10
|
-
artifacts: IScannedArtifact[];
|
|
11
|
-
}): Promise<TGeneratedArtifactIndex>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=auto-loader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-loader.d.ts","sourceRoot":"","sources":["../../../src/bun/auto-loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;AAG7B,0MAA0M;AAC1M,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;WASxC,IAAI,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAyBrD,2HAA2H;WAC9G,WAAW,CAAC,IAAI,EAAE;QAC7B,SAAS,EAAE,gBAAgB,EAAE,CAAC;KAC/B,GAAG,OAAO,CAAC,uBAAuB,CAAC;CA2BrC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AutoArtifactsLoader = void 0;
|
|
4
|
-
const ignis_helpers_1 = require("@venizia/ignis-helpers");
|
|
5
|
-
const node_path_1 = require("node:path");
|
|
6
|
-
const common_1 = require("../generator/common");
|
|
7
|
-
const sources_1 = require("./sources");
|
|
8
|
-
/** Loads the application's index for `@venizia/ignis-boot/auto` from source: registers the run-time plugin, then imports the virtual module. A binary never runs this - the build replaces the module. */
|
|
9
|
-
class AutoArtifactsLoader {
|
|
10
|
-
static assertRuntime(opts) {
|
|
11
|
-
if (!opts.hasBun) {
|
|
12
|
-
throw (0, ignis_helpers_1.getError)({
|
|
13
|
-
message: '[@venizia/ignis-boot/auto] Auto artifacts need Bun (a Bun plugin builds the index) | On Node, generate the index with `ignis-artifacts generate --root src --out src/_artifacts.ts` and pass it to configs.artifacts',
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
static async load() {
|
|
18
|
-
AutoArtifactsLoader.assertRuntime({ hasBun: typeof Bun !== 'undefined' });
|
|
19
|
-
// A warm scan cache needs neither the plugin nor TypeScript: import the listed classes directly.
|
|
20
|
-
const entry = sources_1.ArtifactSources.entry();
|
|
21
|
-
const packageSource = sources_1.ArtifactSources.packageSource({
|
|
22
|
-
from: entry ? (0, node_path_1.dirname)(entry) : process.cwd(),
|
|
23
|
-
});
|
|
24
|
-
if (sources_1.ArtifactSources.isCached({ packageSource })) {
|
|
25
|
-
const artifacts = sources_1.ArtifactSources.scan({ packageSource });
|
|
26
|
-
return AutoArtifactsLoader.importIndex({
|
|
27
|
-
artifacts: entry ? sources_1.ArtifactSources.runningArtifacts({ artifacts, from: entry }) : artifacts,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
// A non-static specifier: a bundler must not pull the scanner (and TypeScript) into a binary.
|
|
31
|
-
const pluginModule = './plugin';
|
|
32
|
-
const { IgnisArtifactsPlugin } = await import(pluginModule);
|
|
33
|
-
await IgnisArtifactsPlugin.registerRuntime();
|
|
34
|
-
// A static specifier on purpose: a build without IgnisArtifactsPlugin then fails to resolve it, instead of shipping a binary with no classes.
|
|
35
|
-
const { GeneratedArtifacts } = await import('ignis:artifacts');
|
|
36
|
-
return GeneratedArtifacts;
|
|
37
|
-
}
|
|
38
|
-
/** The index the emitter would render for `artifacts`: modules imported in path order, each field sorted by class name. */
|
|
39
|
-
static async importIndex(opts) {
|
|
40
|
-
const emitted = opts.artifacts
|
|
41
|
-
.filter((artifact) => artifact.type !== common_1.ArtifactTypes.MODEL)
|
|
42
|
-
.sort((left, right) => left.filePath.localeCompare(right.filePath) ||
|
|
43
|
-
left.className.localeCompare(right.className));
|
|
44
|
-
const loaded = new Map();
|
|
45
|
-
for (const artifact of emitted) {
|
|
46
|
-
const module = await import(artifact.filePath);
|
|
47
|
-
loaded.set(artifact, module[artifact.className]);
|
|
48
|
-
}
|
|
49
|
-
const index = {};
|
|
50
|
-
for (const { type, field } of common_1.ArtifactStereotypes.EMIT_ORDER) {
|
|
51
|
-
const classes = emitted
|
|
52
|
-
.filter((artifact) => artifact.type === type)
|
|
53
|
-
.sort((left, right) => left.className.localeCompare(right.className))
|
|
54
|
-
.flatMap((artifact) => loaded.get(artifact) ?? []);
|
|
55
|
-
if (classes.length > 0) {
|
|
56
|
-
index[field] = classes;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return index;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.AutoArtifactsLoader = AutoArtifactsLoader;
|
|
63
|
-
//# sourceMappingURL=auto-loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-loader.js","sourceRoot":"","sources":["../../../src/bun/auto-loader.ts"],"names":[],"mappings":";;;AAAA,0DAAkD;AAElD,yC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EAAE,CAAC,CAAC;YACrD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;YACzB,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAjED,kDAiEC","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport type { AnyType, TClass } from '@venizia/ignis-helpers';\nimport { dirname } from 'node:path';\nimport {\n ArtifactStereotypes,\n ArtifactTypes,\n type IScannedArtifact,\n type TGeneratedArtifactIndex,\n} from '../generator/common';\nimport { ArtifactSources } from './sources';\n\n/** Loads the application's index for `@venizia/ignis-boot/auto` from source: registers the run-time plugin, then imports the virtual module. A binary never runs this - the build replaces the module. */\nexport class AutoArtifactsLoader {\n static assertRuntime(opts: { hasBun: boolean }): void {\n if (!opts.hasBun) {\n throw getError({\n message:\n '[@venizia/ignis-boot/auto] Auto artifacts need Bun (a Bun plugin builds the index) | On Node, generate the index with `ignis-artifacts generate --root src --out src/_artifacts.ts` and pass it to configs.artifacts',\n });\n }\n }\n\n static async load(): Promise<TGeneratedArtifactIndex> {\n AutoArtifactsLoader.assertRuntime({ hasBun: typeof Bun !== 'undefined' });\n\n // A warm scan cache needs neither the plugin nor TypeScript: import the listed classes directly.\n const entry = ArtifactSources.entry();\n const packageSource = ArtifactSources.packageSource({\n from: entry ? dirname(entry) : process.cwd(),\n });\n if (ArtifactSources.isCached({ packageSource })) {\n const artifacts = ArtifactSources.scan({ packageSource });\n return AutoArtifactsLoader.importIndex({\n artifacts: entry ? ArtifactSources.runningArtifacts({ artifacts, from: entry }) : artifacts,\n });\n }\n\n // A non-static specifier: a bundler must not pull the scanner (and TypeScript) into a binary.\n const pluginModule = './plugin';\n const { IgnisArtifactsPlugin } = await import(pluginModule);\n await IgnisArtifactsPlugin.registerRuntime();\n\n // A static specifier on purpose: a build without IgnisArtifactsPlugin then fails to resolve it, instead of shipping a binary with no classes.\n const { GeneratedArtifacts } = await import('ignis:artifacts');\n return GeneratedArtifacts;\n }\n\n /** The index the emitter would render for `artifacts`: modules imported in path order, each field sorted by class name. */\n static async importIndex(opts: {\n artifacts: IScannedArtifact[];\n }): Promise<TGeneratedArtifactIndex> {\n const emitted = opts.artifacts\n .filter((artifact) => artifact.type !== ArtifactTypes.MODEL)\n .sort(\n (left, right) =>\n left.filePath.localeCompare(right.filePath) ||\n left.className.localeCompare(right.className),\n );\n\n const loaded = new Map<IScannedArtifact, TClass<AnyType>>();\n for (const artifact of emitted) {\n const module = await import(artifact.filePath);\n loaded.set(artifact, module[artifact.className]);\n }\n\n const index: Record<string, Array<TClass<AnyType>>> = {};\n for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {\n const classes = emitted\n .filter((artifact) => artifact.type === type)\n .sort((left, right) => left.className.localeCompare(right.className))\n .flatMap((artifact) => loaded.get(artifact) ?? []);\n if (classes.length > 0) {\n index[field] = classes;\n }\n }\n return index;\n }\n}\n"]}
|
package/dist/cjs/bun/auto.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { AutoArtifactGroup } from './auto-group';
|
|
2
|
-
/** The application's own decorated classes, found by the scanner - pass it in `configs.artifacts`. From source the run-time plugin builds the index when artifacts are registered; in a binary built with `IgnisArtifactsPlugin` this module is replaced by one carrying the built index. */
|
|
3
|
-
declare const AutoArtifacts: AutoArtifactGroup;
|
|
4
|
-
export default AutoArtifacts;
|
|
5
|
-
//# sourceMappingURL=auto.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto.d.ts","sourceRoot":"","sources":["../../../src/bun/auto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOjD,6RAA6R;AAC7R,QAAA,MAAM,aAAa,mBAAuE,CAAC;AAE3F,eAAe,aAAa,CAAC"}
|
package/dist/cjs/bun/auto.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const auto_group_1 = require("./auto-group");
|
|
4
|
-
const auto_loader_1 = require("./auto-loader");
|
|
5
|
-
const group_resolver_1 = require("./group-resolver");
|
|
6
|
-
// Groups a shared package defined without content resolve from source through this resolver.
|
|
7
|
-
group_resolver_1.GroupArtifactsResolver.install();
|
|
8
|
-
/** The application's own decorated classes, found by the scanner - pass it in `configs.artifacts`. From source the run-time plugin builds the index when artifacts are registered; in a binary built with `IgnisArtifactsPlugin` this module is replaced by one carrying the built index. */
|
|
9
|
-
const AutoArtifacts = new auto_group_1.AutoArtifactGroup({ resolve: () => auto_loader_1.AutoArtifactsLoader.load() });
|
|
10
|
-
exports.default = AutoArtifacts;
|
|
11
|
-
//# sourceMappingURL=auto.js.map
|
package/dist/cjs/bun/auto.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto.js","sourceRoot":"","sources":["../../../src/bun/auto.ts"],"names":[],"mappings":";;AAAA,6CAAiD;AACjD,+CAAoD;AACpD,qDAA0D;AAE1D,6FAA6F;AAC7F,uCAAsB,CAAC,OAAO,EAAE,CAAC;AAEjC,6RAA6R;AAC7R,MAAM,aAAa,GAAG,IAAI,8BAAiB,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,iCAAmB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAE3F,kBAAe,aAAa,CAAC","sourcesContent":["import { AutoArtifactGroup } from './auto-group';\nimport { AutoArtifactsLoader } from './auto-loader';\nimport { GroupArtifactsResolver } from './group-resolver';\n\n// Groups a shared package defined without content resolve from source through this resolver.\nGroupArtifactsResolver.install();\n\n/** The application's own decorated classes, found by the scanner - pass it in `configs.artifacts`. From source the run-time plugin builds the index when artifacts are registered; in a binary built with `IgnisArtifactsPlugin` this module is replaced by one carrying the built index. */\nconst AutoArtifacts = new AutoArtifactGroup({ resolve: () => AutoArtifactsLoader.load() });\n\nexport default AutoArtifacts;\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type TGeneratedArtifactIndex } from '../generator/common';
|
|
2
|
-
/** Fills an `ArtifactGroup` defined without content, from source: the defining package is the nearest `package.json` above the group's call site, and the group is every decorated class under a directory named `folder` in its `src`. */
|
|
3
|
-
export declare class GroupArtifactsResolver {
|
|
4
|
-
/** The kernel's `SingletonRealm` slot for the group resolver (`ArtifactGroup.SINGLETON_REALM_KEY`). */
|
|
5
|
-
static readonly REALM_SLOT: unique symbol;
|
|
6
|
-
static resolve(opts: {
|
|
7
|
-
group: {
|
|
8
|
-
folder: string | undefined;
|
|
9
|
-
site: string | undefined;
|
|
10
|
-
ignore?: ReadonlyArray<string>;
|
|
11
|
-
};
|
|
12
|
-
}): Promise<TGeneratedArtifactIndex>;
|
|
13
|
-
/** Fills the kernel's realm slot; the holder may already exist (the kernel created it empty), so it is mutated, never replaced. */
|
|
14
|
-
static install(): void;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=group-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"group-resolver.d.ts","sourceRoot":"","sources":["../../../src/bun/group-resolver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAIxF,2OAA2O;AAC3O,qBAAa,sBAAsB;IACjC,uGAAuG;IACvG,MAAM,CAAC,QAAQ,CAAC,UAAU,gBAA+D;WAE5E,OAAO,CAAC,IAAI,EAAE;QACzB,KAAK,EAAE;YACL,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;YAC3B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;YACzB,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;SAChC,CAAC;KACH,GAAG,OAAO,CAAC,uBAAuB,CAAC;IA8BpC,mIAAmI;IACnI,MAAM,CAAC,OAAO,IAAI,IAAI;CAavB"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GroupArtifactsResolver = void 0;
|
|
4
|
-
const ignis_helpers_1 = require("@venizia/ignis-helpers");
|
|
5
|
-
const common_1 = require("../generator/common");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
|
-
const sources_1 = require("./sources");
|
|
8
|
-
/** Fills an `ArtifactGroup` defined without content, from source: the defining package is the nearest `package.json` above the group's call site, and the group is every decorated class under a directory named `folder` in its `src`. */
|
|
9
|
-
class GroupArtifactsResolver {
|
|
10
|
-
/** The kernel's `SingletonRealm` slot for the group resolver (`ArtifactGroup.SINGLETON_REALM_KEY`). */
|
|
11
|
-
static { this.REALM_SLOT = Symbol.for('@venizia/ignis-kernel:artifact-group-resolver'); }
|
|
12
|
-
static async resolve(opts) {
|
|
13
|
-
const { folder, site, ignore } = opts.group;
|
|
14
|
-
if (!site) {
|
|
15
|
-
throw (0, ignis_helpers_1.getError)({
|
|
16
|
-
message: `[ArtifactGroup] '${folder ?? '<application>'}' has no call site to resolve from | Define it with ArtifactGroup.define in the shared package's own source`,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
if (!sources_1.ArtifactSources.isCached({
|
|
20
|
-
packageSource: sources_1.ArtifactSources.packageSource({ from: (0, node_path_1.dirname)(site) }),
|
|
21
|
-
})) {
|
|
22
|
-
await sources_1.ArtifactSources.loadScanner();
|
|
23
|
-
}
|
|
24
|
-
const index = {};
|
|
25
|
-
for (const artifact of sources_1.ArtifactSources.folderArtifacts({ folder, site, ignore })) {
|
|
26
|
-
const field = common_1.ArtifactStereotypes.EMIT_ORDER.find((entry) => entry.type === artifact.type)?.field;
|
|
27
|
-
if (!field) {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const loaded = await import(artifact.filePath);
|
|
31
|
-
index[field] = [...(index[field] ?? []), loaded[artifact.className]];
|
|
32
|
-
}
|
|
33
|
-
return index;
|
|
34
|
-
}
|
|
35
|
-
/** Fills the kernel's realm slot; the holder may already exist (the kernel created it empty), so it is mutated, never replaced. */
|
|
36
|
-
static install() {
|
|
37
|
-
const existing = Reflect.get(globalThis, GroupArtifactsResolver.REALM_SLOT);
|
|
38
|
-
const holder = typeof existing === 'object' && existing !== null ? existing : {};
|
|
39
|
-
holder.resolve = (resolveOpts) => GroupArtifactsResolver.resolve(resolveOpts);
|
|
40
|
-
Reflect.set(globalThis, GroupArtifactsResolver.REALM_SLOT, holder);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.GroupArtifactsResolver = GroupArtifactsResolver;
|
|
44
|
-
//# sourceMappingURL=group-resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"group-resolver.js","sourceRoot":"","sources":["../../../src/bun/group-resolver.ts"],"names":[],"mappings":";;;AAAA,0DAAkD;AAElD,gDAAwF;AACxF,yCAAoC;AACpC,uCAA4C;AAE5C,2OAA2O;AAC3O,MAAa,sBAAsB;IACjC,uGAAuG;aACvF,eAAU,GAAG,MAAM,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;IAEzF,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAMpB;QACC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAA,wBAAQ,EAAC;gBACb,OAAO,EAAE,oBAAoB,MAAM,IAAI,eAAe,6GAA6G;aACpK,CAAC,CAAC;QACL,CAAC;QAED,IACE,CAAC,yBAAe,CAAC,QAAQ,CAAC;YACxB,aAAa,EAAE,yBAAe,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,IAAA,mBAAO,EAAC,IAAI,CAAC,EAAE,CAAC;SACtE,CAAC,EACF,CAAC;YACD,MAAM,yBAAe,CAAC,WAAW,EAAE,CAAC;QACtC,CAAC;QAED,MAAM,KAAK,GAA2C,EAAE,CAAC;QACzD,KAAK,MAAM,QAAQ,IAAI,yBAAe,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;YACjF,MAAM,KAAK,GAAG,4BAAmB,CAAC,UAAU,CAAC,IAAI,CAC/C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CACxC,EAAE,KAAK,CAAC;YACT,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,SAAS;YACX,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC/C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,mIAAmI;IACnI,MAAM,CAAC,OAAO;QACZ,MAAM,QAAQ,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;QACrF,MAAM,MAAM,GACV,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,MAAM,CAAC,OAAO,GAAG,CAAC,WAMjB,EAAE,EAAE,CAAC,sBAAsB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,sBAAsB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC;;AArDH,wDAsDC","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport type { AnyType, TClass } from '@venizia/ignis-helpers';\nimport { ArtifactStereotypes, type TGeneratedArtifactIndex } from '../generator/common';\nimport { dirname } from 'node:path';\nimport { ArtifactSources } from './sources';\n\n/** Fills an `ArtifactGroup` defined without content, from source: the defining package is the nearest `package.json` above the group's call site, and the group is every decorated class under a directory named `folder` in its `src`. */\nexport class GroupArtifactsResolver {\n /** The kernel's `SingletonRealm` slot for the group resolver (`ArtifactGroup.SINGLETON_REALM_KEY`). */\n static readonly REALM_SLOT = Symbol.for('@venizia/ignis-kernel:artifact-group-resolver');\n\n static async resolve(opts: {\n group: {\n folder: string | undefined;\n site: string | undefined;\n ignore?: ReadonlyArray<string>;\n };\n }): Promise<TGeneratedArtifactIndex> {\n const { folder, site, ignore } = opts.group;\n if (!site) {\n throw getError({\n message: `[ArtifactGroup] '${folder ?? '<application>'}' has no call site to resolve from | Define it with ArtifactGroup.define in the shared package's own source`,\n });\n }\n\n if (\n !ArtifactSources.isCached({\n packageSource: ArtifactSources.packageSource({ from: dirname(site) }),\n })\n ) {\n await ArtifactSources.loadScanner();\n }\n\n const index: Record<string, Array<TClass<AnyType>>> = {};\n for (const artifact of ArtifactSources.folderArtifacts({ folder, site, ignore })) {\n const field = ArtifactStereotypes.EMIT_ORDER.find(\n (entry) => entry.type === artifact.type,\n )?.field;\n if (!field) {\n continue;\n }\n const loaded = await import(artifact.filePath);\n index[field] = [...(index[field] ?? []), loaded[artifact.className]];\n }\n return index;\n }\n\n /** Fills the kernel's realm slot; the holder may already exist (the kernel created it empty), so it is mutated, never replaced. */\n static install(): void {\n const existing: unknown = Reflect.get(globalThis, GroupArtifactsResolver.REALM_SLOT);\n const holder: { resolve?: unknown } =\n typeof existing === 'object' && existing !== null ? existing : {};\n holder.resolve = (resolveOpts: {\n group: {\n folder: string | undefined;\n site: string | undefined;\n ignore?: ReadonlyArray<string>;\n };\n }) => GroupArtifactsResolver.resolve(resolveOpts);\n Reflect.set(globalThis, GroupArtifactsResolver.REALM_SLOT, holder);\n }\n}\n"]}
|
package/dist/cjs/bun/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bun/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
package/dist/cjs/bun/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./auto-group"), exports);
|
|
18
|
-
__exportStar(require("./auto-loader"), exports);
|
|
19
|
-
__exportStar(require("./group-resolver"), exports);
|
|
20
|
-
__exportStar(require("./plugin"), exports);
|
|
21
|
-
__exportStar(require("./scan-cache"), exports);
|
|
22
|
-
__exportStar(require("./sources"), exports);
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bun/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,gDAA8B;AAC9B,mDAAiC;AACjC,2CAAyB;AACzB,+CAA6B;AAC7B,4CAA0B","sourcesContent":["export * from './auto-group';\nexport * from './auto-loader';\nexport * from './group-resolver';\nexport * from './plugin';\nexport * from './scan-cache';\nexport * from './sources';\n"]}
|