@flisk-sh/flisk-export 0.2.1 → 0.3.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 CHANGED
@@ -45,7 +45,7 @@ flisk-export compose --check # exit 1 when that file is out of date (for CI)
45
45
  ```
46
46
 
47
47
  Writes a **standalone** `docker-compose.yml` from the bring-your-own `service.json` files (`image` or `dockerfile`, `env`,
48
- `secrets.required`, `volumes`, `extraPorts`, `dependsOn`, `healthCheck`, `sidecarOf`, `container`). It runs with plain `docker compose up` and no Flisk: no external
48
+ `secrets.required`, `models`, `volumes`, `extraPorts`, `dependsOn`, `healthCheck`, `sidecarOf`, `container`). It runs with plain `docker compose up` and no Flisk: no external
49
49
  networks, no `FLISK_*` variables, no generated secrets. `${VAR}` references in `env`, and every name in `secrets.required`, pass through as `${NAME}` for Compose to read from `.env`.
50
50
  `healthCheck.command` becomes a Compose `healthcheck`; a service that lists a checked service in `dependsOn` waits for `service_healthy`, and one that lists a `restart: "no"` job waits for `service_completed_successfully`.
51
51
  Other resource types and `command` (native) services are not exported. The file is generated: change `service.json` and run it
package/dist/compose.js CHANGED
@@ -51,6 +51,7 @@ function serviceLines(resource, outDir, services) {
51
51
  }
52
52
  const lines = [` ${name}:`];
53
53
  const namedVolumes = new Set();
54
+ const models = new Map();
54
55
  const image = typeof c.image === "string" && c.image ? c.image : undefined;
55
56
  const dockerfile = typeof c.dockerfile === "string" && c.dockerfile ? c.dockerfile : undefined;
56
57
  const buildContext = typeof c.buildContext === "string" ? c.buildContext : undefined;
@@ -138,6 +139,21 @@ function serviceLines(resource, outDir, services) {
138
139
  }
139
140
  }
140
141
  lines.push(...healthcheckLines(name, c.healthCheck));
142
+ // Docker Model Runner: the service lists model names, the top-level `models` block says which model each is.
143
+ const modelRefs = (Array.isArray(c.models) ? c.models : []).map(record);
144
+ if (modelRefs.length > 0) {
145
+ lines.push(" models:");
146
+ for (const ref of modelRefs) {
147
+ if (typeof ref.name !== "string" || !ENV_NAME.test(ref.name.replace(/[-.]/g, "_"))) {
148
+ throw new ExportError(`${name}: a model needs a name of letters, digits, dashes and dots`);
149
+ }
150
+ if (typeof ref.model !== "string" || !ref.model) {
151
+ throw new ExportError(`${name}: model "${ref.name}" needs a model reference`);
152
+ }
153
+ lines.push(` - ${q(ref.name)}`);
154
+ models.set(ref.name, ref.model);
155
+ }
156
+ }
141
157
  const capAdd = strings(container.capAdd);
142
158
  const capDrop = strings(container.capDrop);
143
159
  const securityOpt = strings(container.securityOpt);
@@ -158,7 +174,7 @@ function serviceLines(resource, outDir, services) {
158
174
  }
159
175
  lines.push(` shm_size: ${q(container.shmSize)}`);
160
176
  }
161
- return { lines, namedVolumes };
177
+ return { lines, namedVolumes, models };
162
178
  }
163
179
  /** What Compose waits for before starting a dependent: a passing check, a finished one-shot job, or the start. */
164
180
  function dependencyCondition(dep) {
@@ -226,11 +242,14 @@ export function buildCompose(outDir, resources) {
226
242
  const known = new Map(services.map((s) => [s.name, s]));
227
243
  const body = [];
228
244
  const volumes = new Set();
245
+ const models = new Map();
229
246
  for (const service of services) {
230
247
  const built = serviceLines(service, outDir, known);
231
248
  body.push(...built.lines, "");
232
249
  for (const v of built.namedVolumes)
233
250
  volumes.add(v);
251
+ for (const [n, m] of built.models)
252
+ models.set(n, m);
234
253
  }
235
254
  const header = [
236
255
  "###############################################################################",
@@ -242,6 +261,15 @@ export function buildCompose(outDir, resources) {
242
261
  "",
243
262
  "services:",
244
263
  ];
245
- const tail = volumes.size > 0 ? ["volumes:", ...[...volumes].sort().map((v) => ` ${v}:`), ""] : [];
264
+ const tail = [
265
+ ...(models.size > 0
266
+ ? [
267
+ "models:",
268
+ ...[...models].sort().flatMap(([n, m]) => [` ${n}:`, ` model: ${q(m)}`]),
269
+ "",
270
+ ]
271
+ : []),
272
+ ...(volumes.size > 0 ? ["volumes:", ...[...volumes].sort().map((v) => ` ${v}:`), ""] : []),
273
+ ];
246
274
  return [...header, ...body, ...tail].join("\n").replace(/\n{3,}/g, "\n\n");
247
275
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flisk-sh/flisk-export",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Write a Render Blueprint (render.yaml), a Cloudflare wrangler.toml or a standalone docker-compose.yml from Flisk service.json files. Never deploys.",
5
5
  "type": "module",
6
6
  "license": "MIT",