create-blaze 0.1.0 → 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.
Files changed (2) hide show
  1. package/dist/index.js +168 -41
  2. package/package.json +14 -4
package/dist/index.js CHANGED
@@ -14,6 +14,103 @@ import { get } from "node:https";
14
14
  import { tmpdir } from "node:os";
15
15
  import { basename, extname, join } from "node:path";
16
16
 
17
+ // ../../node_modules/.bun/kleur@4.1.5/node_modules/kleur/index.mjs
18
+ var FORCE_COLOR;
19
+ var NODE_DISABLE_COLORS;
20
+ var NO_COLOR;
21
+ var TERM;
22
+ var isTTY = true;
23
+ if (typeof process !== "undefined") {
24
+ ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
25
+ isTTY = process.stdout && process.stdout.isTTY;
26
+ }
27
+ var $ = {
28
+ enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY),
29
+ reset: init(0, 0),
30
+ bold: init(1, 22),
31
+ dim: init(2, 22),
32
+ italic: init(3, 23),
33
+ underline: init(4, 24),
34
+ inverse: init(7, 27),
35
+ hidden: init(8, 28),
36
+ strikethrough: init(9, 29),
37
+ black: init(30, 39),
38
+ red: init(31, 39),
39
+ green: init(32, 39),
40
+ yellow: init(33, 39),
41
+ blue: init(34, 39),
42
+ magenta: init(35, 39),
43
+ cyan: init(36, 39),
44
+ white: init(37, 39),
45
+ gray: init(90, 39),
46
+ grey: init(90, 39),
47
+ bgBlack: init(40, 49),
48
+ bgRed: init(41, 49),
49
+ bgGreen: init(42, 49),
50
+ bgYellow: init(43, 49),
51
+ bgBlue: init(44, 49),
52
+ bgMagenta: init(45, 49),
53
+ bgCyan: init(46, 49),
54
+ bgWhite: init(47, 49)
55
+ };
56
+ function run(arr, str) {
57
+ let i = 0, tmp, beg = "", end = "";
58
+ for (;i < arr.length; i++) {
59
+ tmp = arr[i];
60
+ beg += tmp.open;
61
+ end += tmp.close;
62
+ if (!!~str.indexOf(tmp.close)) {
63
+ str = str.replace(tmp.rgx, tmp.close + tmp.open);
64
+ }
65
+ }
66
+ return beg + str + end;
67
+ }
68
+ function chain(has, keys) {
69
+ let ctx = { has, keys };
70
+ ctx.reset = $.reset.bind(ctx);
71
+ ctx.bold = $.bold.bind(ctx);
72
+ ctx.dim = $.dim.bind(ctx);
73
+ ctx.italic = $.italic.bind(ctx);
74
+ ctx.underline = $.underline.bind(ctx);
75
+ ctx.inverse = $.inverse.bind(ctx);
76
+ ctx.hidden = $.hidden.bind(ctx);
77
+ ctx.strikethrough = $.strikethrough.bind(ctx);
78
+ ctx.black = $.black.bind(ctx);
79
+ ctx.red = $.red.bind(ctx);
80
+ ctx.green = $.green.bind(ctx);
81
+ ctx.yellow = $.yellow.bind(ctx);
82
+ ctx.blue = $.blue.bind(ctx);
83
+ ctx.magenta = $.magenta.bind(ctx);
84
+ ctx.cyan = $.cyan.bind(ctx);
85
+ ctx.white = $.white.bind(ctx);
86
+ ctx.gray = $.gray.bind(ctx);
87
+ ctx.grey = $.grey.bind(ctx);
88
+ ctx.bgBlack = $.bgBlack.bind(ctx);
89
+ ctx.bgRed = $.bgRed.bind(ctx);
90
+ ctx.bgGreen = $.bgGreen.bind(ctx);
91
+ ctx.bgYellow = $.bgYellow.bind(ctx);
92
+ ctx.bgBlue = $.bgBlue.bind(ctx);
93
+ ctx.bgMagenta = $.bgMagenta.bind(ctx);
94
+ ctx.bgCyan = $.bgCyan.bind(ctx);
95
+ ctx.bgWhite = $.bgWhite.bind(ctx);
96
+ return ctx;
97
+ }
98
+ function init(open, close) {
99
+ let blk = {
100
+ open: `\x1B[${open}m`,
101
+ close: `\x1B[${close}m`,
102
+ rgx: new RegExp(`\\x1b\\[${close}m`, "g")
103
+ };
104
+ return function(txt) {
105
+ if (this !== undefined && this.has !== undefined) {
106
+ !!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
107
+ return txt === undefined ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
108
+ }
109
+ return txt === undefined ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
110
+ };
111
+ }
112
+ var kleur_default = $;
113
+
17
114
  // ../../node_modules/.bun/tar@7.5.13/node_modules/tar/dist/esm/index.min.js
18
115
  import Kr from "events";
19
116
  import I from "fs";
@@ -31,7 +128,7 @@ import qr from "zlib";
31
128
  import { posix as Zt } from "node:path";
32
129
  import { basename as wn } from "node:path";
33
130
  import fi from "fs";
34
- import $ from "fs";
131
+ import $2 from "fs";
35
132
  import $s from "path";
36
133
  import { win32 as In } from "node:path";
37
134
  import sr from "path";
@@ -1583,7 +1680,7 @@ var de = class extends D {
1583
1680
  return t === "error" && (this.#t = true), super.emit(t, ...e);
1584
1681
  }
1585
1682
  [Qi]() {
1586
- $.lstat(this.absolute, (t, e) => {
1683
+ $2.lstat(this.absolute, (t, e) => {
1587
1684
  if (t)
1588
1685
  return this.emit("error", t);
1589
1686
  this[ei](e);
@@ -1625,7 +1722,7 @@ var de = class extends D {
1625
1722
  this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[fe](), this.end();
1626
1723
  }
1627
1724
  [ji]() {
1628
- $.readlink(this.absolute, (t, e) => {
1725
+ $2.readlink(this.absolute, (t, e) => {
1629
1726
  if (t)
1630
1727
  return this.emit("error", t);
1631
1728
  this[ts](e);
@@ -1653,7 +1750,7 @@ var de = class extends D {
1653
1750
  this[es]();
1654
1751
  }
1655
1752
  [es]() {
1656
- $.open(this.absolute, "r", (t, e) => {
1753
+ $2.open(this.absolute, "r", (t, e) => {
1657
1754
  if (t)
1658
1755
  return this.emit("error", t);
1659
1756
  this[is](e);
@@ -1672,14 +1769,14 @@ var de = class extends D {
1672
1769
  let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
1673
1770
  if (t === undefined || e === undefined)
1674
1771
  throw new Error("cannot read file without first opening");
1675
- $.read(t, e, i, r, n, (o, h) => {
1772
+ $2.read(t, e, i, r, n, (o, h) => {
1676
1773
  if (o)
1677
1774
  return this[pt](() => this.emit("error", o));
1678
1775
  this[Ji](h);
1679
1776
  });
1680
1777
  }
1681
1778
  [pt](t = () => {}) {
1682
- this.fd !== undefined && $.close(this.fd, t);
1779
+ this.fd !== undefined && $2.close(this.fd, t);
1683
1780
  }
1684
1781
  [Ji](t) {
1685
1782
  if (t <= 0 && this.remain > 0) {
@@ -1719,13 +1816,13 @@ var de = class extends D {
1719
1816
  var si = class extends de {
1720
1817
  sync = true;
1721
1818
  [Qi]() {
1722
- this[ei]($.lstatSync(this.absolute));
1819
+ this[ei]($2.lstatSync(this.absolute));
1723
1820
  }
1724
1821
  [ji]() {
1725
- this[ts]($.readlinkSync(this.absolute));
1822
+ this[ts]($2.readlinkSync(this.absolute));
1726
1823
  }
1727
1824
  [es]() {
1728
- this[is]($.openSync(this.absolute, "r"));
1825
+ this[is]($2.openSync(this.absolute, "r"));
1729
1826
  }
1730
1827
  [ti]() {
1731
1828
  let t = true;
@@ -1733,7 +1830,7 @@ var si = class extends de {
1733
1830
  let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
1734
1831
  if (e === undefined || i === undefined)
1735
1832
  throw new Error("fd and buf must be set in READ method");
1736
- let h = $.readSync(e, i, r, n, o);
1833
+ let h = $2.readSync(e, i, r, n, o);
1737
1834
  this[Ji](h), t = false;
1738
1835
  } finally {
1739
1836
  if (t)
@@ -1746,7 +1843,7 @@ var si = class extends de {
1746
1843
  t();
1747
1844
  }
1748
1845
  [pt](t = () => {}) {
1749
- this.fd !== undefined && $.closeSync(this.fd), t();
1846
+ this.fd !== undefined && $2.closeSync(this.fd), t();
1750
1847
  }
1751
1848
  };
1752
1849
  var ri = class extends D {
@@ -3165,7 +3262,9 @@ var So = (s3) => {
3165
3262
  var REPO_OWNER = "Alshahriah";
3166
3263
  var REPO_NAME = "blazestack";
3167
3264
  var REPO_BRANCH = "main";
3265
+ var VERSION = "0.2.0";
3168
3266
  var EXCLUDE = new Set(["node_modules", ".git", "bun.lock", "packages/create-blaze"]);
3267
+ var EXCLUDE_FILES = new Set([".github/workflows/publish.yml"]);
3169
3268
  var TEXT_EXTENSIONS = new Set([
3170
3269
  ".ts",
3171
3270
  ".tsx",
@@ -3212,17 +3311,23 @@ function shouldExclude(relPath) {
3212
3311
  return true;
3213
3312
  if (parts[0] === "packages" && parts[1] === "create-blaze")
3214
3313
  return true;
3314
+ const normalized = relPath.replace(/\\/g, "/");
3315
+ if (EXCLUDE_FILES.has(normalized))
3316
+ return true;
3215
3317
  return false;
3216
3318
  }
3217
- function copyDir(src, dest, name) {
3319
+ function copyDir(src, dest, name, relBase = "") {
3218
3320
  mkdirSync(dest, { recursive: true });
3219
3321
  const entries = readdirSync(src);
3220
3322
  for (const entry of entries) {
3221
3323
  const srcPath = join(src, entry);
3222
3324
  const destPath = join(dest, entry);
3325
+ const relPath = relBase ? `${relBase}/${entry}` : entry;
3326
+ if (EXCLUDE_FILES.has(relPath))
3327
+ continue;
3223
3328
  const stat = statSync(srcPath);
3224
3329
  if (stat.isDirectory()) {
3225
- copyDir(srcPath, destPath, name);
3330
+ copyDir(srcPath, destPath, name, relPath);
3226
3331
  } else {
3227
3332
  if (isTextFile(srcPath)) {
3228
3333
  const content = readFileSync(srcPath, "utf8");
@@ -3261,13 +3366,26 @@ function dirExists(p2) {
3261
3366
  return false;
3262
3367
  }
3263
3368
  }
3369
+ function step(label) {
3370
+ process.stdout.write(` ${kleur_default.cyan("◆")} ${label.padEnd(30)}`);
3371
+ }
3372
+ function stepDone() {
3373
+ process.stdout.write(`${kleur_default.green("✓")}
3374
+ `);
3375
+ }
3376
+ function stepFail() {
3377
+ process.stdout.write(`${kleur_default.red("✗")}
3378
+ `);
3379
+ }
3264
3380
  async function main() {
3265
3381
  const input = process.argv[2];
3266
3382
  const DEFAULT_NAME = "my-blazestack-app";
3267
3383
  const rawName = input ?? DEFAULT_NAME;
3268
3384
  const baseName = sanitizeName(rawName);
3269
3385
  if (!baseName) {
3270
- console.error(`Invalid project name: "${rawName}"`);
3386
+ console.error(kleur_default.red(`
3387
+ Invalid project name: "${rawName}"
3388
+ `));
3271
3389
  process.exit(1);
3272
3390
  }
3273
3391
  let safeName = baseName;
@@ -3276,27 +3394,29 @@ async function main() {
3276
3394
  safeName = `${baseName}-${counter}`;
3277
3395
  counter++;
3278
3396
  }
3279
- if (safeName !== baseName) {
3280
- console.log(`
3281
- "${baseName}" already exists — using "${safeName}" instead.`);
3282
- }
3283
3397
  const targetDir = join(process.cwd(), safeName);
3284
3398
  const tarUrl = `https://codeload.github.com/${REPO_OWNER}/${REPO_NAME}/tar.gz/refs/heads/${REPO_BRANCH}`;
3285
3399
  const tmpFile = join(tmpdir(), `create-blaze-${Date.now()}.tar.gz`);
3286
3400
  const tmpExtract = join(tmpdir(), `create-blaze-${Date.now()}`);
3287
- console.log(`
3288
- Creating ${safeName}...
3289
- `);
3401
+ console.log();
3402
+ console.log(` ${kleur_default.bgCyan().black(` create-blaze v${VERSION} `)}`);
3403
+ console.log();
3404
+ if (safeName !== baseName) {
3405
+ console.log(` ${kleur_default.yellow("!")} ${kleur_default.dim(`"${baseName}" already exists — using "${safeName}" instead.`)}`);
3406
+ console.log();
3407
+ }
3408
+ console.log(` Scaffolding ${kleur_default.cyan().bold(safeName)}...`);
3409
+ console.log();
3290
3410
  try {
3291
- process.stdout.write(" Downloading template...");
3411
+ step("Downloading template");
3292
3412
  await download(tarUrl, tmpFile);
3293
- console.log(" done");
3294
- process.stdout.write(" Extracting...");
3413
+ stepDone();
3414
+ step("Extracting");
3295
3415
  mkdirSync(tmpExtract, { recursive: true });
3296
3416
  await co({ file: tmpFile, cwd: tmpExtract });
3297
- console.log(" done");
3417
+ stepDone();
3418
+ step("Setting up project");
3298
3419
  const extractedRoot = join(tmpExtract, `${REPO_NAME}-${REPO_BRANCH}`);
3299
- process.stdout.write(" Scaffolding project...");
3300
3420
  mkdirSync(targetDir, { recursive: true });
3301
3421
  const entries = readdirSync(extractedRoot);
3302
3422
  for (const entry of entries) {
@@ -3311,10 +3431,10 @@ Creating ${safeName}...
3311
3431
  for (const pkg of readdirSync(srcPath)) {
3312
3432
  if (pkg === "create-blaze")
3313
3433
  continue;
3314
- copyDir(join(srcPath, pkg), join(destPath, pkg), safeName);
3434
+ copyDir(join(srcPath, pkg), join(destPath, pkg), safeName, `packages/${pkg}`);
3315
3435
  }
3316
3436
  } else {
3317
- copyDir(srcPath, destPath, safeName);
3437
+ copyDir(srcPath, destPath, safeName, entry);
3318
3438
  }
3319
3439
  } else {
3320
3440
  if (isTextFile(srcPath)) {
@@ -3325,7 +3445,10 @@ Creating ${safeName}...
3325
3445
  }
3326
3446
  }
3327
3447
  }
3328
- console.log(" done");
3448
+ stepDone();
3449
+ } catch (err) {
3450
+ stepFail();
3451
+ throw err;
3329
3452
  } finally {
3330
3453
  try {
3331
3454
  rmSync(tmpFile, { force: true });
@@ -3334,20 +3457,24 @@ Creating ${safeName}...
3334
3457
  rmSync(tmpExtract, { recursive: true, force: true });
3335
3458
  } catch {}
3336
3459
  }
3337
- console.log(`
3338
- Done! Next steps:
3339
-
3340
- cd ${safeName}
3341
- bun install
3342
- cp apps/api/.dev.vars.example apps/api/.dev.vars
3343
- # Edit apps/api/.dev.vars with your DATABASE_URL and BETTER_AUTH_SECRET
3344
- bun db:setup && bun db:generate && bun db:migrate
3345
- bun dev:api # terminal 1 API on http://localhost:8787
3346
- bun dev:web # terminal 2 web on http://localhost:5173
3347
- `);
3460
+ console.log();
3461
+ console.log(` ${kleur_default.green().bold("Ready!")} Your project is set up.`);
3462
+ console.log();
3463
+ console.log(` ${kleur_default.dim("Next steps:")}`);
3464
+ console.log();
3465
+ console.log(` ${kleur_default.yellow(`cd ${safeName}`)}`);
3466
+ console.log(` ${kleur_default.yellow("bun install")}`);
3467
+ console.log(` ${kleur_default.yellow("cp apps/api/.dev.vars.example apps/api/.dev.vars")}`);
3468
+ console.log(` ${kleur_default.dim("# add DATABASE_URL + BETTER_AUTH_SECRET to .dev.vars")}`);
3469
+ console.log(` ${kleur_default.yellow("bun db:setup && bun db:generate && bun db:migrate")}`);
3470
+ console.log();
3471
+ console.log(` ${kleur_default.yellow("bun dev:api")} ${kleur_default.dim("─")} ${kleur_default.dim("API")} ${kleur_default.dim("→")} ${kleur_default.cyan("http://localhost:8787")}`);
3472
+ console.log(` ${kleur_default.yellow("bun dev:web")} ${kleur_default.dim("─")} ${kleur_default.dim("Web")} ${kleur_default.dim("→")} ${kleur_default.cyan("http://localhost:5173")}`);
3473
+ console.log();
3348
3474
  }
3349
3475
  main().catch((err) => {
3350
3476
  console.error(`
3351
- Error:`, err.message);
3477
+ ${kleur_default.red("Error:")} ${err.message}
3478
+ `);
3352
3479
  process.exit(1);
3353
3480
  });
package/package.json CHANGED
@@ -1,24 +1,34 @@
1
1
  {
2
2
  "name": "create-blaze",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Create a new blazestack project",
5
- "keywords": ["blazestack", "create-blaze", "hono", "trpc", "drizzle", "better-auth", "expo", "cloudflare"],
5
+ "keywords": [
6
+ "blazestack",
7
+ "create-blaze",
8
+ "hono",
9
+ "trpc",
10
+ "drizzle",
11
+ "better-auth",
12
+ "expo",
13
+ "cloudflare"
14
+ ],
6
15
  "homepage": "https://github.com/Alshahriah/blazestack",
7
16
  "repository": {
8
17
  "type": "git",
9
- "url": "https://github.com/Alshahriah/blazestack.git",
18
+ "url": "git+https://github.com/Alshahriah/blazestack.git",
10
19
  "directory": "packages/create-blaze"
11
20
  },
12
21
  "license": "MIT",
13
22
  "type": "module",
14
23
  "bin": {
15
- "create-blaze": "./dist/index.js"
24
+ "create-blaze": "dist/index.js"
16
25
  },
17
26
  "scripts": {
18
27
  "build": "bun build src/index.ts --outdir dist --target node --format esm",
19
28
  "dev": "bun run src/index.ts"
20
29
  },
21
30
  "dependencies": {
31
+ "kleur": "^4.1.5",
22
32
  "tar": "^7.4.3"
23
33
  },
24
34
  "devDependencies": {