create-fornix 0.0.10 → 0.0.12
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 +104 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2074,9 +2074,10 @@ import {
|
|
|
2074
2074
|
mkdirSync as mkdirSync2,
|
|
2075
2075
|
statSync as statSync2,
|
|
2076
2076
|
writeFileSync as writeFileSync2,
|
|
2077
|
-
rmSync
|
|
2077
|
+
rmSync,
|
|
2078
|
+
cpSync
|
|
2078
2079
|
} from "fs";
|
|
2079
|
-
import { join as join3 } from "path";
|
|
2080
|
+
import { join as join3, resolve } from "path";
|
|
2080
2081
|
import { homedir as homedir2 } from "os";
|
|
2081
2082
|
import { createRequire } from "module";
|
|
2082
2083
|
var DEFAULT_CONFIG2 = {
|
|
@@ -2132,6 +2133,15 @@ async function fetchBlock(blockName, config = {}) {
|
|
|
2132
2133
|
if (!cfg.force && isCacheValid2(blockCacheDir, cfg.maxCacheAge)) {
|
|
2133
2134
|
return loadFromCache2(blockName, blockCacheDir);
|
|
2134
2135
|
}
|
|
2136
|
+
const localBlocksDir = process.env.FORNIX_LOCAL_BLOCKS_DIR;
|
|
2137
|
+
if (localBlocksDir) {
|
|
2138
|
+
const localBlockPath = resolve(process.cwd(), localBlocksDir, blockName);
|
|
2139
|
+
if (existsSync2(localBlockPath)) {
|
|
2140
|
+
mkdirSync2(cfg.cacheDir, { recursive: true });
|
|
2141
|
+
cpSync(localBlockPath, blockCacheDir, { recursive: true, force: true });
|
|
2142
|
+
return loadFromCache2(blockName, blockCacheDir);
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2135
2145
|
try {
|
|
2136
2146
|
const source = `gh:${cfg.repo}/${cfg.blocksPrefix}/${blockName}#${cfg.ref}`;
|
|
2137
2147
|
mkdirSync2(cfg.cacheDir, { recursive: true });
|
|
@@ -2146,10 +2156,14 @@ async function fetchBlock(blockName, config = {}) {
|
|
|
2146
2156
|
return loadFromCache2(blockName, blockCacheDir);
|
|
2147
2157
|
}
|
|
2148
2158
|
const message = error instanceof Error ? error.message : String(error);
|
|
2159
|
+
let refinedMessage = message;
|
|
2160
|
+
if (message.includes("404") || message.includes("zlib: invalid distance code")) {
|
|
2161
|
+
refinedMessage += ` (This usually means the block doesn't exist on the remote branch. If developing locally, set FORNIX_LOCAL_BLOCKS_DIR or push your block to GitHub.)`;
|
|
2162
|
+
}
|
|
2149
2163
|
return err({
|
|
2150
2164
|
kind: "FetchError",
|
|
2151
2165
|
blockName,
|
|
2152
|
-
message: `Failed to fetch block '${blockName}': ${
|
|
2166
|
+
message: `Failed to fetch block '${blockName}': ${refinedMessage}`
|
|
2153
2167
|
});
|
|
2154
2168
|
}
|
|
2155
2169
|
}
|
|
@@ -2270,32 +2284,56 @@ async function runManualFlow(input) {
|
|
|
2270
2284
|
let selectedHeader;
|
|
2271
2285
|
let selectedFooter;
|
|
2272
2286
|
let selectedContentBlocks = [];
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2287
|
+
while (true) {
|
|
2288
|
+
selectedHeader = void 0;
|
|
2289
|
+
selectedFooter = void 0;
|
|
2290
|
+
selectedContentBlocks = [];
|
|
2291
|
+
if (headerOptions.length > 0) {
|
|
2292
|
+
const noneOption = { value: "__none__", label: "None", hint: "No header" };
|
|
2293
|
+
const headerChoice = await p.select({
|
|
2294
|
+
message: "Choose a header (appears on every page)",
|
|
2295
|
+
options: [noneOption, ...headerOptions]
|
|
2296
|
+
});
|
|
2297
|
+
if (p.isCancel(headerChoice)) return handleCancel();
|
|
2298
|
+
if (headerChoice !== "__none__") selectedHeader = headerChoice;
|
|
2299
|
+
}
|
|
2300
|
+
if (contentOptions.length > 0) {
|
|
2301
|
+
const blocks = await p.multiselect({
|
|
2302
|
+
message: "Select content blocks (space to toggle, enter to confirm)",
|
|
2303
|
+
options: contentOptions,
|
|
2304
|
+
required: false
|
|
2305
|
+
});
|
|
2306
|
+
if (p.isCancel(blocks)) return handleCancel();
|
|
2307
|
+
selectedContentBlocks = blocks;
|
|
2308
|
+
}
|
|
2309
|
+
if (footerOptions.length > 0) {
|
|
2310
|
+
const noneOption = { value: "__none__", label: "None", hint: "No footer" };
|
|
2311
|
+
const footerChoice = await p.select({
|
|
2312
|
+
message: "Choose a footer (appears on every page)",
|
|
2313
|
+
options: [noneOption, ...footerOptions]
|
|
2314
|
+
});
|
|
2315
|
+
if (p.isCancel(footerChoice)) return handleCancel();
|
|
2316
|
+
if (footerChoice !== "__none__") selectedFooter = footerChoice;
|
|
2317
|
+
}
|
|
2318
|
+
const tempSelected = [];
|
|
2319
|
+
if (selectedHeader) tempSelected.push(selectedHeader);
|
|
2320
|
+
tempSelected.push(...selectedContentBlocks);
|
|
2321
|
+
if (selectedFooter) tempSelected.push(selectedFooter);
|
|
2322
|
+
if (tempSelected.length > 0) {
|
|
2323
|
+
const checkResult = resolveDependencies(tempSelected, input.manifests);
|
|
2324
|
+
if (!isOk(checkResult)) {
|
|
2325
|
+
if (checkResult.error.kind === "DependencyConflictError") {
|
|
2326
|
+
p.log.warn(`Conflict detected: ${checkResult.error.blockA} conflicts with ${checkResult.error.blockB}`);
|
|
2327
|
+
const retry = await p.confirm({
|
|
2328
|
+
message: "Block conflict detected. Would you like to select your blocks again?",
|
|
2329
|
+
initialValue: true
|
|
2330
|
+
});
|
|
2331
|
+
if (p.isCancel(retry) || !retry) return handleCancel();
|
|
2332
|
+
continue;
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
break;
|
|
2299
2337
|
}
|
|
2300
2338
|
const localesInput = await p.text({
|
|
2301
2339
|
message: "Locales (comma-separated, e.g. en,es,ar)",
|
|
@@ -2463,58 +2501,58 @@ import { writeFileSync as writeFileSync3 } from "fs";
|
|
|
2463
2501
|
import { join as join4, basename } from "path";
|
|
2464
2502
|
import pc2 from "picocolors";
|
|
2465
2503
|
function runPostScaffold(input, callbacks) {
|
|
2466
|
-
const
|
|
2504
|
+
const log2 = callbacks?.onLog ?? ((msg) => console.log(msg));
|
|
2467
2505
|
const warn = callbacks?.onWarn ?? ((msg) => console.warn(msg));
|
|
2468
2506
|
const { config, resolvedBlockNames, filesWritten, verbose } = input;
|
|
2469
2507
|
const projectDir = config.projectDir;
|
|
2470
2508
|
const projectName = basename(projectDir);
|
|
2471
2509
|
generateClaudeMd(projectDir, config, resolvedBlockNames);
|
|
2472
|
-
if (verbose)
|
|
2510
|
+
if (verbose) log2(pc2.dim(" created CLAUDE.md"));
|
|
2473
2511
|
let installSuccess = false;
|
|
2474
2512
|
if (!input.skipInstall) {
|
|
2475
|
-
installSuccess = installDependencies(projectDir, config.packageManager, verbose,
|
|
2513
|
+
installSuccess = installDependencies(projectDir, config.packageManager, verbose, log2, warn);
|
|
2476
2514
|
}
|
|
2477
2515
|
let gitSuccess = false;
|
|
2478
2516
|
if (!input.skipGit) {
|
|
2479
|
-
gitSuccess = initGit(projectDir, verbose,
|
|
2480
|
-
}
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2517
|
+
gitSuccess = initGit(projectDir, verbose, log2, warn);
|
|
2518
|
+
}
|
|
2519
|
+
log2("");
|
|
2520
|
+
log2(pc2.green(pc2.bold("\u2714 Project created successfully!")));
|
|
2521
|
+
log2("");
|
|
2522
|
+
log2(` ${pc2.bold("Project:")} ${config.projectName}`);
|
|
2523
|
+
log2(` ${pc2.bold("Dir:")} ${projectDir}`);
|
|
2524
|
+
log2(` ${pc2.bold("Render:")} ${config.renderMode}`);
|
|
2525
|
+
log2(` ${pc2.bold("Deploy:")} ${config.deployTarget}`);
|
|
2526
|
+
log2(` ${pc2.bold("CSS:")} ${config.cssEngine}`);
|
|
2489
2527
|
if (resolvedBlockNames.length > 0) {
|
|
2490
|
-
|
|
2528
|
+
log2(` ${pc2.bold("Blocks:")} ${resolvedBlockNames.join(", ")}`);
|
|
2491
2529
|
}
|
|
2492
2530
|
if (config.locales.length > 1) {
|
|
2493
|
-
|
|
2531
|
+
log2(` ${pc2.bold("Locales:")} ${config.locales.join(", ")} (default: ${config.defaultLocale})`);
|
|
2494
2532
|
}
|
|
2495
2533
|
if (config.palette.preset) {
|
|
2496
|
-
|
|
2534
|
+
log2(` ${pc2.bold("Palette:")} ${config.palette.preset}`);
|
|
2497
2535
|
}
|
|
2498
|
-
|
|
2536
|
+
log2(` ${pc2.bold("Files:")} ${filesWritten} files written`);
|
|
2499
2537
|
if (installSuccess) {
|
|
2500
|
-
|
|
2538
|
+
log2(` ${pc2.bold("Deps:")} ${pc2.green("installed")}`);
|
|
2501
2539
|
}
|
|
2502
2540
|
if (gitSuccess) {
|
|
2503
|
-
|
|
2541
|
+
log2(` ${pc2.bold("Git:")} ${pc2.green("initialized")}`);
|
|
2504
2542
|
}
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2543
|
+
log2("");
|
|
2544
|
+
log2(pc2.dim(" Next steps:"));
|
|
2545
|
+
log2(pc2.dim(` cd ${projectName}`));
|
|
2508
2546
|
if (!installSuccess) {
|
|
2509
|
-
|
|
2547
|
+
log2(pc2.dim(` ${config.packageManager} install`));
|
|
2510
2548
|
}
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2549
|
+
log2(pc2.dim(` ${config.packageManager} dev`));
|
|
2550
|
+
log2(pc2.dim(` npx create-fornix add <block>`));
|
|
2551
|
+
log2("");
|
|
2514
2552
|
}
|
|
2515
|
-
function installDependencies(projectDir, packageManager, verbose,
|
|
2553
|
+
function installDependencies(projectDir, packageManager, verbose, log2, warn) {
|
|
2516
2554
|
try {
|
|
2517
|
-
|
|
2555
|
+
log2(pc2.dim(" Installing dependencies..."));
|
|
2518
2556
|
const cmd = `${packageManager} install`;
|
|
2519
2557
|
execSync(cmd, {
|
|
2520
2558
|
cwd: projectDir,
|
|
@@ -2528,9 +2566,9 @@ function installDependencies(projectDir, packageManager, verbose, log, warn) {
|
|
|
2528
2566
|
return false;
|
|
2529
2567
|
}
|
|
2530
2568
|
}
|
|
2531
|
-
function initGit(projectDir, verbose,
|
|
2569
|
+
function initGit(projectDir, verbose, log2, warn) {
|
|
2532
2570
|
try {
|
|
2533
|
-
if (verbose)
|
|
2571
|
+
if (verbose) log2(pc2.dim(" Initializing git repository..."));
|
|
2534
2572
|
execSync("git init", {
|
|
2535
2573
|
cwd: projectDir,
|
|
2536
2574
|
stdio: "pipe",
|
|
@@ -4502,6 +4540,13 @@ var addCommand = defineCommand2({
|
|
|
4502
4540
|
content
|
|
4503
4541
|
});
|
|
4504
4542
|
}
|
|
4543
|
+
if (sources["default-content.json"]) {
|
|
4544
|
+
const collection = bManifest.type === "section" ? "sections" : bManifest.type + "s";
|
|
4545
|
+
filesToWrite.push({
|
|
4546
|
+
path: join8(cwd, `src/content/${collection}/${name}.json`),
|
|
4547
|
+
content: sources["default-content.json"]
|
|
4548
|
+
});
|
|
4549
|
+
}
|
|
4505
4550
|
}
|
|
4506
4551
|
if (typedArgs["dry-run"]) {
|
|
4507
4552
|
console.log(pc4.bold("\n Dry run \u2014 no files written\n"));
|