@jarooda/jlds 0.1.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.
- package/README.md +29 -0
- package/bin/jlds.js +100 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @jarooda/jlds
|
|
2
|
+
|
|
3
|
+
The CLI for the [JLDS design system](https://github.com/jarooda/jlds). It downloads React/Vue
|
|
4
|
+
component source straight into your project — you own and customize the code, shadcn-style.
|
|
5
|
+
|
|
6
|
+
## Run it
|
|
7
|
+
|
|
8
|
+
No install needed — run on the fly with `npx`:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npx @jarooda/jlds init # detect framework, write jlds.json, inject design tokens
|
|
12
|
+
npx @jarooda/jlds add button # download a component into your project
|
|
13
|
+
npx @jarooda/jlds list # list available components
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or install it globally — the command is `jlds`:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm i -g @jarooda/jlds
|
|
20
|
+
jlds init
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This package is a thin launcher: on first run it downloads the prebuilt native binary for your
|
|
24
|
+
platform from the matching [GitHub Release](https://github.com/jarooda/jlds/releases), caches it
|
|
25
|
+
by version, and runs it directly. Later runs reuse the cache (no network).
|
|
26
|
+
|
|
27
|
+
## Docs
|
|
28
|
+
|
|
29
|
+
See the full documentation at <https://github.com/jarooda/jlds>.
|
package/bin/jlds.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Launcher for the JLDS CLI. The real program is a native Rust binary attached
|
|
5
|
+
// to the matching GitHub Release. On first run we download the binary for this
|
|
6
|
+
// platform, cache it by version, then hand off — forwarding args, stdio, and
|
|
7
|
+
// exit code. Subsequent runs reuse the cached binary (no network).
|
|
8
|
+
|
|
9
|
+
const fs = require("node:fs");
|
|
10
|
+
const os = require("node:os");
|
|
11
|
+
const path = require("node:path");
|
|
12
|
+
const https = require("node:https");
|
|
13
|
+
const { spawnSync } = require("node:child_process");
|
|
14
|
+
|
|
15
|
+
const pkg = require("../package.json");
|
|
16
|
+
const VERSION = pkg.version;
|
|
17
|
+
const REPO = "jarooda/jlds";
|
|
18
|
+
|
|
19
|
+
// platform + arch -> rust target triple used in the release asset name
|
|
20
|
+
const TARGETS = {
|
|
21
|
+
"darwin arm64": "aarch64-apple-darwin",
|
|
22
|
+
"darwin x64": "x86_64-apple-darwin",
|
|
23
|
+
"linux arm64": "aarch64-unknown-linux-gnu",
|
|
24
|
+
"linux x64": "x86_64-unknown-linux-gnu",
|
|
25
|
+
"win32 x64": "x86_64-pc-windows-msvc",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const key = `${process.platform} ${process.arch}`;
|
|
29
|
+
const target = TARGETS[key];
|
|
30
|
+
if (!target) {
|
|
31
|
+
console.error(`jlds: no prebuilt binary for your platform (${key}).`);
|
|
32
|
+
console.error(
|
|
33
|
+
"Install from source instead:\n" +
|
|
34
|
+
" cargo install --git https://github.com/jarooda/jlds.git jlds"
|
|
35
|
+
);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const isWin = process.platform === "win32";
|
|
40
|
+
const ext = isWin ? ".exe" : "";
|
|
41
|
+
const assetName = `jlds-${target}${ext}`;
|
|
42
|
+
|
|
43
|
+
function cacheRoot() {
|
|
44
|
+
if (isWin) return process.env.LOCALAPPDATA || os.tmpdir();
|
|
45
|
+
return process.env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const cacheDir = path.join(cacheRoot(), "jlds", VERSION);
|
|
49
|
+
const binPath = path.join(cacheDir, `jlds${ext}`);
|
|
50
|
+
|
|
51
|
+
function download(url, dest) {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
const req = https.get(url, { headers: { "User-Agent": "jlds-cli" } }, (res) => {
|
|
54
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
55
|
+
res.resume();
|
|
56
|
+
resolve(download(res.headers.location, dest));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (res.statusCode !== 200) {
|
|
60
|
+
res.resume();
|
|
61
|
+
reject(new Error(`HTTP ${res.statusCode}`));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const file = fs.createWriteStream(dest);
|
|
65
|
+
res.pipe(file);
|
|
66
|
+
file.on("finish", () => file.close((err) => (err ? reject(err) : resolve())));
|
|
67
|
+
file.on("error", reject);
|
|
68
|
+
});
|
|
69
|
+
req.on("error", reject);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
(async () => {
|
|
74
|
+
if (!fs.existsSync(binPath)) {
|
|
75
|
+
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${assetName}`;
|
|
76
|
+
process.stderr.write(`jlds: downloading ${assetName} (v${VERSION})…\n`);
|
|
77
|
+
try {
|
|
78
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
79
|
+
const tmp = `${binPath}.tmp-${process.pid}`;
|
|
80
|
+
await download(url, tmp);
|
|
81
|
+
if (!isWin) fs.chmodSync(tmp, 0o755);
|
|
82
|
+
fs.renameSync(tmp, binPath);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
console.error(`jlds: failed to download the CLI binary (${err.message}).`);
|
|
85
|
+
console.error(` asset: ${url}`);
|
|
86
|
+
console.error(
|
|
87
|
+
" If this keeps happening, install from source:\n" +
|
|
88
|
+
" cargo install --git https://github.com/jarooda/jlds.git jlds"
|
|
89
|
+
);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const result = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
95
|
+
if (result.error) {
|
|
96
|
+
console.error(result.error.message);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
100
|
+
})();
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jarooda/jlds",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Own-your-code component CLI for the JLDS design system — downloads React/Vue components straight into your project.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"jlds": "bin/jlds.js"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin"
|
|
13
|
+
],
|
|
14
|
+
"keywords": [
|
|
15
|
+
"jlds",
|
|
16
|
+
"design-system",
|
|
17
|
+
"cli",
|
|
18
|
+
"react",
|
|
19
|
+
"vue",
|
|
20
|
+
"components",
|
|
21
|
+
"ui"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"homepage": "https://github.com/jarooda/jlds",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/jarooda/jlds.git",
|
|
28
|
+
"directory": "npm/jlds"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=16"
|
|
32
|
+
}
|
|
33
|
+
}
|