create-mikstack 0.1.4 → 0.1.6

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.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import * as p from "@clack/prompts";
3
+ import { execSync } from "node:child_process";
3
4
  import path from "node:path";
4
5
  import { parseArgs } from "node:util";
5
- import { execSync } from "node:child_process";
6
6
  import fs from "node:fs";
7
7
 
8
8
  //#region src/config.ts
@@ -41,40 +41,6 @@ function pmLockfile(pm) {
41
41
  return "bun.lock";
42
42
  }
43
43
 
44
- //#endregion
45
- //#region src/post-scaffold.ts
46
- function postScaffold(targetDir, packageManager) {
47
- const cwd = path.resolve(process.cwd(), targetDir);
48
- const run = (cmd) => execSync(cmd, {
49
- cwd,
50
- stdio: "pipe"
51
- });
52
- const s = p.spinner();
53
- s.start("Installing dependencies...");
54
- try {
55
- run(`${packageManager} install`);
56
- s.stop("Dependencies installed.");
57
- } catch {
58
- s.stop("Failed to install dependencies. You can run install manually.");
59
- }
60
- s.start("Formatting project...");
61
- try {
62
- run(`${packageManager} run format`);
63
- s.stop("Project formatted.");
64
- } catch {
65
- s.stop("Formatting skipped.");
66
- }
67
- s.start("Initializing git repository...");
68
- try {
69
- run("git init");
70
- run("git add .");
71
- run("git commit -m \"the future is now\"");
72
- s.stop("Git repository initialized.");
73
- } catch {
74
- s.stop("Failed to initialize git. You can run git init manually.");
75
- }
76
- }
77
-
78
44
  //#endregion
79
45
  //#region src/prompts.ts
80
46
  function isCancel(value) {
@@ -286,7 +252,8 @@ function buildContext(config) {
286
252
  uiPrefix: config.uiMode === "vendor" ? "$lib/components/ui" : "@mikstack/ui",
287
253
  pmIsNpm: config.packageManager === "npm",
288
254
  pmIsPnpm: config.packageManager === "pnpm",
289
- pmIsBun: config.packageManager === "bun"
255
+ pmIsBun: config.packageManager === "bun",
256
+ needsEnvLoad: config.packageManager !== "bun"
290
257
  };
291
258
  }
292
259
  function appendGitignoreFiles(dir) {
@@ -384,22 +351,51 @@ async function cli() {
384
351
  p.intro("create-mikstack");
385
352
  p.log.info(`Scaffolding ${config.projectName} with recommended defaults (non-interactive)...`);
386
353
  } else config = await runPrompts(projectName, packageManager);
387
- const s = p.spinner();
388
- s.start("Running sv create...");
389
- try {
390
- scaffold(config, (msg) => s.message(msg));
391
- s.stop("Project scaffolded.");
392
- } catch (err) {
393
- s.stop("Scaffolding failed.");
394
- p.log.error(err instanceof Error ? err.message : String(err));
395
- process.exit(1);
396
- }
397
- postScaffold(config.targetDir, config.packageManager);
398
- const run = pmRun(config.packageManager);
354
+ const cwd = path.resolve(process.cwd(), config.targetDir);
355
+ const run = (cmd) => execSync(cmd, {
356
+ cwd,
357
+ stdio: "pipe"
358
+ });
359
+ await p.tasks([
360
+ {
361
+ title: "Scaffolding project",
362
+ task: async (message) => {
363
+ message("Running sv create...");
364
+ scaffold(config, message);
365
+ return "Project scaffolded";
366
+ }
367
+ },
368
+ {
369
+ title: "Installing dependencies",
370
+ task: async () => {
371
+ run(`${packageManager} install`);
372
+ return "Dependencies installed";
373
+ }
374
+ },
375
+ {
376
+ title: "Formatting project",
377
+ task: async () => {
378
+ try {
379
+ run(`${packageManager} run format`);
380
+ } catch {}
381
+ return "Project formatted";
382
+ }
383
+ },
384
+ {
385
+ title: "Initializing git repository",
386
+ task: async () => {
387
+ run("git init");
388
+ run("git add .");
389
+ run("git commit -m \"the future is now\"");
390
+ return "Git repository initialized";
391
+ }
392
+ }
393
+ ]);
394
+ const pmrun = pmRun(config.packageManager);
399
395
  p.note([
400
396
  `cd ${config.targetDir}`,
401
- `${run} db:push`,
402
- `${run} dev`
397
+ `${pmrun} db:push`,
398
+ `${pmrun} dev`
403
399
  ].join("\n"), "Next steps");
404
400
  }
405
401
  function printHelp() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mikstack",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,9 +1,11 @@
1
1
  import { defineConfig } from "drizzle-kit";
2
- import { existsSync } from "fs";
2
+ // {{#if:needsEnvLoad}}
3
+ import { existsSync } from "node:fs";
3
4
 
4
5
  if (existsSync(".env")) {
5
6
  process.loadEnvFile();
6
7
  }
8
+ // {{/if:needsEnvLoad}}
7
9
 
8
10
  const DATABASE_URL = process.env.DATABASE_URL || "postgresql://placeholder";
9
11
 
@@ -1,7 +1,3 @@
1
- [run]
2
- # Use Bun runtime instead of following shebangs (needed for zero-cache native addons)
3
- bun = true
4
-
5
1
  [install]
6
2
  # Reject packages published less than 3 days ago
7
3
  minPublishAge = "3d"