create-insight 0.25.0 → 0.25.2

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.
Files changed (2) hide show
  1. package/create-insight.mjs +20 -6
  2. package/package.json +1 -1
@@ -109,15 +109,29 @@ function appPort(dir2) {
109
109
  function containerNames(project2) {
110
110
  return { insight: `${project2}-insight`, db: `${project2}-db` };
111
111
  }
112
+ function composeCommand(tool2, file = "docker-compose.yml") {
113
+ return file === "docker-compose.yml" ? tool2 : `${tool2} -f ${file}`;
114
+ }
115
+ function afterInstallLines(p) {
116
+ const compose = composeCommand(p.tool, p.file);
117
+ return [
118
+ `Insight runs in the container ${p.container}.`,
119
+ `For datasets in your app's database (sql: in insight.yaml), the SQL for Insight's read-only login: ${p.cli} exec ${p.container} insight-db plan`,
120
+ `Later: ${compose} down to stop, ${compose} up -d to start again, npx create-insight upgrade for a new release.`
121
+ ];
122
+ }
123
+ function upgradedCompose(text, image2, compose) {
124
+ return text.replace(/(image:\s*)\S+\/insight:\S+/, `$1${image2}`).replace(/^# Insight beside this app, written by Insight's installer\. Start: .* up -d · Stop: .* down$/m, `# Insight beside this app, written by Insight's installer. Start: ${compose} up -d \xB7 Stop: ${compose} down`).replace(/^# Upgrade: change the image's version, then .* up -d\./m, "# Upgrade: npx create-insight upgrade (in this folder).");
125
+ }
112
126
  function projectName(folder) {
113
127
  const slug = folder.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
114
128
  return `insight-${slug || "app"}`;
115
129
  }
116
130
  function composeYaml(p) {
117
131
  const names2 = containerNames(p.project);
118
- const tool2 = p.engine === "podman" ? "podman compose" : "docker compose";
132
+ const tool2 = composeCommand(p.engine === "podman" ? "podman compose" : "docker compose", p.file);
119
133
  return `# Insight beside this app, written by Insight's installer. Start: ${tool2} up -d \xB7 Stop: ${tool2} down
120
- # Upgrade: change the image's version, then ${tool2} up -d. Settings and secrets are in insight.env.
134
+ # Upgrade: npx create-insight upgrade (in this folder). Settings and secrets are in insight.env.
121
135
  name: ${p.project}
122
136
  services:
123
137
  insight:
@@ -260,7 +274,7 @@ INSIGHT_APP_SECRET=${secret}
260
274
  }
261
275
  const file = composeFile(dir);
262
276
  const compose = join3(dir, file);
263
- writeFileSync2(compose, readFileSync3(compose, "utf8").replace(/(image:\s*)\S+\/insight:\S+/, `$1${image}`));
277
+ writeFileSync2(compose, upgradedCompose(readFileSync3(compose, "utf8"), image, composeCommand(tool, file)));
264
278
  const up2 = run(engine.compose[0], [...engine.compose.slice(1), ...file === "docker-compose.yml" ? [] : ["-f", file], "up", "-d"], { stdio: ["ignore", "ignore", "pipe"] });
265
279
  if (up2.status !== 0) stop(`${tool} up didn\u2019t start:
266
280
  ${(up2.stderr ?? "").trim()}`);
@@ -285,7 +299,7 @@ var consoleUrl = `http://127.0.0.1:${port}`;
285
299
  mkdirSync(join3(dir, "keys"), { recursive: true });
286
300
  var appSecret = ensureAppSecret(join3(dir, "keys")).secret;
287
301
  mkdirSync(join3(dir, "insight-config"), { recursive: true });
288
- writeFileSync2(join3(dir, composeName), composeYaml({ engine: engine.name, selinux: engine.selinux, project, image, port }));
302
+ writeFileSync2(join3(dir, composeName), composeYaml({ engine: engine.name, selinux: engine.selinux, project, image, port, file: composeName }));
289
303
  writeFileSync2(
290
304
  envFile,
291
305
  [
@@ -323,7 +337,7 @@ if (add.length) appendFileSync(ignore, `${ignored.length && ignored.at(-1) !== "
323
337
  ${add.join("\n")}
324
338
  `);
325
339
  done(`Wrote ${composeName}, insight.env (secrets, kept out of git) and insight-config/`);
326
- if (composeName !== "docker-compose.yml") say(` Your app has its own docker-compose.yml, left as it is. Insight's is ${composeName}: start it with ${tool} -f ${composeName} up -d`);
340
+ if (composeName !== "docker-compose.yml") say(` Your app has its own docker-compose.yml, left as it is. Insight's is ${composeName}: start it with ${composeCommand(tool, composeName)} up -d`);
327
341
  if (!values["app-url"]) say(` Insight reads your app at port ${found?.port ?? 3e3} (${found ? `from ${found.from}` : "nothing in package.json or .env said, so the usual 3000"}). If that's wrong, change INSIGHT_READ_URL in insight.env.`);
328
342
  var keysDir = join3(dir, "keys");
329
343
  mkdirSync(keysDir, { recursive: true });
@@ -349,7 +363,7 @@ say(` INSIGHT_URL=${consoleUrl}`);
349
363
  say(` INSIGHT_KEYS_DIR=${keysDir} (deploy this folder with the app: its signing key and watch secret)`);
350
364
  if (packageDirs.length) say(`Commit vendor/kaleyla-insight-${version}.tgz with package.json: your CI installs Insight\u2019s package from it, with no key.`);
351
365
  say("Next, in the console: Your app \u203A Connection. Choose how people will ask and which AI model answers (nothing reaches a model before that), then give the prompt to your coding agent.");
352
- say(`Later: ${tool} down to stop, ${tool} up -d to start again, npx create-insight upgrade for a new release.`);
366
+ for (const line of afterInstallLines({ cli, tool, file: composeName, container: names.insight })) say(line);
353
367
  function detectEngine() {
354
368
  const ok = (cmd, args) => run(cmd, args, { stdio: "ignore" }).status === 0;
355
369
  const has = (cmd) => run(cmd, ["--version"], { stdio: "ignore" }).error === void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-insight",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
4
4
  "description": "Sets Insight up beside your app, with your Kaleyla key: npx create-insight",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",