@flisk-sh/flisk-import 0.8.0 → 0.9.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.
@@ -46,6 +46,7 @@ const TRANSLATED_KEYS = new Set([
46
46
  "restart",
47
47
  "command",
48
48
  "entrypoint",
49
+ "models",
49
50
  // Flisk gives every service its own stack network and container name, so these change nothing it needs.
50
51
  "networks",
51
52
  "expose",
@@ -290,6 +291,20 @@ function healthProbeOf(healthcheck) {
290
291
  ...(retries ? { retries } : {}),
291
292
  };
292
293
  }
294
+ /** The models a service uses, joined to their top-level definitions. A model without a literal `model` is skipped. */
295
+ function modelsOf(uses, defined) {
296
+ const names = Array.isArray(uses) ? uses : isObj(uses) ? Object.keys(uses) : [];
297
+ const out = [];
298
+ for (const name of names) {
299
+ const def = isObj(defined) && typeof name === "string" ? defined[name] : undefined;
300
+ if (typeof name === "string" &&
301
+ isObj(def) &&
302
+ typeof def.model === "string" &&
303
+ /^[A-Za-z0-9_.-]+$/.test(name))
304
+ out.push({ name, model: def.model });
305
+ }
306
+ return out.length ? out : undefined;
307
+ }
293
308
  function healthPathOf(healthcheck) {
294
309
  if (!isObj(healthcheck) || !Array.isArray(healthcheck.test))
295
310
  return undefined;
@@ -417,6 +432,7 @@ registerDetector({
417
432
  ? Object.keys(raw.depends_on)
418
433
  : [];
419
434
  const command = commandOf(raw.command);
435
+ const models = modelsOf(raw.models, isObj(root) ? root.models : undefined);
420
436
  const containerCommand = containerCommandOf(raw.command);
421
437
  const containerEntrypoint = containerCommandOf(raw.entrypoint);
422
438
  const healthProbe = healthProbeOf(raw.healthcheck);
@@ -508,6 +524,7 @@ registerDetector({
508
524
  ...(command ? { command } : {}),
509
525
  ...(containerCommand ? { containerCommand } : {}),
510
526
  ...(containerEntrypoint ? { containerEntrypoint } : {}),
527
+ ...(models ? { models } : {}),
511
528
  ...(healthProbe ? { healthCheck: healthProbe } : {}),
512
529
  ...(selectedPort !== undefined ? { port: selectedPort } : {}),
513
530
  ...(healthCheckPath ? { healthCheckPath } : {}),
package/dist/merge.js CHANGED
@@ -73,6 +73,7 @@ function mergeGroup(name, dir, members, resolve) {
73
73
  ...firstOf(ordered, "restart"),
74
74
  ...firstOf(ordered, "containerCommand"),
75
75
  ...firstOf(ordered, "containerEntrypoint"),
76
+ ...firstOf(ordered, "models"),
76
77
  ...firstOf(ordered, "healthCheck"),
77
78
  ...(ordered.find((c) => c.sidecarOf)?.sidecarOf
78
79
  ? { sidecarOf: resolve(ordered.find((c) => c.sidecarOf)?.sidecarOf) }
package/dist/write.js CHANGED
@@ -271,6 +271,7 @@ export function planWrites(plan, force) {
271
271
  ...(secretNames.length ? { secrets: { required: secretNames } } : {}),
272
272
  ...(service.restart ? { restart: service.restart } : {}),
273
273
  ...(service.container ? { container: service.container } : {}),
274
+ ...(service.models ? { models: service.models } : {}),
274
275
  ...(extraPorts.length ? { extraPorts } : {}),
275
276
  ...(sidecarOf ? { sidecarOf } : {}),
276
277
  ...(volumes.length
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flisk-sh/flisk-import",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Import a repository's root docker-compose.yml into Flisk service.json files, or register its Tiltfile.",
5
5
  "type": "module",
6
6
  "license": "MIT",