@venizia/ignis-boot 0.2.0-3 → 0.2.0-31
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/README.md +127 -151
- package/dist/cjs/build-info/common/constants.d.ts +20 -0
- package/dist/cjs/build-info/common/constants.d.ts.map +1 -0
- package/dist/cjs/build-info/common/constants.js +41 -0
- package/dist/cjs/build-info/common/constants.js.map +1 -0
- package/dist/{esm → cjs/build-info}/common/index.d.ts +1 -1
- package/dist/cjs/build-info/common/index.d.ts.map +1 -0
- package/dist/cjs/{common → build-info/common}/index.js +1 -1
- package/dist/cjs/build-info/common/index.js.map +1 -0
- package/dist/cjs/build-info/common/types.d.ts +16 -0
- package/dist/cjs/build-info/common/types.d.ts.map +1 -0
- package/dist/cjs/build-info/common/types.js +3 -0
- package/dist/cjs/build-info/common/types.js.map +1 -0
- package/dist/cjs/build-info/emitter.d.ts +12 -0
- package/dist/cjs/build-info/emitter.d.ts.map +1 -0
- package/dist/cjs/build-info/emitter.js +26 -0
- package/dist/cjs/build-info/emitter.js.map +1 -0
- package/dist/cjs/build-info/index.d.ts +10 -0
- package/dist/cjs/build-info/index.d.ts.map +1 -0
- package/dist/cjs/build-info/index.js +43 -0
- package/dist/cjs/build-info/index.js.map +1 -0
- package/dist/cjs/build-info/resolver.d.ts +25 -0
- package/dist/cjs/build-info/resolver.d.ts.map +1 -0
- package/dist/cjs/build-info/resolver.js +105 -0
- package/dist/cjs/build-info/resolver.js.map +1 -0
- package/dist/cjs/clis/artifacts.d.ts +3 -0
- package/dist/cjs/clis/artifacts.d.ts.map +1 -0
- package/dist/cjs/clis/artifacts.js +60 -0
- package/dist/cjs/clis/artifacts.js.map +1 -0
- package/dist/cjs/clis/build-info.d.ts +3 -0
- package/dist/cjs/clis/build-info.d.ts.map +1 -0
- package/dist/cjs/clis/build-info.js +48 -0
- package/dist/cjs/clis/build-info.js.map +1 -0
- package/dist/cjs/common/install-quiet-logger.d.ts +2 -0
- package/dist/cjs/common/install-quiet-logger.d.ts.map +1 -0
- package/dist/cjs/common/install-quiet-logger.js +7 -0
- package/dist/cjs/common/install-quiet-logger.js.map +1 -0
- package/dist/cjs/common/quiet-logger.d.ts +18 -0
- package/dist/cjs/common/quiet-logger.d.ts.map +1 -0
- package/dist/cjs/common/quiet-logger.js +46 -0
- package/dist/cjs/common/quiet-logger.js.map +1 -0
- package/dist/cjs/generator/common/constants.d.ts +46 -0
- package/dist/cjs/generator/common/constants.d.ts.map +1 -0
- package/dist/cjs/generator/common/constants.js +87 -0
- package/dist/cjs/generator/common/constants.js.map +1 -0
- package/dist/cjs/{common → generator/common}/index.d.ts +1 -1
- package/dist/cjs/generator/common/index.d.ts.map +1 -0
- package/dist/cjs/{base → generator/common}/index.js +2 -1
- package/dist/cjs/generator/common/index.js.map +1 -0
- package/dist/cjs/generator/common/types.d.ts +18 -0
- package/dist/cjs/generator/common/types.d.ts.map +1 -0
- package/dist/cjs/generator/common/types.js +3 -0
- package/dist/cjs/generator/common/types.js.map +1 -0
- package/dist/cjs/generator/emitter.d.ts +29 -0
- package/dist/cjs/generator/emitter.d.ts.map +1 -0
- package/dist/cjs/generator/emitter.js +65 -0
- package/dist/cjs/generator/emitter.js.map +1 -0
- package/dist/cjs/generator/index.d.ts +24 -0
- package/dist/cjs/generator/index.d.ts.map +1 -0
- package/dist/cjs/generator/index.js +62 -0
- package/dist/cjs/generator/index.js.map +1 -0
- package/dist/cjs/generator/scanner.d.ts +24 -0
- package/dist/cjs/generator/scanner.d.ts.map +1 -0
- package/dist/cjs/generator/scanner.js +199 -0
- package/dist/cjs/generator/scanner.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -6
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +2 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/build-info/common/constants.d.ts +20 -0
- package/dist/esm/build-info/common/constants.d.ts.map +1 -0
- package/dist/esm/build-info/common/constants.js +36 -0
- package/dist/esm/build-info/common/constants.js.map +1 -0
- package/dist/esm/build-info/common/index.d.ts +3 -0
- package/dist/esm/build-info/common/index.d.ts.map +1 -0
- package/dist/esm/{common → build-info/common}/index.js +1 -1
- package/dist/esm/build-info/common/index.js.map +1 -0
- package/dist/esm/build-info/common/types.d.ts +16 -0
- package/dist/esm/build-info/common/types.d.ts.map +1 -0
- package/dist/esm/build-info/common/types.js +2 -0
- package/dist/esm/build-info/common/types.js.map +1 -0
- package/dist/esm/build-info/emitter.d.ts +12 -0
- package/dist/esm/build-info/emitter.d.ts.map +1 -0
- package/dist/esm/build-info/emitter.js +22 -0
- package/dist/esm/build-info/emitter.js.map +1 -0
- package/dist/esm/build-info/index.d.ts +10 -0
- package/dist/esm/build-info/index.d.ts.map +1 -0
- package/dist/esm/build-info/index.js +25 -0
- package/dist/esm/build-info/index.js.map +1 -0
- package/dist/esm/build-info/resolver.d.ts +25 -0
- package/dist/esm/build-info/resolver.d.ts.map +1 -0
- package/dist/esm/build-info/resolver.js +101 -0
- package/dist/esm/build-info/resolver.js.map +1 -0
- package/dist/esm/clis/artifacts.d.ts +3 -0
- package/dist/esm/clis/artifacts.d.ts.map +1 -0
- package/dist/esm/clis/artifacts.js +58 -0
- package/dist/esm/clis/artifacts.js.map +1 -0
- package/dist/esm/clis/build-info.d.ts +3 -0
- package/dist/esm/clis/build-info.d.ts.map +1 -0
- package/dist/esm/clis/build-info.js +46 -0
- package/dist/esm/clis/build-info.js.map +1 -0
- package/dist/esm/common/install-quiet-logger.d.ts +2 -0
- package/dist/esm/common/install-quiet-logger.d.ts.map +1 -0
- package/dist/esm/common/install-quiet-logger.js +5 -0
- package/dist/esm/common/install-quiet-logger.js.map +1 -0
- package/dist/esm/common/quiet-logger.d.ts +18 -0
- package/dist/esm/common/quiet-logger.d.ts.map +1 -0
- package/dist/esm/common/quiet-logger.js +42 -0
- package/dist/esm/common/quiet-logger.js.map +1 -0
- package/dist/esm/generator/common/constants.d.ts +46 -0
- package/dist/esm/generator/common/constants.d.ts.map +1 -0
- package/dist/esm/generator/common/constants.js +81 -0
- package/dist/esm/generator/common/constants.js.map +1 -0
- package/dist/esm/generator/common/index.d.ts +3 -0
- package/dist/esm/generator/common/index.d.ts.map +1 -0
- package/dist/esm/generator/common/index.js +3 -0
- package/dist/esm/generator/common/index.js.map +1 -0
- package/dist/esm/generator/common/types.d.ts +18 -0
- package/dist/esm/generator/common/types.d.ts.map +1 -0
- package/dist/esm/generator/common/types.js +2 -0
- package/dist/esm/generator/common/types.js.map +1 -0
- package/dist/esm/generator/emitter.d.ts +29 -0
- package/dist/esm/generator/emitter.d.ts.map +1 -0
- package/dist/esm/generator/emitter.js +61 -0
- package/dist/esm/generator/emitter.js.map +1 -0
- package/dist/esm/generator/index.d.ts +24 -0
- package/dist/esm/generator/index.d.ts.map +1 -0
- package/dist/esm/generator/index.js +43 -0
- package/dist/esm/generator/index.js.map +1 -0
- package/dist/esm/generator/scanner.d.ts +24 -0
- package/dist/esm/generator/scanner.d.ts.map +1 -0
- package/dist/esm/generator/scanner.js +192 -0
- package/dist/esm/generator/scanner.js.map +1 -0
- package/dist/esm/index.d.ts +2 -6
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -6
- package/dist/esm/index.js.map +1 -1
- package/package.json +34 -46
- package/dist/cjs/base/base-artifact-booter.d.ts +0 -18
- package/dist/cjs/base/base-artifact-booter.d.ts.map +0 -1
- package/dist/cjs/base/base-artifact-booter.js +0 -85
- package/dist/cjs/base/base-artifact-booter.js.map +0 -1
- package/dist/cjs/base/index.d.ts +0 -2
- package/dist/cjs/base/index.d.ts.map +0 -1
- package/dist/cjs/base/index.js.map +0 -1
- package/dist/cjs/boot.mixin.d.ts +0 -65
- package/dist/cjs/boot.mixin.d.ts.map +0 -1
- package/dist/cjs/boot.mixin.js +0 -29
- package/dist/cjs/boot.mixin.js.map +0 -1
- package/dist/cjs/booters/controller.booter.d.ts +0 -10
- package/dist/cjs/booters/controller.booter.d.ts.map +0 -1
- package/dist/cjs/booters/controller.booter.js +0 -45
- package/dist/cjs/booters/controller.booter.js.map +0 -1
- package/dist/cjs/booters/datasource.booter.d.ts +0 -10
- package/dist/cjs/booters/datasource.booter.d.ts.map +0 -1
- package/dist/cjs/booters/datasource.booter.js +0 -45
- package/dist/cjs/booters/datasource.booter.js.map +0 -1
- package/dist/cjs/booters/index.d.ts +0 -5
- package/dist/cjs/booters/index.d.ts.map +0 -1
- package/dist/cjs/booters/index.js +0 -21
- package/dist/cjs/booters/index.js.map +0 -1
- package/dist/cjs/booters/repository.booter.d.ts +0 -10
- package/dist/cjs/booters/repository.booter.d.ts.map +0 -1
- package/dist/cjs/booters/repository.booter.js +0 -45
- package/dist/cjs/booters/repository.booter.js.map +0 -1
- package/dist/cjs/booters/service.booter.d.ts +0 -10
- package/dist/cjs/booters/service.booter.d.ts.map +0 -1
- package/dist/cjs/booters/service.booter.js +0 -45
- package/dist/cjs/booters/service.booter.js.map +0 -1
- package/dist/cjs/bootstrapper.d.ts +0 -14
- package/dist/cjs/bootstrapper.d.ts.map +0 -1
- package/dist/cjs/bootstrapper.js +0 -121
- package/dist/cjs/bootstrapper.js.map +0 -1
- package/dist/cjs/common/constants.d.ts +0 -6
- package/dist/cjs/common/constants.d.ts.map +0 -1
- package/dist/cjs/common/constants.js +0 -10
- package/dist/cjs/common/constants.js.map +0 -1
- package/dist/cjs/common/index.d.ts.map +0 -1
- package/dist/cjs/common/index.js.map +0 -1
- package/dist/cjs/common/types.d.ts +0 -52
- package/dist/cjs/common/types.d.ts.map +0 -1
- package/dist/cjs/common/types.js +0 -5
- package/dist/cjs/common/types.js.map +0 -1
- package/dist/cjs/utilities/boot.utility.d.ts +0 -9
- package/dist/cjs/utilities/boot.utility.d.ts.map +0 -1
- package/dist/cjs/utilities/boot.utility.js +0 -51
- package/dist/cjs/utilities/boot.utility.js.map +0 -1
- package/dist/cjs/utilities/index.d.ts +0 -2
- package/dist/cjs/utilities/index.d.ts.map +0 -1
- package/dist/cjs/utilities/index.js +0 -18
- package/dist/cjs/utilities/index.js.map +0 -1
- package/dist/esm/base/base-artifact-booter.d.ts +0 -18
- package/dist/esm/base/base-artifact-booter.d.ts.map +0 -1
- package/dist/esm/base/base-artifact-booter.js +0 -81
- package/dist/esm/base/base-artifact-booter.js.map +0 -1
- package/dist/esm/base/index.d.ts +0 -2
- package/dist/esm/base/index.d.ts.map +0 -1
- package/dist/esm/base/index.js +0 -2
- package/dist/esm/base/index.js.map +0 -1
- package/dist/esm/boot.mixin.d.ts +0 -65
- package/dist/esm/boot.mixin.d.ts.map +0 -1
- package/dist/esm/boot.mixin.js +0 -25
- package/dist/esm/boot.mixin.js.map +0 -1
- package/dist/esm/booters/controller.booter.d.ts +0 -10
- package/dist/esm/booters/controller.booter.d.ts.map +0 -1
- package/dist/esm/booters/controller.booter.js +0 -42
- package/dist/esm/booters/controller.booter.js.map +0 -1
- package/dist/esm/booters/datasource.booter.d.ts +0 -10
- package/dist/esm/booters/datasource.booter.d.ts.map +0 -1
- package/dist/esm/booters/datasource.booter.js +0 -42
- package/dist/esm/booters/datasource.booter.js.map +0 -1
- package/dist/esm/booters/index.d.ts +0 -5
- package/dist/esm/booters/index.d.ts.map +0 -1
- package/dist/esm/booters/index.js +0 -5
- package/dist/esm/booters/index.js.map +0 -1
- package/dist/esm/booters/repository.booter.d.ts +0 -10
- package/dist/esm/booters/repository.booter.d.ts.map +0 -1
- package/dist/esm/booters/repository.booter.js +0 -42
- package/dist/esm/booters/repository.booter.js.map +0 -1
- package/dist/esm/booters/service.booter.d.ts +0 -10
- package/dist/esm/booters/service.booter.d.ts.map +0 -1
- package/dist/esm/booters/service.booter.js +0 -42
- package/dist/esm/booters/service.booter.js.map +0 -1
- package/dist/esm/bootstrapper.d.ts +0 -14
- package/dist/esm/bootstrapper.d.ts.map +0 -1
- package/dist/esm/bootstrapper.js +0 -118
- package/dist/esm/bootstrapper.js.map +0 -1
- package/dist/esm/common/constants.d.ts +0 -6
- package/dist/esm/common/constants.d.ts.map +0 -1
- package/dist/esm/common/constants.js +0 -6
- package/dist/esm/common/constants.js.map +0 -1
- package/dist/esm/common/index.d.ts.map +0 -1
- package/dist/esm/common/index.js.map +0 -1
- package/dist/esm/common/types.d.ts +0 -52
- package/dist/esm/common/types.d.ts.map +0 -1
- package/dist/esm/common/types.js +0 -2
- package/dist/esm/common/types.js.map +0 -1
- package/dist/esm/utilities/boot.utility.d.ts +0 -9
- package/dist/esm/utilities/boot.utility.d.ts.map +0 -1
- package/dist/esm/utilities/boot.utility.js +0 -46
- package/dist/esm/utilities/boot.utility.js.map +0 -1
- package/dist/esm/utilities/index.d.ts +0 -2
- package/dist/esm/utilities/index.d.ts.map +0 -1
- package/dist/esm/utilities/index.js +0 -2
- package/dist/esm/utilities/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,216 +4,195 @@
|
|
|
4
4
|
|
|
5
5
|
# :fire: IGNIS - `@venizia/ignis-boot`
|
|
6
6
|
|
|
7
|
-
**
|
|
7
|
+
**Generates one static registration file from your decorated classes.**
|
|
8
8
|
|
|
9
9
|
[](https://ignis.venizia.ai/references/base/bootstrapping)
|
|
10
10
|
[](https://www.npmjs.com/package/@venizia/ignis-boot)
|
|
11
11
|
[](LICENSE.md)
|
|
12
12
|
[](https://www.typescriptlang.org/)
|
|
13
13
|
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
14
|
+
[Artifact registration reference](https://ignis.venizia.ai/references/base/bootstrapping) •
|
|
15
|
+
[Registering artifacts guide](https://ignis.venizia.ai/guides/core-concepts/application/bootstrapping) •
|
|
16
|
+
[Changelog](https://ignis.venizia.ai/changelogs/2026-09-03-deprecated-boot-api-removed)
|
|
17
17
|
|
|
18
18
|
</div>
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
`ignis-artifacts` walks a source root with the TypeScript compiler API, finds every named,
|
|
23
|
+
non-abstract class that carries an IGNIS stereotype decorator (`@service`, `@controller`, ...), and
|
|
24
|
+
writes one file of plain static imports: `src/generated/artifacts.ts`. The application passes that
|
|
25
|
+
file as `configs.artifacts`; `@venizia/ignis`'s `registerArtifacts` boot step binds it.
|
|
24
26
|
|
|
25
|
-
**
|
|
26
|
-
|
|
27
|
-
write a custom booter for an artifact type of your own.
|
|
27
|
+
**This package runs at build time only.** No decorator runs and no class is imported while
|
|
28
|
+
scanning - detection reads source text, so a datasource that opens a pool at import stays inert.
|
|
28
29
|
|
|
29
30
|
## Install
|
|
30
31
|
|
|
31
32
|
```bash
|
|
32
|
-
bun add @venizia/ignis-boot
|
|
33
|
+
bun add -d @venizia/ignis-boot
|
|
33
34
|
```
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
`ignis-artifacts` runs at build time; the generated file imports nothing from this package, so a
|
|
37
|
+
deployed application installs nothing extra for it at runtime.
|
|
36
38
|
|
|
37
39
|
## Use it
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
Decorate the classes you want registered:
|
|
40
42
|
|
|
41
43
|
```typescript
|
|
42
|
-
import {
|
|
44
|
+
import { component, service } from '@venizia/ignis';
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return { name: 'my-app', version: '1.0.0', description: 'My app' };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
staticConfigure() {}
|
|
50
|
-
preConfigure() {}
|
|
51
|
-
postConfigure() {}
|
|
52
|
-
setupMiddlewares() {}
|
|
53
|
-
}
|
|
46
|
+
@service()
|
|
47
|
+
export class PricingService extends BaseService {}
|
|
54
48
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
config: {
|
|
58
|
-
host: '0.0.0.0',
|
|
59
|
-
port: 3000,
|
|
60
|
-
path: { base: '/api', isStrict: false },
|
|
61
|
-
bootOptions: {}, // the defaults cover the conventional layout
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
await application.boot(); // discover and bind every artifact
|
|
66
|
-
await application.start();
|
|
49
|
+
@component()
|
|
50
|
+
export class MetricsComponent extends BaseComponent {}
|
|
67
51
|
```
|
|
68
52
|
|
|
69
|
-
|
|
70
|
-
`services.UserService`, and `controllers.UserController` - no further code.
|
|
53
|
+
Add the generator scripts and run one:
|
|
71
54
|
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"scripts": {
|
|
58
|
+
"generate:artifacts": "ignis-artifacts generate --root src --out src/generated/artifacts.ts",
|
|
59
|
+
"check:artifacts": "ignis-artifacts check --root src --out src/generated/artifacts.ts"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
72
62
|
```
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
services/user.service.js
|
|
77
|
-
controllers/user.controller.js
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
bun run generate:artifacts
|
|
78
66
|
```
|
|
79
67
|
|
|
80
|
-
|
|
68
|
+
Pass the generated index to your application:
|
|
81
69
|
|
|
82
|
-
|
|
70
|
+
```typescript
|
|
71
|
+
import { GeneratedArtifacts } from './generated/artifacts';
|
|
83
72
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
| `ControllerBooter` | `controllers` | `.controller.js` | `controllers.<ClassName>` | `controllers` | transient |
|
|
73
|
+
export const configs: IApplicationConfigs = {
|
|
74
|
+
path: { base: '/api', isStrict: true },
|
|
75
|
+
artifacts: GeneratedArtifacts,
|
|
76
|
+
};
|
|
77
|
+
```
|
|
90
78
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
Subdirectories are included - `isNested` defaults to `true`.
|
|
79
|
+
Commit the generated file; never edit it by hand - the next `generate` overwrites it. Full
|
|
80
|
+
walkthrough: [Registering artifacts](https://ignis.venizia.ai/guides/core-concepts/application/bootstrapping).
|
|
94
81
|
|
|
95
|
-
|
|
96
|
-
always resolve the datasource it injects.
|
|
82
|
+
## CLI
|
|
97
83
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
> it is designed to run against your **compiled output**. Build first, and have `getProjectRoot()` point
|
|
101
|
-
> at the built directory - returning `__dirname` from the compiled entrypoint does exactly that. If
|
|
102
|
-
> `boot()` reports zero artifacts, this is almost always why. To boot from TypeScript sources instead,
|
|
103
|
-
> set the extensions explicitly: `{ controllers: { extensions: ['.controller.ts'] } }`.
|
|
84
|
+
Shipped as the `ignis-artifacts` binary. Requires `typescript >= 5` (peer dependency) and runs
|
|
85
|
+
under bun.
|
|
104
86
|
|
|
105
|
-
|
|
87
|
+
```
|
|
88
|
+
ignis-artifacts <generate|check> [--root src] [--out src/generated/artifacts.ts] [--ignore a,b] [--export GeneratedArtifacts]
|
|
89
|
+
```
|
|
106
90
|
|
|
107
|
-
|
|
91
|
+
| Flag | Default | Meaning |
|
|
92
|
+
| :--- | :--- | :--- |
|
|
93
|
+
| `--root` | `src` | Directory to scan, recursively |
|
|
94
|
+
| `--out` | `src/generated/artifacts.ts` | Output path; import paths are relative to it |
|
|
95
|
+
| `--ignore` | `**/__tests__/**`, `**/*.test.ts`, `**/*.spec.ts`, `**/generated/**` | Comma-separated globs, merged with the default ignore list - never replaces it |
|
|
96
|
+
| `--export` | `GeneratedArtifacts` | Name of the exported constant |
|
|
108
97
|
|
|
109
|
-
|
|
|
110
|
-
| :--- | :--- |
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
113
|
-
| `load` | `import()` each file, keep the exported classes, bind them into the container |
|
|
98
|
+
| Command | Effect | Exit code |
|
|
99
|
+
| :--- | :--- | :--- |
|
|
100
|
+
| `generate` | Writes `--out` when its content changed | `0` |
|
|
101
|
+
| `check` | Renders in memory and compares with `--out`; fails a stale index | `0` fresh, `1` stale |
|
|
114
102
|
|
|
115
|
-
|
|
116
|
-
`totalDurationMs`. A throw in any phase is rewrapped naming both the phase and the booter, with the
|
|
117
|
-
original error kept as `cause`.
|
|
103
|
+
Default ignore list: `**/__tests__/**`, `**/*.test.ts`, `**/*.spec.ts`, `**/generated/**`.
|
|
118
104
|
|
|
119
|
-
##
|
|
105
|
+
## Detection rules
|
|
120
106
|
|
|
121
|
-
|
|
107
|
+
A class is emitted when every rule holds. Every miss is logged with its reason.
|
|
122
108
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
| `glob` | `string` | Raw glob pattern; overrides the three above |
|
|
109
|
+
- Named export (`export class`), not `export default`, not module-private.
|
|
110
|
+
- Not `abstract`.
|
|
111
|
+
- Decorated with `component`, `controller`, `service`, `repository` or `datasource`, imported from
|
|
112
|
+
`@venizia/ignis` or `@venizia/ignis-kernel` (import aliases resolved) - or with
|
|
113
|
+
`injectable({ type })` where `type` is a string literal or `ArtifactTypes.<NAME>`.
|
|
129
114
|
|
|
130
|
-
|
|
131
|
-
bootOptions: {
|
|
132
|
-
controllers: { dirs: ['controllers', 'api'], extensions: ['.controller.js'] },
|
|
133
|
-
services: { glob: 'modules/**/*.service.js' },
|
|
134
|
-
}
|
|
135
|
-
```
|
|
115
|
+
`model` classes are recognised and never emitted - a model is reached through its repository.
|
|
136
116
|
|
|
137
|
-
|
|
138
|
-
treated as not provided and falls back to the default. An empty `dirs` or `extensions` array is not: it
|
|
139
|
-
throws when the pattern is built.
|
|
117
|
+
## Programmatic API
|
|
140
118
|
|
|
141
|
-
|
|
119
|
+
`@venizia/ignis-boot/generator` exports the same machinery as functions, for a caller that is not
|
|
120
|
+
a shell script.
|
|
142
121
|
|
|
143
|
-
|
|
144
|
-
|
|
122
|
+
| Export | What it is |
|
|
123
|
+
| :--- | :--- |
|
|
124
|
+
| `generateArtifactIndex(opts)` | Renders and writes `opts.out` when the content changed |
|
|
125
|
+
| `checkArtifactIndex(opts)` | Renders in memory and compares with `opts.out`, without writing |
|
|
126
|
+
| `IGenerateOptions` | `{ root, out, ignore?, exportName? }` - shared options for both |
|
|
127
|
+
| `ArtifactScanner.getInstance().scan({ root, ignore? })` | The scan step alone, as `IScannedArtifact[]` |
|
|
128
|
+
| `ArtifactIndexEmitter.render({ artifacts, outFile, exportName })` | The render step alone, as text |
|
|
129
|
+
| `ArtifactStereotypes`, `ArtifactTypes`, `ArtifactIndexFields` | The decorator-to-type map and the emitted field names |
|
|
145
130
|
|
|
146
131
|
```typescript
|
|
147
|
-
import {
|
|
148
|
-
import { BindingKeys, inject } from '@venizia/ignis-inversion';
|
|
149
|
-
|
|
150
|
-
export class ObserverBooter extends BaseArtifactBooter {
|
|
151
|
-
constructor(
|
|
152
|
-
@inject({ key: '@app/project_root' }) root: string,
|
|
153
|
-
@inject({ key: '@app/instance' }) private readonly application: IApplication,
|
|
154
|
-
@inject({ key: '@app/boot-options' }) bootOptions: IBootOptions,
|
|
155
|
-
) {
|
|
156
|
-
super({ scope: ObserverBooter.name, root, artifactOptions: bootOptions.observers ?? {} });
|
|
157
|
-
}
|
|
132
|
+
import { checkArtifactIndex } from '@venizia/ignis-boot/generator';
|
|
158
133
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
134
|
+
const { isFresh } = checkArtifactIndex({ root: 'src', out: 'src/generated/artifacts.ts' });
|
|
135
|
+
```
|
|
162
136
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
137
|
+
## `ignis-build-info` - stamp the build
|
|
138
|
+
|
|
139
|
+
A second binary in the same package. It resolves what a running service should be able to say
|
|
140
|
+
about itself - service, version, commit, branch, build time - at BUILD time, and writes it as a
|
|
141
|
+
static file the bundle bakes in. Nothing is read back at run time: a `bun build --compile` binary
|
|
142
|
+
ships no `node_modules`, no `.git` and no readable `package.json`, and a Distroless image has no
|
|
143
|
+
`git` to spawn, so a runtime resolver would report blanks in exactly the deployment that matters.
|
|
166
144
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const key = BindingKeys.build({ namespace: 'observers', key: cls.name });
|
|
170
|
-
this.application.bind({ key }).toClass(cls).setTags('observers');
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
145
|
+
```
|
|
146
|
+
ignis-build-info generate [--out src/_build_info.ts] [--root .] [--format ts|json] [--export BUILD_INFO]
|
|
174
147
|
```
|
|
175
148
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
149
|
+
| Flag | Default | Meaning |
|
|
150
|
+
| :--- | :--- | :--- |
|
|
151
|
+
| `--out` | `src/_build_info.ts` | Output path; always rewritten - `builtAt` changes every run |
|
|
152
|
+
| `--root` | `.` | Where `package.json` is read and where `git` is asked |
|
|
153
|
+
| `--format` | `ts` | `ts` - a static `export const`; `json` - the same record, for a Vite app or a Tauri shell |
|
|
154
|
+
| `--export` | `BUILD_INFO` | Name of the exported constant in `ts` format |
|
|
179
155
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this.booter(ObserverBooter);
|
|
183
|
-
return super.boot();
|
|
184
|
-
}
|
|
185
|
-
```
|
|
156
|
+
Each field is read from the environment first, then `git`, then `package.json`; anything left reads
|
|
157
|
+
`unspecified`, so a pipeline that forgot a variable is visible rather than silent.
|
|
186
158
|
|
|
187
|
-
|
|
188
|
-
|
|
159
|
+
| Field | Environment, first present wins | Fallback |
|
|
160
|
+
| :--- | :--- | :--- |
|
|
161
|
+
| `version` | `APP_ENV_BUILD_VERSION`, `APP_BUILD_VERSION`, `CI_COMMIT_TAG`, `GITHUB_REF_NAME` | `package.json#version` |
|
|
162
|
+
| `commit` | `APP_ENV_BUILD_COMMIT_TAG`, `APP_BUILD_COMMIT`, `CI_COMMIT_SHA`, `GITHUB_SHA`, `COMMIT_SHA` | `git rev-parse --short=12 HEAD` |
|
|
163
|
+
| `branch` | `APP_BUILD_BRANCH`, `CI_COMMIT_REF_NAME`, `GITHUB_REF_NAME`, `BRANCH_NAME` | `git rev-parse --abbrev-ref HEAD` |
|
|
164
|
+
| `builtAt` | `APP_ENV_BUILD_DATE`, `APP_BUILD_DATE` | the moment the generator ran |
|
|
165
|
+
| `service` | - | `package.json#name` |
|
|
189
166
|
|
|
190
|
-
|
|
167
|
+
Register the stamp once at the entrypoint, and `GET /health/stats` reports it:
|
|
191
168
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
directory is invisible to it - register that one manually with `this.controller(...)`.
|
|
196
|
-
- Calling `boot()` twice does not double-register: the bootstrapper resets its booter list on each run.
|
|
197
|
-
- `reflect-metadata` must be imported once at your entrypoint, and `experimentalDecorators` plus
|
|
198
|
-
`emitDecoratorMetadata` must be `true` **inline** in your `tsconfig.json` - Bun does not resolve them
|
|
199
|
-
through `extends`, and `@inject` is silently dropped without them.
|
|
169
|
+
```typescript
|
|
170
|
+
import { BUILD_INFO } from './_build_info';
|
|
171
|
+
import { BuildInfoRegistry } from '@venizia/ignis-helpers/core';
|
|
200
172
|
|
|
201
|
-
|
|
173
|
+
BuildInfoRegistry.set({ buildInfo: BUILD_INFO });
|
|
174
|
+
```
|
|
202
175
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
| `BootPhases` | `configure`, `discover`, `load` |
|
|
211
|
-
| `IBootOptions` / `IArtifactOptions` / `IBootReport` / `IBooter` | Public types |
|
|
176
|
+
`git` runs through Bun Shell, so the binary needs bun (it carries a `bun` shebang). Under plain
|
|
177
|
+
Node the `git` fields degrade to `unspecified` and the build still succeeds; set the variables
|
|
178
|
+
above if a Node invocation has to be exact.
|
|
179
|
+
|
|
180
|
+
Programmatic: `@venizia/ignis-boot/build-info` exports `generateBuildInfo(opts)`,
|
|
181
|
+
`BuildInfoResolver.getInstance().resolve({ root })`, `BuildInfoEmitter.render({ buildInfo, format, exportName })`,
|
|
182
|
+
`BuildInfoFormats` and `BuildInfoEnvironmentKeys`.
|
|
212
183
|
|
|
213
|
-
|
|
214
|
-
`Container`. `BaseApplication` does its own registration and does not use the mixin.
|
|
184
|
+
## What you must know
|
|
215
185
|
|
|
216
|
-
|
|
186
|
+
- **Output is deterministic.** Imports sorted by path, class names sorted within each field, one
|
|
187
|
+
field per kind, empty arrays kept. A field wider than 100 columns wraps one name per line, so the
|
|
188
|
+
file passes the repo's `prettier -l` unchanged.
|
|
189
|
+
- **The scanner never executes a module.** No decorator runs and no import side effect fires while
|
|
190
|
+
scanning, so a stereotype re-exported through a local wrapper module is not recognised - the
|
|
191
|
+
import must name an IGNIS module directly.
|
|
192
|
+
- **`check` belongs where lint runs**, not only in CI - a stale index should fail locally before a
|
|
193
|
+
push reaches the pipeline.
|
|
194
|
+
|
|
195
|
+
Full detail: [Artifact registration reference](https://ignis.venizia.ai/references/base/bootstrapping).
|
|
217
196
|
|
|
218
197
|
## Links
|
|
219
198
|
|
|
@@ -223,8 +202,5 @@ Full detail: [Bootstrapping reference](https://ignis.venizia.ai/references/base/
|
|
|
223
202
|
[Best practices](https://ignis.venizia.ai/best-practices/) •
|
|
224
203
|
[Changelog](https://ignis.venizia.ai/changelogs/)
|
|
225
204
|
|
|
226
|
-
Inspired by [LoopBack 4's boot system](https://loopback.io/doc/en/lb4/Booting-an-Application.html).
|
|
227
|
-
|
|
228
205
|
MIT licensed - see [LICENSE.md](LICENSE.md).
|
|
229
206
|
Questions: [GitHub Issues](https://github.com/VENIZIA-AI/ignis/issues) • developer@venizia.ai
|
|
230
|
-
</content>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TConstValue } from '@venizia/ignis-helpers';
|
|
2
|
+
export declare class BuildInfoFormats {
|
|
3
|
+
static readonly TS = "ts";
|
|
4
|
+
static readonly JSON = "json";
|
|
5
|
+
static readonly SCHEME_SET: Set<string>;
|
|
6
|
+
static isValid(value: string): boolean;
|
|
7
|
+
}
|
|
8
|
+
export type TBuildInfoFormat = TConstValue<typeof BuildInfoFormats>;
|
|
9
|
+
/**
|
|
10
|
+
* Each field is spelled differently by every CI provider, and `APP_ENV_*` is what this
|
|
11
|
+
* organisation's pipelines export - so it is read before the generic `APP_BUILD_*` pair and before
|
|
12
|
+
* anything provider-specific. The first key carrying a non-blank value wins.
|
|
13
|
+
*/
|
|
14
|
+
export declare class BuildInfoEnvironmentKeys {
|
|
15
|
+
static readonly VERSION: readonly string[];
|
|
16
|
+
static readonly COMMIT: readonly string[];
|
|
17
|
+
static readonly BRANCH: readonly string[];
|
|
18
|
+
static readonly BUILT_AT: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/build-info/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ;IAC1B,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ,CAAC,UAAU,cAAyC;IAEnE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEpE;;;;GAIG;AACH,qBAAa,wBAAwB;IACnC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAKxC;IAEF,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAMvC;IAEF,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAKvC;IAEF,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAA4C;CACxF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildInfoEnvironmentKeys = exports.BuildInfoFormats = void 0;
|
|
4
|
+
class BuildInfoFormats {
|
|
5
|
+
static { this.TS = 'ts'; }
|
|
6
|
+
static { this.JSON = 'json'; }
|
|
7
|
+
static { this.SCHEME_SET = new Set([this.TS, this.JSON]); }
|
|
8
|
+
static isValid(value) {
|
|
9
|
+
return this.SCHEME_SET.has(value);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.BuildInfoFormats = BuildInfoFormats;
|
|
13
|
+
/**
|
|
14
|
+
* Each field is spelled differently by every CI provider, and `APP_ENV_*` is what this
|
|
15
|
+
* organisation's pipelines export - so it is read before the generic `APP_BUILD_*` pair and before
|
|
16
|
+
* anything provider-specific. The first key carrying a non-blank value wins.
|
|
17
|
+
*/
|
|
18
|
+
class BuildInfoEnvironmentKeys {
|
|
19
|
+
static { this.VERSION = [
|
|
20
|
+
'APP_ENV_BUILD_VERSION',
|
|
21
|
+
'APP_BUILD_VERSION',
|
|
22
|
+
'CI_COMMIT_TAG',
|
|
23
|
+
'GITHUB_REF_NAME',
|
|
24
|
+
]; }
|
|
25
|
+
static { this.COMMIT = [
|
|
26
|
+
'APP_ENV_BUILD_COMMIT_TAG',
|
|
27
|
+
'APP_BUILD_COMMIT',
|
|
28
|
+
'CI_COMMIT_SHA',
|
|
29
|
+
'GITHUB_SHA',
|
|
30
|
+
'COMMIT_SHA',
|
|
31
|
+
]; }
|
|
32
|
+
static { this.BRANCH = [
|
|
33
|
+
'APP_BUILD_BRANCH',
|
|
34
|
+
'CI_COMMIT_REF_NAME',
|
|
35
|
+
'GITHUB_REF_NAME',
|
|
36
|
+
'BRANCH_NAME',
|
|
37
|
+
]; }
|
|
38
|
+
static { this.BUILT_AT = ['APP_ENV_BUILD_DATE', 'APP_BUILD_DATE']; }
|
|
39
|
+
}
|
|
40
|
+
exports.BuildInfoEnvironmentKeys = BuildInfoEnvironmentKeys;
|
|
41
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/build-info/common/constants.ts"],"names":[],"mappings":";;;AAEA,MAAa,gBAAgB;aACX,OAAE,GAAG,IAAI,CAAC;aACV,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEnE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AARH,4CASC;AAID;;;;GAIG;AACH,MAAa,wBAAwB;aACnB,YAAO,GAAsB;QAC3C,uBAAuB;QACvB,mBAAmB;QACnB,eAAe;QACf,iBAAiB;KAClB,CAAC;aAEc,WAAM,GAAsB;QAC1C,0BAA0B;QAC1B,kBAAkB;QAClB,eAAe;QACf,YAAY;QACZ,YAAY;KACb,CAAC;aAEc,WAAM,GAAsB;QAC1C,kBAAkB;QAClB,oBAAoB;QACpB,iBAAiB;QACjB,aAAa;KACd,CAAC;aAEc,aAAQ,GAAsB,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;;AAvBzF,4DAwBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/build-info/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
17
|
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/build-info/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,0CAAwB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TBuildInfoRecord } from '@venizia/ignis-helpers/core';
|
|
2
|
+
import type { TBuildInfoFormat } from './constants';
|
|
3
|
+
export interface IBuildInfoOptions {
|
|
4
|
+
out: string;
|
|
5
|
+
/** Where `package.json` is read from and where `git` is asked; default the cwd. */
|
|
6
|
+
root?: string;
|
|
7
|
+
format?: TBuildInfoFormat;
|
|
8
|
+
/** Name of the exported constant in `ts` format; default `BUILD_INFO`. */
|
|
9
|
+
exportName?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IBuildInfoResult {
|
|
12
|
+
buildInfo: TBuildInfoRecord;
|
|
13
|
+
content: string;
|
|
14
|
+
out: string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/build-info/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/build-info/common/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TBuildInfoRecord } from '@venizia/ignis-helpers/core';
|
|
2
|
+
import { type TBuildInfoFormat } from './common';
|
|
3
|
+
/** Renders the stamp: a static `ts` const a bundler bakes in, or the same record as `json` for a Vite app or a Tauri shell. */
|
|
4
|
+
export declare class BuildInfoEmitter {
|
|
5
|
+
static readonly DEFAULT_EXPORT_NAME = "BUILD_INFO";
|
|
6
|
+
static render(opts: {
|
|
7
|
+
buildInfo: TBuildInfoRecord;
|
|
8
|
+
format: TBuildInfoFormat;
|
|
9
|
+
exportName: string;
|
|
10
|
+
}): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../../src/build-info/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEnE,+HAA+H;AAC/H,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,mBAAmB,gBAAgB;IAEnD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAClB,SAAS,EAAE,gBAAgB,CAAC;QAC5B,MAAM,EAAE,gBAAgB,CAAC;QACzB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,MAAM;CAmBX"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildInfoEmitter = void 0;
|
|
4
|
+
const common_1 = require("./common");
|
|
5
|
+
/** Renders the stamp: a static `ts` const a bundler bakes in, or the same record as `json` for a Vite app or a Tauri shell. */
|
|
6
|
+
class BuildInfoEmitter {
|
|
7
|
+
static { this.DEFAULT_EXPORT_NAME = 'BUILD_INFO'; }
|
|
8
|
+
static render(opts) {
|
|
9
|
+
const { buildInfo, format, exportName } = opts;
|
|
10
|
+
if (format === common_1.BuildInfoFormats.JSON) {
|
|
11
|
+
return `${JSON.stringify(buildInfo, null, 2)}\n`;
|
|
12
|
+
}
|
|
13
|
+
const fields = Object.entries(buildInfo)
|
|
14
|
+
.map(([key, value]) => ` ${key}: ${JSON.stringify(value)},`)
|
|
15
|
+
.join('\n');
|
|
16
|
+
return [
|
|
17
|
+
'// AUTO-GENERATED by @venizia/ignis-boot - do not edit. Regenerate: ignis-build-info generate',
|
|
18
|
+
`export const ${exportName} = {`,
|
|
19
|
+
fields,
|
|
20
|
+
'} as const;',
|
|
21
|
+
'',
|
|
22
|
+
].join('\n');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.BuildInfoEmitter = BuildInfoEmitter;
|
|
26
|
+
//# sourceMappingURL=emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../../src/build-info/emitter.ts"],"names":[],"mappings":";;;AACA,qCAAmE;AAEnE,+HAA+H;AAC/H,MAAa,gBAAgB;aACX,wBAAmB,GAAG,YAAY,CAAC;IAEnD,MAAM,CAAC,MAAM,CAAC,IAIb;QACC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAE/C,IAAI,MAAM,KAAK,yBAAgB,CAAC,IAAI,EAAE,CAAC;YACrC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;QACnD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;aACrC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;aAC5D,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,OAAO;YACL,+FAA+F;YAC/F,gBAAgB,UAAU,MAAM;YAChC,MAAM;YACN,aAAa;YACb,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;;AAzBH,4CA0BC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type IBuildInfoOptions, type IBuildInfoResult } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* Writes the stamp. Unlike the artifact index this ALWAYS writes: `builtAt` changes every run, so
|
|
4
|
+
* an unchanged-content short-circuit would be dead code that hides a stale timestamp.
|
|
5
|
+
*/
|
|
6
|
+
export declare const generateBuildInfo: (opts: IBuildInfoOptions) => Promise<IBuildInfoResult>;
|
|
7
|
+
export * from './common';
|
|
8
|
+
export * from './emitter';
|
|
9
|
+
export * from './resolver';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/build-info/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI3F;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAU,MAAM,iBAAiB,KAAG,OAAO,CAAC,gBAAgB,CAazF,CAAC;AAEF,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
exports.generateBuildInfo = void 0;
|
|
18
|
+
const node_fs_1 = require("node:fs");
|
|
19
|
+
const node_path_1 = require("node:path");
|
|
20
|
+
const common_1 = require("./common");
|
|
21
|
+
const emitter_1 = require("./emitter");
|
|
22
|
+
const resolver_1 = require("./resolver");
|
|
23
|
+
/**
|
|
24
|
+
* Writes the stamp. Unlike the artifact index this ALWAYS writes: `builtAt` changes every run, so
|
|
25
|
+
* an unchanged-content short-circuit would be dead code that hides a stale timestamp.
|
|
26
|
+
*/
|
|
27
|
+
const generateBuildInfo = async (opts) => {
|
|
28
|
+
const buildInfo = await resolver_1.BuildInfoResolver.getInstance().resolve({ root: opts.root });
|
|
29
|
+
const content = emitter_1.BuildInfoEmitter.render({
|
|
30
|
+
buildInfo,
|
|
31
|
+
format: opts.format ?? common_1.BuildInfoFormats.TS,
|
|
32
|
+
exportName: opts.exportName ?? emitter_1.BuildInfoEmitter.DEFAULT_EXPORT_NAME,
|
|
33
|
+
});
|
|
34
|
+
const out = (0, node_path_1.resolve)(opts.out);
|
|
35
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(out), { recursive: true });
|
|
36
|
+
(0, node_fs_1.writeFileSync)(out, content);
|
|
37
|
+
return { buildInfo, content, out };
|
|
38
|
+
};
|
|
39
|
+
exports.generateBuildInfo = generateBuildInfo;
|
|
40
|
+
__exportStar(require("./common"), exports);
|
|
41
|
+
__exportStar(require("./emitter"), exports);
|
|
42
|
+
__exportStar(require("./resolver"), exports);
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/build-info/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAmD;AACnD,yCAA6C;AAC7C,qCAA2F;AAC3F,uCAA6C;AAC7C,yCAA+C;AAE/C;;;GAGG;AACI,MAAM,iBAAiB,GAAG,KAAK,EAAE,IAAuB,EAA6B,EAAE;IAC5F,MAAM,SAAS,GAAG,MAAM,4BAAiB,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACrF,MAAM,OAAO,GAAG,0BAAgB,CAAC,MAAM,CAAC;QACtC,SAAS;QACT,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,yBAAgB,CAAC,EAAE;QAC1C,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,0BAAgB,CAAC,mBAAmB;KACpE,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,IAAA,mBAAO,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAA,mBAAS,EAAC,IAAA,mBAAO,EAAC,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,IAAA,uBAAa,EAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAE5B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AACrC,CAAC,CAAC;AAbW,QAAA,iBAAiB,qBAa5B;AAEF,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|