create-fornix 0.0.10 → 0.0.11

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
@@ -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}': ${message}`
2166
+ message: `Failed to fetch block '${blockName}': ${refinedMessage}`
2153
2167
  });
2154
2168
  }
2155
2169
  }
@@ -4502,6 +4516,13 @@ var addCommand = defineCommand2({
4502
4516
  content
4503
4517
  });
4504
4518
  }
4519
+ if (sources["default-content.json"]) {
4520
+ const collection = bManifest.type === "section" ? "sections" : bManifest.type + "s";
4521
+ filesToWrite.push({
4522
+ path: join8(cwd, `src/content/${collection}/${name}.json`),
4523
+ content: sources["default-content.json"]
4524
+ });
4525
+ }
4505
4526
  }
4506
4527
  if (typedArgs["dry-run"]) {
4507
4528
  console.log(pc4.bold("\n Dry run \u2014 no files written\n"));