create-devrig 1.0.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -0
  3. package/index.js +111 -0
  4. package/package.json +33 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lakpriya Senevirathna
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # create-devrig
2
+
3
+ One command to scaffold a [devrig](https://github.com/lakpriya1s/devrig) workspace — no cloning, no separate setup step.
4
+
5
+ ```bash
6
+ npx create-devrig my-project
7
+ ```
8
+
9
+ This:
10
+
11
+ 1. Fetches the devrig template into `my-project/` (no git history — just the files).
12
+ 2. Initializes a fresh git repository there.
13
+ 3. Launches devrig's interactive `setup.sh` wizard immediately, so you configure your project name, GitHub org, repos, issue tracker, and toggles in the same command.
14
+
15
+ Omit the directory and you'll be prompted for one:
16
+
17
+ ```bash
18
+ npx create-devrig
19
+ ```
20
+
21
+ ## Requirements
22
+
23
+ - Node.js 18+
24
+ - `git`
25
+ - `bash` (native on macOS/Linux; on Windows, run this inside WSL or Git Bash — devrig's `setup.sh` is a bash script)
26
+
27
+ ## What this package does *not* do
28
+
29
+ It doesn't reimplement any of devrig's setup logic — it only fetches the template and hands off to its own `setup.sh`. Updates to devrig's setup flow, skills, or config schema take effect automatically the next time someone runs `npx create-devrig`; this package itself rarely needs to change.
30
+
31
+ ## See also
32
+
33
+ - [devrig](https://github.com/lakpriya1s/devrig) — the template itself
34
+ - Prefer GitHub's UI? Use the [**Use this template**](https://github.com/lakpriya1s/devrig/generate) button instead.
35
+
36
+ ## License
37
+
38
+ MIT
package/index.js ADDED
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync, readdirSync, chmodSync } from "node:fs";
3
+ import { resolve, join } from "node:path";
4
+ import { spawn, spawnSync } from "node:child_process";
5
+ import readline from "node:readline/promises";
6
+ import { stdin, stdout } from "node:process";
7
+
8
+ const REPO = "lakpriya1s/devrig";
9
+ const HELP = `
10
+ create-devrig — scaffold a devrig multi-repo AI dev workspace
11
+
12
+ Usage:
13
+ npx create-devrig [directory]
14
+
15
+ Fetches the devrig template (no git history), makes the target directory
16
+ its own git repo, and launches its interactive setup wizard.
17
+
18
+ Options:
19
+ -h, --help Show this help
20
+ `;
21
+
22
+ function fail(msg) {
23
+ console.error(`\x1b[31merror:\x1b[0m ${msg}`);
24
+ process.exit(1);
25
+ }
26
+
27
+ function isEmptyDir(dir) {
28
+ if (!existsSync(dir)) return true;
29
+ const entries = readdirSync(dir).filter((e) => e !== ".git");
30
+ return entries.length === 0;
31
+ }
32
+
33
+ async function promptTarget() {
34
+ const rl = readline.createInterface({ input: stdin, output: stdout });
35
+ const answer = await rl.question(
36
+ "Directory to create (. for current directory) [my-devrig-workspace]: "
37
+ );
38
+ rl.close();
39
+ return answer.trim() || "my-devrig-workspace";
40
+ }
41
+
42
+ function commandExists(cmd) {
43
+ const probe = process.platform === "win32" ? "where" : "command";
44
+ const args = process.platform === "win32" ? [cmd] : ["-v", cmd];
45
+ const res = spawnSync(probe, args, { stdio: "ignore", shell: process.platform === "win32" });
46
+ return res.status === 0;
47
+ }
48
+
49
+ async function main() {
50
+ const args = process.argv.slice(2);
51
+ if (args.includes("-h") || args.includes("--help")) {
52
+ console.log(HELP);
53
+ return;
54
+ }
55
+
56
+ let target = args.find((a) => !a.startsWith("-"));
57
+ if (!target) target = await promptTarget();
58
+ const dest = resolve(process.cwd(), target);
59
+
60
+ if (!isEmptyDir(dest)) {
61
+ fail(`'${target}' already exists and is not empty. Choose an empty or new directory.`);
62
+ }
63
+
64
+ if (!commandExists("git")) {
65
+ fail("git is required. On macOS run: xcode-select --install");
66
+ }
67
+
68
+ console.log(`\x1b[34m==>\x1b[0m Fetching devrig template into ${target}...`);
69
+ const { default: degit } = await import("degit");
70
+ const emitter = degit(REPO, { cache: false, force: true, verbose: false });
71
+ try {
72
+ await emitter.clone(dest);
73
+ } catch (err) {
74
+ fail(`Failed to fetch the template: ${err.message}`);
75
+ }
76
+
77
+ if (!existsSync(join(dest, ".git"))) {
78
+ console.log("\x1b[34m==>\x1b[0m Initializing git repository...");
79
+ const initRes = spawnSync("git", ["init", "-q"], { cwd: dest, stdio: "inherit" });
80
+ if (initRes.status !== 0) fail("git init failed.");
81
+ }
82
+
83
+ for (const rel of ["setup.sh", "git-hooks/pre-commit", "git-hooks/pre-push"]) {
84
+ const p = join(dest, rel);
85
+ if (existsSync(p)) {
86
+ try {
87
+ chmodSync(p, 0o755);
88
+ } catch {
89
+ // non-fatal — setup.sh chmods the hooks itself; worst case the user
90
+ // runs `chmod +x setup.sh` once by hand on an unusual filesystem.
91
+ }
92
+ }
93
+ }
94
+
95
+ console.log(`\x1b[34m==>\x1b[0m Launching setup — answer its prompts to configure your workspace.\n`);
96
+
97
+ const runner = process.platform === "win32" && !commandExists("bash") ? null : "bash";
98
+ if (!runner) {
99
+ console.log(
100
+ `${target} is ready, but no bash was found to run setup.sh automatically.\n` +
101
+ `Open this folder in WSL or Git Bash and run:\n\n ./setup.sh\n`
102
+ );
103
+ return;
104
+ }
105
+
106
+ const child = spawn(runner, ["setup.sh"], { cwd: dest, stdio: "inherit" });
107
+ child.on("exit", (code) => process.exit(code ?? 0));
108
+ child.on("error", (err) => fail(`Failed to launch setup.sh: ${err.message}`));
109
+ }
110
+
111
+ main().catch((err) => fail(err.message));
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "create-devrig",
3
+ "version": "1.0.0",
4
+ "description": "Scaffold a devrig multi-repo AI dev workspace: fetches the template and launches its interactive setup.",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-devrig": "index.js"
8
+ },
9
+ "files": [
10
+ "index.js"
11
+ ],
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
15
+ "license": "MIT",
16
+ "author": "Lakpriya Senevirathna",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/lakpriya1s/create-devrig.git"
20
+ },
21
+ "keywords": [
22
+ "devrig",
23
+ "scaffold",
24
+ "template",
25
+ "ai",
26
+ "claude-code",
27
+ "workspace",
28
+ "mcp"
29
+ ],
30
+ "dependencies": {
31
+ "degit": "^2.8.4"
32
+ }
33
+ }