@getcliqio/cliq-docker 0.0.0-stage → 1.15.32

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 CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # @getcliqio/cliq-docker
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Generate Docker images that bundle cliq teams for a realm.
4
+
5
+ Publishes the npm package and SEA binaries (`cliq-docker`) on `v*` tags.
package/dist/auth.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Auth: resolve a Hub bearer token, in order:
3
+ * 1. CLIQ_HUB_TOKEN env var — CI / build boxes
4
+ * 2. ~/.cliqrc/settings.json — reuse cliq's session (JWT or PAT)
5
+ *
6
+ * This reads the same file `cliq login` writes to. cliq-docker never mints
7
+ * or refreshes tokens; if a JWT is expired, we surface that clearly and
8
+ * point the user at `cliq login`.
9
+ *
10
+ * Shape (documented — kept in sync with cli/src/cli/lib/hub_credentials.ts):
11
+ * {
12
+ * "cliq": { "api_url": "...", "api_key": "cliq_tok_..." },
13
+ * "hub": { "session": "<jwt>", ... }
14
+ * }
15
+ */
16
+ /** The Hub credentials cliq-docker will use, and where they came from. */
17
+ export interface Credentials {
18
+ bearer: string;
19
+ api_url: string;
20
+ source: 'env' | 'cliqrc_session' | 'cliqrc_pat';
21
+ }
22
+ /**
23
+ * Resolve credentials. Returns null when no auth is available.
24
+ * Callers should render a helpful "run `cliq login`" hint on null.
25
+ */
26
+ export declare function resolve_credentials(override_api_url?: string): Credentials | null;
27
+ /** The message shown when no credentials are found: how to sign in. */
28
+ export declare function auth_hint(): string;
29
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,KAAK,GAAG,gBAAgB,GAAG,YAAY,CAAC;CAChD;AA4DD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CA2BjF;AAED,uEAAuE;AACvE,wBAAgB,SAAS,IAAI,MAAM,CAQlC"}
package/dist/auth.js ADDED
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Auth: resolve a Hub bearer token, in order:
3
+ * 1. CLIQ_HUB_TOKEN env var — CI / build boxes
4
+ * 2. ~/.cliqrc/settings.json — reuse cliq's session (JWT or PAT)
5
+ *
6
+ * This reads the same file `cliq login` writes to. cliq-docker never mints
7
+ * or refreshes tokens; if a JWT is expired, we surface that clearly and
8
+ * point the user at `cliq login`.
9
+ *
10
+ * Shape (documented — kept in sync with cli/src/cli/lib/hub_credentials.ts):
11
+ * {
12
+ * "cliq": { "api_url": "...", "api_key": "cliq_tok_..." },
13
+ * "hub": { "session": "<jwt>", ... }
14
+ * }
15
+ */
16
+ import fs from 'node:fs';
17
+ import path from 'node:path';
18
+ const USER_PAT_PREFIX = 'cliq_tok_';
19
+ function _cliqrc_home() {
20
+ if (process.env.CLIQ_HOME)
21
+ return process.env.CLIQ_HOME;
22
+ const home = process.env.HOME;
23
+ if (!home)
24
+ throw new Error('$HOME is not set');
25
+ return path.join(home, '.cliqrc');
26
+ }
27
+ function _settings_path() {
28
+ return path.join(_cliqrc_home(), 'settings.json');
29
+ }
30
+ function _load_settings() {
31
+ const file = _settings_path();
32
+ if (!fs.existsSync(file))
33
+ return {};
34
+ try {
35
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
36
+ }
37
+ catch {
38
+ // An unreadable settings file means no saved credentials; the hint tells the person how to sign in.
39
+ return {};
40
+ }
41
+ }
42
+ function _is_pat(token) {
43
+ return token.startsWith(USER_PAT_PREFIX);
44
+ }
45
+ function _looks_like_jwt(token) {
46
+ const parts = token.split('.');
47
+ return parts.length === 3 && parts.every((p) => p.length > 0);
48
+ }
49
+ function _jwt_expired(token) {
50
+ try {
51
+ const payload = token.split('.')[1];
52
+ if (!payload)
53
+ return false;
54
+ const body = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8'));
55
+ if (typeof body.exp !== 'number')
56
+ return false;
57
+ return body.exp * 1000 < Date.now();
58
+ }
59
+ catch {
60
+ // Not a decodable JWT payload: treat it as unexpired and let Hub decide.
61
+ return false;
62
+ }
63
+ }
64
+ const DEFAULT_API_URL = 'https://api.cliqhub.io';
65
+ /** `url` without trailing slashes (a loop, not a regex: no backtracking on long input). */
66
+ function trim_trailing_slashes(url) {
67
+ let end = url.length;
68
+ while (end > 0 && url[end - 1] === '/')
69
+ end -= 1;
70
+ return url.slice(0, end);
71
+ }
72
+ /**
73
+ * Resolve credentials. Returns null when no auth is available.
74
+ * Callers should render a helpful "run `cliq login`" hint on null.
75
+ */
76
+ export function resolve_credentials(override_api_url) {
77
+ const env_token = process.env.CLIQ_HUB_TOKEN?.trim();
78
+ if (env_token) {
79
+ return {
80
+ bearer: env_token,
81
+ api_url: trim_trailing_slashes(override_api_url ?? process.env.CLIQ_API_URL ?? DEFAULT_API_URL),
82
+ source: 'env',
83
+ };
84
+ }
85
+ const settings = _load_settings();
86
+ const api_url = trim_trailing_slashes(override_api_url ?? settings.cliq?.api_url ?? DEFAULT_API_URL);
87
+ const session = settings.hub?.session?.trim();
88
+ if (session) {
89
+ if (_looks_like_jwt(session) && _jwt_expired(session)) {
90
+ return null;
91
+ }
92
+ return { bearer: session, api_url, source: 'cliqrc_session' };
93
+ }
94
+ const api_key = settings.cliq?.api_key?.trim();
95
+ if (api_key && _is_pat(api_key)) {
96
+ return { bearer: api_key, api_url, source: 'cliqrc_pat' };
97
+ }
98
+ return null;
99
+ }
100
+ /** The message shown when no credentials are found: how to sign in. */
101
+ export function auth_hint() {
102
+ return [
103
+ 'Not authenticated.',
104
+ '',
105
+ 'Run one of:',
106
+ ' cliq login https://api.cliqhub.io',
107
+ ' export CLIQ_HUB_TOKEN=<personal-access-token>',
108
+ ].join('\n');
109
+ }
110
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,eAAe,GAAG,WAAW,CAAC;AAcpC,SAAS,YAAY;IACpB,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IACxD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;IAC9B,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,cAAc;IACtB,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,eAAe,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,cAAc;IACtB,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAmB,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACR,oGAAoG;QACpG,OAAO,EAAE,CAAC;IACX,CAAC;AACF,CAAC;AAED,SAAS,OAAO,CAAC,KAAa;IAC7B,OAAO,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AAC1C,CAAC;A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
+ *
4
+ * Realm-driven: the realm on Hub is the source of truth for which teams
5
+ * go into the image. CLI flags provide overrides for a few things that
6
+ * aren't derivable from a realm (base image, platforms, extra secrets).
7
+ *
8
+ * There is no committed manifest file. If you need reproducibility across
9
+ * team-manifest churn, use a lockfile (planned) or pin versions in the
10
+ * realm's team_list.
11
+ */
12
+ import { type ImageConfigOverrides } from '../image_config.js';
13
+ /** Inputs of `cliq-docker generate`. */
14
+ export interface GenerateOptions {
15
+ out_dir: string;
16
+ realm: string;
17
+ overrides: ImageConfigOverrides;
18
+ generator_version: string;
19
+ }
20
+ /**
21
+ * Generate the Dockerfile, bundle.json and build.sh for a realm's teams.
22
+ *
23
+ * @param opts - Output directory, realm and overrides.
24
+ * @returns the process exit code: 0 written, 1 failed (the reason is logged).
25
+ */
26
+ export declare function run_generate(opts: GenerateOptions): Promise<number>;
27
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,EAAgB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAK7E,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,oBAAoB,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;CAC1B;AAWD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBzE"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * `cliq-docker generate <out-dir> --realm <slug> [overrides...]`
3
+ *
4
+ * Realm-driven: the realm on Hub is the source of truth for which teams
5
+ * go into the image. CLI flags provide overrides for a few things that
6
+ * aren't derivable from a realm (base image, platforms, extra secrets).
7
+ *
8
+ * There is no committed manifest file. If you need reproducibility across
9
+ * team-manifest churn, use a lockfile (planned) or pin versions in the
10
+ * realm's team_list.
11
+ */
12
+ import fs from 'node:fs';
13
+ import path from 'node:path';
14
+ import { resolve_credentials, auth_hint } from '../auth.js';
15
+ import { get_team_manifest_by_id, list_realm_teams } from '../hub_client.js';
16
+ import { build_config } from '../image_config.js';
17
+ import { compose_dependencies } from '../compose.js';
18
+ import { render } from '../render.js';
19
+ import { log } from '../log.js';
20
+ /** A failure the command reports as one line and exit code 1. */
21
+ class GenerateError extends Error {
22
+ }
23
+ /**
24
+ * Generate the Dockerfile, bundle.json and build.sh for a realm's teams.
25
+ *
26
+ * @param opts - Output directory, realm and overrides.
27
+ * @returns the process exit code: 0 written, 1 failed (the reason is logged).
28
+ */
29
+ export async function run_generate(opts) {
30
+ const creds = resolve_credentials();
31
+ if (!creds) {
32
+ log.error(auth_hint());
33
+ return 1;
34
+ }
35
+ try {
36
+ const config = build_config(opts.realm, opts.overrides);
37
+ const manifests = await _load_manifests(creds, config.realm);
38
+ const bundle = compose_dependencies(manifests);
39
+ const artifacts = render({
40
+ config,
41
+ bundle,
42
+ generated_at: new Date().toISOString(),
43
+ generator_version: opts.generator_version,
44
+ });
45
+ _write_artifacts(path.resolve(opts.out_dir), artifacts);
46
+ log.info(`teams: ${bundle.teams.length} (${bundle.teams.join(', ')})`);
47
+ if (bundle.secrets_detected.length > 0)
48
+ log.info(`secrets: ${bundle.secrets_detected.join(', ')}`);
49
+ return 0;
50
+ }
51
+ catch (err) {
52
+ log.error(err instanceof Error ? err.message : String(err));
53
+ return 1;
54
+ }
55
+ }
56
+ /** The dependencies of every team in the realm (teams with no installed row are skipped with a warning). */
57
+ async function _load_manifests(creds, realm) {
58
+ const rows = await list_realm_teams(creds, realm);
59
+ if (rows.length === 0)
60
+ throw new GenerateError(`realm "${realm}" has no teams`);
61
+ const manifests = [];
62
+ for (const row of rows) {
63
+ const team_ref = `${row.scope}/${row.slug}`;
64
+ if (!row.sample_team_id) {
65
+ log.warn(`skipping ${team_ref} — no installed row to sample manifest from`);
66
+ continue;
67
+ }
68
+ const manifest = await get_team_manifest_by_id(creds, row.sample_team_id);
69
+ manifests.push({ team_ref, dependencies_yml: manifest.dependencies_yml });
70
+ }
71
+ if (manifests.length === 0)
72
+ throw new GenerateError(`no teams in realm "${realm}" had resolvable manifests`);
73
+ return manifests;
74
+ }
75
+ /** Write the three generated files into `out_dir` (created if missing). */
76
+ function _write_artifacts(out_dir, artifacts) {
77
+ fs.mkdirSync(out_dir, { recursive: true });
78
+ fs.writeFileSync(path.join(out_dir, 'Dockerfile'), artifacts.dockerfile, 'utf8');
79
+ fs.writeFileSync(path.join(out_dir, 'bundle.json'), artifacts.bundle_json, 'utf8');
80
+ fs.writeFileSync(path.join(out_dir, 'build.sh'), artifacts.build_sh, { mode: 0o755 });
81
+ for (const name of ['Dockerfile', 'bundle.json', 'build.sh'])
82
+ log.info(`wrote ${out_dir}/${name}`);
83
+ }
84
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAoB,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAA6B,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAUhC,iEAAiE;AACjE,MAAM,aAAc,SAAQ,KAAK;CAAG;AAQpC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAqB;I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EAAE,aAAa,CAAC,EAAE,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACnF,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACtF,KAAK,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,aAAa,EAAE,UAAU,CAAC;QAAE,GAAG,CAAC,IAAI,CAAC,SAAS,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC;AACpG,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `cliq-docker whoami` — echo which Hub credentials would be used.
3
+ * Reads only; never modifies settings.json.
4
+ */
5
+ /**
6
+ * Print which Hub credentials would be used, and from where.
7
+ *
8
+ * @returns the process exit code: 0 found, 1 none (the sign-in hint is logged).
9
+ */
10
+ export declare function run_whoami(): number;
11
+ //# sourceMappingURL=whoami.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAgBnC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * `cliq-docker whoami` — echo which Hub credentials would be used.
3
+ * Reads only; never modifies settings.json.
4
+ */
5
+ import { resolve_credentials, auth_hint } from '../auth.js';
6
+ import { log } from '../log.js';
7
+ /**
8
+ * Print which Hub credentials would be used, and from where.
9
+ *
10
+ * @returns the process exit code: 0 found, 1 none (the sign-in hint is logged).
11
+ */
12
+ export function run_whoami() {
13
+ const creds = resolve_credentials();
14
+ if (!creds) {
15
+ log.error(auth_hint());
16
+ return 1;
17
+ }
18
+ const source_label = {
19
+ env: 'CLIQ_HUB_TOKEN env var',
20
+ cliqrc_session: '~/.cliqrc/settings.json (hub.session)',
21
+ cliqrc_pat: '~/.cliqrc/settings.json (cliq.api_key PAT)',
22
+ }[creds.source];
23
+ process.stdout.write(`api_url ${creds.api_url}\n`);
24
+ process.stdout.write(`source ${source_label}\n`);
25
+ process.stdout.write(`token ${_mask(creds.bearer)}\n`);
26
+ return 0;
27
+ }
28
+ function _mask(token) {
29
+ if (token.length <= 12)
30
+ return '****';
31
+ return `${token.slice(0, 6)}…${token.slice(-4)}`;
32
+ }
33
+ //# sourceMappingURL=whoami.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACzB,MAAM,KAAK,GAAG,mBAAmB,EAAE,CAAC;IACpC,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QACvB,OAAO,CAAC,CAAC;IACV,CAAC;IACD,MAAM,YAAY,GAAG;QACpB,GAAG,EAAE,wBAAwB;QAC7B,cAAc,EAAE,uCAAuC;QACvD,UAAU,EAAE,4CAA4C;KACxD,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEhB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;IACpD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,YAAY,IAAI,CAAC,CAAC;IACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1D,OAAO,CAAC,CAAC;AACV,CAAC;AAED,SAAS,KAAK,CAAC,KAAa;IAC3B,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE;QAAE,OAAO,MAAM,CAAC;IACtC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAClD,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Compose: union multiple `dependencies.yml` blobs into a single, ordered,
3
+ * de-duplicated set of install steps. Detects secret references that must
4
+ * flow through BuildKit secrets at build time.
5
+ */
6
+ /** One install step from a team's `dependencies.yml`. */
7
+ export interface DependencyEntry {
8
+ name: string;
9
+ version?: string;
10
+ install: string;
11
+ }
12
+ /** The merged install plan: ordered steps, secrets they reference, and the teams it covers. */
13
+ export interface ComposedBundle {
14
+ steps: DependencyEntry[];
15
+ secrets_detected: string[];
16
+ teams: string[];
17
+ }
18
+ /**
19
+ * Compose N dependencies.yml blobs (each keyed by their team ref for error
20
+ * messages) into a single install plan. Later teams may add new steps but
21
+ * never override the first-seen `install` for a given `name`.
22
+ */
23
+ export declare function compose_dependencies(inputs: Array<{
24
+ team_ref: string;
25
+ dependencies_yml: string | null;
26
+ }>): ComposedBundle;
27
+ //# sourceMappingURL=compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,yDAAyD;AACzD,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,+FAA+F;AAC/F,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,KAAK,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,GAClE,cAAc,CAsBhB"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Compose: union multiple `dependencies.yml` blobs into a single, ordered,
3
+ * de-duplicated set of install steps. Detects secret references that must
4
+ * flow through BuildKit secrets at build time.
5
+ */
6
+ import yaml from 'js-yaml';
7
+ /**
8
+ * Compose N dependencies.yml blobs (each keyed by their team ref for error
9
+ * messages) into a single install plan. Later teams may add new steps but
10
+ * never override the first-seen `install` for a given `name`.
11
+ */
12
+ export function compose_dependencies(inputs) {
13
+ const by_name = new Map();
14
+ const secrets = new Set();
15
+ const teams = [];
16
+ for (const { team_ref, dependencies_yml } of inputs) {
17
+ teams.push(team_ref);
18
+ if (!dependencies_yml)
19
+ continue;
20
+ const parsed = _parse_dependencies_yml(team_ref, dependencies_yml);
21
+ for (const entry of parsed) {
22
+ for (const secret of _detect_secrets(entry.install))
23
+ secrets.add(secret);
24
+ if (by_name.has(entry.name))
25
+ continue;
26
+ by_name.set(entry.name, entry);
27
+ }
28
+ }
29
+ return {
30
+ steps: Array.from(by_name.values()),
31
+ secrets_detected: Array.from(secrets).sort(),
32
+ teams,
33
+ };
34
+ }
35
+ function _parse_dependencies_yml(team_ref, blob) {
36
+ let raw;
37
+ try {
38
+ raw = yaml.load(blob);
39
+ }
40
+ catch (err) {
41
+ const msg = err instanceof Error ? err.message : String(err);
42
+ throw new Error(`${team_ref}: invalid dependencies.yml — ${msg}`);
43
+ }
44
+ if (raw === null || raw === undefined)
45
+ return [];
46
+ if (!Array.isArray(raw)) {
47
+ throw new Error(`${team_ref}: dependencies.yml must be a YAML sequence`);
48
+ }
49
+ const out = [];
50
+ for (const item of raw) {
51
+ if (!item || typeof item !== 'object') {
52
+ throw new Error(`${team_ref}: dependencies.yml entries must be mappings`);
53
+ }
54
+ const rec = item;
55
+ const name = rec.name;
56
+ const install = rec.install;
57
+ if (typeof name !== 'string' || !name.trim()) {
58
+ throw new Error(`${team_ref}: dependency missing \`name\``);
59
+ }
60
+ if (typeof install !== 'string' || !install.trim()) {
61
+ throw new Error(`${team_ref}: dependency "${name}" missing \`install\``);
62
+ }
63
+ const version = typeof rec.version === 'string' ? rec.version : undefined;
64
+ out.push({ name: name.trim(), version, install: install.trim() });
65
+ }
66
+ return out;
67
+ }
68
+ /**
69
+ * Detect `{{secret.NAME}}` and `{{provider.token}}` refs in install strings.
70
+ * Also treats `x-token-auth:$SECRET` (bitbucket/github token URLs) as a
71
+ * signal that the install line needs credentials injected at build time.
72
+ */
73
+ function _detect_secrets(install) {
74
+ const out = new Set();
75
+ const template_pattern = /\{\{\s*([a-zA-Z0-9_.]+)\s*\}\}/g;
76
+ for (const m of install.matchAll(template_pattern)) {
77
+ const ref = m[1];
78
+ if (!ref)
79
+ continue;
80
+ // Namespaced tokens like `bitbucket.api_token` or `secret.foo` → normalize to secret name.
81
+ if (ref.startsWith('bitbucket.'))
82
+ out.add('bitbucket_token');
83
+ if (ref.startsWith('github.'))
84
+ out.add('github_token');
85
+ if (ref.startsWith('gitlab.'))
86
+ out.add('gitlab_token');
87
+ if (ref.startsWith('secret.'))
88
+ out.add(ref.slice('secret.'.length));
89
+ }
90
+ // Bitbucket private clones in the wild use x-token-auth style even without
91
+ // a template ref. Trust the pattern: if we see it, hoist bitbucket_token.
92
+ if (/bitbucket\.org\//.test(install) && /(clone|fetch)/.test(install)) {
93
+ out.add('bitbucket_token');
94
+ }
95
+ return Array.from(out);
96
+ }
97
+ //# sourceMappingURL=compose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.js","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,SAAS,CAAC;AAgB3B;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CACnC,MAAoE;IAEpE,MAAM,OAAO,GAAG,IAAI,GAAG,EAA2B,CAAC;IACnD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,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CAAC,OAAe;IACvC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9B,MAAM,gBAAgB,GAAG,iCAAiC,CAAC;IAC3D,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACpD,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACjB,IAAI,CAAC,GAAG;YAAE,SAAS;QACnB,2FAA2F;QAC3F,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC7D,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACvD,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACvD,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,2EAA2E;IAC3E,0EAA0E;IAC1E,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACvE,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Thin Hub API client used by `cliq-docker init`.
3
+ *
4
+ * We deliberately keep this small and typed here (no import from the wider
5
+ * cliq codebase) so cliq-docker remains standalone. If the Hub API contract
6
+ * changes, this file is the one place to update.
7
+ */
8
+ import type { Credentials } from './auth.js';
9
+ /** A team on a realm's team list, with an installed row to read its manifest from (if any). */
10
+ export interface RealmTeamRef {
11
+ scope: string;
12
+ slug: string;
13
+ version: string | null;
14
+ sample_team_id: string | null;
15
+ }
16
+ /** A team's manifest files as Hub stores them. */
17
+ export interface TeamManifest {
18
+ team_yml: string;
19
+ dependencies_yml: string | null;
20
+ version: string | null;
21
+ }
22
+ /**
23
+ * Resolve a realm slug (e.g. "sapan.default") to its UUID. Hub's realm
24
+ * endpoints all take realm_id, so callers convert once and reuse.
25
+ */
26
+ export declare function get_realm_id(credentials: Credentials, realm_slug: string): Promise<string>;
27
+ /**
28
+ * List teams declared on / installed under / discovered via a realm.
29
+ * Hits POST /v1/realms/teams/get which returns the coverage union of
30
+ * `realm.team_list`, installed daemons, and workspace teams. Each row
31
+ * carries a `sample_team_id` — the UUID of one Team row (across
32
+ * daemons) that we then fetch by id to get the manifest bytes.
33
+ */
34
+ export declare function list_realm_teams(credentials: Credentials, realm_slug: string): Promise<RealmTeamRef[]>;
35
+ /**
36
+ * Load a team by its UUID (Hub returns the full Team row, including
37
+ * `manifest` = team.yml and `dependencies` = dependencies.yml).
38
+ */
39
+ export declare function get_team_manifest_by_id(credentials: Credentials, team_id: string): Promise<TeamManifest>;
40
+ //# sourceMappingURL=hub_client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hub_client.d.ts","sourceRoot":"","sources":["../src/hub_client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,+FAA+F;AAC/F,MAAM,WAAW,YAAY;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,kDAAkD;AAClD,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AA0DD;;;GAGG;AACH,wBAAsB,YAAY,CACjC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACrC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,EAAE,CAAC,CAiBzB;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC5C,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,MAAM,GACb,OAAO,CAAC,YAAY,CAAC,CAqBvB"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Thin Hub API client used by `cliq-docker init`.
3
+ *
4
+ * We deliberately keep this small and typed here (no import from the wider
5
+ * cliq codebase) so cliq-docker remains standalone. If the Hub API contract
6
+ * changes, this file is the one place to update.
7
+ */
8
+ const DEFAULT_TIMEOUT_MS = 15_000;
9
+ async function _post(credentials, path, body) {
10
+ const url = `${credentials.api_url}${path}`;
11
+ const controller = new AbortController();
12
+ const timer = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT_MS);
13
+ let response;
14
+ try {
15
+ response = await fetch(url, {
16
+ method: 'POST',
17
+ headers: {
18
+ 'Content-Type': 'application/json',
19
+ Authorization: `Bearer ${credentials.bearer}`,
20
+ 'X-Client': 'cliq-docker',
21
+ 'X-Requested-With': 'XMLHttpRequest',
22
+ },
23
+ body: JSON.stringify(body),
24
+ signal: controller.signal,
25
+ });
26
+ }
27
+ finally {
28
+ clearTimeout(timer);
29
+ }
30
+ const text = await response.text();
31
+ let parsed = null;
32
+ if (text) {
33
+ try {
34
+ parsed = JSON.parse(text);
35
+ }
36
+ catch { /* non-JSON */ }
37
+ }
38
+ if (!response.ok) {
39
+ const msg = _extract_error(parsed, response.status, text);
40
+ throw new Error(`POST ${path} failed: ${msg}`);
41
+ }
42
+ if (!parsed)
43
+ throw new Error(`POST ${path}: empty or non-JSON response`);
44
+ if (parsed.ok === false)
45
+ throw new Error(`POST ${path}: ${_extract_error(parsed, response.status, text)}`);
46
+ if (parsed.data === undefined)
47
+ return parsed;
48
+ return parsed.data;
49
+ }
50
+ function _extract_error(envelope, status, text) {
51
+ if (envelope?.error) {
52
+ if (typeof envelope.error === 'string')
53
+ return envelope.error;
54
+ if (envelope.error.message)
55
+ return envelope.error.message;
56
+ }
57
+ if (text.length > 0 && text.length < 500)
58
+ return `${status} ${text}`;
59
+ return `HTTP ${status}`;
60
+ }
61
+ /**
62
+ * Resolve a realm slug (e.g. "sapan.default") to its UUID. Hub's realm
63
+ * endpoints all take realm_id, so callers convert once and reuse.
64
+ */
65
+ export async function get_realm_id(credentials, realm_slug) {
66
+ const data = await _post(credentials, '/v1/realms/get_by_slug', { slug: realm_slug });
67
+ const id = data.realm?.id;
68
+ if (typeof id !== 'string' || !id) {
69
+ throw new Error(`realm "${realm_slug}" not found`);
70
+ }
71
+ return id;
72
+ }
73
+ /**
74
+ * List teams declared on / installed under / discovered via a realm.
75
+ * Hits POST /v1/realms/teams/get which returns the coverage union of
76
+ * `realm.team_list`, installed daemons, and workspace teams. Each row
77
+ * carries a `sample_team_id` — the UUID of one Team row (across
78
+ * daemons) that we then fetch by id to get the manifest bytes.
79
+ */
80
+ export async function list_realm_teams(credentials, realm_slug) {
81
+ const realm_id = await get_realm_id(credentials, realm_slug);
82
+ const data = await _post(credentials, '/v1/realms/teams/get', { realm_id });
83
+ const rows = data.rows ?? [];
84
+ return rows.map((r) => ({
85
+ scope: r.scope,
86
+ slug: r.slug,
87
+ version: r.version ?? null,
88
+ sample_team_id: r.sample_team_id ?? null,
89
+ }));
90
+ }
91
+ /**
92
+ * Load a team by its UUID (Hub returns the full Team row, including
93
+ * `manifest` = team.yml and `dependencies` = dependencies.yml).
94
+ */
95
+ export async function get_team_manifest_by_id(credentials, team_id) {
96
+ const data = await _post(credentials, '/v1/control/teams/get_by_id', { id: team_id });
97
+ const team = data.team;
98
+ if (!team)
99
+ throw new Error(`team ${team_id} not found`);
100
+ const manifest = team.manifest;
101
+ if (typeof manifest !== 'string' || !manifest.trim()) {
102
+ throw new Error(`team ${team_id}: manifest (team.yml) missing`);
103
+ }
104
+ return {
105
+ team_yml: manifest,
106
+ dependencies_yml: typeof team.dependencies === 'string' ? team.dependencies : null,
107
+ version: team.version ?? null,
108
+ };
109
+ }
110
+ //# sourceMappingURL=hub_client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hub_client.js","sourceRoot":"","sources":["../src/hub_client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAuBlC,KAAK,UAAU,KAAK,CACnB,WAAwB,EACxB,IAAY,EACZ,IAA6B;IAE7B,MAAM,GAAG,GAAG,GAAG,WAAW,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,kBAAkB,CAAC,CAAC;IACvE,IAAI,QAAkB,CAAC;IACvB,IAAI,CAAC;QACJ,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC3B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACR,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,WAAW,CAAC,MAAM,EAAE;gBAC7C,UAAU,EAAE,aAAa;gBACzB,kBAAkB,EAAE,gBAAgB;aACpC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAC1B,MAAM,EAAE,UAAU,CAAC,MAAM;SACzB,CAAC,CAAC;IACJ,CAAC;YAAS,CAAC;QACV,YAAY,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,I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AAC,CAAC;IAEhE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACvB,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,QAAQ,OAAO,YAAY,CAAC,CAAC;IAExD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,QAAQ,OAAO,+BAA+B,CAAC,CAAC;IACjE,CAAC;IACD,OAAO;QACN,QAAQ,EAAE,QAAQ;QAClB,gBAAgB,EAAE,OAAO,IAAI,CAAC,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI;QAClF,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI;KAC7B,CAAC;AACH,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * ImageConfig — the internal shape describing "what goes into the image".
3
+ *
4
+ * There is deliberately NO yaml file behind this. cliq-docker is realm-
5
+ * driven: `generate --realm <slug>` resolves the team list from Hub every
6
+ * run. CLI flags override the few things that aren't derivable from a
7
+ * realm (base image, platforms, extra secrets, install-at-runtime).
8
+ *
9
+ * If reproducibility becomes an ask, we add a lockfile — not a source
10
+ * manifest.
11
+ */
12
+ export interface ImageConfig {
13
+ image_name: string;
14
+ realm: string;
15
+ base: string;
16
+ platforms: string[];
17
+ install_at_runtime: boolean;
18
+ extra_secrets: string[];
19
+ extra_env: Record<string, string>;
20
+ }
21
+ /** CLI flags that override what the realm decides about the image. */
22
+ export interface ImageConfigOverrides {
23
+ image_name?: string;
24
+ base?: string;
25
+ platforms?: string[];
26
+ install_at_runtime?: boolean;
27
+ extra_secrets?: string[];
28
+ extra_env?: Record<string, string>;
29
+ }
30
+ /**
31
+ * Build a config from a realm slug + optional CLI-supplied overrides.
32
+ * Throws with a user-friendly message on invalid values so bad flags
33
+ * surface at parse time, not deep in Dockerfile emission.
34
+ */
35
+ export declare function build_config(realm: string, overrides?: ImageConfigOverrides): ImageConfig;
36
+ //# sourceMappingURL=image_config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image_config.d.ts","sourceRoot":"","sources":["../src/image_config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,WAAW;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAOD,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,oBAAyB,GAAG,WAAW,CA0B7F"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * ImageConfig — the internal shape describing "what goes into the image".
3
+ *
4
+ * There is deliberately NO yaml file behind this. cliq-docker is realm-
5
+ * driven: `generate --realm <slug>` resolves the team list from Hub every
6
+ * run. CLI flags override the few things that aren't derivable from a
7
+ * realm (base image, platforms, extra secrets, install-at-runtime).
8
+ *
9
+ * If reproducibility becomes an ask, we add a lockfile — not a source
10
+ * manifest.
11
+ */
12
+ const DEFAULT_BASE = 'ghcr.io/getcliqio/cliq-runtime:latest';
13
+ const DEFAULT_PLATFORMS = ['linux/amd64', 'linux/arm64'];
14
+ const IMAGE_NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
15
+ const PLATFORM_PATTERN = /^linux\/(amd64|arm64|arm\/v7)$/;
16
+ /**
17
+ * Build a config from a realm slug + optional CLI-supplied overrides.
18
+ * Throws with a user-friendly message on invalid values so bad flags
19
+ * surface at parse time, not deep in Dockerfile emission.
20
+ */
21
+ export function build_config(realm, overrides = {}) {
22
+ if (!realm.trim())
23
+ throw new Error('realm is required');
24
+ const image_name = overrides.image_name?.trim() || _slug_from_realm(realm);
25
+ if (!IMAGE_NAME_PATTERN.test(image_name)) {
26
+ throw new Error(`invalid image name "${image_name}" (kebab/dot only)`);
27
+ }
28
+ const base = overrides.base?.trim() || DEFAULT_BASE;
29
+ const platforms = overrides.platforms && overrides.platforms.length > 0
30
+ ? overrides.platforms.slice()
31
+ : DEFAULT_PLATFORMS.slice();
32
+ for (const p of platforms) {
33
+ if (!PLATFORM_PATTERN.test(p))
34
+ throw new Error(`invalid platform "${p}"`);
35
+ }
36
+ return {
37
+ image_name,
38
+ realm: realm.trim(),
39
+ base,
40
+ platforms,
41
+ install_at_runtime: overrides.install_at_runtime ?? true,
42
+ extra_secrets: (overrides.extra_secrets ?? []).map((s) => s.trim()).filter(Boolean),
43
+ extra_env: overrides.extra_env ?? {},
44
+ };
45
+ }
46
+ function _slug_from_realm(realm) {
47
+ const dashed = realm.replace(/[^a-z0-9._-]+/gi, '-').toLowerCase();
48
+ let start = 0;
49
+ let end = dashed.length;
50
+ while (start < end && dashed[start] === '-')
51
+ start += 1;
52
+ while (end > start && dashed[end - 1] === '-')
53
+ end -= 1;
54
+ return dashed.slice(start, end) || 'fleet';
55
+ }
56
+ //# sourceMappingURL=image_config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image_config.js","sourceRoot":"","sources":["../src/image_config.ts"],"names":[],"mappings":"AAAA;;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AAS,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;QACnF,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,EAAE;KACpC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACtC,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IACnE,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,OAAO,KAAK,GAAG,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG;QAAE,KAAK,IAAI,CAAC,CAAC;IACxD,OAAO,GAAG,GAAG,KAAK,IAAI,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG;QAAE,GAAG,IAAI,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,OAAO,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * cliq-docker — generate Docker images that bundle cliq teams.
4
+ *
5
+ * Realm-driven: point at a realm on Hub, get a Dockerfile out. Not part
6
+ * of the cliq runtime; reads ~/.cliqrc/settings.json opportunistically
7
+ * for auth so users don't have to log in twice.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;GAMG"}
package/dist/index.js ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * cliq-docker — generate Docker images that bundle cliq teams.
4
+ *
5
+ * Realm-driven: point at a realm on Hub, get a Dockerfile out. Not part
6
+ * of the cliq runtime; reads ~/.cliqrc/settings.json opportunistically
7
+ * for auth so users don't have to log in twice.
8
+ */
9
+ import { Command } from 'commander';
10
+ import { run_generate } from './commands/generate.js';
11
+ import { run_whoami } from './commands/whoami.js';
12
+ import { log } from './log.js';
13
+ const VERSION = process.env.CLIQ_DOCKER_VERSION ?? '0.1.0';
14
+ async function main() {
15
+ const program = new Command();
16
+ program
17
+ .name('cliq-docker')
18
+ .description('Generate Docker images that bundle cliq teams for a realm.')
19
+ .version(VERSION);
20
+ program
21
+ .command('whoami')
22
+ .description('Show which Hub credentials cliq-docker would use.')
23
+ .action(() => {
24
+ process.exit(run_whoami());
25
+ });
26
+ program
27
+ .command('generate')
28
+ .description('Emit Dockerfile + bundle.json + build.sh for a realm.')
29
+ .argument('<out_dir>', 'directory to write outputs into')
30
+ .requiredOption('--realm <slug>', 'realm slug on Hub')
31
+ .option('--image-name <name>', 'image tag stem (default: derived from realm slug)')
32
+ .option('--base <image>', 'base image (default: ghcr.io/getcliqio/cliq-runtime:latest)')
33
+ .option('--platform <p...>', 'target platform (repeatable, default: linux/amd64, linux/arm64)')
34
+ .option('--secret <name...>', 'additional BuildKit secret to declare (repeatable)')
35
+ .option('--env <kv...>', 'extra ENV directive KEY=VALUE (repeatable)')
36
+ .option('--no-install-at-runtime', 'bake teams into image at build time instead of pulling at start')
37
+ .action(async (out_dir, opts) => {
38
+ const code = await run_generate({
39
+ out_dir,
40
+ realm: opts.realm,
41
+ overrides: {
42
+ image_name: opts.imageName,
43
+ base: opts.base,
44
+ platforms: opts.platform,
45
+ extra_secrets: opts.secret,
46
+ install_at_runtime: opts.installAtRuntime,
47
+ extra_env: _parse_env(opts.env ?? []),
48
+ },
49
+ generator_version: VERSION,
50
+ });
51
+ process.exit(code);
52
+ });
53
+ try {
54
+ await program.parseAsync(process.argv);
55
+ }
56
+ catch (err) {
57
+ log.error(err instanceof Error ? err.message : String(err));
58
+ process.exit(1);
59
+ }
60
+ }
61
+ function _parse_env(pairs) {
62
+ const out = {};
63
+ for (const kv of pairs) {
64
+ const eq = kv.indexOf('=');
65
+ if (eq <= 0)
66
+ throw new Error(`--env "${kv}" must be KEY=VALUE`);
67
+ const key = kv.slice(0, eq).trim();
68
+ const value = kv.slice(eq + 1);
69
+ if (!key)
70
+ throw new Error(`--env "${kv}" has empty key`);
71
+ out[key] = value;
72
+ }
73
+ return out;
74
+ }
75
+ void main();
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC;AAE3D,KAAK,UAAU,IAAI;IAClB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO;SACL,IAAI,CAAC,aAAa,CAAC;SACnB,WAAW,CAAC,4DAA4D,CAAC;SACzE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnB,OAAO;SACL,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,mDAAmD,CAAC;SAChE,MAAM,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEJ,OAAO;SACL,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,uDAAuD,CAAC;SACpE,QAAQ,CAAC,WAAW,EAAE,iCAAiC,CAAC;SACxD,cAAc,CAAC,gBAAgB,EAAE,mBAAmB,CAAC;SACrD,MAAM,CAAC,qBAAqB,EAAE,mDAAmD,CAAC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QACxB,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,EAAE,IAAI,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC;QAChE,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;QACzD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
package/dist/log.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Minimal logger. Writes to stderr so stdout stays clean for machine-readable
3
+ * output (e.g. `cliq-docker generate ... --json`).
4
+ */
5
+ /** Leveled logger writing to stderr. */
6
+ export declare const log: {
7
+ info: (msg: string) => void;
8
+ warn: (msg: string) => void;
9
+ error: (msg: string) => void;
10
+ };
11
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,wCAAwC;AACxC,eAAO,MAAM,GAAG;gBACH,MAAM,KAAG,IAAI;gBACb,MAAM,KAAG,IAAI;iBACZ,MAAM,KAAG,IAAI;CAC1B,CAAC"}
package/dist/log.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Minimal logger. Writes to stderr so stdout stays clean for machine-readable
3
+ * output (e.g. `cliq-docker generate ... --json`).
4
+ */
5
+ const PREFIX = { error: '✗', warn: '!', info: '›' };
6
+ function _emit(level, msg) {
7
+ const prefix = PREFIX[level];
8
+ process.stderr.write(`${prefix} ${msg}\n`);
9
+ }
10
+ /** Leveled logger writing to stderr. */
11
+ export const log = {
12
+ info: (msg) => _emit('info', msg),
13
+ warn: (msg) => _emit('warn', msg),
14
+ error: (msg) => _emit('error', msg),
15
+ };
16
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,MAAM,GAA0B,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAE3E,SAAS,KAAK,CAAC,KAAY,EAAE,GAAW;IACvC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,wCAAwC;AACxC,MAAM,CAAC,MAAM,GAAG,GAAG;IAClB,IAAI,EAAE,CAAC,GAAW,EAAQ,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC;IAC/C,IAAI,EAAE,CAAC,GAAW,EAAQ,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC;IAC/C,KAAK,EAAE,CAAC,GAAW,EAAQ,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC;CACjD,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Render: turn a composed bundle + image config into a Dockerfile,
3
+ * bundle.json (receipt), and build.sh (thin BuildKit wrapper).
4
+ *
5
+ * All output is pure text — no I/O in this module. The caller writes files.
6
+ */
7
+ import type { ImageConfig } from './image_config.js';
8
+ import type { ComposedBundle } from './compose.js';
9
+ /** The three generated files' contents. */
10
+ export interface RenderedArtifacts {
11
+ dockerfile: string;
12
+ bundle_json: string;
13
+ build_sh: string;
14
+ }
15
+ /** Everything `render` needs: image config, composed bundle and generation stamp. */
16
+ export interface RenderContext {
17
+ config: ImageConfig;
18
+ bundle: ComposedBundle;
19
+ generated_at: string;
20
+ generator_version: string;
21
+ }
22
+ /**
23
+ * Produce all three output files. Deterministic given the same inputs so
24
+ * the output is diffable and reproducible in CI.
25
+ */
26
+ export declare function render(ctx: RenderContext): RenderedArtifacts;
27
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,2CAA2C;AAC3C,MAAM,WAAW,iBAAiB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,qFAAqF;AACrF,MAAM,WAAW,aAAa;IAC7B,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,iBAAiB,CAO5D"}
package/dist/render.js ADDED
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Render: turn a composed bundle + image config into a Dockerfile,
3
+ * bundle.json (receipt), and build.sh (thin BuildKit wrapper).
4
+ *
5
+ * All output is pure text — no I/O in this module. The caller writes files.
6
+ */
7
+ /**
8
+ * Produce all three output files. Deterministic given the same inputs so
9
+ * the output is diffable and reproducible in CI.
10
+ */
11
+ export function render(ctx) {
12
+ const secrets = _merge_secrets(ctx.config.extra_secrets, ctx.bundle.secrets_detected);
13
+ return {
14
+ dockerfile: _render_dockerfile(ctx, secrets),
15
+ bundle_json: _render_bundle_json(ctx, secrets),
16
+ build_sh: _render_build_sh(ctx, secrets),
17
+ };
18
+ }
19
+ function _merge_secrets(declared, detected) {
20
+ return Array.from(new Set([...declared, ...detected])).sort();
21
+ }
22
+ function _render_dockerfile(ctx, secrets) {
23
+ const { config, bundle } = ctx;
24
+ const lines = [];
25
+ lines.push(`# Generated by cliq-docker ${ctx.generator_version} at ${ctx.generated_at}`);
26
+ lines.push(`# realm: ${config.realm}`);
27
+ lines.push(`# teams: ${bundle.teams.join(', ')}`);
28
+ lines.push('#');
29
+ lines.push('# DO NOT EDIT — regenerate with:');
30
+ lines.push(`# cliq-docker generate . --realm ${config.realm}`);
31
+ lines.push('');
32
+ lines.push('# syntax=docker/dockerfile:1.7');
33
+ lines.push(`FROM ${config.base}`);
34
+ lines.push('');
35
+ if (config.extra_env && Object.keys(config.extra_env).length > 0) {
36
+ for (const [k, v] of Object.entries(config.extra_env).sort()) {
37
+ lines.push(`ENV ${k}=${_quote_env(v)}`);
38
+ }
39
+ lines.push('');
40
+ }
41
+ if (bundle.steps.length === 0) {
42
+ lines.push('# No install steps declared by any team in this realm.');
43
+ }
44
+ for (const step of bundle.steps) {
45
+ const step_secrets = _secrets_used_by(step.install, secrets);
46
+ const version = step.version ? ` (${step.version})` : '';
47
+ lines.push(`# ${step.name}${version}`);
48
+ if (step_secrets.length > 0) {
49
+ const mounts = step_secrets.map((s) => ` --mount=type=secret,id=${s} \\`);
50
+ lines.push('RUN \\');
51
+ for (const m of mounts)
52
+ lines.push(m);
53
+ lines.push(` ${_inline_shell(step.install, step_secrets)}`);
54
+ continue;
55
+ }
56
+ lines.push(`RUN ${_inline_shell(step.install, [])}`);
57
+ lines.push('');
58
+ }
59
+ if (config.install_at_runtime) {
60
+ lines.push('');
61
+ lines.push('# Teams are auto-installed by cliq-runtime at container start.');
62
+ lines.push(`ENV CLIQ_INSTALL_TEAMS=${_quote_env(bundle.teams.join(','))}`);
63
+ }
64
+ lines.push('');
65
+ lines.push(`LABEL org.cliqhub.realm="${config.realm}"`);
66
+ lines.push(`LABEL org.cliqhub.teams="${bundle.teams.join(',')}"`);
67
+ lines.push(`LABEL org.cliqhub.generator="cliq-docker ${ctx.generator_version}"`);
68
+ lines.push('');
69
+ return lines.join('\n');
70
+ }
71
+ /**
72
+ * Wrap a multi-line `install` shell snippet so it fits on a single RUN line.
73
+ * When secrets are attached, read them from /run/secrets/<id> so the token
74
+ * never lands in a layer.
75
+ */
76
+ function _inline_shell(install, secrets) {
77
+ let body = install.trim();
78
+ if (secrets.length > 0) {
79
+ const preamble = secrets
80
+ .map((s) => `${s.toUpperCase()}="$(cat /run/secrets/${s})"`)
81
+ .join(' && ');
82
+ body = `set -eu && ${preamble} && ${body}`;
83
+ }
84
+ return body.replace(/\r?\n\s*/g, ' && ');
85
+ }
86
+ function _secrets_used_by(install, all_secrets) {
87
+ const used = [];
88
+ for (const secret of all_secrets) {
89
+ const patterns = [
90
+ new RegExp(`\\{\\{\\s*secret\\.${_esc(secret)}\\s*\\}\\}`),
91
+ new RegExp(`\\{\\{\\s*${_esc(secret).replace('_', '\\.')}\\s*\\}\\}`),
92
+ new RegExp(`\\$${_esc(secret.toUpperCase())}\\b`),
93
+ ];
94
+ if (patterns.some((p) => p.test(install))) {
95
+ used.push(secret);
96
+ continue;
97
+ }
98
+ if (secret === 'bitbucket_token' && /bitbucket\.org\//.test(install) && /(clone|fetch)/.test(install)) {
99
+ used.push(secret);
100
+ }
101
+ }
102
+ return used;
103
+ }
104
+ function _esc(s) {
105
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
106
+ }
107
+ function _quote_env(v) {
108
+ if (/^[A-Za-z0-9_,/:.-]+$/.test(v))
109
+ return v;
110
+ return `"${v.replace(/(["\\$`])/g, '\\$1')}"`;
111
+ }
112
+ function _render_bundle_json(ctx, secrets) {
113
+ const receipt = {
114
+ image: ctx.config.image_name,
115
+ realm: ctx.config.realm,
116
+ base: ctx.config.base,
117
+ platforms: ctx.config.platforms,
118
+ teams: ctx.bundle.teams,
119
+ steps: ctx.bundle.steps.map((s) => ({
120
+ name: s.name,
121
+ version: s.version ?? null,
122
+ })),
123
+ secrets_required: secrets,
124
+ install_at_runtime: ctx.config.install_at_runtime,
125
+ generated_at: ctx.generated_at,
126
+ generator: `cliq-docker ${ctx.generator_version}`,
127
+ };
128
+ return `${JSON.stringify(receipt, null, 2)}\n`;
129
+ }
130
+ function _render_build_sh(ctx, secrets) {
131
+ const { config } = ctx;
132
+ const image = `${config.image_name}:latest`;
133
+ const platforms = config.platforms.join(',');
134
+ const lines = [];
135
+ lines.push('#!/usr/bin/env bash');
136
+ lines.push('#');
137
+ lines.push(`# Build ${image} — generated by cliq-docker ${ctx.generator_version}`);
138
+ lines.push('#');
139
+ lines.push('# Required env for secrets (missing ones fail loudly):');
140
+ for (const s of secrets)
141
+ lines.push(`# ${s.toUpperCase()}`);
142
+ lines.push('#');
143
+ lines.push('');
144
+ lines.push('set -euo pipefail');
145
+ lines.push('cd "$(dirname "$0")"');
146
+ lines.push('');
147
+ lines.push('missing=()');
148
+ for (const s of secrets) {
149
+ lines.push(`[ -n "\${${s.toUpperCase()}:-}" ] || missing+=("${s.toUpperCase()}")`);
150
+ }
151
+ if (secrets.length > 0) {
152
+ lines.push('if [ "${#missing[@]}" -gt 0 ]; then');
153
+ lines.push(' echo "ERROR: missing required env: ${missing[*]}" >&2');
154
+ lines.push(' exit 2');
155
+ lines.push('fi');
156
+ }
157
+ lines.push('');
158
+ const secret_flags = secrets.map((s) => ` --secret id=${s},env=${s.toUpperCase()} \\`).join('\n');
159
+ lines.push('DOCKER_BUILDKIT=1 docker buildx build \\');
160
+ lines.push(` --platform "${platforms}" \\`);
161
+ lines.push(` --tag "${image}" \\`);
162
+ if (secret_flags)
163
+ lines.push(secret_flags);
164
+ lines.push(' --file Dockerfile \\');
165
+ lines.push(' --load \\');
166
+ lines.push(' .');
167
+ lines.push('');
168
+ return lines.join('\n');
169
+ }
170
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
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I,CAAC,UAAU,CAAC,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnG,KAAK,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;IACvD,KAAK,CAAC,IAAI,CAAC,iBAAiB,SAAS,MAAM,CAAC,CAAC;IAC7C,KAAK,CAAC,IAAI,CAAC,YAAY,KAAK,MAAM,CAAC,CAAC;IACpC,IAAI,YAAY;QAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3C,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACrC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC1B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
- "name": "@getcliqio/cliq-docker",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@getcliqio/cliq-docker",
3
+ "version": "1.15.32",
4
+ "description": "Generate Docker images that bundle cliq teams for a realm.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "cliq-docker": "./dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "rm -f tsconfig.tsbuildinfo && tsc",
12
+ "build:cli": "npm run build && npm run build:sea",
13
+ "build:sea": "./scripts/build-sea.sh",
14
+ "test": "vitest run",
15
+ "test:watch": "vitest",
16
+ "lint": "tsc --noEmit && eslint .",
17
+ "release": "node scripts/release.mjs"
18
+ },
19
+ "engines": {
20
+ "node": ">=22"
21
+ },
22
+ "files": [
23
+ "dist/",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "publishConfig": {
28
+ "registry": "https://registry.npmjs.org",
29
+ "access": "public"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/getcliqio/cliq-docker.git"
34
+ },
35
+ "dependencies": {
36
+ "commander": "^13.1.0",
37
+ "js-yaml": "^4.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "@eslint/js": "^9.39.5",
41
+ "@types/js-yaml": "^4.0.9",
42
+ "@types/node": "^22.13.10",
43
+ "esbuild": "^0.25.0",
44
+ "eslint": "^9.39.5",
45
+ "eslint-plugin-sonarjs": "^3.0.7",
46
+ "globals": "^16.5.0",
47
+ "typescript": "^5.8.2",
48
+ "typescript-eslint": "^8.71.1",
49
+ "vitest": "^3.0.8"
50
+ }
51
+ }