@farming-labs/docs 0.0.16 → 0.0.17

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.mjs +71 -16
  2. package/package.json +1 -1
@@ -1699,11 +1699,65 @@ const VALID_TEMPLATES = [
1699
1699
  async function init(options = {}) {
1700
1700
  const cwd = process.cwd();
1701
1701
  p.intro(pc.bgCyan(pc.black(" @farming-labs/docs ")));
1702
- if (options.template) {
1703
- const template = options.template.toLowerCase();
1704
- if (!VALID_TEMPLATES.includes(template)) {
1705
- p.log.error(`Invalid ${pc.cyan("--template")}. Use one of: ${VALID_TEMPLATES.map((t) => pc.cyan(t)).join(", ")}`);
1706
- process.exit(1);
1702
+ let projectType = "existing";
1703
+ if (!options.template) {
1704
+ const projectTypeAnswer = await p.select({
1705
+ message: "Are you adding docs to an existing project or starting fresh?",
1706
+ options: [{
1707
+ value: "existing",
1708
+ label: "Existing project",
1709
+ hint: "Add docs to the current app in this directory"
1710
+ }, {
1711
+ value: "fresh",
1712
+ label: "Fresh project",
1713
+ hint: "Bootstrap a new app from a template (Next, Nuxt, SvelteKit, Astro)"
1714
+ }]
1715
+ });
1716
+ if (p.isCancel(projectTypeAnswer)) {
1717
+ p.outro(pc.red("Init cancelled."));
1718
+ process.exit(0);
1719
+ }
1720
+ projectType = projectTypeAnswer;
1721
+ }
1722
+ if (projectType === "fresh" || options.template) {
1723
+ let template;
1724
+ if (options.template) {
1725
+ template = options.template.toLowerCase();
1726
+ if (!VALID_TEMPLATES.includes(template)) {
1727
+ p.log.error(`Invalid ${pc.cyan("--template")}. Use one of: ${VALID_TEMPLATES.map((t) => pc.cyan(t)).join(", ")}`);
1728
+ process.exit(1);
1729
+ }
1730
+ } else {
1731
+ const templateAnswer = await p.select({
1732
+ message: "Which framework would you like to use?",
1733
+ options: [
1734
+ {
1735
+ value: "next",
1736
+ label: "Next.js",
1737
+ hint: "React with App Router"
1738
+ },
1739
+ {
1740
+ value: "nuxt",
1741
+ label: "Nuxt",
1742
+ hint: "Vue 3 with file-based routing"
1743
+ },
1744
+ {
1745
+ value: "sveltekit",
1746
+ label: "SvelteKit",
1747
+ hint: "Svelte with file-based routing"
1748
+ },
1749
+ {
1750
+ value: "astro",
1751
+ label: "Astro",
1752
+ hint: "Content-focused with islands"
1753
+ }
1754
+ ]
1755
+ });
1756
+ if (p.isCancel(templateAnswer)) {
1757
+ p.outro(pc.red("Init cancelled."));
1758
+ process.exit(0);
1759
+ }
1760
+ template = templateAnswer;
1707
1761
  }
1708
1762
  let projectName = options.name?.trim();
1709
1763
  if (!projectName) {
@@ -1894,21 +1948,22 @@ async function init(options = {}) {
1894
1948
  }
1895
1949
  astroAdapter = adapter;
1896
1950
  }
1951
+ const defaultEntry = "docs";
1897
1952
  const entry = await p.text({
1898
1953
  message: "Where should your docs live?",
1899
- placeholder: "docs",
1900
- defaultValue: "docs",
1954
+ placeholder: defaultEntry,
1955
+ defaultValue: defaultEntry,
1901
1956
  validate: (value) => {
1902
- if (!value) return "Entry path is required";
1903
- if (value.startsWith("/")) return "Use a relative path (no leading /)";
1904
- if (value.includes(" ")) return "Path cannot contain spaces";
1957
+ const v = (value ?? "").trim();
1958
+ if (v.startsWith("/")) return "Use a relative path (no leading /)";
1959
+ if (v.includes(" ")) return "Path cannot contain spaces";
1905
1960
  }
1906
1961
  });
1907
1962
  if (p.isCancel(entry)) {
1908
1963
  p.outro(pc.red("Init cancelled."));
1909
1964
  process.exit(0);
1910
1965
  }
1911
- const entryPath = entry;
1966
+ const entryPath = entry.trim() || defaultEntry;
1912
1967
  const detectedCssFiles = detectGlobalCssFiles(cwd);
1913
1968
  let globalCssRelPath;
1914
1969
  const defaultCssPath = framework === "sveltekit" ? "src/app.css" : framework === "astro" ? "src/styles/global.css" : framework === "nuxt" ? "assets/css/main.css" : "app/globals.css";
@@ -1929,20 +1984,20 @@ async function init(options = {}) {
1929
1984
  }
1930
1985
  globalCssRelPath = picked;
1931
1986
  } else {
1932
- const cssPath = await p.text({
1987
+ const cssPathAnswer = await p.text({
1933
1988
  message: "Where is your global CSS file?",
1934
1989
  placeholder: defaultCssPath,
1935
1990
  defaultValue: defaultCssPath,
1936
1991
  validate: (value) => {
1937
- if (!value) return "CSS file path is required";
1938
- if (!value.endsWith(".css")) return "Path must end with .css";
1992
+ const v = (value ?? "").trim();
1993
+ if (v && !v.endsWith(".css")) return "Path must end with .css";
1939
1994
  }
1940
1995
  });
1941
- if (p.isCancel(cssPath)) {
1996
+ if (p.isCancel(cssPathAnswer)) {
1942
1997
  p.outro(pc.red("Init cancelled."));
1943
1998
  process.exit(0);
1944
1999
  }
1945
- globalCssRelPath = cssPath;
2000
+ globalCssRelPath = cssPathAnswer.trim() || defaultCssPath;
1946
2001
  }
1947
2002
  const pkgJsonContent = readFileSafe(path.join(cwd, "package.json"));
1948
2003
  const pkgJson = pkgJsonContent ? JSON.parse(pkgJsonContent) : { name: "my-project" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/docs",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "Modern, flexible MDX-based docs framework — core types, config, and CLI",
5
5
  "keywords": [
6
6
  "docs",