archik 0.6.2 → 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 +84 -2
- package/dist/cli/archik.mjs +171 -171
- package/dist/ui/assets/{index-DiMwrfG0.js → index-Cxb-Myhy.js} +87 -87
- package/dist/ui/index.html +1 -1
- package/package.json +1 -2
- package/bin/postinstall.js +0 -58
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 {
|
|
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
|
+
}
|