archik 0.6.3 → 0.6.4

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/bin/archik.js CHANGED
@@ -13,9 +13,16 @@
13
13
  * where its install lives.
14
14
  */
15
15
  import { spawnSync } from "node:child_process";
16
- import { dirname, resolve } from "node:path";
16
+ import { dirname, join, resolve } from "node:path";
17
17
  import { fileURLToPath } from "node:url";
18
- import { existsSync, realpathSync } from "node:fs";
18
+ import {
19
+ existsSync,
20
+ mkdirSync,
21
+ readFileSync,
22
+ realpathSync,
23
+ writeFileSync,
24
+ } from "node:fs";
25
+ import { homedir } from "node:os";
19
26
 
20
27
  const here = dirname(realpathSync(fileURLToPath(import.meta.url)));
21
28
  const pkgRoot = resolve(here, "..");
@@ -24,6 +31,14 @@ const env = { ...process.env, ARCHIK_PKG_ROOT: pkgRoot };
24
31
 
25
32
  const distEntry = resolve(pkgRoot, "dist", "cli", "archik.mjs");
26
33
 
34
+ // First-run / new-version banner. We can't reliably print on `npm
35
+ // install` itself — npm 10+ silences postinstall stdout/stderr by
36
+ // default unless --foreground-scripts is passed. So we print on
37
+ // the first archik invocation after install or upgrade, and stamp
38
+ // a marker file so the next call stays quiet. Honours NO_COLOR /
39
+ // ARCHIK_NO_BANNER and stays silent when stdout isn't a TTY.
40
+ maybePrintFirstRunBanner();
41
+
27
42
  let result;
28
43
  if (existsSync(distEntry)) {
29
44
  result = spawnSync(process.execPath, [distEntry, ...args], {
@@ -56,3 +71,70 @@ if (existsSync(distEntry)) {
56
71
  }
57
72
 
58
73
  process.exit(result.status ?? 1);
74
+
75
+ function maybePrintFirstRunBanner() {
76
+ if (
77
+ process.env["ARCHIK_NO_BANNER"] !== undefined ||
78
+ process.env["CI"] !== undefined ||
79
+ !process.stdout.isTTY
80
+ ) {
81
+ return;
82
+ }
83
+ let pkg;
84
+ try {
85
+ pkg = JSON.parse(readFileSync(resolve(pkgRoot, "package.json"), "utf8"));
86
+ } catch {
87
+ return;
88
+ }
89
+ const version = String(pkg.version ?? "");
90
+ if (version === "") return;
91
+
92
+ const markerDir = join(homedir(), ".archik");
93
+ const markerFile = join(markerDir, "last-banner-version");
94
+ let lastSeen = "";
95
+ try {
96
+ lastSeen = readFileSync(markerFile, "utf8").trim();
97
+ } catch {
98
+ // first install — no marker yet
99
+ }
100
+ if (lastSeen === version) return;
101
+
102
+ // Show the banner and persist the version. Failure to persist is
103
+ // non-fatal — the banner just shows again next call.
104
+ printBanner(version);
105
+ try {
106
+ mkdirSync(markerDir, { recursive: true });
107
+ writeFileSync(markerFile, version + "\n");
108
+ } catch {
109
+ // read-only home or similar — fine
110
+ }
111
+ }
112
+
113
+ function printBanner(version) {
114
+ const colour = process.env["NO_COLOR"] === undefined;
115
+ const c = (open, close) => (s) =>
116
+ colour ? `\x1b[${open}m${s}\x1b[${close}m` : s;
117
+ const bold = c("1", "22");
118
+ const dim = c("2", "22");
119
+ const cyan = c("36", "39");
120
+ const green = c("32", "39");
121
+ const magenta = c("35", "39");
122
+ const line = dim("─".repeat(56));
123
+ const tick = bold(green("✓"));
124
+ const arrow = cyan("▸");
125
+
126
+ process.stdout.write(
127
+ [
128
+ "",
129
+ line,
130
+ ` ${tick} ${bold(magenta("archik"))} ${dim("v" + version)} ${dim("ready")}`,
131
+ line,
132
+ ` ${arrow} ${bold("archik init")} ${dim("scaffold .archik/main.archik.yaml")}`,
133
+ ` ${arrow} ${bold("archik dev")} ${dim("open the live canvas in your browser")}`,
134
+ ` ${arrow} ${bold("archik --help")} ${dim("full command list")}`,
135
+ "",
136
+ ` ${dim("Docs: https://npmjs.com/package/archik")}`,
137
+ "",
138
+ ].join("\n") + "\n",
139
+ );
140
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archik",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "Architecture diagrams as YAML. Live canvas in the browser, headless SVG render in CI, and an installable Claude skill so the model edits the same file you do.",
5
5
  "keywords": [
6
6
  "architecture",
@@ -38,7 +38,6 @@
38
38
  "test": "vitest run",
39
39
  "test:watch": "vitest",
40
40
  "archik": "tsx --tsconfig tsconfig.app.json src/cli/index.ts",
41
- "postinstall": "node bin/postinstall.js || true",
42
41
  "prepublishOnly": "npm run typecheck && npm test && npm run build"
43
42
  },
44
43
  "devDependencies": {
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Friendly post-install banner. npm 10+ stopped echoing the package
4
- * version ("added 1 package in 3s" is all the user sees), so this
5
- * gives them a confirmation, the version they got, and where to go
6
- * next. Stays quiet under CI / non-TTY / inside a parent npm install
7
- * so it doesn't pollute logs.
8
- */
9
- import { readFileSync } from "node:fs";
10
- import { dirname, resolve } from "node:path";
11
- import { fileURLToPath } from "node:url";
12
-
13
- // Skip when noise would hurt more than help.
14
- if (
15
- process.env["CI"] !== undefined ||
16
- process.env["ARCHIK_NO_BANNER"] !== undefined ||
17
- !process.stdout.isTTY ||
18
- // Inside `npm install` / yarn / pnpm of a host project — only
19
- // show the banner for global installs and direct local installs.
20
- process.env["npm_config_global"] !== "true" &&
21
- process.env["npm_command"] === "install" &&
22
- process.env["npm_config_save"] !== undefined
23
- ) {
24
- process.exit(0);
25
- }
26
-
27
- const here = dirname(fileURLToPath(import.meta.url));
28
- const pkg = JSON.parse(
29
- readFileSync(resolve(here, "..", "package.json"), "utf8"),
30
- );
31
-
32
- const enabled = process.env["NO_COLOR"] === undefined;
33
- const c = (open, close) => (s) =>
34
- enabled ? `\x1b[${open}m${s}\x1b[${close}m` : s;
35
- const bold = c("1", "22");
36
- const dim = c("2", "22");
37
- const cyan = c("36", "39");
38
- const green = c("32", "39");
39
- const magenta = c("35", "39");
40
-
41
- const line = dim("─".repeat(56));
42
- const tick = bold(green("✓"));
43
- const arrow = cyan("▸");
44
-
45
- process.stdout.write(
46
- [
47
- "",
48
- line,
49
- ` ${tick} ${bold(magenta("archik"))} ${dim("v" + pkg.version)} ${dim("installed")}`,
50
- line,
51
- ` ${arrow} ${bold("archik init")} ${dim("scaffold .archik/main.archik.yaml")}`,
52
- ` ${arrow} ${bold("archik dev")} ${dim("open the live canvas in your browser")}`,
53
- ` ${arrow} ${bold("archik --help")} ${dim("full command list")}`,
54
- "",
55
- ` ${dim("Docs: https://npmjs.com/package/archik")}`,
56
- "",
57
- ].join("\n"),
58
- );