@flisk-sh/flisk-import 0.2.2 → 0.2.3
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/dist/cli.js +2 -2
- package/dist/detectors/compose.js +4 -4
- package/dist/format.js +1 -1
- package/dist/plan.js +3 -3
- package/dist/scan.js +5 -5
- package/dist/tdk.js +4 -4
- package/dist/write.js +5 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,7 +25,7 @@ async function confirm(message) {
|
|
|
25
25
|
}
|
|
26
26
|
const program = new Command("flisk-import")
|
|
27
27
|
.version(JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version)
|
|
28
|
-
.description("Import services from the root docker-compose.yml into
|
|
28
|
+
.description("Import services from the root docker-compose.yml into Flisk")
|
|
29
29
|
.argument("[dir]", "Directory containing docker-compose.yml", ".")
|
|
30
30
|
.option("--dry-run", "Print the plan and write nothing", false)
|
|
31
31
|
.option("--yes", "Write without prompting", false)
|
|
@@ -60,7 +60,7 @@ const program = new Command("flisk-import")
|
|
|
60
60
|
console.log("\nNext:");
|
|
61
61
|
if (plan.services.some((s) => s.envKeys.length))
|
|
62
62
|
console.log(` - Put the environment values these services need in ${envFile}; values in docker-compose.yml were not copied.`);
|
|
63
|
-
console.log(` - Run \`
|
|
63
|
+
console.log(` - Run \`flisk up\` with Flisk core ${MIN_CORE_VERSION} or later. The import did not start anything.`);
|
|
64
64
|
});
|
|
65
65
|
try {
|
|
66
66
|
await program.parseAsync();
|
|
@@ -21,7 +21,7 @@ const NON_HTTP_PORTS = new Set([
|
|
|
21
21
|
22, 25, 1883, 2181, 3306, 5432, 5672, 6379, 9092, 9200, 11211, 27017,
|
|
22
22
|
]);
|
|
23
23
|
/**
|
|
24
|
-
* Service keys this detector translates. Every other key is named in the report:
|
|
24
|
+
* Service keys this detector translates. Every other key is named in the report: Flisk runs a
|
|
25
25
|
* bring-your-own container without volumes, command overrides, env files and the rest.
|
|
26
26
|
* `healthcheck` only contributes an HTTP path; `environment` only contributes names.
|
|
27
27
|
*/
|
|
@@ -116,7 +116,7 @@ registerDetector({
|
|
|
116
116
|
if (raw.profiles !== undefined) {
|
|
117
117
|
skips.push({
|
|
118
118
|
...base,
|
|
119
|
-
reason: `service "${name}" has profiles ${JSON.stringify(raw.profiles)}; profiles are not enforced by
|
|
119
|
+
reason: `service "${name}" has profiles ${JSON.stringify(raw.profiles)}; profiles are not enforced by Flisk`,
|
|
120
120
|
});
|
|
121
121
|
continue;
|
|
122
122
|
}
|
|
@@ -166,7 +166,7 @@ registerDetector({
|
|
|
166
166
|
else if (ports.length > 1) {
|
|
167
167
|
skips.push({
|
|
168
168
|
...base,
|
|
169
|
-
reason: `service "${name}" publishes extra container ports (${ports.filter((port) => port !== selectedPort).join(", ")});
|
|
169
|
+
reason: `service "${name}" publishes extra container ports (${ports.filter((port) => port !== selectedPort).join(", ")}); Flisk routes only ${selectedPort}`,
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
const dependsOn = Array.isArray(raw.depends_on)
|
|
@@ -183,7 +183,7 @@ registerDetector({
|
|
|
183
183
|
if (foundHealthPath && !healthCheckPath) {
|
|
184
184
|
skips.push({
|
|
185
185
|
...base,
|
|
186
|
-
reason: `service "${name}" health path "${foundHealthPath}" has characters
|
|
186
|
+
reason: `service "${name}" health path "${foundHealthPath}" has characters Flisk does not accept (only a-z, 0-9, / and -); not used`,
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
const untranslated = Object.keys(raw).filter((key) => !TRANSLATED_KEYS.has(key));
|
package/dist/format.js
CHANGED
|
@@ -10,7 +10,7 @@ export function formatPlan(plan, writes) {
|
|
|
10
10
|
const jobs = plan.services.filter((s) => s.kind === "job").length;
|
|
11
11
|
out.push(`Found ${plan.services.length - jobs} service(s) and ${jobs} job(s) in ${plan.root}`, `Read only: ${plan.files.join(", ")}. Lines below name what was not translated.`, "");
|
|
12
12
|
if (writes.projectConfig)
|
|
13
|
-
out.push(` .tdk/project.json [create
|
|
13
|
+
out.push(` .tdk/project.json [create Flisk project]`, "");
|
|
14
14
|
for (const service of plan.services) {
|
|
15
15
|
const item = writes.items.find((i) => i.service === service);
|
|
16
16
|
out.push(` ${service.name} (${service.kind}${service.dir ? `, ${service.dir}/` : ""})`);
|
package/dist/plan.js
CHANGED
|
@@ -29,11 +29,11 @@ export function buildPlan(dir) {
|
|
|
29
29
|
const isFile = (name) => statSync(resolve(root, name), { throwIfNoEntry: false })?.isFile() ?? false;
|
|
30
30
|
if (!isFile(composePath)) {
|
|
31
31
|
const others = OTHER_COMPOSE_FILES.filter(isFile);
|
|
32
|
-
throw new ImportError(`No root docker-compose.yml found in ${root}${others.length ? ` (found ${others.join(", ")})` : ""};
|
|
32
|
+
throw new ImportError(`No root docker-compose.yml found in ${root}${others.length ? ` (found ${others.join(", ")})` : ""}; flisk import reads only that file`, others.length
|
|
33
33
|
? [
|
|
34
34
|
`Other Compose file names are not read yet. To import ${others[0]}, link it: ln -s ${others[0]} docker-compose.yml`,
|
|
35
35
|
]
|
|
36
|
-
: ["Run
|
|
36
|
+
: ["Run flisk import in the directory that holds docker-compose.yml"]);
|
|
37
37
|
}
|
|
38
38
|
for (const name of OTHER_COMPOSE_FILES.filter(isFile)) {
|
|
39
39
|
skips.push({
|
|
@@ -46,7 +46,7 @@ export function buildPlan(dir) {
|
|
|
46
46
|
skips.push({
|
|
47
47
|
file: name,
|
|
48
48
|
detector: "compose",
|
|
49
|
-
reason: `not applied; \`docker compose up\` merges it over ${COMPOSE_FILE},
|
|
49
|
+
reason: `not applied; \`docker compose up\` merges it over ${COMPOSE_FILE}, flisk import does not`,
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
for (const detector of detectors) {
|
package/dist/scan.js
CHANGED
|
@@ -7,7 +7,7 @@ export const HARD_SKIPS = new Set([
|
|
|
7
7
|
"target",
|
|
8
8
|
"dist",
|
|
9
9
|
".autogenerated",
|
|
10
|
-
// Output of `
|
|
10
|
+
// Output of `flisk project`: never a source of services.
|
|
11
11
|
".tdk",
|
|
12
12
|
"shared-platform-engineering",
|
|
13
13
|
]);
|
|
@@ -83,15 +83,15 @@ export function scanTree(root, limits = { depth: MAX_DEPTH, files: MAX_FILES })
|
|
|
83
83
|
const managed = [];
|
|
84
84
|
let depthCapped = false;
|
|
85
85
|
let fileCapped = false;
|
|
86
|
-
// In a
|
|
86
|
+
// In a Flisk project, `services/` holds manifests and generated compose files, not sources.
|
|
87
87
|
const isTdkProject = existsSync(join(root, ".tdk", "project.json"));
|
|
88
88
|
if (isTdkProject)
|
|
89
|
-
notes.push("
|
|
89
|
+
notes.push("Flisk project detected: services/ was not scanned");
|
|
90
90
|
const walk = (rel, depth, inherited) => {
|
|
91
91
|
const abs = join(root, rel);
|
|
92
92
|
const rules = [...inherited, ...readIgnoreRules(abs, rel, notes)];
|
|
93
93
|
const entries = readdirSync(abs, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
94
|
-
// A directory with a service.json is already a
|
|
94
|
+
// A directory with a service.json is already a Flisk service (possibly written by an earlier
|
|
95
95
|
// import, with a scaffolded Dockerfile): re-importing it would not be idempotent.
|
|
96
96
|
if (rel !== "" && entries.some((e) => e.isFile() && e.name === "service.json")) {
|
|
97
97
|
managed.push(rel);
|
|
@@ -127,7 +127,7 @@ export function scanTree(root, limits = { depth: MAX_DEPTH, files: MAX_FILES })
|
|
|
127
127
|
};
|
|
128
128
|
walk("", 0, []);
|
|
129
129
|
if (managed.length) {
|
|
130
|
-
notes.push(`${managed.length} director${managed.length === 1 ? "y" : "ies"} with a service.json skipped (already
|
|
130
|
+
notes.push(`${managed.length} director${managed.length === 1 ? "y" : "ies"} with a service.json skipped (already Flisk services)`);
|
|
131
131
|
}
|
|
132
132
|
if (depthCapped)
|
|
133
133
|
notes.push(`directories deeper than ${limits.depth} levels were not scanned`);
|
package/dist/tdk.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { dirname, join, resolve } from "node:path";
|
|
3
|
-
/** Manifest constants of the
|
|
3
|
+
/** Manifest constants of the Flisk service.json this tool writes. */
|
|
4
4
|
export const SERVICE_MANIFEST_SCHEMA_VERSION = 1;
|
|
5
5
|
export const SERVICE_MANIFEST_SCHEMA_URL = "https://flisk.sh/schema.service.json";
|
|
6
6
|
/**
|
|
7
|
-
* Oldest
|
|
7
|
+
* Oldest Flisk core that starts an imported project: 1.3.104 added `buildContext`, and 1.3.145
|
|
8
8
|
* (flisk#1018) bootstraps a project that has `.tdk/project.json` but no Tiltfile yet.
|
|
9
9
|
* Stated, not checked: the importer does not read the installed core version.
|
|
10
10
|
*/
|
|
11
11
|
export const MIN_CORE_VERSION = "1.3.145";
|
|
12
|
-
/**
|
|
12
|
+
/** Flisk's bring-your-own port range. */
|
|
13
13
|
export const BYO_PORT_RANGE = { min: 4000, max: 5999, label: "4000-5999" };
|
|
14
14
|
/**
|
|
15
|
-
* Values
|
|
15
|
+
* Values Flisk copies into generated Compose and Traefik config must match these, or `flisk up` refuses
|
|
16
16
|
* the manifest (flisk `cli/src/utils/service-manifest.ts`, engine `manifest/parser.star`).
|
|
17
17
|
*/
|
|
18
18
|
export const HEALTH_CHECK_PATH_PATTERN = /^\/[a-z0-9/-]*$/;
|
package/dist/write.js
CHANGED
|
@@ -14,7 +14,7 @@ function existingPort(path) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Maps merged services onto
|
|
17
|
+
* Maps merged services onto Flisk bring-your-own manifests. This is the only stage that knows the
|
|
18
18
|
* layout `<project>/services/<stack>/<name>/service.json`. Nothing is written here.
|
|
19
19
|
*/
|
|
20
20
|
/** Images that serve a protocol other than HTTP. Matched against the image name, not its tag. */
|
|
@@ -40,7 +40,7 @@ export function planWrites(plan, force) {
|
|
|
40
40
|
phases: {
|
|
41
41
|
pre_alpha: {
|
|
42
42
|
name: "Pre-Alpha",
|
|
43
|
-
description: "
|
|
43
|
+
description: "Flisk proxy and imported Compose services",
|
|
44
44
|
enabledStacks: ["proxy", stack],
|
|
45
45
|
},
|
|
46
46
|
alpha: { name: "Alpha", description: "", enabledStacks: [] },
|
|
@@ -71,7 +71,7 @@ export function planWrites(plan, force) {
|
|
|
71
71
|
: !service.image
|
|
72
72
|
? "Compose gives it neither `image` nor a usable `build`"
|
|
73
73
|
: !IMAGE_PATTERN.test(service.image)
|
|
74
|
-
? `image "${service.image}" uses Compose variables or characters
|
|
74
|
+
? `image "${service.image}" uses Compose variables or characters Flisk does not accept; set a literal image in docker-compose.yml, or write this service.json by hand`
|
|
75
75
|
: undefined;
|
|
76
76
|
if (reason)
|
|
77
77
|
rejected.push({ name: service.name, reason });
|
|
@@ -138,9 +138,9 @@ export function planWrites(plan, force) {
|
|
|
138
138
|
if (service.envKeys.length)
|
|
139
139
|
notes.push("environment values are not written; put them in the project .env");
|
|
140
140
|
if (service.dockerfile && service.image)
|
|
141
|
-
notes.push(`image "${service.image}" is not written: with build and image,
|
|
141
|
+
notes.push(`image "${service.image}" is not written: with build and image, Flisk builds from ${service.dockerfile} and does not pull the tag`);
|
|
142
142
|
// With both build and image, Compose builds the Dockerfile and tags the result as `image`.
|
|
143
|
-
// Omit `image` from service.json so
|
|
143
|
+
// Omit `image` from service.json so Flisk builds from the Dockerfile instead of pulling the tag.
|
|
144
144
|
const source = service.dockerfile
|
|
145
145
|
? {
|
|
146
146
|
buildContext: relative(dirname(path), resolve(plan.root, service.dir)).split("\\").join("/") || ".",
|