create-rigg 0.1.2 → 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.
package/dist/index.mjs CHANGED
@@ -168,12 +168,13 @@ function run(cmd, args, opts) {
168
168
  });
169
169
  });
170
170
  }
171
- /** Recursively copies a directory, renaming _gitignore to .gitignore. */
171
+ /** Recursively copies a directory, renaming _gitignore .gitignore (npm strips dotfiles during publish). */
172
172
  function copyDir(src, dest) {
173
173
  fs.mkdirSync(dest, { recursive: true });
174
174
  for (const entry of fs.readdirSync(src)) {
175
175
  const srcPath = path.join(src, entry);
176
- const destPath = path.join(dest, entry === "_gitignore" ? ".gitignore" : entry);
176
+ const destName = entry === "_gitignore" ? ".gitignore" : entry;
177
+ const destPath = path.join(dest, destName);
177
178
  if (fs.statSync(srcPath).isDirectory()) copyDir(srcPath, destPath);
178
179
  else fs.copyFileSync(srcPath, destPath);
179
180
  }
@@ -242,7 +243,9 @@ async function scaffoldFiles(options, targetDir) {
242
243
  const pkgJsonPath = path.join(targetDir, "package.json");
243
244
  const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
244
245
  pkg.name = options.projectName;
246
+ if (options.pkgManager === "npm") pkg.allowScripts = { esbuild: true };
245
247
  fs.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + "\n");
248
+ if (options.pkgManager === "pnpm") fs.writeFileSync(path.join(targetDir, "pnpm-workspace.yaml"), "allowBuilds:\n esbuild: true\n");
246
249
  /** Replace the placeholder project name in README.md. */
247
250
  const readmePath = path.join(targetDir, "README.md");
248
251
  const readme = fs.readFileSync(readmePath, "utf-8");
@@ -317,12 +320,20 @@ async function resolveOptions(argv) {
317
320
  verbose: argv.verbose ?? false
318
321
  };
319
322
  }
323
+ /** Initializes a git repository in targetDir, unless git is missing or targetDir is already inside one. */
320
324
  async function initializeGit(options, targetDir) {
321
325
  const git = spawn.sync("git", ["--version"], { stdio: "ignore" });
322
326
  if (git.error || git.status !== 0) {
323
327
  p.log.info("Git not found. Skipping repository initialization.");
324
328
  return;
325
329
  }
330
+ if (spawn.sync("git", ["rev-parse", "--is-inside-work-tree"], {
331
+ cwd: targetDir,
332
+ stdio: "ignore"
333
+ }).status === 0) {
334
+ p.log.info("Already inside a git repository. Skipping git init.");
335
+ return;
336
+ }
326
337
  const spin = p.spinner();
327
338
  spin.start("Initializing git repository...");
328
339
  await run("git", [
@@ -335,6 +346,12 @@ async function initializeGit(options, targetDir) {
335
346
  });
336
347
  spin.stop("Git repository initialized");
337
348
  }
349
+ /** Adds dist and node_modules to a generated oxlint/oxfmt config's ignorePatterns. */
350
+ function addIgnorePatterns(configPath) {
351
+ const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
352
+ config.ignorePatterns = ["dist", "node_modules"];
353
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
354
+ }
338
355
  /**
339
356
  * Creates oxlint+oxfmt configuration files and formats the code.
340
357
  */
@@ -363,6 +380,8 @@ async function formatCode(options, targetDir) {
363
380
  cwd: targetDir,
364
381
  stdio
365
382
  });
383
+ addIgnorePatterns(path.join(targetDir, ".oxlintrc.json"));
384
+ addIgnorePatterns(path.join(targetDir, ".oxfmtrc.json"));
366
385
  await run(pkgManager, [
367
386
  execCmd,
368
387
  "oxfmt",
@@ -374,15 +393,25 @@ async function formatCode(options, targetDir) {
374
393
  });
375
394
  spin.stop("Code formatted");
376
395
  }
396
+ /** Reads the CLI's own version from its package.json. */
397
+ function getVersion() {
398
+ const directory = path.dirname(fileURLToPath(import.meta.url));
399
+ const pkgJsonPath = path.join(directory, "..", "package.json");
400
+ return JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8")).version;
401
+ }
377
402
  async function main() {
378
403
  const argv = mri(process.argv.slice(2), {
379
404
  string: ["framework", "pm"],
380
- boolean: ["verbose"],
405
+ boolean: ["verbose", "version"],
381
406
  alias: {
382
407
  f: "framework",
383
408
  v: "verbose"
384
409
  }
385
410
  });
411
+ if (argv.version) {
412
+ console.log(getVersion());
413
+ return;
414
+ }
386
415
  showIntro();
387
416
  const options = await resolveOptions(argv);
388
417
  const targetDir = path.resolve(process.cwd(), options.projectName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-rigg",
3
- "version": "0.1.2",
3
+ "version": "1.0.0",
4
4
  "description": "Create Node.js TypeScript projects using the Vite+ Toolchain - for everything outside the browser.",
5
5
  "keywords": [
6
6
  "backend",
@@ -38,34 +38,36 @@
38
38
  "template"
39
39
  ],
40
40
  "type": "module",
41
+ "scripts": {
42
+ "test": "vitest",
43
+ "lint": "oxlint",
44
+ "lint:fix": "oxlint --fix",
45
+ "fmt": "oxfmt",
46
+ "fmt:check": "oxfmt --check",
47
+ "check": "oxlint && oxfmt --check && tsc --noEmit",
48
+ "dev": "tsx src/index.ts",
49
+ "build": "tsdown src/index.ts",
50
+ "start": "node dist/index.mjs",
51
+ "prepublishOnly": "git diff --exit-code && git diff --cached --exit-code && oxlint && oxfmt && tsc --noEmit && vitest run && pnpm build"
52
+ },
41
53
  "dependencies": {
42
- "@clack/prompts": "^1.1.0",
54
+ "@clack/prompts": "^1.7.0",
43
55
  "cross-spawn": "^7.0.6",
44
56
  "mri": "^1.2.0",
45
57
  "picocolors": "^1.1.1"
46
58
  },
47
59
  "devDependencies": {
48
60
  "@types/cross-spawn": "^6.0.6",
49
- "@types/node": "^25.5.0",
50
- "oxfmt": "^0.43.0",
51
- "oxlint": "^1.58.0",
52
- "tsdown": "^0.21.7",
53
- "tsx": "^4.21.0",
54
- "typescript": "^6.0.2",
55
- "vitest": "^4.1.2"
61
+ "@types/node": "^24.13.3",
62
+ "oxfmt": "^0.60.0",
63
+ "oxlint": "^1.75.0",
64
+ "tsdown": "^0.22.14",
65
+ "tsx": "^4.23.1",
66
+ "typescript": "^7.0.2",
67
+ "vitest": "^4.1.10"
56
68
  },
57
69
  "engines": {
58
70
  "node": ">=22.12.0"
59
71
  },
60
- "scripts": {
61
- "test": "vitest",
62
- "lint": "oxlint",
63
- "lint:fix": "oxlint --fix",
64
- "fmt": "oxfmt",
65
- "fmt:check": "oxfmt --check",
66
- "check": "oxlint && oxfmt --check && tsc --noEmit",
67
- "dev": "tsx src/index.ts",
68
- "build": "tsdown src/index.ts",
69
- "start": "node dist/index.mjs"
70
- }
71
- }
72
+ "packageManager": "pnpm@10.30.3"
73
+ }
@@ -0,0 +1,21 @@
1
+ # macOS settings file
2
+ .DS_Store
3
+
4
+ # Contains all your dependencies
5
+ node_modules
6
+
7
+ /dist
8
+
9
+ # Deal with environment files
10
+ .env
11
+ .env.*
12
+
13
+ # We'll allow an example .env file which can be copied + schemas
14
+ !.env.example
15
+ !.env.schema
16
+
17
+ # Coverage directory used by testing tools
18
+ coverage
19
+
20
+ # Visual Studio Code configuration
21
+ .vscode/
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "type": "module",
13
13
  "scripts": {
14
- "dev": "tsx src/index.ts",
14
+ "dev": "tsx watch src/index.ts",
15
15
  "build": "tsdown src/index.ts",
16
16
  "start": "node dist/index.mjs",
17
17
  "test": "vitest",