@kindgi/cli 0.1.0 → 0.1.1
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 +63 -15
- package/dist/build/bundle.d.ts +5 -2
- package/dist/build/bundle.d.ts.map +1 -1
- package/dist/build/bundle.js +8 -4
- package/dist/build/bundle.js.map +1 -1
- package/dist/build/containerfile.d.ts.map +1 -1
- package/dist/build/containerfile.js +1 -0
- package/dist/build/containerfile.js.map +1 -1
- package/dist/build/defaults.d.ts.map +1 -1
- package/dist/build/defaults.js +14 -3
- package/dist/build/defaults.js.map +1 -1
- package/dist/build/host-install.d.ts +52 -0
- package/dist/build/host-install.d.ts.map +1 -1
- package/dist/build/host-install.js +68 -0
- package/dist/build/host-install.js.map +1 -1
- package/dist/commands/auth.d.ts +22 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +197 -2
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/build.d.ts +7 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +31 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/dev.d.ts +1 -2
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +136 -58
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/helpers.d.ts +14 -3
- package/dist/commands/helpers.d.ts.map +1 -1
- package/dist/commands/helpers.js +20 -3
- package/dist/commands/helpers.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +2 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/providers.d.ts.map +1 -1
- package/dist/commands/providers.js +11 -1
- package/dist/commands/providers.js.map +1 -1
- package/dist/commands/runs.d.ts.map +1 -1
- package/dist/commands/runs.js +17 -15
- package/dist/commands/runs.js.map +1 -1
- package/dist/commands/secrets.d.ts +1 -4
- package/dist/commands/secrets.d.ts.map +1 -1
- package/dist/commands/secrets.js +7 -55
- package/dist/commands/secrets.js.map +1 -1
- package/dist/commands/test.js +1 -1
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/tools.d.ts.map +1 -1
- package/dist/commands/tools.js +11 -2
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/unwired.d.ts +5 -0
- package/dist/commands/unwired.d.ts.map +1 -1
- package/dist/commands/unwired.js +11 -0
- package/dist/commands/unwired.js.map +1 -1
- package/dist/context.d.ts +9 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -0
- package/dist/context.js.map +1 -1
- package/dist/dev/bundler.d.ts +2 -0
- package/dist/dev/bundler.d.ts.map +1 -1
- package/dist/dev/bundler.js +91 -10
- package/dist/dev/bundler.js.map +1 -1
- package/dist/dev/defaults.d.ts +8 -6
- package/dist/dev/defaults.d.ts.map +1 -1
- package/dist/dev/defaults.js +78 -60
- package/dist/dev/defaults.js.map +1 -1
- package/dist/dev/dev-only-imports.d.ts +15 -0
- package/dist/dev/dev-only-imports.d.ts.map +1 -0
- package/dist/dev/dev-only-imports.js +57 -0
- package/dist/dev/dev-only-imports.js.map +1 -0
- package/dist/dev/docker-compose.dev.yml +19 -7
- package/dist/dev/pack-service.d.ts +8 -0
- package/dist/dev/pack-service.d.ts.map +1 -1
- package/dist/dev/pack-service.js +1 -0
- package/dist/dev/pack-service.js.map +1 -1
- package/dist/dev/postgres-container.d.ts +77 -0
- package/dist/dev/postgres-container.d.ts.map +1 -0
- package/dist/dev/postgres-container.js +346 -0
- package/dist/dev/postgres-container.js.map +1 -0
- package/dist/dev/runners.d.ts +36 -11
- package/dist/dev/runners.d.ts.map +1 -1
- package/dist/dev/runtime-container.d.ts +11 -2
- package/dist/dev/runtime-container.d.ts.map +1 -1
- package/dist/dev/runtime-container.js +16 -7
- package/dist/dev/runtime-container.js.map +1 -1
- package/dist/dev/runtime-image.d.ts +15 -2
- package/dist/dev/runtime-image.d.ts.map +1 -1
- package/dist/dev/runtime-image.js +31 -2
- package/dist/dev/runtime-image.js.map +1 -1
- package/dist/dev/runtime-registry.d.ts +73 -0
- package/dist/dev/runtime-registry.d.ts.map +1 -0
- package/dist/dev/runtime-registry.js +111 -0
- package/dist/dev/runtime-registry.js.map +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -1
- package/dist/errors.js.map +1 -1
- package/dist/init/augment-scaffolder.d.ts +12 -0
- package/dist/init/augment-scaffolder.d.ts.map +1 -1
- package/dist/init/augment-scaffolder.js +93 -14
- package/dist/init/augment-scaffolder.js.map +1 -1
- package/dist/init/pnpm-workspace-patcher.d.ts +55 -0
- package/dist/init/pnpm-workspace-patcher.d.ts.map +1 -0
- package/dist/init/pnpm-workspace-patcher.js +248 -0
- package/dist/init/pnpm-workspace-patcher.js.map +1 -0
- package/dist/init/template-files.d.ts +2 -0
- package/dist/init/template-files.d.ts.map +1 -1
- package/dist/init/template-files.js +16 -1
- package/dist/init/template-files.js.map +1 -1
- package/dist/main.d.ts +7 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/parse.d.ts +6 -0
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +1 -0
- package/dist/parse.js.map +1 -1
- package/dist/sdk-skills/kindgi-authoring-agents/SKILL.md +3 -4
- package/dist/sdk-skills/kindgi-authoring-flows/SKILL.md +12 -9
- package/dist/sdk-skills/kindgi-authoring-guardrails/SKILL.md +13 -7
- package/dist/sdk-skills/kindgi-authoring-mcp-servers/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-authoring-providers/SKILL.md +10 -9
- package/dist/sdk-skills/kindgi-authoring-tools/SKILL.md +15 -5
- package/dist/sdk-skills/kindgi-framework-feedback/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-getting-started/SKILL.md +16 -8
- package/dist/sdk-skills/kindgi-python-authoring-agents/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-python-authoring-flows/SKILL.md +12 -9
- package/dist/sdk-skills/kindgi-python-authoring-guardrails/SKILL.md +10 -7
- package/dist/sdk-skills/kindgi-python-authoring-tools/SKILL.md +8 -2
- package/dist/sdk-skills/kindgi-python-getting-started/SKILL.md +5 -3
- package/dist/templates/minimal/pnpm-workspace.yaml +6 -4
- package/dist/templates/sample/guardrails/response-not-empty/index.ts.tmpl +14 -6
- package/dist/templates/sample/pnpm-workspace.yaml +6 -4
- package/dist/terminal-input.d.ts +17 -0
- package/dist/terminal-input.d.ts.map +1 -0
- package/dist/terminal-input.js +88 -0
- package/dist/terminal-input.js.map +1 -0
- package/package.json +10 -10
- /package/dist/templates/minimal/{.gitignore → gitignore} +0 -0
- /package/dist/templates/python/{.gitignore → gitignore} +0 -0
- /package/dist/templates/sample/{.gitignore → gitignore} +0 -0
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type KindgiClient } from '@kindgi/client';
|
|
2
2
|
import type { BuildRunners } from './build/runners.js';
|
|
3
|
+
import type { RegistryAuthSeam } from './commands/auth.js';
|
|
3
4
|
import type { EnvInitInputSeam } from './commands/env.js';
|
|
4
5
|
import type { SecretsValueInputSeam } from './commands/secrets.js';
|
|
5
6
|
import type { ResolvedConfig } from './config.js';
|
|
@@ -125,6 +126,13 @@ export interface CommandContext {
|
|
|
125
126
|
* `env init` spins up a real `readline.Interface`.
|
|
126
127
|
*/
|
|
127
128
|
readonly envInitInputSeam: EnvInitInputSeam | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Injectable seams for `kindgi auth registry`: the `docker` runner, the
|
|
131
|
+
* stdin reader, the hidden prompt and the image checked. Tests pass
|
|
132
|
+
* fixtures so the login and the check run without Docker or a
|
|
133
|
+
* terminal; production leaves this undefined (the real ones).
|
|
134
|
+
*/
|
|
135
|
+
readonly registryAuthSeam: RegistryAuthSeam | undefined;
|
|
128
136
|
}
|
|
129
137
|
export interface BuildContextInputs {
|
|
130
138
|
readonly globals: GlobalFlags;
|
|
@@ -148,6 +156,7 @@ export interface BuildContextInputs {
|
|
|
148
156
|
readonly keyRunners?: KeyRunners;
|
|
149
157
|
readonly secretsInputSeam?: SecretsValueInputSeam;
|
|
150
158
|
readonly envInitInputSeam?: EnvInitInputSeam;
|
|
159
|
+
readonly registryAuthSeam?: RegistryAuthSeam;
|
|
151
160
|
}
|
|
152
161
|
export declare function buildContext(inputs: BuildContextInputs): CommandContext;
|
|
153
162
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtE;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC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AI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC5D,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,CAAC;IAC7F,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,qBAAqB,CAAC;IAClD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CAC9C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,cAAc,CA8CvE"}
|
package/dist/context.js
CHANGED
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC,OAAO,EAAqB,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,i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;QACjB,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;QAChC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE;QACrB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,CAAC;AACJ,CAAC"}
|
package/dist/dev/bundler.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export interface DevPackBuilderOptions {
|
|
|
3
3
|
readonly packDir: string;
|
|
4
4
|
/** The pack's discovery patterns. */
|
|
5
5
|
readonly patterns: readonly string[];
|
|
6
|
+
/** The pack's `kindgi.config.*`, whose imports count among the externals. */
|
|
7
|
+
readonly configPath?: string;
|
|
6
8
|
}
|
|
7
9
|
export declare function createDevPackBuilder(options: DevPackBuilderOptions): PackBuilder;
|
|
8
10
|
//# sourceMappingURL=bundler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../src/dev/bundler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../src/dev/bundler.ts"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAA8B,WAAW,EAAE,MAAM,cAAc,CAAC;AAE5E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAKD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,WAAW,CAuHhF"}
|
package/dist/dev/bundler.js
CHANGED
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
* `syncEntries()` recreates the build. When the last primitive file is
|
|
17
17
|
* removed there is nothing for esbuild to build or watch, so the (empty)
|
|
18
18
|
* build is reported directly — the refresh then publishes an empty index.
|
|
19
|
+
*
|
|
20
|
+
* Each build says which packages the code loads from `node_modules`
|
|
21
|
+
* (`externals`), by the same rule as a pack image's bundles. An image
|
|
22
|
+
* bundles the pack's config too, so the config's own are added: it is
|
|
23
|
+
* bundled for them once, as `kindgi dev` reads the config once.
|
|
19
24
|
*/
|
|
20
25
|
import { stat } from 'node:fs/promises';
|
|
21
26
|
import { relative, resolve, sep } from 'node:path';
|
|
@@ -29,6 +34,23 @@ export function createDevPackBuilder(options) {
|
|
|
29
34
|
let listener;
|
|
30
35
|
/** What the last reported build read: each input's path, size and mtime. */
|
|
31
36
|
let reportedInputs;
|
|
37
|
+
/** The externals of the build running now (a new map per build, read once it ends). */
|
|
38
|
+
let importing = new Map();
|
|
39
|
+
let configImporting;
|
|
40
|
+
const configExternals = () => {
|
|
41
|
+
configImporting ??= configExternalsOf(options.packDir, options.configPath);
|
|
42
|
+
return configImporting;
|
|
43
|
+
};
|
|
44
|
+
const externalsOf = async (code) => listExternals([code, await configExternals()], options.packDir);
|
|
45
|
+
/** Each build starts with no externals; `nodeModulesExternalPlugin` records them. */
|
|
46
|
+
const collector = {
|
|
47
|
+
name: 'kindgi-dev-externals',
|
|
48
|
+
setup(build) {
|
|
49
|
+
build.onStart(() => {
|
|
50
|
+
importing = new Map();
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
};
|
|
32
54
|
/** Each build's outcome, for the listener while watching. */
|
|
33
55
|
const reporter = {
|
|
34
56
|
name: 'kindgi-dev-build-report',
|
|
@@ -36,11 +58,13 @@ export function createDevPackBuilder(options) {
|
|
|
36
58
|
build.onEnd(async (result) => {
|
|
37
59
|
if (listener === undefined)
|
|
38
60
|
return;
|
|
61
|
+
const code = importing;
|
|
39
62
|
const read = result.errors.length > 0 ? undefined : await inputsOf(result, options.packDir);
|
|
40
63
|
if (read !== undefined && read === reportedInputs)
|
|
41
64
|
return;
|
|
42
65
|
reportedInputs = read;
|
|
43
|
-
|
|
66
|
+
const outcome = outcomeOf(result, entries, options.packDir, await externalsOf(code));
|
|
67
|
+
listener?.(outcome);
|
|
44
68
|
});
|
|
45
69
|
},
|
|
46
70
|
};
|
|
@@ -65,7 +89,13 @@ export function createDevPackBuilder(options) {
|
|
|
65
89
|
target: 'node22',
|
|
66
90
|
sourcemap: 'linked',
|
|
67
91
|
banner: { js: REQUIRE_BANNER },
|
|
68
|
-
plugins: [
|
|
92
|
+
plugins: [
|
|
93
|
+
collector,
|
|
94
|
+
nodeModulesExternalPlugin({
|
|
95
|
+
onExternal: (name, importer) => add(importing, name, importer),
|
|
96
|
+
}),
|
|
97
|
+
reporter,
|
|
98
|
+
],
|
|
69
99
|
metafile: true,
|
|
70
100
|
logLevel: 'silent',
|
|
71
101
|
});
|
|
@@ -74,12 +104,14 @@ export function createDevPackBuilder(options) {
|
|
|
74
104
|
return {
|
|
75
105
|
async build() {
|
|
76
106
|
await ensureContext();
|
|
77
|
-
if (context === undefined)
|
|
78
|
-
return { kind: 'ok', bundleMap: {} };
|
|
107
|
+
if (context === undefined) {
|
|
108
|
+
return { kind: 'ok', bundleMap: {}, externals: await externalsOf(new Map()) };
|
|
109
|
+
}
|
|
79
110
|
try {
|
|
80
111
|
const result = await context.rebuild();
|
|
112
|
+
const code = importing;
|
|
81
113
|
reportedInputs = await inputsOf(result, options.packDir);
|
|
82
|
-
return outcomeOf(result, entries, options.packDir);
|
|
114
|
+
return outcomeOf(result, entries, options.packDir, await externalsOf(code));
|
|
83
115
|
}
|
|
84
116
|
catch (failure) {
|
|
85
117
|
return failed(failure.errors ?? [], failure);
|
|
@@ -95,7 +127,8 @@ export function createDevPackBuilder(options) {
|
|
|
95
127
|
return changed;
|
|
96
128
|
if (entries.length === 0) {
|
|
97
129
|
reportedInputs = '';
|
|
98
|
-
|
|
130
|
+
const externals = await externalsOf(new Map());
|
|
131
|
+
listener?.({ kind: 'ok', bundleMap: {}, externals });
|
|
99
132
|
}
|
|
100
133
|
else {
|
|
101
134
|
// A new context doesn't watch yet; watching triggers its first build.
|
|
@@ -112,10 +145,10 @@ export function createDevPackBuilder(options) {
|
|
|
112
145
|
}
|
|
113
146
|
/**
|
|
114
147
|
* A build's outcome: each primitive's source path (as the index records
|
|
115
|
-
* it) mapped to its bundle, both relative to the pack root
|
|
116
|
-
* errors, each located `file:line:column`.
|
|
148
|
+
* it) mapped to its bundle, both relative to the pack root, and the
|
|
149
|
+
* externals — or the errors, each located `file:line:column`.
|
|
117
150
|
*/
|
|
118
|
-
function outcomeOf(result, entries, packDir) {
|
|
151
|
+
function outcomeOf(result, entries, packDir, externals) {
|
|
119
152
|
if (result.errors.length > 0)
|
|
120
153
|
return failed(result.errors, undefined);
|
|
121
154
|
const bundleMap = {};
|
|
@@ -123,7 +156,55 @@ function outcomeOf(result, entries, packDir) {
|
|
|
123
156
|
for (const entry of entries) {
|
|
124
157
|
bundleMap[entry.sourceRel] = toPosix(relative(packDir, `${outDir}/${entry.outRel}.mjs`));
|
|
125
158
|
}
|
|
126
|
-
return { kind: 'ok', bundleMap };
|
|
159
|
+
return { kind: 'ok', bundleMap, externals };
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* What the config imports from `node_modules`: bundled in memory, by the
|
|
163
|
+
* externals rule. A config that doesn't bundle adds nothing here (`kindgi
|
|
164
|
+
* build` reports it).
|
|
165
|
+
*/
|
|
166
|
+
async function configExternalsOf(packDir, configPath) {
|
|
167
|
+
const found = new Map();
|
|
168
|
+
if (configPath === undefined)
|
|
169
|
+
return found;
|
|
170
|
+
const esbuild = await import('esbuild');
|
|
171
|
+
try {
|
|
172
|
+
await esbuild.build({
|
|
173
|
+
absWorkingDir: packDir,
|
|
174
|
+
entryPoints: [configPath],
|
|
175
|
+
bundle: true,
|
|
176
|
+
write: false,
|
|
177
|
+
format: 'esm',
|
|
178
|
+
platform: 'node',
|
|
179
|
+
target: 'node22',
|
|
180
|
+
logLevel: 'silent',
|
|
181
|
+
plugins: [
|
|
182
|
+
nodeModulesExternalPlugin({ onExternal: (name, importer) => add(found, name, importer) }),
|
|
183
|
+
],
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return new Map();
|
|
188
|
+
}
|
|
189
|
+
return found;
|
|
190
|
+
}
|
|
191
|
+
function add(importers, name, importer) {
|
|
192
|
+
const files = importers.get(name) ?? new Set();
|
|
193
|
+
files.add(importer);
|
|
194
|
+
importers.set(name, files);
|
|
195
|
+
}
|
|
196
|
+
/** The externals, merged, sorted by name; importers relative to the pack root. */
|
|
197
|
+
function listExternals(sets, packDir) {
|
|
198
|
+
const merged = new Map();
|
|
199
|
+
for (const set of sets) {
|
|
200
|
+
for (const [name, files] of set)
|
|
201
|
+
for (const file of files)
|
|
202
|
+
add(merged, name, file);
|
|
203
|
+
}
|
|
204
|
+
return [...merged.keys()].sort().map((name) => ({
|
|
205
|
+
name,
|
|
206
|
+
importers: [...(merged.get(name) ?? [])].map((file) => toPosix(relative(packDir, file))).sort(),
|
|
207
|
+
}));
|
|
127
208
|
}
|
|
128
209
|
/** Every file a build read, with its size and mtime — equal when nothing changed. */
|
|
129
210
|
async function inputsOf(result, packDir) {
|
package/dist/dev/bundler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../src/dev/bundler.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC
|
|
1
|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
package/dist/dev/defaults.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { FSWatcher } from 'node:fs';
|
|
|
2
2
|
import { watch } from 'node:fs/promises';
|
|
3
3
|
import { runIndexer as runIndexerReal } from '@kindgi/handler-runtime';
|
|
4
4
|
import { type PackCode } from './pack-code.js';
|
|
5
|
+
import { type DockerRunner } from './postgres-container.js';
|
|
5
6
|
import type { DevPackService, DevPackServiceOptions, DevRunners, IndexResult, IndexerRunOptions, PackBuilder, RunningApiServer, StartApiServerOptions, StartServicesResult, WatchHandle } from './runners.js';
|
|
6
7
|
import { type RuntimeNetwork } from './runtime-container.js';
|
|
7
8
|
/**
|
|
@@ -20,6 +21,7 @@ export declare function createPackServiceReal(opts: DevPackServiceOptions): DevP
|
|
|
20
21
|
export declare function createPackBuilderReal(opts: {
|
|
21
22
|
readonly packDir: string;
|
|
22
23
|
readonly patterns: readonly string[];
|
|
24
|
+
readonly configPath?: string;
|
|
23
25
|
readonly code: PackCode;
|
|
24
26
|
readonly env: () => Promise<Readonly<Record<string, string>>>;
|
|
25
27
|
}): PackBuilder;
|
|
@@ -103,11 +105,6 @@ export declare function watchPackReal(packDir: string, onChange: () => void, opt
|
|
|
103
105
|
readonly patterns?: readonly string[];
|
|
104
106
|
readonly files?: readonly string[];
|
|
105
107
|
}): Promise<WatchHandle>;
|
|
106
|
-
/**
|
|
107
|
-
* The host port in `docker compose port` output (`0.0.0.0:51741`, or
|
|
108
|
-
* `[::]:51741`); `undefined` when there is none.
|
|
109
|
-
*/
|
|
110
|
-
export declare function hostPortOf(portOutput: string): number | undefined;
|
|
111
108
|
/**
|
|
112
109
|
* Boot the bundled services with plain `docker compose`, in the
|
|
113
110
|
* `kindgi-dev` project:
|
|
@@ -115,6 +112,11 @@ export declare function hostPortOf(portOutput: string): number | undefined;
|
|
|
115
112
|
* 1. `up -d --wait` Postgres, which waits for its healthcheck;
|
|
116
113
|
* 2. read its published port back.
|
|
117
114
|
*
|
|
115
|
+
* Without compose (a Docker engine without the plugin), the same
|
|
116
|
+
* Postgres starts with plain `docker` (`postgres-container.ts`): the
|
|
117
|
+
* same names, so the data is shared whichever way it was started.
|
|
118
|
+
* `unavailable` only when docker itself doesn't work.
|
|
119
|
+
*
|
|
118
120
|
* Not testcontainers: its reaper (Ryuk) is handed the compose project
|
|
119
121
|
* and, when the process exits, deletes everything labelled with it —
|
|
120
122
|
* the named volumes too — so every restart came up empty. The data in
|
|
@@ -127,7 +129,7 @@ export declare function hostPortOf(portOutput: string): number | undefined;
|
|
|
127
129
|
*/
|
|
128
130
|
export declare function startServicesReal(options: {
|
|
129
131
|
readonly recreate: boolean;
|
|
130
|
-
}): Promise<StartServicesResult>;
|
|
132
|
+
}, run?: DockerRunner): Promise<StartServicesResult>;
|
|
131
133
|
/** Default wiring used by the `kindgi dev` command in production. */
|
|
132
134
|
export declare const REAL_DEV_RUNNERS: DevRunners;
|
|
133
135
|
export declare const _internals: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/dev/defaults.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAA2C,KAAK,EAAa,MAAM,kBAAkB,CAAC;AAI7F,OAAO,EAML,UAAU,IAAI,cAAc,EAC7B,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,KAAK,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/dev/defaults.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAA2C,KAAK,EAAa,MAAM,kBAAkB,CAAC;AAI7F,OAAO,EAML,UAAU,IAAI,cAAc,EAC7B,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,KAAK,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AAEhE,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AC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B,GACL,OAAO,CAAC,WAAW,CAAC,CAuDtB;AAmJD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,EACvC,GAAG,GAAE,YAAqB,GACzB,OAAO,CAAC,mBAAmB,CAAC,CA+B9B;AAwCD,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,EAAE,UAS9B,CAAC;AAGF,eAAO,MAAM,UAAU;;;CAGb,CAAC;AAGX,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/dev/defaults.js
CHANGED
|
@@ -23,8 +23,9 @@ import { createPackServiceSupervisor } from '@kindgi/handler-runtime/pack-servic
|
|
|
23
23
|
import { createDevPackBuilder } from './bundler.js';
|
|
24
24
|
import { checkPackPython } from './pack-code.js';
|
|
25
25
|
import { devBundleMapPath, devIndexPath } from './paths.js';
|
|
26
|
+
import { hostPortOf, postgresSpecFromCompose, startPostgresContainer, } from './postgres-container.js';
|
|
26
27
|
import { createPythonPackBuilder } from './python-builder.js';
|
|
27
|
-
import { IMAGE_API_PORT, detectRuntimeNetwork, ensureRuntimeImage, startRuntimeContainer, } from './runtime-container.js';
|
|
28
|
+
import { IMAGE_API_PORT, detectRuntimeNetwork, docker, ensureRuntimeImage, startRuntimeContainer, } from './runtime-container.js';
|
|
28
29
|
import { RUNTIME_GOOGLE_CREDENTIALS, RUNTIME_PACK_DIR, RUNTIME_PUBLIC_TOKEN_KEY, buildRuntimeEnv, runtimeEnvPath, shellReferencesOf, writeRuntimeEnv, } from './runtime-env.js';
|
|
29
30
|
const DEFAULT_DEBOUNCE_MS = 200;
|
|
30
31
|
/**
|
|
@@ -68,7 +69,11 @@ export function createPackServiceReal(opts) {
|
|
|
68
69
|
export function createPackBuilderReal(opts) {
|
|
69
70
|
return opts.code.language === 'python'
|
|
70
71
|
? createPythonPackBuilder({ packDir: opts.packDir, python: opts.code.python, env: opts.env })
|
|
71
|
-
: createDevPackBuilder({
|
|
72
|
+
: createDevPackBuilder({
|
|
73
|
+
packDir: opts.packDir,
|
|
74
|
+
patterns: opts.patterns,
|
|
75
|
+
...(opts.configPath !== undefined && { configPath: opts.configPath }),
|
|
76
|
+
});
|
|
72
77
|
}
|
|
73
78
|
/**
|
|
74
79
|
* `python -m kindgi.pack index` with the pack's Python and an environment,
|
|
@@ -563,69 +568,42 @@ function bundledComposeFilePath() {
|
|
|
563
568
|
/**
|
|
564
569
|
* Detect whether `docker compose` is invokable. Returns `undefined`
|
|
565
570
|
* when available; a human-readable reason otherwise. Used to decide
|
|
566
|
-
* between
|
|
567
|
-
* error.
|
|
571
|
+
* between `docker compose` and plain `docker` for the bundled services.
|
|
568
572
|
*/
|
|
569
|
-
async function detectDockerCompose() {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
finish(undefined);
|
|
588
|
-
else
|
|
589
|
-
finish(`\`docker compose version\` exited with code ${code}`);
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
catch (err) {
|
|
593
|
-
finish(`spawn failed: ${err.message}`);
|
|
594
|
-
}
|
|
595
|
-
});
|
|
573
|
+
async function detectDockerCompose(run) {
|
|
574
|
+
const version = await run(['compose', 'version']);
|
|
575
|
+
if (version.code === 0)
|
|
576
|
+
return undefined;
|
|
577
|
+
if (version.code === null)
|
|
578
|
+
return `docker CLI not available: ${version.stderr}`;
|
|
579
|
+
return `\`docker compose version\` exited with code ${version.code}`;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Whether plain `docker` works: the CLI is installed and the engine
|
|
583
|
+
* answers. Returns `undefined` when it does; why not otherwise.
|
|
584
|
+
*/
|
|
585
|
+
async function detectDocker(run) {
|
|
586
|
+
const version = await run(['version', '--format', '{{.Server.Version}}']);
|
|
587
|
+
if (version.code === 0)
|
|
588
|
+
return undefined;
|
|
589
|
+
const detail = version.stderr.trim().split('\n').at(-1) ?? '';
|
|
590
|
+
return `Docker isn't available${detail === '' ? '' : `: ${detail}`}`;
|
|
596
591
|
}
|
|
597
592
|
/** The compose project every `kindgi dev` shares; its named volumes hold the dev data. */
|
|
598
593
|
const COMPOSE_PROJECT = 'kindgi-dev';
|
|
599
594
|
/** The services `up --wait` waits on: Postgres only (OpenFGA and MinIO aren't wired in dev). */
|
|
600
595
|
const LONG_RUNNING_SERVICES = ['postgres'];
|
|
601
596
|
/** Run `docker compose` against the bundled compose file, in the `kindgi-dev` project. */
|
|
602
|
-
function compose(args) {
|
|
603
|
-
return
|
|
604
|
-
const child = spawn('docker', ['compose', '-f', bundledComposeFilePath(), '-p', COMPOSE_PROJECT, ...args], { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
605
|
-
let stdout = '';
|
|
606
|
-
let stderr = '';
|
|
607
|
-
child.stdout.on('data', (chunk) => {
|
|
608
|
-
stdout += chunk.toString();
|
|
609
|
-
});
|
|
610
|
-
child.stderr.on('data', (chunk) => {
|
|
611
|
-
stderr += chunk.toString();
|
|
612
|
-
});
|
|
613
|
-
child.once('error', (err) => resolvePromise({ code: null, stdout, stderr: err.message }));
|
|
614
|
-
child.once('close', (code) => resolvePromise({ code, stdout, stderr }));
|
|
615
|
-
});
|
|
597
|
+
function compose(run, args) {
|
|
598
|
+
return run(['compose', '-f', bundledComposeFilePath(), '-p', COMPOSE_PROJECT, ...args]);
|
|
616
599
|
}
|
|
617
600
|
function composeFailure(step, outcome) {
|
|
618
601
|
const detail = outcome.stderr.trim().split('\n').slice(-5).join('\n');
|
|
619
602
|
return `\`docker compose ${step}\` failed (exit ${outcome.code ?? 'spawn error'})${detail === '' ? '' : `: ${detail}`}`;
|
|
620
603
|
}
|
|
621
|
-
/**
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
*/
|
|
625
|
-
export function hostPortOf(portOutput) {
|
|
626
|
-
const line = portOutput.trim().split('\n')[0] ?? '';
|
|
627
|
-
const port = Number(line.slice(line.lastIndexOf(':') + 1));
|
|
628
|
-
return Number.isInteger(port) && port > 0 ? port : undefined;
|
|
604
|
+
/** The bundled Postgres's URL, on this machine, at its published host port. */
|
|
605
|
+
function bundledDatabaseUrl(port) {
|
|
606
|
+
return `postgres://kindgi:kindgi_dev_only@127.0.0.1:${port}/kindgi?sslmode=disable`;
|
|
629
607
|
}
|
|
630
608
|
/**
|
|
631
609
|
* Boot the bundled services with plain `docker compose`, in the
|
|
@@ -634,6 +612,11 @@ export function hostPortOf(portOutput) {
|
|
|
634
612
|
* 1. `up -d --wait` Postgres, which waits for its healthcheck;
|
|
635
613
|
* 2. read its published port back.
|
|
636
614
|
*
|
|
615
|
+
* Without compose (a Docker engine without the plugin), the same
|
|
616
|
+
* Postgres starts with plain `docker` (`postgres-container.ts`): the
|
|
617
|
+
* same names, so the data is shared whichever way it was started.
|
|
618
|
+
* `unavailable` only when docker itself doesn't work.
|
|
619
|
+
*
|
|
637
620
|
* Not testcontainers: its reaper (Ryuk) is handed the compose project
|
|
638
621
|
* and, when the process exits, deletes everything labelled with it —
|
|
639
622
|
* the named volumes too — so every restart came up empty. The data in
|
|
@@ -644,14 +627,17 @@ export function hostPortOf(portOutput) {
|
|
|
644
627
|
* Containers left running by a killed `kindgi dev` are picked up by the
|
|
645
628
|
* next boot.
|
|
646
629
|
*/
|
|
647
|
-
export async function startServicesReal(options) {
|
|
648
|
-
const reason = await detectDockerCompose();
|
|
630
|
+
export async function startServicesReal(options, run = docker) {
|
|
631
|
+
const reason = await detectDockerCompose(run);
|
|
649
632
|
if (reason !== undefined) {
|
|
650
|
-
|
|
633
|
+
const noDocker = await detectDocker(run);
|
|
634
|
+
if (noDocker !== undefined)
|
|
635
|
+
return { kind: 'unavailable', reason: noDocker };
|
|
636
|
+
return startPostgresWithDocker(options, run);
|
|
651
637
|
}
|
|
652
638
|
// An existing container is reused as it is unless asked: recreating it
|
|
653
639
|
// (a changed definition) drops every other kindgi dev's connection.
|
|
654
|
-
const up = await compose([
|
|
640
|
+
const up = await compose(run, [
|
|
655
641
|
'up',
|
|
656
642
|
'-d',
|
|
657
643
|
'--wait',
|
|
@@ -660,18 +646,50 @@ export async function startServicesReal(options) {
|
|
|
660
646
|
]);
|
|
661
647
|
if (up.code !== 0)
|
|
662
648
|
return { kind: 'error', message: composeFailure('up', up) };
|
|
663
|
-
const published = await compose(['port', 'postgres', '5432']);
|
|
649
|
+
const published = await compose(run, ['port', 'postgres', '5432']);
|
|
664
650
|
const port = published.code === 0 ? hostPortOf(published.stdout) : undefined;
|
|
665
651
|
if (port === undefined) {
|
|
666
652
|
return { kind: 'error', message: composeFailure('port postgres 5432', published) };
|
|
667
653
|
}
|
|
668
|
-
const databaseUrl = `postgres://kindgi:kindgi_dev_only@127.0.0.1:${port}/kindgi?sslmode=disable`;
|
|
669
654
|
const handle = {
|
|
670
|
-
databaseUrl,
|
|
655
|
+
databaseUrl: bundledDatabaseUrl(port),
|
|
671
656
|
services: ['postgres'],
|
|
657
|
+
startedWith: 'docker compose',
|
|
672
658
|
};
|
|
673
659
|
return { kind: 'ok', handle };
|
|
674
660
|
}
|
|
661
|
+
/**
|
|
662
|
+
* The bundled Postgres with plain `docker`, as the compose file defines
|
|
663
|
+
* it. An existing container is reused as it is, so `--recreate-services`
|
|
664
|
+
* (a compose feature) can't apply: the developer is told how to recreate
|
|
665
|
+
* it by hand.
|
|
666
|
+
*/
|
|
667
|
+
async function startPostgresWithDocker(options, run) {
|
|
668
|
+
let spec;
|
|
669
|
+
try {
|
|
670
|
+
spec = postgresSpecFromCompose(await readFile(bundledComposeFilePath(), 'utf8'), COMPOSE_PROJECT);
|
|
671
|
+
}
|
|
672
|
+
catch (err) {
|
|
673
|
+
return { kind: 'error', message: err.message };
|
|
674
|
+
}
|
|
675
|
+
const started = await startPostgresContainer(spec, run);
|
|
676
|
+
if (started.kind === 'error')
|
|
677
|
+
return started;
|
|
678
|
+
const notes = options.recreate && started.container !== 'created'
|
|
679
|
+
? [
|
|
680
|
+
`--recreate-services needs docker compose: the existing ${spec.name} is reused as it is. To recreate it, remove it (docker rm -f ${spec.name}; its data stays in the ${spec.volume.name} volume) and run kindgi dev again.`,
|
|
681
|
+
]
|
|
682
|
+
: [];
|
|
683
|
+
return {
|
|
684
|
+
kind: 'ok',
|
|
685
|
+
handle: {
|
|
686
|
+
databaseUrl: bundledDatabaseUrl(started.port),
|
|
687
|
+
services: ['postgres'],
|
|
688
|
+
startedWith: 'docker',
|
|
689
|
+
...(notes.length > 0 && { notes }),
|
|
690
|
+
},
|
|
691
|
+
};
|
|
692
|
+
}
|
|
675
693
|
/** Default wiring used by the `kindgi dev` command in production. */
|
|
676
694
|
export const REAL_DEV_RUNNERS = {
|
|
677
695
|
startApiServer: startApiServerReal,
|