@s0rt/3dvf 0.1.1 → 0.1.3

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/cli/index.js +57 -11
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -3572,13 +3572,51 @@ var require_picocolors = __commonJS((exports, module) => {
3572
3572
  module.exports.createColors = createColors;
3573
3573
  });
3574
3574
 
3575
+ // package.json
3576
+ var package_default;
3577
+ var init_package = __esm(() => {
3578
+ package_default = {
3579
+ name: "@s0rt/3dvf",
3580
+ version: "0.1.2",
3581
+ description: "shadcn-style Three.js function library CLI",
3582
+ type: "module",
3583
+ bin: {
3584
+ "3dvf": "./dist/cli/index.js"
3585
+ },
3586
+ files: [
3587
+ "dist/"
3588
+ ],
3589
+ publishConfig: {
3590
+ access: "public"
3591
+ },
3592
+ scripts: {
3593
+ build: "bun build src/cli/index.ts --outdir dist/cli --target node --format esm",
3594
+ "build:registry": "bun run scripts/build-registry.ts",
3595
+ "serve:registry": "bunx serve public -p 3001",
3596
+ dev: "bun run src/cli/index.ts",
3597
+ test: "bun test"
3598
+ },
3599
+ dependencies: {
3600
+ commander: "^12.1.0",
3601
+ ora: "^8.1.1",
3602
+ picocolors: "^1.1.1",
3603
+ prompts: "^2.4.2"
3604
+ },
3605
+ devDependencies: {
3606
+ "@types/prompts": "^2.4.9",
3607
+ typescript: "^5.7.0"
3608
+ }
3609
+ };
3610
+ });
3611
+
3575
3612
  // src/cli/utils/config.ts
3576
3613
  var exports_config = {};
3577
3614
  __export(exports_config, {
3578
3615
  writeConfig: () => writeConfig,
3579
3616
  readConfig: () => readConfig,
3580
3617
  configExists: () => configExists,
3581
- DEFAULT_CONFIG: () => DEFAULT_CONFIG
3618
+ DEFAULT_CONFIG: () => DEFAULT_CONFIG,
3619
+ CLI_VERSION: () => CLI_VERSION
3582
3620
  });
3583
3621
  import {existsSync, readFileSync, writeFileSync} from "fs";
3584
3622
  import {join} from "path";
@@ -3597,11 +3635,13 @@ function writeConfig(config, cwd = process.cwd()) {
3597
3635
  function configExists(cwd = process.cwd()) {
3598
3636
  return existsSync(join(cwd, CONFIG_FILE));
3599
3637
  }
3600
- var CONFIG_FILE = "3dvf.json", DEFAULT_CONFIG;
3638
+ var CLI_VERSION, CONFIG_FILE = "3dvf.json", BASE_REGISTRY_URL = "https://app.pierrelespingal.xyz/3dvf/registry", DEFAULT_CONFIG;
3601
3639
  var init_config = __esm(() => {
3640
+ init_package();
3641
+ CLI_VERSION = package_default.version;
3602
3642
  DEFAULT_CONFIG = {
3603
3643
  outputDir: "src/lib/3dvf",
3604
- registry: "https://pierreleblond.github.io/3d-viewer-functions/registry",
3644
+ registry: `${BASE_REGISTRY_URL}/v${CLI_VERSION}`,
3605
3645
  typescript: true
3606
3646
  };
3607
3647
  });
@@ -9837,16 +9877,18 @@ init_config();
9837
9877
 
9838
9878
  // src/cli/utils/registry.ts
9839
9879
  async function fetchRegistryIndex(registryUrl) {
9840
- const res = await fetch(`${registryUrl}/registry.json`);
9880
+ const url = `${registryUrl}/registry.json`;
9881
+ const res = await fetch(url);
9841
9882
  if (!res.ok) {
9842
- throw new Error(`Failed to fetch registry index: ${res.status} ${res.statusText}`);
9883
+ throw new Error(`Failed to fetch registry index from ${url}: ${res.status} ${res.statusText}`);
9843
9884
  }
9844
9885
  return res.json();
9845
9886
  }
9846
9887
  async function fetchRegistryItem(registryUrl, name) {
9847
- const res = await fetch(`${registryUrl}/${name}.json`);
9888
+ const url = `${registryUrl}/${name}.json`;
9889
+ const res = await fetch(url);
9848
9890
  if (!res.ok) {
9849
- throw new Error(`Function "${name}" not found in registry (${res.status})`);
9891
+ throw new Error(`Function "${name}" not found in registry at ${url} (${res.status})`);
9850
9892
  }
9851
9893
  return res.json();
9852
9894
  }
@@ -9875,16 +9917,20 @@ function collectDeps(items) {
9875
9917
  // src/cli/utils/write.ts
9876
9918
  import {mkdirSync, writeFileSync as writeFileSync2} from "fs";
9877
9919
  import {dirname, join as join2} from "path";
9878
- function writeRegistryItem(item, outputDir, cwd = process.cwd()) {
9920
+ function writeRegistryItem(item, outputDir, version, cwd = process.cwd()) {
9879
9921
  const written = [];
9922
+ const itemDir = join2(cwd, outputDir, item.name);
9880
9923
  for (const file of item.files) {
9881
- const dest = join2(cwd, outputDir, item.name, file.path);
9924
+ const dest = join2(itemDir, file.path);
9882
9925
  mkdirSync(dirname(dest), { recursive: true });
9883
9926
  writeFileSync2(dest, file.content, "utf-8");
9884
9927
  written.push(dest);
9885
9928
  }
9929
+ const stampPath = join2(itemDir, VERSION_STAMP_FILE);
9930
+ writeFileSync2(stampPath, version, "utf-8");
9886
9931
  return written;
9887
9932
  }
9933
+ var VERSION_STAMP_FILE = ".3dvf-version";
9888
9934
 
9889
9935
  // src/cli/utils/packageManager.ts
9890
9936
  import {existsSync as existsSync2} from "fs";
@@ -9934,9 +9980,9 @@ async function addCommand(names) {
9934
9980
  const items = [...tree.values()];
9935
9981
  const written = [];
9936
9982
  for (const item of items) {
9937
- const paths = writeRegistryItem(item, config2.outputDir);
9983
+ const paths = writeRegistryItem(item, config2.outputDir, CLI_VERSION);
9938
9984
  written.push(...paths);
9939
- console.log(import_picocolors.default.green("\u2713") + ` Installed ${import_picocolors.default.bold(item.name)}`);
9985
+ console.log(import_picocolors.default.green("\u2713") + ` Installed ${import_picocolors.default.bold(item.name)} ${import_picocolors.default.dim(`(v${CLI_VERSION})`)}`);
9940
9986
  for (const p of paths) {
9941
9987
  console.log(import_picocolors.default.dim(` ${p.replace(process.cwd() + "/", "")}`));
9942
9988
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s0rt/3dvf",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "shadcn-style Three.js function library CLI",
5
5
  "type": "module",
6
6
  "bin": {