@promovaweb/designfy 0.0.0-stage → 0.2.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.
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * npm launcher of Designfy.
4
+ *
5
+ * Resolves the compiled binary for this platform (downloading it from the
6
+ * GitHub Release on the first run, see `lib/binary.cjs`) and runs it with
7
+ * the same arguments and inherited stdio, so the TUI, the CLI and the MCP
8
+ * stdio server behave exactly as the standalone binary. The exit code and
9
+ * terminating signal are passed through. `DESIGNFY_LAUNCHER=npm` tells the
10
+ * binary it was started by npm.
11
+ */
12
+ "use strict";
13
+
14
+ const { spawnSync } = require("node:child_process");
15
+ const { ensureBinary } = require("../lib/binary.cjs");
16
+
17
+ ensureBinary()
18
+ .then((binary) => {
19
+ const result = spawnSync(binary, process.argv.slice(2), {
20
+ stdio: "inherit",
21
+ env: { ...process.env, DESIGNFY_LAUNCHER: "npm" },
22
+ });
23
+ if (result.error) {
24
+ process.stderr.write(`designfy: could not start ${binary}: ${result.error.message}\n`);
25
+ process.exit(1);
26
+ }
27
+ if (result.signal) process.kill(process.pid, result.signal);
28
+ process.exit(result.status ?? 1);
29
+ })
30
+ .catch((e) => {
31
+ process.stderr.write(`designfy: ${e.message}\n`);
32
+ process.exit(1);
33
+ });
package/lib/binary.cjs ADDED
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Locates or downloads the compiled Designfy binary for this platform.
3
+ *
4
+ * The npm package is a thin wrapper: the real executable is the Bun binary
5
+ * published in the GitHub Release of the same version. On the first run the
6
+ * wrapper downloads `designfy-<platform>` and `SHA256SUMS` from
7
+ * `https://github.com/promovaweb/designfy/releases/download/v<version>/`,
8
+ * checks the hash, and keeps the file in
9
+ * `~/.designfy/bin/v<version>/` (or `DESIGNFY_BINARY_DIR`). Later runs use
10
+ * the cached file. `DESIGNFY_BINARY_PATH` points to a binary directly and
11
+ * skips the download; `DESIGNFY_RELEASE_BASE_URL` replaces the release URL
12
+ * (mirrors and tests). Progress goes to stderr, so the MCP stdio transport
13
+ * on stdout stays clean.
14
+ *
15
+ * Run as a script (`node lib/binary.cjs`), it pre-downloads the binary and
16
+ * never fails, which is what the `postinstall` hook uses.
17
+ */
18
+ "use strict";
19
+
20
+ const { createHash } = require("node:crypto");
21
+ const { chmodSync, existsSync, mkdirSync, renameSync, writeFileSync, unlinkSync } = require("node:fs");
22
+ const { homedir } = require("node:os");
23
+ const { join } = require("node:path");
24
+
25
+ const pkg = require("../package.json");
26
+ const REPOSITORY = "https://github.com/promovaweb/designfy";
27
+
28
+ const TARGETS = {
29
+ "linux-x64": "linux-x64",
30
+ "linux-arm64": "linux-arm64",
31
+ "darwin-x64": "darwin-x64",
32
+ "darwin-arm64": "darwin-arm64",
33
+ "win32-x64": "windows-x64",
34
+ };
35
+
36
+ /** Release asset name for the current platform, or null when unsupported. */
37
+ function assetName(platform = process.platform, arch = process.arch) {
38
+ const suffix = TARGETS[`${platform}-${arch}`];
39
+ if (!suffix) return null;
40
+ return `designfy-${suffix}${platform === "win32" ? ".exe" : ""}`;
41
+ }
42
+
43
+ /** Directory that caches the binary of this package version. */
44
+ function cacheDir() {
45
+ const override = process.env.DESIGNFY_BINARY_DIR;
46
+ if (override && override.trim()) return override;
47
+ return join(homedir(), ".designfy", "bin", `v${pkg.version}`);
48
+ }
49
+
50
+ async function download(url) {
51
+ const response = await fetch(url, { redirect: "follow" });
52
+ if (!response.ok) throw new Error(`HTTP ${response.status} for ${url}`);
53
+ return Buffer.from(await response.arrayBuffer());
54
+ }
55
+
56
+ /**
57
+ * Returns the path of a ready-to-run binary, downloading and verifying it
58
+ * when the cache is empty. Throws with an actionable message on failure.
59
+ */
60
+ async function ensureBinary() {
61
+ const explicit = process.env.DESIGNFY_BINARY_PATH;
62
+ if (explicit && explicit.trim()) {
63
+ if (!existsSync(explicit)) throw new Error(`DESIGNFY_BINARY_PATH points to a missing file: ${explicit}`);
64
+ return explicit;
65
+ }
66
+ const asset = assetName();
67
+ if (!asset) {
68
+ throw new Error(`No Designfy binary is published for ${process.platform}-${process.arch}. Supported: ${Object.keys(TARGETS).join(", ")}.`);
69
+ }
70
+ const dir = cacheDir();
71
+ const target = join(dir, asset);
72
+ if (existsSync(target)) return target;
73
+
74
+ const base = process.env.DESIGNFY_RELEASE_BASE_URL || `${REPOSITORY}/releases/download/v${pkg.version}`;
75
+ process.stderr.write(`designfy: downloading ${asset} v${pkg.version} (first run)...\n`);
76
+ const [binary, sums] = await Promise.all([download(`${base}/${asset}`), download(`${base}/SHA256SUMS`)]);
77
+ const expected = sums
78
+ .toString("utf8")
79
+ .split(/\r?\n/)
80
+ .map((line) => line.trim().split(/\s+\*?/))
81
+ .find(([, name]) => name === asset);
82
+ if (!expected) throw new Error(`SHA256SUMS of v${pkg.version} has no entry for ${asset}.`);
83
+ const actual = createHash("sha256").update(binary).digest("hex");
84
+ if (actual !== expected[0]) throw new Error(`Checksum mismatch for ${asset}: expected ${expected[0]}, got ${actual}.`);
85
+
86
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
87
+ const temp = `${target}.${process.pid}.tmp`;
88
+ try {
89
+ writeFileSync(temp, binary, { mode: 0o755 });
90
+ if (process.platform !== "win32") chmodSync(temp, 0o755);
91
+ renameSync(temp, target);
92
+ } catch (e) {
93
+ try {
94
+ unlinkSync(temp);
95
+ } catch {}
96
+ throw e;
97
+ }
98
+ process.stderr.write(`designfy: binary saved to ${target}\n`);
99
+ return target;
100
+ }
101
+
102
+ module.exports = { assetName, cacheDir, ensureBinary, TARGETS };
103
+
104
+ if (require.main === module) {
105
+ ensureBinary().catch((e) => {
106
+ process.stderr.write(`designfy: the binary will be downloaded on first run (${e.message})\n`);
107
+ });
108
+ }
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@promovaweb/designfy",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Visual framework for web projects: design system, React and Astro components with Tailwind, shadcn and motion, skills, dependency and MCP setup, and Playwright screen captures.",
5
+ "license": "AGPL-3.0-only",
6
+ "author": "Promovaweb",
7
+ "homepage": "https://github.com/promovaweb/designfy",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/promovaweb/designfy.git"
11
+ },
12
+ "keywords": [
13
+ "design-system",
14
+ "tailwind",
15
+ "shadcn",
16
+ "react",
17
+ "astro",
18
+ "motion",
19
+ "components",
20
+ "cli",
21
+ "tui",
22
+ "mcp",
23
+ "ai-agents",
24
+ "playwright"
25
+ ],
26
+ "bin": {
27
+ "designfy": "bin/designfy.cjs"
28
+ },
29
+ "files": [
30
+ "bin",
31
+ "lib",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "scripts": {
36
+ "postinstall": "node lib/binary.cjs"
37
+ },
38
+ "engines": {
39
+ "node": ">=18.17.0"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ }
44
+ }