create-zenith 1.3.17 → 1.3.19
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 +39 -3
- package/dist/cli.js +328 -127
- package/dist/index.js +328 -127
- package/package.json +11 -6
package/dist/index.js
CHANGED
|
@@ -3,20 +3,34 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
function __accessProp(key) {
|
|
7
|
+
return this[key];
|
|
8
|
+
}
|
|
9
|
+
var __toESMCache_node;
|
|
10
|
+
var __toESMCache_esm;
|
|
6
11
|
var __toESM = (mod, isNodeMode, target) => {
|
|
12
|
+
var canCache = mod != null && typeof mod === "object";
|
|
13
|
+
if (canCache) {
|
|
14
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
15
|
+
var cached = cache.get(mod);
|
|
16
|
+
if (cached)
|
|
17
|
+
return cached;
|
|
18
|
+
}
|
|
7
19
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
8
20
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
9
21
|
for (let key of __getOwnPropNames(mod))
|
|
10
22
|
if (!__hasOwnProp.call(to, key))
|
|
11
23
|
__defProp(to, key, {
|
|
12
|
-
get: (
|
|
24
|
+
get: __accessProp.bind(mod, key),
|
|
13
25
|
enumerable: true
|
|
14
26
|
});
|
|
27
|
+
if (canCache)
|
|
28
|
+
cache.set(mod, to);
|
|
15
29
|
return to;
|
|
16
30
|
};
|
|
17
31
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
18
32
|
|
|
19
|
-
//
|
|
33
|
+
// ../../node_modules/.bun/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
20
34
|
var require_picocolors = __commonJS((exports, module) => {
|
|
21
35
|
var p = process || {};
|
|
22
36
|
var argv = p.argv || [];
|
|
@@ -86,7 +100,7 @@ var require_picocolors = __commonJS((exports, module) => {
|
|
|
86
100
|
module.exports.createColors = createColors;
|
|
87
101
|
});
|
|
88
102
|
|
|
89
|
-
//
|
|
103
|
+
// ../../node_modules/.bun/tinycolor2@1.6.0/node_modules/tinycolor2/cjs/tinycolor.js
|
|
90
104
|
var require_tinycolor = __commonJS((exports, module) => {
|
|
91
105
|
(function(global, factory) {
|
|
92
106
|
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.tinycolor = factory());
|
|
@@ -1070,7 +1084,7 @@ var require_tinycolor = __commonJS((exports, module) => {
|
|
|
1070
1084
|
});
|
|
1071
1085
|
});
|
|
1072
1086
|
|
|
1073
|
-
//
|
|
1087
|
+
// ../../node_modules/.bun/tinygradient@1.1.5/node_modules/tinygradient/index.js
|
|
1074
1088
|
var require_tinygradient = __commonJS((exports, module) => {
|
|
1075
1089
|
var tinycolor = require_tinycolor();
|
|
1076
1090
|
var RGBA_MAX = { r: 256, g: 256, b: 256, a: 1 };
|
|
@@ -1325,7 +1339,7 @@ var require_tinygradient = __commonJS((exports, module) => {
|
|
|
1325
1339
|
};
|
|
1326
1340
|
});
|
|
1327
1341
|
|
|
1328
|
-
//
|
|
1342
|
+
// ../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
1329
1343
|
var require_src = __commonJS((exports, module) => {
|
|
1330
1344
|
var ESC = "\x1B";
|
|
1331
1345
|
var CSI = `${ESC}[`;
|
|
@@ -1388,11 +1402,12 @@ import * as fs from "node:fs";
|
|
|
1388
1402
|
import * as path from "node:path";
|
|
1389
1403
|
import * as os2 from "node:os";
|
|
1390
1404
|
import { execSync } from "node:child_process";
|
|
1405
|
+
import { fileURLToPath } from "node:url";
|
|
1391
1406
|
|
|
1392
1407
|
// src/branding.ts
|
|
1393
1408
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
1394
1409
|
|
|
1395
|
-
//
|
|
1410
|
+
// ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
1396
1411
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
1397
1412
|
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
1398
1413
|
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
@@ -1569,7 +1584,7 @@ function assembleStyles() {
|
|
|
1569
1584
|
var ansiStyles = assembleStyles();
|
|
1570
1585
|
var ansi_styles_default = ansiStyles;
|
|
1571
1586
|
|
|
1572
|
-
//
|
|
1587
|
+
// ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
|
|
1573
1588
|
import process2 from "node:process";
|
|
1574
1589
|
import os from "node:os";
|
|
1575
1590
|
import tty from "node:tty";
|
|
@@ -1701,7 +1716,7 @@ var supportsColor = {
|
|
|
1701
1716
|
};
|
|
1702
1717
|
var supports_color_default = supportsColor;
|
|
1703
1718
|
|
|
1704
|
-
//
|
|
1719
|
+
// ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/utilities.js
|
|
1705
1720
|
function stringReplaceAll(string, substring, replacer) {
|
|
1706
1721
|
let index = string.indexOf(substring);
|
|
1707
1722
|
if (index === -1) {
|
|
@@ -1734,7 +1749,7 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
|
1734
1749
|
return returnValue;
|
|
1735
1750
|
}
|
|
1736
1751
|
|
|
1737
|
-
//
|
|
1752
|
+
// ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/index.js
|
|
1738
1753
|
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
1739
1754
|
var GENERATOR = Symbol("GENERATOR");
|
|
1740
1755
|
var STYLER = Symbol("STYLER");
|
|
@@ -1881,7 +1896,7 @@ var chalk = createChalk();
|
|
|
1881
1896
|
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
1882
1897
|
var source_default = chalk;
|
|
1883
1898
|
|
|
1884
|
-
//
|
|
1899
|
+
// ../../node_modules/.bun/gradient-string@3.0.0/node_modules/gradient-string/dist/index.js
|
|
1885
1900
|
var import_tinygradient = __toESM(require_tinygradient(), 1);
|
|
1886
1901
|
var gradient = (...colors) => {
|
|
1887
1902
|
let gradient2;
|
|
@@ -1999,20 +2014,40 @@ gradient.summer = summer;
|
|
|
1999
2014
|
gradient.rainbow = rainbow;
|
|
2000
2015
|
gradient.pastel = pastel;
|
|
2001
2016
|
|
|
2017
|
+
// src/ui/env.ts
|
|
2018
|
+
function flagEnabled(value) {
|
|
2019
|
+
if (value == null)
|
|
2020
|
+
return false;
|
|
2021
|
+
const normalized = value.trim().toLowerCase();
|
|
2022
|
+
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
2023
|
+
}
|
|
2024
|
+
function getUiMode(runtime = process) {
|
|
2025
|
+
const tty2 = Boolean(runtime.stdout?.isTTY);
|
|
2026
|
+
const ci = flagEnabled(runtime.env.CI);
|
|
2027
|
+
const noUi = flagEnabled(runtime.env.ZENITH_NO_UI);
|
|
2028
|
+
const noColor = runtime.env.NO_COLOR !== undefined;
|
|
2029
|
+
const forceColor = flagEnabled(runtime.env.FORCE_COLOR);
|
|
2030
|
+
const debug = flagEnabled(runtime.env.ZENITH_DEBUG);
|
|
2031
|
+
const plain = noUi || ci || !tty2;
|
|
2032
|
+
const color = !plain && !noColor && (forceColor || tty2);
|
|
2033
|
+
const animate = tty2 && !plain && !ci;
|
|
2034
|
+
return { tty: tty2, plain, color, animate, debug };
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2002
2037
|
// src/branding.ts
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2038
|
+
function ui() {
|
|
2039
|
+
return getUiMode(process);
|
|
2040
|
+
}
|
|
2041
|
+
function pc() {
|
|
2042
|
+
return import_picocolors.createColors(ui().color);
|
|
2043
|
+
}
|
|
2044
|
+
function zenithGradientText(text) {
|
|
2045
|
+
if (!ui().color)
|
|
2046
|
+
return text;
|
|
2047
|
+
return dist_default(["#3b82f6", "#06b6d4", "#22d3ee"])(text);
|
|
2048
|
+
}
|
|
2014
2049
|
function isTTY() {
|
|
2015
|
-
return
|
|
2050
|
+
return ui().animate;
|
|
2016
2051
|
}
|
|
2017
2052
|
var LOGO_LINES = [
|
|
2018
2053
|
" ███████╗███████╗███╗ ██╗██╗████████╗██╗ ██╗",
|
|
@@ -2023,107 +2058,124 @@ var LOGO_LINES = [
|
|
|
2023
2058
|
" ╚══════╝╚══════╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚═╝"
|
|
2024
2059
|
];
|
|
2025
2060
|
var TAGLINE = "The Modern Reactive Web Framework";
|
|
2061
|
+
function renderLogoLine(line) {
|
|
2062
|
+
return ui().color ? zenithGradientText(line) : line;
|
|
2063
|
+
}
|
|
2026
2064
|
var LOGO = `
|
|
2027
|
-
${
|
|
2028
|
-
${
|
|
2029
|
-
${LOGO_LINES.map((line) => `${
|
|
2065
|
+
${pc().cyan("╔" + "═".repeat(55) + "╗")}
|
|
2066
|
+
${pc().cyan("║")}${" ".repeat(55)}${pc().cyan("║")}
|
|
2067
|
+
${LOGO_LINES.map((line) => `${pc().cyan("║")} ${renderLogoLine(line)} ${pc().cyan("║")}`).join(`
|
|
2030
2068
|
`)}
|
|
2031
|
-
${
|
|
2032
|
-
${
|
|
2033
|
-
${
|
|
2034
|
-
${
|
|
2035
|
-
`;
|
|
2036
|
-
var LOGO_COMPACT = `
|
|
2037
|
-
${import_picocolors.default.bold(zenithGradient("⚡ ZENITH"))} ${import_picocolors.default.dim("- Modern Reactive Framework")}
|
|
2069
|
+
${pc().cyan("║")}${" ".repeat(55)}${pc().cyan("║")}
|
|
2070
|
+
${pc().cyan("║")}${" ".repeat(10)}${pc().dim(TAGLINE)}${" ".repeat(10)}${pc().cyan("║")}
|
|
2071
|
+
${pc().cyan("║")}${" ".repeat(55)}${pc().cyan("║")}
|
|
2072
|
+
${pc().cyan("╚" + "═".repeat(55) + "╝")}
|
|
2038
2073
|
`;
|
|
2074
|
+
var LOGO_COMPACT = ` ${pc().bold(renderLogoLine("⚡ ZENITH"))} ${pc().dim("- Modern Reactive Framework")}`;
|
|
2039
2075
|
function sleep(ms) {
|
|
2040
2076
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2041
2077
|
}
|
|
2042
2078
|
async function animateLogo() {
|
|
2043
|
-
if (!
|
|
2044
|
-
|
|
2079
|
+
if (!ui().animate) {
|
|
2080
|
+
showCompactLogo();
|
|
2045
2081
|
return;
|
|
2046
2082
|
}
|
|
2047
2083
|
console.clear();
|
|
2048
|
-
console.log(
|
|
2049
|
-
console.log(
|
|
2050
|
-
for (
|
|
2051
|
-
|
|
2052
|
-
process.stdout.write(import_picocolors.default.cyan("║") + " ");
|
|
2084
|
+
console.log(pc().cyan("╔" + "═".repeat(55) + "╗"));
|
|
2085
|
+
console.log(pc().cyan("║") + " ".repeat(55) + pc().cyan("║"));
|
|
2086
|
+
for (const line of LOGO_LINES) {
|
|
2087
|
+
process.stdout.write(pc().cyan("║") + " ");
|
|
2053
2088
|
const chars = [...line];
|
|
2054
2089
|
const chunkSize = Math.ceil(chars.length / 8);
|
|
2055
2090
|
for (let j = 0;j < chars.length; j += chunkSize) {
|
|
2056
2091
|
const chunk = chars.slice(j, j + chunkSize).join("");
|
|
2057
|
-
process.stdout.write(
|
|
2092
|
+
process.stdout.write(renderLogoLine(chunk));
|
|
2058
2093
|
await sleep(30);
|
|
2059
2094
|
}
|
|
2060
|
-
console.log(" " +
|
|
2095
|
+
console.log(" " + pc().cyan("║"));
|
|
2061
2096
|
}
|
|
2062
|
-
console.log(
|
|
2063
|
-
process.stdout.write(
|
|
2097
|
+
console.log(pc().cyan("║") + " ".repeat(55) + pc().cyan("║"));
|
|
2098
|
+
process.stdout.write(pc().cyan("║") + " ".repeat(10));
|
|
2064
2099
|
const taglineChars = [...TAGLINE];
|
|
2065
2100
|
for (let i = 0;i < taglineChars.length; i += 4) {
|
|
2066
2101
|
const chunk = taglineChars.slice(i, i + 4).join("");
|
|
2067
|
-
process.stdout.write(
|
|
2102
|
+
process.stdout.write(pc().dim(chunk));
|
|
2068
2103
|
await sleep(20);
|
|
2069
2104
|
}
|
|
2070
|
-
console.log(" ".repeat(10) +
|
|
2071
|
-
console.log(
|
|
2072
|
-
console.log(
|
|
2105
|
+
console.log(" ".repeat(10) + pc().cyan("║"));
|
|
2106
|
+
console.log(pc().cyan("║") + " ".repeat(55) + pc().cyan("║"));
|
|
2107
|
+
console.log(pc().cyan("╚" + "═".repeat(55) + "╝"));
|
|
2073
2108
|
await sleep(150);
|
|
2074
2109
|
}
|
|
2075
|
-
function showLogo() {
|
|
2076
|
-
console.log(LOGO);
|
|
2077
|
-
}
|
|
2078
2110
|
function showCompactLogo() {
|
|
2111
|
+
if (ui().plain) {
|
|
2112
|
+
console.log("ZENITH - Modern Reactive Framework");
|
|
2113
|
+
return;
|
|
2114
|
+
}
|
|
2079
2115
|
console.log(LOGO_COMPACT);
|
|
2080
2116
|
}
|
|
2081
2117
|
async function showCompletionAnimation() {
|
|
2082
|
-
if (!
|
|
2083
|
-
console.log(
|
|
2118
|
+
if (!ui().animate) {
|
|
2119
|
+
console.log("OK: Done!");
|
|
2084
2120
|
return;
|
|
2085
2121
|
}
|
|
2086
2122
|
const frames = ["✓", "✨", "✓", "✨", "✓"];
|
|
2087
|
-
const
|
|
2123
|
+
const colors = [pc().green, pc().yellow, pc().green, pc().yellow, pc().green];
|
|
2088
2124
|
for (let i = 0;i < frames.length; i++) {
|
|
2089
|
-
process.stdout.write(`\r${
|
|
2125
|
+
process.stdout.write(`\r${colors[i](frames[i])} ${pc().bold("Done!")}`);
|
|
2090
2126
|
await sleep(100);
|
|
2091
2127
|
}
|
|
2092
2128
|
console.log();
|
|
2093
2129
|
}
|
|
2094
2130
|
function error(text) {
|
|
2095
|
-
console.log(`${
|
|
2131
|
+
console.log(ui().plain ? `ERROR: ${text}` : `${pc().red("✗")} ${text}`);
|
|
2096
2132
|
}
|
|
2097
2133
|
function warn(text) {
|
|
2098
|
-
console.log(`${
|
|
2134
|
+
console.log(ui().plain ? `WARN: ${text}` : `${pc().yellow("⚠")} ${text}`);
|
|
2099
2135
|
}
|
|
2100
2136
|
function bold(text) {
|
|
2101
|
-
return
|
|
2137
|
+
return ui().plain ? text : pc().bold(text);
|
|
2102
2138
|
}
|
|
2103
2139
|
function showNextSteps(projectName, packageManager = "bun") {
|
|
2104
2140
|
const pm = packageManager;
|
|
2105
2141
|
const runCmd = pm === "npm" ? "npm run dev" : `${pm} run dev`;
|
|
2142
|
+
if (ui().plain) {
|
|
2143
|
+
console.log("");
|
|
2144
|
+
console.log("NEXT STEPS:");
|
|
2145
|
+
console.log(` cd ${projectName}`);
|
|
2146
|
+
console.log(` ${runCmd}`);
|
|
2147
|
+
console.log(" open http://localhost:3000");
|
|
2148
|
+
console.log("");
|
|
2149
|
+
return;
|
|
2150
|
+
}
|
|
2106
2151
|
const cdLine = `cd ${projectName}`;
|
|
2107
2152
|
const maxLineLen = 45;
|
|
2108
2153
|
const cdPadding = Math.max(1, maxLineLen - cdLine.length - 6);
|
|
2109
2154
|
const runPadding = Math.max(1, maxLineLen - runCmd.length - 6);
|
|
2110
2155
|
console.log(`
|
|
2111
|
-
${
|
|
2112
|
-
${
|
|
2113
|
-
${
|
|
2114
|
-
${
|
|
2115
|
-
${
|
|
2116
|
-
${
|
|
2117
|
-
${
|
|
2118
|
-
${
|
|
2119
|
-
${
|
|
2120
|
-
${
|
|
2121
|
-
${
|
|
2122
|
-
${
|
|
2156
|
+
${pc().cyan("┌" + "─".repeat(50) + "┐")}
|
|
2157
|
+
${pc().cyan("│")}${" ".repeat(50)}${pc().cyan("│")}
|
|
2158
|
+
${pc().cyan("│")} ${pc().green("✨")} ${pc().bold(renderLogoLine("Your Zenith app is ready!"))}${" ".repeat(17)}${pc().cyan("│")}
|
|
2159
|
+
${pc().cyan("│")}${" ".repeat(50)}${pc().cyan("│")}
|
|
2160
|
+
${pc().cyan("│")} ${pc().dim("Next steps:")}${" ".repeat(36)}${pc().cyan("│")}
|
|
2161
|
+
${pc().cyan("│")}${" ".repeat(50)}${pc().cyan("│")}
|
|
2162
|
+
${pc().cyan("│")} ${pc().cyan("$")} ${pc().bold(cdLine)}${" ".repeat(cdPadding)}${pc().cyan("│")}
|
|
2163
|
+
${pc().cyan("│")} ${pc().cyan("$")} ${pc().bold(runCmd)}${" ".repeat(runPadding)}${pc().cyan("│")}
|
|
2164
|
+
${pc().cyan("│")}${" ".repeat(50)}${pc().cyan("│")}
|
|
2165
|
+
${pc().cyan("│")} ${pc().dim("Then open")} ${pc().underline(pc().blue("http://localhost:3000"))}${" ".repeat(9)}${pc().cyan("│")}
|
|
2166
|
+
${pc().cyan("│")}${" ".repeat(50)}${pc().cyan("│")}
|
|
2167
|
+
${pc().cyan("└" + "─".repeat(50) + "┘")}
|
|
2123
2168
|
`);
|
|
2124
2169
|
}
|
|
2170
|
+
function showScaffoldSummary(projectName, templateLabel) {
|
|
2171
|
+
const title = ui().plain ? "SCAFFOLD PLAN" : pc().bold(pc().cyan("Scaffold Plan"));
|
|
2172
|
+
console.log(`
|
|
2173
|
+
${title}`);
|
|
2174
|
+
console.log(`Project : ${projectName}`);
|
|
2175
|
+
console.log(`Template: ${templateLabel}`);
|
|
2176
|
+
}
|
|
2125
2177
|
|
|
2126
|
-
//
|
|
2178
|
+
// ../../node_modules/.bun/@clack+core@0.5.0/node_modules/@clack/core/dist/index.mjs
|
|
2127
2179
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
2128
2180
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
2129
2181
|
import { stdin as j, stdout as M } from "node:process";
|
|
@@ -2519,7 +2571,7 @@ class RD extends x {
|
|
|
2519
2571
|
}
|
|
2520
2572
|
}
|
|
2521
2573
|
|
|
2522
|
-
//
|
|
2574
|
+
// ../../node_modules/.bun/@clack+prompts@0.11.0/node_modules/@clack/prompts/dist/index.mjs
|
|
2523
2575
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
2524
2576
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
2525
2577
|
import y2 from "node:process";
|
|
@@ -2689,10 +2741,20 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
2689
2741
|
|
|
2690
2742
|
// src/prompts.ts
|
|
2691
2743
|
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
2744
|
+
function pc2() {
|
|
2745
|
+
const mode = getUiMode(process);
|
|
2746
|
+
return import_picocolors4.createColors(mode.color);
|
|
2747
|
+
}
|
|
2692
2748
|
async function intro() {
|
|
2693
2749
|
await animateLogo();
|
|
2694
2750
|
console.log();
|
|
2695
|
-
|
|
2751
|
+
const mode = getUiMode(process);
|
|
2752
|
+
if (mode.plain) {
|
|
2753
|
+
console.log("create-zenith");
|
|
2754
|
+
return;
|
|
2755
|
+
}
|
|
2756
|
+
const colors = pc2();
|
|
2757
|
+
Ie(colors.bgCyan(colors.black(" create-zenith ")));
|
|
2696
2758
|
}
|
|
2697
2759
|
async function text(opts) {
|
|
2698
2760
|
if (!isTTY()) {
|
|
@@ -2718,30 +2780,145 @@ function isCancel(value) {
|
|
|
2718
2780
|
return pD(value);
|
|
2719
2781
|
}
|
|
2720
2782
|
function handleCancel() {
|
|
2721
|
-
|
|
2783
|
+
if (getUiMode(process).plain) {
|
|
2784
|
+
console.log("WARN: Operation cancelled.");
|
|
2785
|
+
} else {
|
|
2786
|
+
xe("Operation cancelled.");
|
|
2787
|
+
}
|
|
2722
2788
|
process.exit(0);
|
|
2723
2789
|
}
|
|
2724
2790
|
function spinner() {
|
|
2725
|
-
|
|
2791
|
+
if (getUiMode(process).animate) {
|
|
2792
|
+
return Y2();
|
|
2793
|
+
}
|
|
2794
|
+
return {
|
|
2795
|
+
start(message) {
|
|
2796
|
+
console.log(`INFO: ${message}`);
|
|
2797
|
+
},
|
|
2798
|
+
stop(message) {
|
|
2799
|
+
if (message) {
|
|
2800
|
+
console.log(`OK: ${message}`);
|
|
2801
|
+
}
|
|
2802
|
+
},
|
|
2803
|
+
message(message) {
|
|
2804
|
+
console.log(`INFO: ${message}`);
|
|
2805
|
+
}
|
|
2806
|
+
};
|
|
2726
2807
|
}
|
|
2727
2808
|
async function outro(projectName, packageManager) {
|
|
2728
2809
|
await showCompletionAnimation();
|
|
2729
2810
|
showNextSteps(projectName, packageManager);
|
|
2730
2811
|
}
|
|
2731
2812
|
var log = {
|
|
2732
|
-
info: (message) => M2.info(message),
|
|
2733
|
-
success: (message) => M2.success(message),
|
|
2734
|
-
warn: (message) => M2.warn(message),
|
|
2735
|
-
error: (message) => M2.error(message),
|
|
2736
|
-
step: (message) => M2.step(message),
|
|
2737
|
-
message: (message) => M2.message(message)
|
|
2813
|
+
info: (message) => getUiMode(process).plain ? console.log(`INFO: ${message}`) : M2.info(message),
|
|
2814
|
+
success: (message) => getUiMode(process).plain ? console.log(`OK: ${message}`) : M2.success(message),
|
|
2815
|
+
warn: (message) => getUiMode(process).plain ? console.log(`WARN: ${message}`) : M2.warn(message),
|
|
2816
|
+
error: (message) => getUiMode(process).plain ? console.log(`ERROR: ${message}`) : M2.error(message),
|
|
2817
|
+
step: (message) => getUiMode(process).plain ? console.log(`STEP: ${message}`) : M2.step(message),
|
|
2818
|
+
message: (message) => getUiMode(process).plain ? console.log(message) : M2.message(message)
|
|
2738
2819
|
};
|
|
2739
2820
|
|
|
2821
|
+
// src/template-features.ts
|
|
2822
|
+
var FEATURE_DEFINITIONS = {
|
|
2823
|
+
eslint: {
|
|
2824
|
+
templatePath: "templates/features/eslint",
|
|
2825
|
+
packagePatch: {
|
|
2826
|
+
scripts: {
|
|
2827
|
+
lint: "eslint ."
|
|
2828
|
+
},
|
|
2829
|
+
devDependencies: {
|
|
2830
|
+
eslint: "^9.39.2",
|
|
2831
|
+
"@typescript-eslint/eslint-plugin": "^8.53.0",
|
|
2832
|
+
"@typescript-eslint/parser": "^8.53.0"
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
},
|
|
2836
|
+
prettier: {
|
|
2837
|
+
templatePath: "templates/features/prettier",
|
|
2838
|
+
packagePatch: {
|
|
2839
|
+
scripts: {
|
|
2840
|
+
format: "prettier --write ."
|
|
2841
|
+
},
|
|
2842
|
+
devDependencies: {
|
|
2843
|
+
prettier: "^3.7.4"
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
};
|
|
2848
|
+
function mergeRecord(target, patch) {
|
|
2849
|
+
if (!patch) {
|
|
2850
|
+
return target;
|
|
2851
|
+
}
|
|
2852
|
+
return { ...target || {}, ...patch };
|
|
2853
|
+
}
|
|
2854
|
+
function selectedTemplateFeaturePaths(options) {
|
|
2855
|
+
const paths = [];
|
|
2856
|
+
if (options.eslint) {
|
|
2857
|
+
paths.push(FEATURE_DEFINITIONS.eslint.templatePath);
|
|
2858
|
+
}
|
|
2859
|
+
if (options.prettier) {
|
|
2860
|
+
paths.push(FEATURE_DEFINITIONS.prettier.templatePath);
|
|
2861
|
+
}
|
|
2862
|
+
return paths;
|
|
2863
|
+
}
|
|
2864
|
+
function applyPackageFeatures(manifest, options) {
|
|
2865
|
+
const nextManifest = {
|
|
2866
|
+
...manifest,
|
|
2867
|
+
scripts: { ...manifest.scripts || {} },
|
|
2868
|
+
devDependencies: { ...manifest.devDependencies || {} }
|
|
2869
|
+
};
|
|
2870
|
+
for (const featureName of Object.keys(FEATURE_DEFINITIONS)) {
|
|
2871
|
+
if (!options[featureName]) {
|
|
2872
|
+
continue;
|
|
2873
|
+
}
|
|
2874
|
+
const patch = FEATURE_DEFINITIONS[featureName].packagePatch;
|
|
2875
|
+
nextManifest.scripts = mergeRecord(nextManifest.scripts, patch.scripts);
|
|
2876
|
+
nextManifest.devDependencies = mergeRecord(nextManifest.devDependencies, patch.devDependencies);
|
|
2877
|
+
}
|
|
2878
|
+
if (nextManifest.scripts && Object.keys(nextManifest.scripts).length === 0) {
|
|
2879
|
+
delete nextManifest.scripts;
|
|
2880
|
+
}
|
|
2881
|
+
if (nextManifest.devDependencies && Object.keys(nextManifest.devDependencies).length === 0) {
|
|
2882
|
+
delete nextManifest.devDependencies;
|
|
2883
|
+
}
|
|
2884
|
+
return nextManifest;
|
|
2885
|
+
}
|
|
2886
|
+
|
|
2740
2887
|
// src/index.ts
|
|
2741
|
-
var
|
|
2742
|
-
var GITHUB_REPO = "zenithbuild/create-zenith";
|
|
2888
|
+
var GITHUB_REPO = "zenithbuild/framework";
|
|
2743
2889
|
var DEFAULT_TEMPLATE = "examples/starter";
|
|
2744
2890
|
var TAILWIND_TEMPLATE = "examples/starter-tailwindcss";
|
|
2891
|
+
var __filename2 = fileURLToPath(import.meta.url);
|
|
2892
|
+
var __dirname2 = path.dirname(__filename2);
|
|
2893
|
+
function getCliVersion() {
|
|
2894
|
+
try {
|
|
2895
|
+
const pkgPath = path.resolve(__dirname2, "..", "package.json");
|
|
2896
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
2897
|
+
return typeof pkg.version === "string" ? pkg.version : "0.0.0";
|
|
2898
|
+
} catch {
|
|
2899
|
+
return "0.0.0";
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
var VERSION = getCliVersion();
|
|
2903
|
+
function flagEnabled2(value) {
|
|
2904
|
+
if (value == null)
|
|
2905
|
+
return false;
|
|
2906
|
+
const normalized = value.trim().toLowerCase();
|
|
2907
|
+
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
2908
|
+
}
|
|
2909
|
+
function resolveLocalTemplatePath(templatePath) {
|
|
2910
|
+
const candidate = path.resolve(__dirname2, "..", templatePath);
|
|
2911
|
+
return fs.existsSync(candidate) ? candidate : null;
|
|
2912
|
+
}
|
|
2913
|
+
function copyDirectoryContents(sourceDir, targetDir) {
|
|
2914
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
2915
|
+
for (const entry of fs.readdirSync(sourceDir)) {
|
|
2916
|
+
fs.cpSync(path.join(sourceDir, entry), path.join(targetDir, entry), {
|
|
2917
|
+
recursive: true,
|
|
2918
|
+
force: true
|
|
2919
|
+
});
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2745
2922
|
function detectPackageManager() {
|
|
2746
2923
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
2747
2924
|
if (userAgent.includes("bun"))
|
|
@@ -2772,31 +2949,52 @@ function hasGit() {
|
|
|
2772
2949
|
return false;
|
|
2773
2950
|
}
|
|
2774
2951
|
}
|
|
2775
|
-
async function downloadTemplate(targetDir,
|
|
2952
|
+
async function downloadTemplate(targetDir, templatePaths) {
|
|
2953
|
+
const localTemplatePaths = templatePaths.map((templatePath) => ({
|
|
2954
|
+
templatePath,
|
|
2955
|
+
localPath: resolveLocalTemplatePath(templatePath)
|
|
2956
|
+
}));
|
|
2957
|
+
const forceLocal = process.env.CREATE_ZENITH_TEMPLATE_MODE === "local" || flagEnabled2(process.env.CREATE_ZENITH_OFFLINE);
|
|
2958
|
+
const preferLocal = process.env.CREATE_ZENITH_PREFER_LOCAL !== "0";
|
|
2959
|
+
if (localTemplatePaths.every((entry) => entry.localPath) && (forceLocal || preferLocal)) {
|
|
2960
|
+
for (const entry of localTemplatePaths) {
|
|
2961
|
+
copyDirectoryContents(entry.localPath, targetDir);
|
|
2962
|
+
}
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
if (forceLocal) {
|
|
2966
|
+
const missingPath = localTemplatePaths.find((entry) => !entry.localPath)?.templatePath;
|
|
2967
|
+
throw new Error(`Local template not found: ${missingPath}`);
|
|
2968
|
+
}
|
|
2776
2969
|
const tempDir = path.join(os2.tmpdir(), `zenith-template-${Date.now()}`);
|
|
2777
2970
|
try {
|
|
2778
2971
|
if (hasGit()) {
|
|
2779
2972
|
execSync(`git clone --depth 1 --filter=blob:none --sparse https://github.com/${GITHUB_REPO}.git "${tempDir}"`, {
|
|
2780
2973
|
stdio: "pipe"
|
|
2781
2974
|
});
|
|
2782
|
-
|
|
2975
|
+
const repoTemplatePaths = templatePaths.map((templatePath) => `packages/create-zenith/${templatePath}`);
|
|
2976
|
+
execSync(`git sparse-checkout set ${repoTemplatePaths.join(" ")}`, {
|
|
2783
2977
|
cwd: tempDir,
|
|
2784
2978
|
stdio: "pipe"
|
|
2785
2979
|
});
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2980
|
+
for (const repoTemplatePath of repoTemplatePaths) {
|
|
2981
|
+
const templateSource = path.join(tempDir, repoTemplatePath);
|
|
2982
|
+
copyDirectoryContents(templateSource, targetDir);
|
|
2983
|
+
}
|
|
2788
2984
|
} else {
|
|
2789
2985
|
const tarballUrl = `https://github.com/${GITHUB_REPO}/archive/refs/heads/main.tar.gz`;
|
|
2790
2986
|
const tarballPath = path.join(os2.tmpdir(), `zenith-${Date.now()}.tar.gz`);
|
|
2791
2987
|
execSync(`curl -sL "${tarballUrl}" -o "${tarballPath}"`, { stdio: "pipe" });
|
|
2792
2988
|
fs.mkdirSync(tempDir, { recursive: true });
|
|
2793
2989
|
execSync(`tar -xzf "${tarballPath}" -C "${tempDir}"`, { stdio: "pipe" });
|
|
2794
|
-
const extractedDir = fs.readdirSync(tempDir).find((f) => f.startsWith("
|
|
2990
|
+
const extractedDir = fs.readdirSync(tempDir).find((f) => f.startsWith("framework"));
|
|
2795
2991
|
if (!extractedDir) {
|
|
2796
2992
|
throw new Error("Failed to extract template from GitHub");
|
|
2797
2993
|
}
|
|
2798
|
-
const
|
|
2799
|
-
|
|
2994
|
+
for (const templatePath of templatePaths) {
|
|
2995
|
+
const templateSource = path.join(tempDir, extractedDir, "packages/create-zenith", templatePath);
|
|
2996
|
+
copyDirectoryContents(templateSource, targetDir);
|
|
2997
|
+
}
|
|
2800
2998
|
fs.unlinkSync(tarballPath);
|
|
2801
2999
|
}
|
|
2802
3000
|
} finally {
|
|
@@ -2805,7 +3003,17 @@ async function downloadTemplate(targetDir, templatePath) {
|
|
|
2805
3003
|
}
|
|
2806
3004
|
}
|
|
2807
3005
|
}
|
|
3006
|
+
function readOptionOverride(name) {
|
|
3007
|
+
const value = process.env[name];
|
|
3008
|
+
if (value == null || value.trim() === "") {
|
|
3009
|
+
return;
|
|
3010
|
+
}
|
|
3011
|
+
return flagEnabled2(value);
|
|
3012
|
+
}
|
|
2808
3013
|
async function gatherOptions(providedName, withTailwind) {
|
|
3014
|
+
const eslintOverride = readOptionOverride("CREATE_ZENITH_ESLINT");
|
|
3015
|
+
const prettierOverride = readOptionOverride("CREATE_ZENITH_PRETTIER");
|
|
3016
|
+
const pathAliasOverride = readOptionOverride("CREATE_ZENITH_PATH_ALIAS");
|
|
2809
3017
|
let name = providedName;
|
|
2810
3018
|
if (!name) {
|
|
2811
3019
|
const nameResult = await text({
|
|
@@ -2843,9 +3051,9 @@ async function gatherOptions(providedName, withTailwind) {
|
|
|
2843
3051
|
log.info("Non-interactive mode detected, using defaults...");
|
|
2844
3052
|
return {
|
|
2845
3053
|
name,
|
|
2846
|
-
eslint: true,
|
|
2847
|
-
prettier: true,
|
|
2848
|
-
pathAlias: true,
|
|
3054
|
+
eslint: eslintOverride ?? true,
|
|
3055
|
+
prettier: prettierOverride ?? true,
|
|
3056
|
+
pathAlias: pathAliasOverride ?? true,
|
|
2849
3057
|
tailwind: withTailwind ?? false
|
|
2850
3058
|
};
|
|
2851
3059
|
}
|
|
@@ -2855,23 +3063,23 @@ async function gatherOptions(providedName, withTailwind) {
|
|
|
2855
3063
|
});
|
|
2856
3064
|
if (isCancel(tailwindResult))
|
|
2857
3065
|
handleCancel();
|
|
2858
|
-
const eslintResult = await confirm({
|
|
3066
|
+
const eslintResult = eslintOverride ?? await confirm({
|
|
2859
3067
|
message: "Add ESLint for code linting?",
|
|
2860
3068
|
initialValue: true
|
|
2861
3069
|
});
|
|
2862
|
-
if (isCancel(eslintResult))
|
|
3070
|
+
if (eslintOverride === undefined && isCancel(eslintResult))
|
|
2863
3071
|
handleCancel();
|
|
2864
|
-
const prettierResult = await confirm({
|
|
3072
|
+
const prettierResult = prettierOverride ?? await confirm({
|
|
2865
3073
|
message: "Add Prettier for code formatting?",
|
|
2866
3074
|
initialValue: true
|
|
2867
3075
|
});
|
|
2868
|
-
if (isCancel(prettierResult))
|
|
3076
|
+
if (prettierOverride === undefined && isCancel(prettierResult))
|
|
2869
3077
|
handleCancel();
|
|
2870
|
-
const pathAliasResult = await confirm({
|
|
3078
|
+
const pathAliasResult = pathAliasOverride ?? await confirm({
|
|
2871
3079
|
message: "Add TypeScript path alias (@/*)?",
|
|
2872
3080
|
initialValue: true
|
|
2873
3081
|
});
|
|
2874
|
-
if (isCancel(pathAliasResult))
|
|
3082
|
+
if (pathAliasOverride === undefined && isCancel(pathAliasResult))
|
|
2875
3083
|
handleCancel();
|
|
2876
3084
|
return {
|
|
2877
3085
|
name,
|
|
@@ -2884,31 +3092,13 @@ async function gatherOptions(providedName, withTailwind) {
|
|
|
2884
3092
|
async function createProject(options) {
|
|
2885
3093
|
const targetDir = path.resolve(process.cwd(), options.name);
|
|
2886
3094
|
const templatePath = options.tailwind ? TAILWIND_TEMPLATE : DEFAULT_TEMPLATE;
|
|
2887
|
-
|
|
3095
|
+
const templateFeaturePaths = selectedTemplateFeaturePaths(options);
|
|
3096
|
+
await downloadTemplate(targetDir, [templatePath, ...templateFeaturePaths]);
|
|
2888
3097
|
const pkgPath = path.join(targetDir, "package.json");
|
|
2889
3098
|
if (fs.existsSync(pkgPath)) {
|
|
2890
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
3099
|
+
const pkg = applyPackageFeatures(JSON.parse(fs.readFileSync(pkgPath, "utf8")), options);
|
|
2891
3100
|
pkg.name = options.name;
|
|
2892
3101
|
pkg.version = "0.1.0";
|
|
2893
|
-
if (!options.eslint) {
|
|
2894
|
-
delete pkg.devDependencies?.["eslint"];
|
|
2895
|
-
delete pkg.devDependencies?.["@typescript-eslint/eslint-plugin"];
|
|
2896
|
-
delete pkg.devDependencies?.["@typescript-eslint/parser"];
|
|
2897
|
-
delete pkg.scripts?.lint;
|
|
2898
|
-
const eslintPath = path.join(targetDir, ".eslintrc.json");
|
|
2899
|
-
if (fs.existsSync(eslintPath))
|
|
2900
|
-
fs.unlinkSync(eslintPath);
|
|
2901
|
-
}
|
|
2902
|
-
if (!options.prettier) {
|
|
2903
|
-
delete pkg.devDependencies?.["prettier"];
|
|
2904
|
-
delete pkg.scripts?.format;
|
|
2905
|
-
const prettierRc = path.join(targetDir, ".prettierrc");
|
|
2906
|
-
const prettierIgnore = path.join(targetDir, ".prettierignore");
|
|
2907
|
-
if (fs.existsSync(prettierRc))
|
|
2908
|
-
fs.unlinkSync(prettierRc);
|
|
2909
|
-
if (fs.existsSync(prettierIgnore))
|
|
2910
|
-
fs.unlinkSync(prettierIgnore);
|
|
2911
|
-
}
|
|
2912
3102
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 4));
|
|
2913
3103
|
}
|
|
2914
3104
|
const tsconfigPath = path.join(targetDir, "tsconfig.json");
|
|
@@ -2929,6 +3119,8 @@ async function createProject(options) {
|
|
|
2929
3119
|
async function create(appName, withTailwind) {
|
|
2930
3120
|
await intro();
|
|
2931
3121
|
const options = await gatherOptions(appName, withTailwind);
|
|
3122
|
+
const templateLabel = options.tailwind ? "starter-tailwindcss" : "starter";
|
|
3123
|
+
showScaffoldSummary(options.name, templateLabel);
|
|
2932
3124
|
console.log("");
|
|
2933
3125
|
log.step(`Creating ${bold(options.name)}...`);
|
|
2934
3126
|
const s = spinner();
|
|
@@ -2939,15 +3131,20 @@ async function create(appName, withTailwind) {
|
|
|
2939
3131
|
s.start("Installing dependencies...");
|
|
2940
3132
|
const targetDir = path.resolve(process.cwd(), options.name);
|
|
2941
3133
|
const pm = detectPackageManager();
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
cwd: targetDir,
|
|
2945
|
-
stdio: "pipe"
|
|
2946
|
-
});
|
|
2947
|
-
s.stop("Dependencies installed");
|
|
2948
|
-
} catch {
|
|
2949
|
-
s.stop("Could not install dependencies automatically");
|
|
3134
|
+
if (flagEnabled2(process.env.CREATE_ZENITH_SKIP_INSTALL)) {
|
|
3135
|
+
s.stop("Dependency installation skipped");
|
|
2950
3136
|
warn(`Run "${pm} install" manually in the project directory`);
|
|
3137
|
+
} else {
|
|
3138
|
+
try {
|
|
3139
|
+
execSync(`${pm} install`, {
|
|
3140
|
+
cwd: targetDir,
|
|
3141
|
+
stdio: "pipe"
|
|
3142
|
+
});
|
|
3143
|
+
s.stop("Dependencies installed");
|
|
3144
|
+
} catch {
|
|
3145
|
+
s.stop("Could not install dependencies automatically");
|
|
3146
|
+
warn(`Run "${pm} install" manually in the project directory`);
|
|
3147
|
+
}
|
|
2951
3148
|
}
|
|
2952
3149
|
await outro(options.name, pm);
|
|
2953
3150
|
} catch (err) {
|
|
@@ -2983,6 +3180,10 @@ if (args.includes("--version") || args.includes("-v")) {
|
|
|
2983
3180
|
var projectName = args.find((arg) => !arg.startsWith("-"));
|
|
2984
3181
|
var withTailwind = args.includes("--with-tailwind") ? true : undefined;
|
|
2985
3182
|
create(projectName, withTailwind).catch((err) => {
|
|
3183
|
+
const mode = getUiMode(process);
|
|
3184
|
+
if (mode.plain) {
|
|
3185
|
+
console.log("ERROR: SCAFFOLD_ERROR");
|
|
3186
|
+
}
|
|
2986
3187
|
error(err instanceof Error ? err.message : String(err));
|
|
2987
3188
|
process.exit(1);
|
|
2988
3189
|
});
|