create-fornix 0.0.7 → 0.0.8

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
@@ -9,7 +9,7 @@ import { defineCommand as defineCommand8 } from "citty";
9
9
  // src/cli/commands/create.ts
10
10
  import { defineCommand } from "citty";
11
11
  import { resolve as resolve2, basename as basename2 } from "path";
12
- import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync3 } from "fs";
12
+ import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "fs";
13
13
  import { join as join6 } from "path";
14
14
  import * as p2 from "@clack/prompts";
15
15
  import pc3 from "picocolors";
@@ -1898,10 +1898,13 @@ import {
1898
1898
  readFileSync as readFileSync3,
1899
1899
  readdirSync as readdirSync2,
1900
1900
  mkdirSync as mkdirSync2,
1901
- statSync as statSync2
1901
+ statSync as statSync2,
1902
+ writeFileSync as writeFileSync2,
1903
+ rmSync
1902
1904
  } from "fs";
1903
1905
  import { join as join3 } from "path";
1904
1906
  import { homedir as homedir2 } from "os";
1907
+ import { createRequire } from "module";
1905
1908
  var DEFAULT_CONFIG2 = {
1906
1909
  repo: "kamsqe/fornix",
1907
1910
  ref: "main",
@@ -1911,6 +1914,31 @@ var DEFAULT_CONFIG2 = {
1911
1914
  maxCacheAge: 24 * 60 * 60 * 1e3
1912
1915
  // 24 hours
1913
1916
  };
1917
+ var cacheVersionChecked = false;
1918
+ function ensureCacheVersion(cacheDir) {
1919
+ if (cacheVersionChecked) return;
1920
+ cacheVersionChecked = true;
1921
+ let cliVersion = "unknown";
1922
+ try {
1923
+ const require2 = createRequire(import.meta.url);
1924
+ const pkg = require2("../../package.json");
1925
+ cliVersion = pkg.version ?? "unknown";
1926
+ } catch {
1927
+ }
1928
+ const versionFile = join3(cacheDir, ".version");
1929
+ try {
1930
+ if (existsSync2(versionFile)) {
1931
+ const cached = readFileSync3(versionFile, "utf-8").trim();
1932
+ if (cached === cliVersion) return;
1933
+ }
1934
+ if (existsSync2(cacheDir)) {
1935
+ rmSync(cacheDir, { recursive: true, force: true });
1936
+ }
1937
+ mkdirSync2(cacheDir, { recursive: true });
1938
+ writeFileSync2(versionFile, cliVersion);
1939
+ } catch {
1940
+ }
1941
+ }
1914
1942
  async function fetchBlock(blockName, config = {}) {
1915
1943
  if (process.env.FORNIX_E2E_MOCK === "true") {
1916
1944
  const manifest2 = FIXTURE_MANIFESTS[blockName];
@@ -1925,6 +1953,7 @@ async function fetchBlock(blockName, config = {}) {
1925
1953
  return ok({ manifest: manifest2, files, fromCache: true });
1926
1954
  }
1927
1955
  const cfg = { ...DEFAULT_CONFIG2, ...config };
1956
+ ensureCacheVersion(cfg.cacheDir);
1928
1957
  const blockCacheDir = join3(cfg.cacheDir, blockName);
1929
1958
  if (!cfg.force && isCacheValid2(blockCacheDir, cfg.maxCacheAge)) {
1930
1959
  return loadFromCache2(blockName, blockCacheDir);
@@ -2206,7 +2235,7 @@ function buildSummary(config, blockNames, palette) {
2206
2235
 
2207
2236
  // src/scaffold/post-scaffold.ts
2208
2237
  import { execSync } from "child_process";
2209
- import { writeFileSync as writeFileSync2 } from "fs";
2238
+ import { writeFileSync as writeFileSync3 } from "fs";
2210
2239
  import { join as join4, basename } from "path";
2211
2240
  import pc2 from "picocolors";
2212
2241
  function runPostScaffold(input, callbacks) {
@@ -2373,7 +2402,7 @@ function generateClaudeMd(projectDir, config, blockNames) {
2373
2402
  lines.push("```");
2374
2403
  lines.push("");
2375
2404
  const content = lines.join("\n");
2376
- writeFileSync2(join4(projectDir, "CLAUDE.md"), content, "utf-8");
2405
+ writeFileSync3(join4(projectDir, "CLAUDE.md"), content, "utf-8");
2377
2406
  }
2378
2407
 
2379
2408
  // src/ai/prompt-builder.ts
@@ -3863,7 +3892,7 @@ async function runScaffold(config, manifests, allPalettes, dryRun, verbose, skip
3863
3892
  const fullPath = join6(config.projectDir, relativePath);
3864
3893
  const parentDir = join6(fullPath, "..");
3865
3894
  mkdirSync4(parentDir, { recursive: true });
3866
- writeFileSync3(fullPath, content, "utf-8");
3895
+ writeFileSync4(fullPath, content, "utf-8");
3867
3896
  filesWritten++;
3868
3897
  if (verbose) {
3869
3898
  console.log(pc3.dim(` created ${relativePath}`));
@@ -3952,7 +3981,7 @@ function showNoProviderGuide() {
3952
3981
  // src/cli/commands/add.ts
3953
3982
  import { defineCommand as defineCommand2 } from "citty";
3954
3983
  import pc4 from "picocolors";
3955
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync4, existsSync as existsSync4, mkdirSync as mkdirSync5 } from "fs";
3984
+ import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, existsSync as existsSync4, mkdirSync as mkdirSync5 } from "fs";
3956
3985
  import { join as join7, dirname as dirname3 } from "path";
3957
3986
  var addCommand = defineCommand2({
3958
3987
  meta: {
@@ -4079,7 +4108,7 @@ var addCommand = defineCommand2({
4079
4108
  }
4080
4109
  for (const file of filesToWrite) {
4081
4110
  mkdirSync5(dirname3(file.path), { recursive: true });
4082
- writeFileSync4(file.path, file.content);
4111
+ writeFileSync5(file.path, file.content);
4083
4112
  if (typedArgs.verbose) {
4084
4113
  console.log(` ${pc4.dim("\u2192")} ${file.path}`);
4085
4114
  }
@@ -4095,7 +4124,7 @@ var addCommand = defineCommand2({
4095
4124
  installedAt: now
4096
4125
  });
4097
4126
  }
4098
- writeFileSync4(manifestPath, JSON.stringify(manifest2, null, 2) + "\n");
4127
+ writeFileSync5(manifestPath, JSON.stringify(manifest2, null, 2) + "\n");
4099
4128
  console.log();
4100
4129
  for (const name of blocksToAdd) {
4101
4130
  const isDep = name !== blockName;
@@ -4136,7 +4165,7 @@ function resolveDependencies2(blockName, installedNames, manifests) {
4136
4165
  // src/cli/commands/remove.ts
4137
4166
  import { defineCommand as defineCommand3 } from "citty";
4138
4167
  import pc5 from "picocolors";
4139
- import { readFileSync as readFileSync6, writeFileSync as writeFileSync5, existsSync as existsSync5, unlinkSync, readdirSync as readdirSync3, rmdirSync } from "fs";
4168
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, existsSync as existsSync5, unlinkSync, readdirSync as readdirSync3, rmdirSync } from "fs";
4140
4169
  import { join as join8, dirname as dirname4 } from "path";
4141
4170
  var removeCommand = defineCommand3({
4142
4171
  meta: {
@@ -4231,7 +4260,7 @@ var removeCommand = defineCommand3({
4231
4260
  tryRemoveEmptyDir(dirname4(filePath), cwd);
4232
4261
  }
4233
4262
  manifest2.blocks = manifest2.blocks.filter((b) => b.name !== blockName);
4234
- writeFileSync5(manifestPath, JSON.stringify(manifest2, null, 2) + "\n");
4263
+ writeFileSync6(manifestPath, JSON.stringify(manifest2, null, 2) + "\n");
4235
4264
  console.log();
4236
4265
  console.log(` ${pc5.red("-")} ${pc5.bold(blockName)} removed`);
4237
4266
  if (dependents.length > 0) {
@@ -4713,7 +4742,7 @@ async function listBlocksHandler(args2) {
4713
4742
  }
4714
4743
 
4715
4744
  // src/mcp/tools/add-block.ts
4716
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, existsSync as existsSync8, mkdirSync as mkdirSync6 } from "fs";
4745
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync7, existsSync as existsSync8, mkdirSync as mkdirSync6 } from "fs";
4717
4746
  import { join as join11, dirname as dirname5 } from "path";
4718
4747
  async function addBlock2(input) {
4719
4748
  const { name, variant = "default", projectDirectory } = input;
@@ -4779,7 +4808,7 @@ async function addBlock2(input) {
4779
4808
  }
4780
4809
  const filePath = join11(projectDirectory, file.destination);
4781
4810
  mkdirSync6(dirname5(filePath), { recursive: true });
4782
- writeFileSync6(filePath, content);
4811
+ writeFileSync7(filePath, content);
4783
4812
  filesCreated++;
4784
4813
  }
4785
4814
  }
@@ -4794,7 +4823,7 @@ async function addBlock2(input) {
4794
4823
  installedAt: now
4795
4824
  });
4796
4825
  }
4797
- writeFileSync6(manifestPath, JSON.stringify(manifest2, null, 2) + "\n");
4826
+ writeFileSync7(manifestPath, JSON.stringify(manifest2, null, 2) + "\n");
4798
4827
  return ok({ addedBlocks: blocksToAdd, filesCreated });
4799
4828
  }
4800
4829
  function resolveDependencies3(blockName, installedNames, manifests) {
@@ -4817,7 +4846,7 @@ function resolveDependencies3(blockName, installedNames, manifests) {
4817
4846
  // src/mcp/tools/remove-block.ts
4818
4847
  import {
4819
4848
  readFileSync as readFileSync10,
4820
- writeFileSync as writeFileSync7,
4849
+ writeFileSync as writeFileSync8,
4821
4850
  existsSync as existsSync9,
4822
4851
  unlinkSync as unlinkSync2,
4823
4852
  readdirSync as readdirSync4,
@@ -4871,7 +4900,7 @@ async function removeBlock(input) {
4871
4900
  tryRemoveEmptyDirectory(dirname6(filePath), projectDirectory);
4872
4901
  }
4873
4902
  manifest2.blocks = manifest2.blocks.filter((block) => block.name !== name);
4874
- writeFileSync7(manifestPath, JSON.stringify(manifest2, null, 2) + "\n");
4903
+ writeFileSync8(manifestPath, JSON.stringify(manifest2, null, 2) + "\n");
4875
4904
  return ok({
4876
4905
  removedBlock: name,
4877
4906
  filesRemoved: filesToRemove.length,
@@ -5025,7 +5054,7 @@ function getProjectStatus(input) {
5025
5054
  }
5026
5055
 
5027
5056
  // src/mcp/tools/scaffold-project.ts
5028
- import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync8 } from "fs";
5057
+ import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync9 } from "fs";
5029
5058
  import { join as join14, basename as basename3 } from "path";
5030
5059
  var DEFAULT_COLORS2 = {
5031
5060
  primary: "#6366f1",
@@ -5100,7 +5129,7 @@ async function scaffoldProject(input) {
5100
5129
  const fullPath = join14(projectDirectory, relativePath);
5101
5130
  const parentDirectory = join14(fullPath, "..");
5102
5131
  mkdirSync7(parentDirectory, { recursive: true });
5103
- writeFileSync8(fullPath, content, "utf-8");
5132
+ writeFileSync9(fullPath, content, "utf-8");
5104
5133
  filesCreated++;
5105
5134
  }
5106
5135
  return ok({