@kindgi/cli 0.1.9 → 0.1.10-rc.0
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 +100 -6
- package/dist/build/bundle.d.ts +3 -2
- package/dist/build/bundle.d.ts.map +1 -1
- package/dist/build/bundle.js +3 -2
- package/dist/build/bundle.js.map +1 -1
- package/dist/build/computed-imports.d.ts +27 -0
- package/dist/build/computed-imports.d.ts.map +1 -0
- package/dist/build/computed-imports.js +45 -0
- package/dist/build/computed-imports.js.map +1 -0
- package/dist/build/containerfile.d.ts +2 -2
- package/dist/build/containerfile.d.ts.map +1 -1
- package/dist/build/containerfile.js +81 -12
- package/dist/build/containerfile.js.map +1 -1
- package/dist/build/defaults.d.ts +3 -2
- package/dist/build/defaults.d.ts.map +1 -1
- package/dist/build/defaults.js +28 -6
- package/dist/build/defaults.js.map +1 -1
- package/dist/build/host-install.d.ts +39 -7
- package/dist/build/host-install.d.ts.map +1 -1
- package/dist/build/host-install.js +57 -21
- package/dist/build/host-install.js.map +1 -1
- package/dist/build/image-config.d.ts +6 -0
- package/dist/build/image-config.d.ts.map +1 -1
- package/dist/build/image-config.js +43 -4
- package/dist/build/image-config.js.map +1 -1
- package/dist/build/loaded-install-check.d.ts +22 -0
- package/dist/build/loaded-install-check.d.ts.map +1 -0
- package/dist/build/loaded-install-check.js +240 -0
- package/dist/build/loaded-install-check.js.map +1 -0
- package/dist/build/loaded-install.d.ts +78 -0
- package/dist/build/loaded-install.d.ts.map +1 -0
- package/dist/build/loaded-install.js +791 -0
- package/dist/build/loaded-install.js.map +1 -0
- package/dist/build/runners.d.ts +17 -0
- package/dist/build/runners.d.ts.map +1 -1
- package/dist/commands/build.d.ts +33 -1
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +132 -6
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/helpers.d.ts +6 -0
- package/dist/commands/helpers.d.ts.map +1 -1
- package/dist/commands/helpers.js +14 -0
- package/dist/commands/helpers.js.map +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +4 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/license.d.ts.map +1 -1
- package/dist/commands/license.js +12 -7
- package/dist/commands/license.js.map +1 -1
- package/dist/commands/projects.d.ts.map +1 -1
- package/dist/commands/projects.js +1 -15
- package/dist/commands/projects.js.map +1 -1
- package/dist/commands/sites.d.ts.map +1 -1
- package/dist/commands/sites.js +16 -1
- package/dist/commands/sites.js.map +1 -1
- package/dist/commands/tenant.d.ts +3 -0
- package/dist/commands/tenant.d.ts.map +1 -0
- package/dist/commands/tenant.js +93 -0
- package/dist/commands/tenant.js.map +1 -0
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +153 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/deploy/response.d.ts.map +1 -1
- package/dist/deploy/response.js +15 -1
- package/dist/deploy/response.js.map +1 -1
- package/dist/dev/runtime-image.d.ts +1 -1
- package/dist/dev/runtime-image.d.ts.map +1 -1
- package/dist/dev/runtime-image.js +1 -1
- package/dist/dev/runtime-image.js.map +1 -1
- package/dist/exports/plan.d.ts.map +1 -1
- package/dist/exports/plan.js +2 -0
- package/dist/exports/plan.js.map +1 -1
- package/dist/init/dependency-specs.d.ts +3 -1
- package/dist/init/dependency-specs.d.ts.map +1 -1
- package/dist/init/dependency-specs.js +6 -2
- package/dist/init/dependency-specs.js.map +1 -1
- package/dist/license/renew.d.ts.map +1 -1
- package/dist/license/renew.js +2 -0
- package/dist/license/renew.js.map +1 -1
- package/dist/sdk-skills/kindgi-authoring-agents/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-authoring-flows/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-authoring-guardrails/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-authoring-mcp-servers/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-authoring-providers/SKILL.md +92 -39
- package/dist/sdk-skills/kindgi-authoring-tools/SKILL.md +51 -3
- package/dist/sdk-skills/kindgi-framework-feedback/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-getting-started/SKILL.md +23 -4
- package/dist/sdk-skills/kindgi-java-authoring-agents/SKILL.md +4 -2
- package/dist/sdk-skills/kindgi-java-authoring-flows/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-java-authoring-guardrails/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-java-authoring-tools/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-java-getting-started/SKILL.md +6 -3
- package/dist/sdk-skills/kindgi-python-authoring-agents/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-python-authoring-flows/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-python-authoring-guardrails/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-python-authoring-tools/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-python-getting-started/SKILL.md +6 -2
- package/dist/sdk-skills/kindgi-scala-authoring-agents/SKILL.md +4 -2
- package/dist/sdk-skills/kindgi-scala-authoring-flows/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-scala-authoring-guardrails/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-scala-authoring-tools/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-scala-getting-started/SKILL.md +6 -3
- package/dist/sdk-skills/kindgi-using/SKILL.md +1 -1
- package/dist/slug.d.ts +8 -1
- package/dist/slug.d.ts.map +1 -1
- package/dist/slug.js +8 -1
- package/dist/slug.js.map +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -321,7 +321,8 @@ On each boot, `kindgi dev`:
|
|
|
321
321
|
settings or its key's name, so a difference only there gets the plain line.
|
|
322
322
|
|
|
323
323
|
It records which providers it registered in `.kindgi/dev/providers.json`, per
|
|
324
|
-
database and tenant.
|
|
324
|
+
database and tenant. That file is `kindgi dev`'s local record, under the
|
|
325
|
+
gitignored `.kindgi/`; a provider is declared in the config, which you commit.
|
|
325
326
|
|
|
326
327
|
**Any OpenAI-compatible endpoint** — an open-source model you serve yourself
|
|
327
328
|
(vLLM, llama.cpp's `llama-server`, Ollama, LM Studio), OpenRouter, a LiteLLM
|
|
@@ -500,11 +501,17 @@ Builds a signed pack image with a Kindgi build server, and writes
|
|
|
500
501
|
and the `packageManager` field. A pnpm app with no `packageManager` gets the
|
|
501
502
|
host's pnpm version (`pnpm --version`), the one that wrote the lockfile,
|
|
502
503
|
never the newest. Build scripts are off during the install;
|
|
503
|
-
then `rebuild` runs the ones the app allows
|
|
504
|
-
|
|
504
|
+
then `rebuild` runs the ones the app allows. Only production dependencies
|
|
505
|
+
are installed, unless `image` has build steps (`prisma()`'s `prisma
|
|
506
|
+
generate`), whose tools can be dev dependencies: then dev dependencies are
|
|
507
|
+
installed too, and pruned after the steps. Yarn 2 or later always installs
|
|
508
|
+
them and prunes after, as its production install resolves what
|
|
509
|
+
`yarn.lock` lacks instead of failing, even with `enableImmutableInstalls`
|
|
510
|
+
on. The build says which (`✓ Install: …`).
|
|
505
511
|
- **A workspace:** with pnpm, only the pack's project and what it depends on
|
|
506
512
|
are installed, not the rest of the workspace. npm and yarn install the
|
|
507
|
-
whole workspace.
|
|
513
|
+
whole workspace. With `image.dependencies: 'loaded'`, the install is one
|
|
514
|
+
project, cut down to what the pack loads (below).
|
|
508
515
|
- **Layout:** the lockfile's folder is `/app`, and a pack inside a workspace
|
|
509
516
|
member sits at its own path.
|
|
510
517
|
- **Runs:** the pack service, under tini, as `node`, on `$PORT` (8080).
|
|
@@ -534,12 +541,99 @@ export default {
|
|
|
534
541
|
`prisma generate` after the install, before the prune. The app's own
|
|
535
542
|
`postinstall` doesn't run in the image, because the install runs with
|
|
536
543
|
scripts off.
|
|
537
|
-
- `buildEnv` holds non-secret placeholders for the build steps,
|
|
538
|
-
indexer, which imports the pack's modules. It's never in the final
|
|
544
|
+
- `buildEnv` holds non-secret placeholders for the install, the build steps,
|
|
545
|
+
and the indexer, which imports the pack's modules. It's never in the final
|
|
546
|
+
image. The indexer imports them with `NODE_ENV=production`, as the deployed
|
|
547
|
+
service does, unless `buildEnv` sets `NODE_ENV`. A `NODE_ENV` there doesn't
|
|
548
|
+
change which dependencies the install takes.
|
|
539
549
|
- `defineBuildExtension()` makes an app's own extension from the same parts:
|
|
540
550
|
`contextFiles`, `systemPackages`, `postInstall` steps (a package's bin, run
|
|
541
551
|
through the app's package manager) and `buildEnv`.
|
|
542
552
|
|
|
553
|
+
**Only what the pack loads (`image.dependencies: 'loaded'`).** By default
|
|
554
|
+
(`'all'`) the image carries every production dependency of the app: a Next.js
|
|
555
|
+
app's `next`, `react` and their tooling ride along, though the tools only
|
|
556
|
+
import a few packages. With `'loaded'`, it carries the packages the pack's
|
|
557
|
+
bundles import by name, with their own dependencies (declared, optional and
|
|
558
|
+
peer, as installed), and what `image.keep` names:
|
|
559
|
+
|
|
560
|
+
```ts
|
|
561
|
+
image: {
|
|
562
|
+
dependencies: 'loaded',
|
|
563
|
+
keep: ['pino-pretty'], // loaded by a name in a config string, which no import shows
|
|
564
|
+
},
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
- **What the image downloads:** only those. `kindgi build` finds each
|
|
568
|
+
package as Node finds it from the pack folder, and cuts the app's
|
|
569
|
+
`package.json` and lockfile down to them and what they depend on, by the
|
|
570
|
+
lockfile: dependencies, optional ones for every platform, and peers as
|
|
571
|
+
installed. Each lockfile entry is copied as the app has it (version,
|
|
572
|
+
resolution, integrity), and the result is checked against the app's
|
|
573
|
+
lockfile before the image installs it, frozen, with the usual command.
|
|
574
|
+
pnpm (lockfile `9.0`, with its env document, catalogs, overrides and
|
|
575
|
+
patches), npm (lockfile 2 and 3) and Yarn 1.
|
|
576
|
+
- **How it's chosen in the image:** each package is resolved again as Node
|
|
577
|
+
resolves it at run time, from the bundles' folder and then from each kept
|
|
578
|
+
package's own folder, over the layout the package manager made (pnpm's
|
|
579
|
+
links, npm's and Yarn's hoisting). Packages are kept whole.
|
|
580
|
+
- **Most misses fail the build, naming the package:**
|
|
581
|
+
- an import that isn't installed fails the image's closure step, by name;
|
|
582
|
+
- every package the bundles import, lazily loaded ones included, is loaded
|
|
583
|
+
on the trimmed install before indexing, which also runs there;
|
|
584
|
+
- a `require(x)` / `import(x)` with a computed name in the pack's own code
|
|
585
|
+
fails `kindgi build`, by file and line (esbuild reports each one), until
|
|
586
|
+
`image.keep` names what it loads (or `dependencies` is `'all'`).
|
|
587
|
+
- **The build says what it installs,** and which of the pack's own
|
|
588
|
+
dependencies its tools don't import. A Next.js app whose tools import
|
|
589
|
+
`@kindgi/sdk` and `zod`:
|
|
590
|
+
|
|
591
|
+
```text
|
|
592
|
+
✓ Install: only what the pack loads, 39 of the lockfile's 96 packages; production dependencies only
|
|
593
|
+
Left out 3 of the pack's own dependencies its tools don't import: next, react, react-dom
|
|
594
|
+
```
|
|
595
|
+
- **A `node_modules` out of date with the lockfile fails the build:** the
|
|
596
|
+
bundles were built against a version the lockfile doesn't pin. The message
|
|
597
|
+
names the package, its folder and the command that brings it back in line
|
|
598
|
+
(`pnpm install`, `npm ci`, `yarn install`).
|
|
599
|
+
- **Where the install isn't cut down:** the image downloads the app's whole
|
|
600
|
+
install and trims it after, and the build says why. That happens with:
|
|
601
|
+
- Yarn 2 or later (its lockfile can't be cut down by hand and still install
|
|
602
|
+
immutably);
|
|
603
|
+
- another lockfile version (pnpm's other than `9.0`, npm's other than 2
|
|
604
|
+
and 3);
|
|
605
|
+
- a local package (`link:`, `file:`, `workspace:`) among what the pack
|
|
606
|
+
loads;
|
|
607
|
+
- a package the pack loads that's installed outside the project, above the
|
|
608
|
+
lockfile's folder;
|
|
609
|
+
- a build step (`defineBuildExtension`) whose program no dependency of the
|
|
610
|
+
pack has;
|
|
611
|
+
- a lockfile entry it can't follow, such as one version installed twice
|
|
612
|
+
under different peers, where its folder doesn't say which.
|
|
613
|
+
|
|
614
|
+
An app whose tools import its own `@acme/ui` by `link:`:
|
|
615
|
+
|
|
616
|
+
```text
|
|
617
|
+
✓ Install: production dependencies only, then trimmed to what the pack loads
|
|
618
|
+
It downloads the app's whole install first, since @acme/ui is a local package (link:../../packages/ui).
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
The image's closure step then says what it kept. The Next.js app above,
|
|
622
|
+
installed in full and trimmed:
|
|
623
|
+
|
|
624
|
+
```text
|
|
625
|
+
… kindgi-closure: kept 36 of 59 packages (27.5 MB of 354 MB)
|
|
626
|
+
… kindgi-closure: dropped 3 of the pack's own dependencies its tools don't import: next, react, react-dom
|
|
627
|
+
```
|
|
628
|
+
- **What no check can see reaches a run:** a package loaded by a name in a
|
|
629
|
+
string (a plugin named in a config), through a `createRequire` alias or
|
|
630
|
+
`module.require`, or a dependency's own undeclared one. That call fails,
|
|
631
|
+
saying what to add to `image.keep`.
|
|
632
|
+
- Extensions keep what they need: `prisma()` keeps Prisma 6's generated
|
|
633
|
+
`.prisma/client` when it's there.
|
|
634
|
+
- Python packs keep every dependency for now: `dependencies = "loaded"` in
|
|
635
|
+
`[tool.kindgi.image]` is refused.
|
|
636
|
+
|
|
543
637
|
**`--local`:** builds the image of a TypeScript or Python pack with this
|
|
544
638
|
machine's Docker (`docker buildx build --load`) into its image store, as
|
|
545
639
|
`kindgi-pack/<packId>:<artifactVersion>`, with the same integrity gate. There
|
package/dist/build/bundle.d.ts
CHANGED
|
@@ -39,11 +39,12 @@ export declare const REQUIRE_BANNER = "import { createRequire as __kindgiCreateR
|
|
|
39
39
|
* Which packages are external doesn't depend on `importBy`: a dev bundle
|
|
40
40
|
* and an image's leave out the same ones. `onExternal` (optional) is told
|
|
41
41
|
* each external import: the package's name (`@scope/name` of
|
|
42
|
-
* `@scope/name/sub`),
|
|
42
|
+
* `@scope/name/sub`), the absolute path of the file importing it, and
|
|
43
|
+
* the specifier as written (`@scope/name/sub`).
|
|
43
44
|
*/
|
|
44
45
|
export declare function nodeModulesExternalPlugin(options?: {
|
|
45
46
|
readonly importBy?: 'resolved' | 'bare';
|
|
46
|
-
readonly onExternal?: (name: string, importer: string) => void;
|
|
47
|
+
readonly onExternal?: (name: string, importer: string, specifier: string) => void;
|
|
47
48
|
}): Plugin;
|
|
48
49
|
/**
|
|
49
50
|
* How a dev bundle names a file it imports from `node_modules`. An
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/build/bundle.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,oDAAoD;IACpD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAyB/B;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;AAUD,gEAAgE;AAChE,eAAO,MAAM,cAAc,kIACsG,CAAC;AAIlI
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/build/bundle.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,oDAAoD;IACpD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAyB/B;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;AAUD,gEAAgE;AAChE,eAAO,MAAM,cAAc,kIACsG,CAAC;AAIlI;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,GAAE;IACP,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9E,GACL,MAAM,CAwBR;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,CAGR"}
|
package/dist/build/bundle.js
CHANGED
|
@@ -90,7 +90,8 @@ const SKIP = Symbol('kindgi-externals-resolving');
|
|
|
90
90
|
* Which packages are external doesn't depend on `importBy`: a dev bundle
|
|
91
91
|
* and an image's leave out the same ones. `onExternal` (optional) is told
|
|
92
92
|
* each external import: the package's name (`@scope/name` of
|
|
93
|
-
* `@scope/name/sub`),
|
|
93
|
+
* `@scope/name/sub`), the absolute path of the file importing it, and
|
|
94
|
+
* the specifier as written (`@scope/name/sub`).
|
|
94
95
|
*/
|
|
95
96
|
export function nodeModulesExternalPlugin(options = {}) {
|
|
96
97
|
const importBy = options.importBy ?? 'resolved';
|
|
@@ -110,7 +111,7 @@ export function nodeModulesExternalPlugin(options = {}) {
|
|
|
110
111
|
if (resolved.errors.length > 0 || resolved.external)
|
|
111
112
|
return undefined;
|
|
112
113
|
if (/[\\/]node_modules[\\/]/.test(resolved.path)) {
|
|
113
|
-
onExternal?.(packageName(args.path), args.importer);
|
|
114
|
+
onExternal?.(packageName(args.path), args.importer, args.path);
|
|
114
115
|
const path = importBy === 'bare' ? args.path : resolvedSpecifier(resolved.path, args.kind);
|
|
115
116
|
return { path, external: true };
|
|
116
117
|
}
|
package/dist/build/bundle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/build/bundle.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAY5E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAe,EACf,QAA2B;IAE3B,MAAM,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAgB,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,KAAK,EAAE,GAAW,EAAiB,EAAE;QAChD,IAAI,OAAmC,CAAC;QACxC,IAAI,CAAC;YACH,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE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I,CAAC;AACrE,CAAC;AAED,8DAA8D;AAC9D,SAAS,WAAW,CAAC,SAAiB;IACpC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC;AAC3F,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface ComputedImport {
|
|
2
|
+
/** Absolute path. */
|
|
3
|
+
readonly file: string;
|
|
4
|
+
/** 1-based. */
|
|
5
|
+
readonly line: number;
|
|
6
|
+
/** The line, trimmed. */
|
|
7
|
+
readonly text: string;
|
|
8
|
+
}
|
|
9
|
+
/** The pack build's `logOverride` with `'loaded'`: those notes, as warnings. */
|
|
10
|
+
export declare const COMPUTED_IMPORT_LOG_OVERRIDE: Readonly<Record<string, 'warning'>>;
|
|
11
|
+
/** The subset of an esbuild message this reads. */
|
|
12
|
+
export interface BuildMessage {
|
|
13
|
+
readonly id?: string;
|
|
14
|
+
readonly location?: {
|
|
15
|
+
readonly file: string;
|
|
16
|
+
readonly line: number;
|
|
17
|
+
readonly lineText: string;
|
|
18
|
+
} | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The computed imports among a build's warnings: file (resolved against
|
|
22
|
+
* the build's working folder), line, and the line's text, in file and
|
|
23
|
+
* line order, each site once. Calls inside `node_modules` aren't the
|
|
24
|
+
* pack's (they're externals, not bundled).
|
|
25
|
+
*/
|
|
26
|
+
export declare function computedImportsFrom(warnings: readonly BuildMessage[], workingDir: string): ComputedImport[];
|
|
27
|
+
//# sourceMappingURL=computed-imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed-imports.d.ts","sourceRoot":"","sources":["../../src/build/computed-imports.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,cAAc;IAC7B,qBAAqB;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,eAAe;IACf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yBAAyB;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AASD,gFAAgF;AAChF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAE5E,CAAC;AAEF,mDAAmD;AACnD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;KAC3B,GAAG,IAAI,CAAC;CACV;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,UAAU,EAAE,MAAM,GACjB,cAAc,EAAE,CAYlB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
/**
|
|
4
|
+
* Computed imports in a pack's own code: `require(name)`, `import(name)`,
|
|
5
|
+
* or `require` passed around (`const r = require; r(name)`). In an image
|
|
6
|
+
* that carries only what the pack loads (`image.dependencies: 'loaded'`),
|
|
7
|
+
* the package such a call loads is invisible to the closure, so the build
|
|
8
|
+
* names each one (file:line) and asks for `image.keep`.
|
|
9
|
+
*
|
|
10
|
+
* esbuild knows them: it leaves each such call as it is, with a note at
|
|
11
|
+
* debug level. A `'loaded'` pack build raises those notes to warnings
|
|
12
|
+
* (`COMPUTED_IMPORT_LOG_OVERRIDE`), and they're read from the build's
|
|
13
|
+
* warnings here. Two residual forms esbuild can't see either, a
|
|
14
|
+
* `createRequire` alias and `module.require`, are left to the run-time
|
|
15
|
+
* hint.
|
|
16
|
+
*/
|
|
17
|
+
import { resolve } from 'node:path';
|
|
18
|
+
/** esbuild's notes for a call it can't bundle because its argument is computed. */
|
|
19
|
+
const COMPUTED_IMPORT_NOTES = [
|
|
20
|
+
'unsupported-require-call',
|
|
21
|
+
'unsupported-dynamic-import',
|
|
22
|
+
'indirect-require',
|
|
23
|
+
];
|
|
24
|
+
/** The pack build's `logOverride` with `'loaded'`: those notes, as warnings. */
|
|
25
|
+
export const COMPUTED_IMPORT_LOG_OVERRIDE = Object.fromEntries(COMPUTED_IMPORT_NOTES.map((id) => [id, 'warning']));
|
|
26
|
+
/**
|
|
27
|
+
* The computed imports among a build's warnings: file (resolved against
|
|
28
|
+
* the build's working folder), line, and the line's text, in file and
|
|
29
|
+
* line order, each site once. Calls inside `node_modules` aren't the
|
|
30
|
+
* pack's (they're externals, not bundled).
|
|
31
|
+
*/
|
|
32
|
+
export function computedImportsFrom(warnings, workingDir) {
|
|
33
|
+
const sites = new Map();
|
|
34
|
+
for (const warning of warnings) {
|
|
35
|
+
const at = warning.location;
|
|
36
|
+
if (at == null || !COMPUTED_IMPORT_NOTES.includes(warning.id))
|
|
37
|
+
continue;
|
|
38
|
+
const file = resolve(workingDir, at.file);
|
|
39
|
+
if (/[\\/]node_modules[\\/]/.test(file))
|
|
40
|
+
continue;
|
|
41
|
+
sites.set(`${file}:${at.line}`, { file, line: at.line, text: at.lineText.trim() });
|
|
42
|
+
}
|
|
43
|
+
return [...sites.values()].sort((a, b) => a.file === b.file ? a.line - b.line : a.file < b.file ? -1 : 1);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=computed-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed-imports.js","sourceRoot":"","sources":["../../src/build/computed-imports.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,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC/D,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type HostInstall, type InstallCommands } from './host-install.js';
|
|
2
2
|
import type { ResolvedImage } from './image-config.js';
|
|
3
3
|
export interface RenderContainerfileInputs {
|
|
4
4
|
readonly baseImageRef: string;
|
|
5
5
|
readonly artifactVersion: string;
|
|
6
6
|
readonly publishedAt: string;
|
|
7
7
|
readonly buildTarget: string;
|
|
8
|
-
readonly install: Pick<HostInstall, 'manager' | 'managerSpec' | 'hostPnpm' | 'packRel' | 'secrets' | 'yarnBerry'>;
|
|
8
|
+
readonly install: Pick<HostInstall, 'manager' | 'managerSpec' | 'hostPnpm' | 'packRel' | 'secrets' | 'yarnBerry' | 'reduced'>;
|
|
9
9
|
readonly commands: InstallCommands;
|
|
10
10
|
/** What `image` in `kindgi.config` adds (`image-config.ts`). */
|
|
11
11
|
readonly image: ResolvedImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerfile.d.ts","sourceRoot":"","sources":["../../src/build/containerfile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"containerfile.d.ts","sourceRoot":"","sources":["../../src/build/containerfile.ts"],"names":[],"mappings":"AAwDA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAsB,MAAM,mBAAmB,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,IAAI,CACpB,WAAW,EACX,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CACzF,CAAC;IACF,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,gEAAgE;IAChE,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,iCAAiC,CAAC;AAE7D,wCAAwC;AACxC,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAUjD,CAAC;AAEF,4DAA4D;AAC5D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,MAAM,CAqJ7E"}
|
|
@@ -8,12 +8,24 @@
|
|
|
8
8
|
* packages `image` asks for (corepack on)
|
|
9
9
|
* deps the app's dependencies, with its own package manager from
|
|
10
10
|
* its own lockfile, frozen and scripts off; then the build
|
|
11
|
-
* scripts it allows
|
|
12
|
-
*
|
|
11
|
+
* scripts it allows. With `image.dependencies: 'loaded'`, only
|
|
12
|
+
* what the pack loads, from a manifest and lockfile cut down
|
|
13
|
+
* to it (`loaded-install.ts`), when the lockfile allows. Production dependencies only, unless the
|
|
14
|
+
* extensions have steps (`prisma generate`) or the manager is
|
|
15
|
+
* yarn berry (`whyDevDependencies`): then dev dependencies
|
|
16
|
+
* too, the steps, and a prune to production
|
|
13
17
|
* code the bundles (`dist/`): the pack's, the framework's, the
|
|
14
18
|
* config, the bundle map
|
|
15
|
-
*
|
|
16
|
-
*
|
|
19
|
+
* closure (`image.dependencies: 'loaded'`) the install trimmed to the
|
|
20
|
+
* packages the bundles import, their own dependencies and
|
|
21
|
+
* `image.keep` (`kindgi-closure trim`)
|
|
22
|
+
* trimmed (the same) the trimmed install, on the system stage
|
|
23
|
+
* indexer `index.json`, indexed from the bundles: on `deps`, or with
|
|
24
|
+
* `'loaded'` on `trimmed`, after `kindgi-closure check` loads
|
|
25
|
+
* every package the bundles import there, so a miss fails the
|
|
26
|
+
* build. With `NODE_ENV=production`, as the service loads
|
|
27
|
+
* them, unless `buildEnv` sets `NODE_ENV`
|
|
28
|
+
* final deps (or trimmed) + code + index.json, as the `node` user
|
|
17
29
|
*
|
|
18
30
|
* Image layout: the install root at `/app`, the pack at
|
|
19
31
|
* `/app/<packRel>` (the working directory) with its bundles in `dist/`,
|
|
@@ -40,6 +52,7 @@
|
|
|
40
52
|
*/
|
|
41
53
|
import { binCommand } from '../package-manager.js';
|
|
42
54
|
import { renderAptGetStep } from './apt.js';
|
|
55
|
+
import { whyDevDependencies } from './host-install.js';
|
|
43
56
|
/**
|
|
44
57
|
* pnpm's store in the install stage: the cache mount's own folder, set
|
|
45
58
|
* explicitly (`pnpm_config_store_dir` for pnpm 11, `npm_config_store_dir`
|
|
@@ -84,6 +97,14 @@ export function renderContainerfile(inputs) {
|
|
|
84
97
|
const env = Object.entries(inputs.image.buildEnv)
|
|
85
98
|
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
86
99
|
.map(([name, value]) => `ENV ${name}=${dockerfileString(value)}`);
|
|
100
|
+
const loaded = inputs.image.dependencies === 'loaded';
|
|
101
|
+
const installed = loaded ? 'trimmed' : 'deps';
|
|
102
|
+
const devDependencies = whyDevDependencies(install, inputs.image.steps);
|
|
103
|
+
// The indexer loads the modules as the service will; a `NODE_ENV` in buildEnv is
|
|
104
|
+
// already set there (from deps, or the preamble), so it stands.
|
|
105
|
+
const indexerNodeEnv = Object.hasOwn(inputs.image.buildEnv, 'NODE_ENV')
|
|
106
|
+
? ''
|
|
107
|
+
: '\n# The modules load as in the service: NODE_ENV=production (buildEnv can set it).\nENV NODE_ENV=production';
|
|
87
108
|
const steps = inputs.image.steps.map((step) => {
|
|
88
109
|
const { command, args } = binCommand(install.manager, step.bin, step.args ?? []);
|
|
89
110
|
return `# ${step.extension}\n${run(`cd ${packDir} && ${[command, ...args].map(shellWord).join(' ')}`)}`;
|
|
@@ -124,16 +145,18 @@ USER node${pinPnpm
|
|
|
124
145
|
# host's), never the newest one corepack would take.
|
|
125
146
|
RUN corepack install -g pnpm@${install.hostPnpm}`
|
|
126
147
|
: ''}
|
|
127
|
-
COPY --chown=node:node host/ ./${env.length > 0 ? `\n# Build env: the build steps and the indexer stage only, never the final image.\n${env.join('\n')}` : ''}
|
|
128
|
-
|
|
129
|
-
${
|
|
148
|
+
COPY --chown=node:node host/ ./${env.length > 0 ? `\n# Build env: the install, the build steps and the indexer stage only, never the final image.\n${env.join('\n')}` : ''}${install.reduced === undefined
|
|
149
|
+
? ''
|
|
150
|
+
: `\n# Only what the pack loads: ${install.reduced.kept} of the lockfile's ${install.reduced.total} packages, from the manifest and lockfile kindgi build cut down to them.`}
|
|
151
|
+
# ${devDependencies === undefined ? 'Production dependencies only, as there are no build steps.' : `Dev dependencies too, ${devDependencies}; pruned to production after.`}
|
|
152
|
+
${run(commands.install)}${inputs.image.contextFiles.length > 0 ? '\nCOPY --chown=node:node ext/ ./' : ''}${steps.length > 0 ? `\n${steps.join('\n')}` : ''}${commands.prune === undefined ? '' : `\n${run(commands.prune)}`}
|
|
130
153
|
|
|
131
154
|
# --- stage: code ---
|
|
132
155
|
FROM scratch AS code
|
|
133
156
|
COPY dist/ /dist/
|
|
134
|
-
|
|
157
|
+
${loaded ? closureStages(packDir, inputs.image) : ''}
|
|
135
158
|
# --- stage: indexer ---
|
|
136
|
-
FROM
|
|
159
|
+
FROM ${installed} AS indexer${loaded ? indexerPreamble(env) : ''}${indexerNodeEnv}
|
|
137
160
|
ARG SOURCE_DATE_EPOCH=0
|
|
138
161
|
ARG KINDGI_BUILD_TARGET=${buildTarget}
|
|
139
162
|
ARG KINDGI_ARTIFACT_VERSION=${artifactVersion}
|
|
@@ -143,7 +166,11 @@ ENV KINDGI_BUILD_TARGET=\${KINDGI_BUILD_TARGET}
|
|
|
143
166
|
ENV KINDGI_ARTIFACT_VERSION=\${KINDGI_ARTIFACT_VERSION}
|
|
144
167
|
ENV KINDGI_PUBLISHED_AT=\${KINDGI_PUBLISHED_AT}
|
|
145
168
|
COPY --from=code --chown=node:node /dist ${packDir}/dist
|
|
146
|
-
WORKDIR ${packDir}
|
|
169
|
+
WORKDIR ${packDir}${loaded
|
|
170
|
+
? `
|
|
171
|
+
# Every package the bundles import loads from the trimmed install.
|
|
172
|
+
RUN node ./dist/kindgi-closure.mjs check --bundle-dir ${packDir}/dist --externals ./dist/externals.json`
|
|
173
|
+
: ''}
|
|
147
174
|
RUN node --enable-source-maps ./dist/kindgi-index.mjs \\
|
|
148
175
|
--pack-dir . \\
|
|
149
176
|
--config ./dist/kindgi.config.mjs \\
|
|
@@ -160,11 +187,15 @@ ARG KINDGI_ARTIFACT_VERSION=${artifactVersion}
|
|
|
160
187
|
ARG KINDGI_PUBLISHED_AT=${publishedAt}
|
|
161
188
|
ENV KINDGI_ARTIFACT_VERSION=\${KINDGI_ARTIFACT_VERSION}
|
|
162
189
|
ENV KINDGI_PUBLISHED_AT=\${KINDGI_PUBLISHED_AT}
|
|
163
|
-
ENV NODE_ENV=production
|
|
190
|
+
ENV NODE_ENV=production${loaded
|
|
191
|
+
? `
|
|
192
|
+
# The pack service names a package the trimmed install doesn't have.
|
|
193
|
+
ENV KINDGI_IMAGE_DEPENDENCIES=loaded`
|
|
194
|
+
: ''}
|
|
164
195
|
ENV PORT=8080
|
|
165
196
|
USER node
|
|
166
197
|
WORKDIR ${packDir}
|
|
167
|
-
COPY --from
|
|
198
|
+
COPY --from=${installed} --chown=node:node /app /app
|
|
168
199
|
COPY --from=code --chown=node:node /dist ./dist${inputs.hasIncludes
|
|
169
200
|
? `
|
|
170
201
|
COPY --chown=node:node include/ ./`
|
|
@@ -178,6 +209,44 @@ ENTRYPOINT ${entrypoint}
|
|
|
178
209
|
CMD []
|
|
179
210
|
`;
|
|
180
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* The closure and trimmed stages (`image.dependencies: 'loaded'`): the
|
|
214
|
+
* install trimmed to what the bundles load, with no network and no
|
|
215
|
+
* secrets, then laid on the system stage.
|
|
216
|
+
*/
|
|
217
|
+
function closureStages(packDir, image) {
|
|
218
|
+
const keep = [
|
|
219
|
+
...image.keep.map((name) => `--keep ${shellWord(name)}`),
|
|
220
|
+
...image.keepIfInstalled.map((name) => `--keep-if-installed ${shellWord(name)}`),
|
|
221
|
+
];
|
|
222
|
+
const args = [
|
|
223
|
+
'--root /app',
|
|
224
|
+
`--bundle-dir ${packDir}/dist`,
|
|
225
|
+
'--externals /home/node/closure-in/externals.json',
|
|
226
|
+
...keep,
|
|
227
|
+
'--out /home/node/closure',
|
|
228
|
+
];
|
|
229
|
+
return `
|
|
230
|
+
# --- stage: closure (image.dependencies: 'loaded') ---
|
|
231
|
+
# Only what the pack loads: the packages its bundles import, their own
|
|
232
|
+
# dependencies, and image.keep.
|
|
233
|
+
FROM deps AS closure
|
|
234
|
+
COPY --from=code --chown=node:node /dist/kindgi-closure.mjs /dist/externals.json /home/node/closure-in/
|
|
235
|
+
RUN node /home/node/closure-in/kindgi-closure.mjs trim \\
|
|
236
|
+
${args.join(' \\\n ')}
|
|
237
|
+
|
|
238
|
+
# --- stage: trimmed ---
|
|
239
|
+
FROM system AS trimmed
|
|
240
|
+
COPY --from=closure --chown=node:node /home/node/closure /app
|
|
241
|
+
`;
|
|
242
|
+
}
|
|
243
|
+
/** The indexer on the trimmed install: as the deps stage leaves it, the `node` user and the build env. */
|
|
244
|
+
function indexerPreamble(env) {
|
|
245
|
+
const buildEnv = env.length > 0
|
|
246
|
+
? `\n# Build env: the indexer stage only, never the final image.\n${env.join('\n')}`
|
|
247
|
+
: '';
|
|
248
|
+
return `\nUSER node${buildEnv}`;
|
|
249
|
+
}
|
|
181
250
|
/** The secret mounts for registry config, and the package manager's download cache. */
|
|
182
251
|
function installMounts(install) {
|
|
183
252
|
const owner = 'uid=1000,gid=1000';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerfile.js","sourceRoot":"","sources":["../../src/build/containerfile.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC
|
|
1
|
+
{"version":3,"file":"containerfile.js","sourceRoot":"","sources":["../../src/build/containerfile.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAA0C,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAmB/F;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,8BAA8B,CAAC;AAE7D,wCAAwC;AACxC,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,OAAO,EAAE,CAAC;AACrD,CAAC;AAED,4DAA4D;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,MAAM;IACN,sBAAsB;IACtB,gCAAgC;IAChC,SAAS;IACT,iBAAiB;IACjB,eAAe;IACf,QAAQ;IACR,cAAc;IACd,wBAAwB;CACzB,CAAC;AAEF,4DAA4D;AAC5D,MAAM,UAAU,mBAAmB,CAAC,MAAiC;IACnE,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAC9F,wFAAwF;IACxF,MAAM,OAAO,GAAG,OAAO,CAAC,OAA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AClE,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;AAC3F,CAAC"}
|
package/dist/build/defaults.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export declare function runLocalIndexerReal(opts: RunLocalIndexerOptions): Promi
|
|
|
15
15
|
* `node_modules` (imported by name);
|
|
16
16
|
* - the framework's process entries, `kindgi-index.mjs` and
|
|
17
17
|
* `kindgi-pack-service.mjs`: self-contained, from the CLI's own
|
|
18
|
-
* `@kindgi/handler-runtime` (the
|
|
19
|
-
*
|
|
18
|
+
* `@kindgi/handler-runtime` (the image's install has none: it has
|
|
19
|
+
* production dependencies only);
|
|
20
20
|
* - `bundle-map.json`: each primitive's source path → its bundle.
|
|
21
21
|
*/
|
|
22
22
|
export declare function esbuildBundleReal(opts: EsbuildBundleOptions): Promise<EsbuildBundleResult>;
|
|
@@ -24,6 +24,7 @@ export declare function writeContainerfileReal(opts: WriteContainerfileOptions):
|
|
|
24
24
|
/**
|
|
25
25
|
* Write the image's build context into `contextDir` (emptied first):
|
|
26
26
|
* host/ the files the install reads, at their paths under the install root
|
|
27
|
+
* (with `'loaded'`, the manifest and lockfile cut down to what the pack loads)
|
|
27
28
|
* ext/ the files the build extensions read, at their paths under the install root
|
|
28
29
|
* dist/ the bundles
|
|
29
30
|
* include/ `bundle.include` files, at their pack-relative paths
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/build/defaults.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/build/defaults.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBA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CAAC,CAyDpF;AAwCD;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,eAAe,CAAC,CA4E1B;AAuCD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CAkC/B;AAMD;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAqD1F;AA6ED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAuB7E;AAMD,eAAO,MAAM,kBAAkB,EAAE,YAehC,CAAC;AAIF,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAErD"}
|
package/dist/build/defaults.js
CHANGED
|
@@ -18,13 +18,15 @@ import { readSse } from '@kindgi/sdk/client';
|
|
|
18
18
|
import { runJavaIndexer, runPythonIndexer } from '../dev/defaults.js';
|
|
19
19
|
import { createJavaPackBuilder } from '../dev/java-builder.js';
|
|
20
20
|
import { createScalaPackBuilder } from '../dev/scala-builder.js';
|
|
21
|
-
import { REQUIRE_BANNER, collectPackEntries, nodeModulesExternalPlugin } from './bundle.js';
|
|
21
|
+
import { REQUIRE_BANNER, collectPackEntries, nodeModulesExternalPlugin, } from './bundle.js';
|
|
22
|
+
import { COMPUTED_IMPORT_LOG_OVERRIDE, computedImportsFrom } from './computed-imports.js';
|
|
22
23
|
import { loadEsbuild } from '../esbuild-loader.js';
|
|
23
24
|
import { readPnpmVersion } from '../package-manager.js';
|
|
24
25
|
import { renderContainerfile } from './containerfile.js';
|
|
25
26
|
import { BuildServiceRefusal, retryAfterSeconds } from './hosted.js';
|
|
26
27
|
import { installCommands, withoutInstallScripts } from './host-install.js';
|
|
27
28
|
import { renderJavaContainerfile } from './java-image.js';
|
|
29
|
+
import { loadedInstall } from './loaded-install.js';
|
|
28
30
|
import { renderScalaContainerfile } from './scala-image.js';
|
|
29
31
|
import { renderPythonContainerfile } from './python-image.js';
|
|
30
32
|
// ---------------------------------------------------------------------
|
|
@@ -110,8 +112,8 @@ export async function runLocalIndexerReal(opts) {
|
|
|
110
112
|
* `node_modules` (imported by name);
|
|
111
113
|
* - the framework's process entries, `kindgi-index.mjs` and
|
|
112
114
|
* `kindgi-pack-service.mjs`: self-contained, from the CLI's own
|
|
113
|
-
* `@kindgi/handler-runtime` (the
|
|
114
|
-
*
|
|
115
|
+
* `@kindgi/handler-runtime` (the image's install has none: it has
|
|
116
|
+
* production dependencies only);
|
|
115
117
|
* - `bundle-map.json`: each primitive's source path → its bundle.
|
|
116
118
|
*/
|
|
117
119
|
export async function esbuildBundleReal(opts) {
|
|
@@ -135,10 +137,15 @@ export async function esbuildBundleReal(opts) {
|
|
|
135
137
|
};
|
|
136
138
|
const packEntries = await collectPackEntries(opts.packDir, opts.discoveryPatterns);
|
|
137
139
|
const externalPackages = new Set();
|
|
140
|
+
const externalSpecifiers = new Set();
|
|
138
141
|
const externals = nodeModulesExternalPlugin({
|
|
139
142
|
importBy: 'bare',
|
|
140
|
-
onExternal: (name) =>
|
|
143
|
+
onExternal: (name, _importer, specifier) => {
|
|
144
|
+
externalPackages.add(name);
|
|
145
|
+
externalSpecifiers.add(specifier);
|
|
146
|
+
},
|
|
141
147
|
});
|
|
148
|
+
const loaded = opts.dependencies === 'loaded';
|
|
142
149
|
const pack = await esbuild.build({
|
|
143
150
|
...common,
|
|
144
151
|
entryPoints: [
|
|
@@ -146,6 +153,8 @@ export async function esbuildBundleReal(opts) {
|
|
|
146
153
|
{ in: opts.configPath, out: 'kindgi.config' },
|
|
147
154
|
],
|
|
148
155
|
plugins: [externals],
|
|
156
|
+
// Only what the pack loads: esbuild's notes on computed imports, as warnings.
|
|
157
|
+
...(loaded && { logOverride: COMPUTED_IMPORT_LOG_OVERRIDE }),
|
|
149
158
|
});
|
|
150
159
|
// Resolved from the CLI's own package, whose dependency it is.
|
|
151
160
|
const cliRoot = await cliPackageRoot();
|
|
@@ -155,8 +164,13 @@ export async function esbuildBundleReal(opts) {
|
|
|
155
164
|
entryPoints: [
|
|
156
165
|
{ in: '@kindgi/handler-runtime/kindgi-index-main', out: 'kindgi-index' },
|
|
157
166
|
{ in: '@kindgi/handler-runtime/pack-service-main', out: 'kindgi-pack-service' },
|
|
167
|
+
// Only what the pack loads: the image's closure and load check.
|
|
168
|
+
...(loaded ? [{ in: '@kindgi/handler-runtime/kindgi-closure-main', out: 'kindgi-closure' }] : []),
|
|
158
169
|
],
|
|
159
170
|
});
|
|
171
|
+
if (loaded) {
|
|
172
|
+
await writeFile(join(opts.outputDir, 'externals.json'), `${JSON.stringify({ packages: [...externalPackages].sort(), specifiers: [...externalSpecifiers].sort() }, null, 2)}\n`, 'utf8');
|
|
173
|
+
}
|
|
160
174
|
const bundleMap = {};
|
|
161
175
|
for (const entry of packEntries)
|
|
162
176
|
bundleMap[entry.sourceRel] = `${entry.outRel}.mjs`;
|
|
@@ -170,6 +184,7 @@ export async function esbuildBundleReal(opts) {
|
|
|
170
184
|
emitted: outputs.map(([p]) => p).sort(),
|
|
171
185
|
totalBytes: outputs.reduce((sum, [, o]) => sum + o.bytes, 0),
|
|
172
186
|
externals: [...externalPackages].sort(),
|
|
187
|
+
computedImports: loaded ? computedImportsFrom(pack.warnings, opts.packDir) : [],
|
|
173
188
|
bundleMap,
|
|
174
189
|
};
|
|
175
190
|
}
|
|
@@ -201,7 +216,7 @@ export async function writeContainerfileReal(opts) {
|
|
|
201
216
|
publishedAt: opts.publishedAt,
|
|
202
217
|
buildTarget: opts.buildTarget,
|
|
203
218
|
install: opts.install,
|
|
204
|
-
commands: installCommands(opts.install),
|
|
219
|
+
commands: installCommands(opts.install, opts.image.steps),
|
|
205
220
|
image: opts.image,
|
|
206
221
|
hasIncludes: opts.hasIncludes,
|
|
207
222
|
});
|
|
@@ -214,6 +229,7 @@ export async function writeContainerfileReal(opts) {
|
|
|
214
229
|
/**
|
|
215
230
|
* Write the image's build context into `contextDir` (emptied first):
|
|
216
231
|
* host/ the files the install reads, at their paths under the install root
|
|
232
|
+
* (with `'loaded'`, the manifest and lockfile cut down to what the pack loads)
|
|
217
233
|
* ext/ the files the build extensions read, at their paths under the install root
|
|
218
234
|
* dist/ the bundles
|
|
219
235
|
* include/ `bundle.include` files, at their pack-relative paths
|
|
@@ -225,10 +241,15 @@ export async function writeContextReal(opts) {
|
|
|
225
241
|
await rm(opts.contextDir, { recursive: true, force: true });
|
|
226
242
|
await mkdir(opts.contextDir, { recursive: true });
|
|
227
243
|
const projectManifests = new Set(opts.install.projectManifests);
|
|
244
|
+
const written = opts.install.reduced?.written ?? {};
|
|
228
245
|
for (const rel of opts.install.files) {
|
|
229
246
|
const dest = join(opts.contextDir, 'host', rel);
|
|
230
247
|
await mkdir(dirname(dest), { recursive: true });
|
|
231
|
-
|
|
248
|
+
const text = written[rel];
|
|
249
|
+
if (text !== undefined) {
|
|
250
|
+
await writeFile(dest, text, 'utf8');
|
|
251
|
+
}
|
|
252
|
+
else if (projectManifests.has(rel)) {
|
|
232
253
|
// The app's own install scripts never run in the image.
|
|
233
254
|
const text = await readFile(join(opts.install.root, rel), 'utf8');
|
|
234
255
|
await writeFile(dest, withoutInstallScripts(text), 'utf8');
|
|
@@ -734,6 +755,7 @@ export const REAL_BUILD_RUNNERS = {
|
|
|
734
755
|
python: PYTHON_BUILD_RUNNERS,
|
|
735
756
|
jvm: JVM_BUILD_RUNNERS,
|
|
736
757
|
hostPnpmVersion: readPnpmVersion,
|
|
758
|
+
loadedInstall,
|
|
737
759
|
};
|
|
738
760
|
// Re-export utility for callers that want a portable tmp workdir for
|
|
739
761
|
// the image-pull path.
|