@farming-labs/docs 0.1.103 → 0.1.105

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.
@@ -158,10 +158,14 @@ async function main() {
158
158
  printRobotsGenerateHelp();
159
159
  process.exit(1);
160
160
  } else if (parsedCommand.command === "upgrade") {
161
- const { upgrade } = await import("../upgrade-Nh6Jn6Kk.mjs");
161
+ const { upgrade } = await import("../upgrade-G2f_v09Z.mjs");
162
+ const framework = (typeof flags.framework === "string" ? flags.framework : void 0) ?? (args[1] && !args[1].startsWith("--") ? args[1] : void 0);
163
+ const hasVersionFlag = args.includes("--version") || args.some((arg) => arg.startsWith("--version="));
164
+ const version = typeof flags.version === "string" ? flags.version : hasVersionFlag ? "" : void 0;
162
165
  await upgrade({
163
- framework: (typeof flags.framework === "string" ? flags.framework : void 0) ?? (args[1] && !args[1].startsWith("--") ? args[1] : void 0),
164
- tag: args.includes("--beta") ? "beta" : args.includes("--latest") ? "latest" : parsedCommand.tag ?? "latest"
166
+ framework,
167
+ tag: version !== void 0 ? void 0 : args.includes("--beta") ? "beta" : args.includes("--latest") ? "latest" : parsedCommand.tag ?? "latest",
168
+ version
165
169
  });
166
170
  } else if (parsedCommand.command === "--help" || parsedCommand.command === "-h") printHelp();
167
171
  else if (parsedCommand.command === "--version" || parsedCommand.command === "-v") printVersion();
@@ -189,7 +193,7 @@ ${pc.dim("Commands:")}
189
193
  ${pc.cyan("robots")} Robots.txt utilities (${pc.dim("generate")} for agent access policy)
190
194
  ${pc.cyan("search")} Search utilities (${pc.dim("sync")} for external indexes)
191
195
  ${pc.cyan("sitemap")} Sitemap utilities (${pc.dim("generate")} for sitemap XML/Markdown data)
192
- ${pc.cyan("upgrade")} Upgrade @farming-labs/* packages to latest (auto-detect or use --framework)
196
+ ${pc.cyan("upgrade")} Upgrade @farming-labs/* packages (auto-detect or use --framework)
193
197
 
194
198
  ${pc.dim("Supported frameworks:")}
195
199
  Next.js, TanStack Start, SvelteKit, Astro, Nuxt
@@ -271,6 +275,7 @@ ${pc.dim("Options for robots generate:")}
271
275
 
272
276
  ${pc.dim("Options for upgrade:")}
273
277
  ${pc.cyan("--framework <name>")} Explicit framework (${pc.dim("next")}, ${pc.dim("tanstack-start")}, ${pc.dim("nuxt")}, ${pc.dim("sveltekit")}, ${pc.dim("astro")}); omit to auto-detect
278
+ ${pc.cyan("--version <version>")} Install an exact version (e.g. ${pc.dim("0.1.104")})
274
279
  ${pc.cyan("--latest")} Install latest stable (default)
275
280
  ${pc.cyan("--beta")} Install beta versions
276
281
  ${pc.cyan("upgrade@beta")} Shortcut for ${pc.cyan("upgrade --beta")}
@@ -5,7 +5,7 @@ import * as p from "@clack/prompts";
5
5
 
6
6
  //#region src/cli/upgrade.ts
7
7
  /**
8
- * Upgrade @farming-labs/* packages to latest.
8
+ * Upgrade @farming-labs/* packages to a dist-tag or exact version.
9
9
  * Detects framework from package.json by default, or use --framework (next, tanstack-start, nuxt, sveltekit, astro).
10
10
  */
11
11
  const PRESETS = [
@@ -52,15 +52,31 @@ function frameworkFromPreset(preset) {
52
52
  function getPackagesForFramework(framework) {
53
53
  return PACKAGES_BY_FRAMEWORK[framework];
54
54
  }
55
+ const exactSemverPattern = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
56
+ function validateUpgradeVersion(version) {
57
+ const normalized = version.trim();
58
+ if (!exactSemverPattern.test(normalized)) throw new Error(`Invalid version "${version}". Use an exact semver version like 0.1.104.`);
59
+ return normalized;
60
+ }
61
+ function resolveUpgradeTarget(options) {
62
+ if (options.version !== void 0) return validateUpgradeVersion(options.version);
63
+ return options.tag ?? "latest";
64
+ }
55
65
  /** Build the install command for upgrade (for testing). */
56
- function buildUpgradeCommand(framework, tag, pm) {
57
- const packagesWithTag = PACKAGES_BY_FRAMEWORK[framework].map((name) => `${name}@${tag}`);
58
- return `${installCommand(pm)} ${packagesWithTag.join(" ")}`;
66
+ function buildUpgradeCommand(framework, target, pm) {
67
+ const packagesWithTarget = PACKAGES_BY_FRAMEWORK[framework].map((name) => `${name}@${target}`);
68
+ return `${installCommand(pm)} ${packagesWithTarget.join(" ")}`;
59
69
  }
60
70
  async function upgrade(options = {}) {
61
71
  const cwd = process.cwd();
62
- const tag = options.tag ?? "latest";
63
72
  p.intro(pc.bgCyan(pc.black(" @farming-labs/docs upgrade ")));
73
+ let target;
74
+ try {
75
+ target = resolveUpgradeTarget(options);
76
+ } catch (error) {
77
+ p.log.error(error instanceof Error ? error.message : "Invalid upgrade version.");
78
+ process.exit(1);
79
+ }
64
80
  if (!fileExists(path.join(cwd, "package.json"))) {
65
81
  p.log.error("No package.json found in the current directory. Run this from your project root.");
66
82
  process.exit(1);
@@ -120,13 +136,13 @@ async function upgrade(options = {}) {
120
136
  pm = pmAnswer;
121
137
  p.log.info(`Using ${pc.cyan(pm)} as package manager`);
122
138
  }
123
- const cmd = buildUpgradeCommand(framework, tag, pm);
139
+ const cmd = buildUpgradeCommand(framework, target, pm);
124
140
  const packages = getPackagesForFramework(framework);
125
- p.log.step(`Upgrading ${preset} docs packages to ${tag}...`);
141
+ p.log.step(`Upgrading ${preset} docs packages to ${target}...`);
126
142
  p.log.message(pc.dim(packages.join(", ")));
127
143
  try {
128
144
  exec(cmd, cwd);
129
- p.log.success(`Packages upgraded to ${tag}.`);
145
+ p.log.success(`Packages upgraded to ${target}.`);
130
146
  p.outro(pc.green("Done. Run your dev server to confirm everything works."));
131
147
  } catch {
132
148
  p.log.error("Upgrade failed. Try running manually:\n " + pc.cyan(cmd));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/docs",
3
- "version": "0.1.103",
3
+ "version": "0.1.105",
4
4
  "description": "Modern, flexible MDX-based docs framework — core types, config, and CLI",
5
5
  "keywords": [
6
6
  "docs",