@ahmedrowaihi/8n 0.5.13 → 0.5.14

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.
@@ -2,9 +2,9 @@ import { a as dirname$4, c as resolve$2, i as basename, l as __commonJSMin, o as
2
2
  import { n as require_node_fetch_native_DhEqb06g, t as require_node } from "./node-BEh-s3PG.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { createWriteStream, existsSync, readdirSync } from "node:fs";
5
- import { pipeline } from "node:stream";
6
5
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
7
6
  import { homedir } from "node:os";
7
+ import { pipeline } from "node:stream";
8
8
  import { promisify } from "node:util";
9
9
  import { delimiter, dirname, normalize, resolve } from "path";
10
10
  import { PassThrough as PassThrough$1 } from "stream";
package/dist/index.mjs CHANGED
@@ -2,18 +2,18 @@
2
2
  import { builtinModules, createRequire } from "node:module";
3
3
  import { spawn } from "node:child_process";
4
4
  import path, { delimiter, dirname, join, normalize, resolve } from "node:path";
5
- import fs, { appendFileSync, cpSync, existsSync, mkdirSync, promises, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
5
+ import fs, { appendFileSync, cpSync, existsSync, mkdirSync, promises, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
6
6
  import process$1, { cwd } from "node:process";
7
- import { PassThrough } from "node:stream";
8
- import c from "node:readline";
9
7
  import { readFile, rm, writeFile } from "node:fs/promises";
10
8
  import { homedir } from "node:os";
9
+ import { parseTarGzip } from "nanotar";
10
+ import { PassThrough } from "node:stream";
11
+ import c from "node:readline";
11
12
  import { createJiti } from "jiti";
12
13
  import { fileURLToPath, pathToFileURL } from "node:url";
13
14
  import assert from "node:assert";
14
15
  import v8 from "node:v8";
15
16
  import { format, inspect } from "node:util";
16
- import { parseTarGzip } from "nanotar";
17
17
  import { createInterface } from "node:readline/promises";
18
18
 
19
19
  //#region \0rolldown/runtime.js
@@ -3069,8 +3069,78 @@ var require_commander = /* @__PURE__ */ __commonJSMin(((exports) => {
3069
3069
  var import_commander = /* @__PURE__ */ __toESM(require_commander(), 1);
3070
3070
  const { program: program$1, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help } = import_commander.default;
3071
3071
 
3072
+ //#endregion
3073
+ //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
3074
+ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3075
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
3076
+ let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
3077
+ let formatter = (open, close, replace = open) => (input) => {
3078
+ let string = "" + input, index = string.indexOf(close, open.length);
3079
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
3080
+ };
3081
+ let replaceClose = (string, close, replace, index) => {
3082
+ let result = "", cursor = 0;
3083
+ do {
3084
+ result += string.substring(cursor, index) + replace;
3085
+ cursor = index + close.length;
3086
+ index = string.indexOf(close, cursor);
3087
+ } while (~index);
3088
+ return result + string.substring(cursor);
3089
+ };
3090
+ let createColors = (enabled = isColorSupported) => {
3091
+ let f = enabled ? formatter : () => String;
3092
+ return {
3093
+ isColorSupported: enabled,
3094
+ reset: f("\x1B[0m", "\x1B[0m"),
3095
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
3096
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
3097
+ italic: f("\x1B[3m", "\x1B[23m"),
3098
+ underline: f("\x1B[4m", "\x1B[24m"),
3099
+ inverse: f("\x1B[7m", "\x1B[27m"),
3100
+ hidden: f("\x1B[8m", "\x1B[28m"),
3101
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
3102
+ black: f("\x1B[30m", "\x1B[39m"),
3103
+ red: f("\x1B[31m", "\x1B[39m"),
3104
+ green: f("\x1B[32m", "\x1B[39m"),
3105
+ yellow: f("\x1B[33m", "\x1B[39m"),
3106
+ blue: f("\x1B[34m", "\x1B[39m"),
3107
+ magenta: f("\x1B[35m", "\x1B[39m"),
3108
+ cyan: f("\x1B[36m", "\x1B[39m"),
3109
+ white: f("\x1B[37m", "\x1B[39m"),
3110
+ gray: f("\x1B[90m", "\x1B[39m"),
3111
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
3112
+ bgRed: f("\x1B[41m", "\x1B[49m"),
3113
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
3114
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
3115
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
3116
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
3117
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
3118
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
3119
+ blackBright: f("\x1B[90m", "\x1B[39m"),
3120
+ redBright: f("\x1B[91m", "\x1B[39m"),
3121
+ greenBright: f("\x1B[92m", "\x1B[39m"),
3122
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
3123
+ blueBright: f("\x1B[94m", "\x1B[39m"),
3124
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
3125
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
3126
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
3127
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
3128
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
3129
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
3130
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
3131
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
3132
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
3133
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
3134
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
3135
+ };
3136
+ };
3137
+ module.exports = createColors();
3138
+ module.exports.createColors = createColors;
3139
+ }));
3140
+
3072
3141
  //#endregion
3073
3142
  //#region ../../node_modules/.pnpm/tinyexec@1.0.4/node_modules/tinyexec/dist/main.mjs
3143
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
3074
3144
  var l = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
3075
3145
  var u = /* @__PURE__ */ createRequire(import.meta.url);
3076
3146
  const d = /^path$/i;
@@ -3670,75 +3740,6 @@ const R = (e, t, n) => {
3670
3740
  };
3671
3741
  const z = R;
3672
3742
 
3673
- //#endregion
3674
- //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
3675
- var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3676
- let p = process || {}, argv = p.argv || [], env = p.env || {};
3677
- let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
3678
- let formatter = (open, close, replace = open) => (input) => {
3679
- let string = "" + input, index = string.indexOf(close, open.length);
3680
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
3681
- };
3682
- let replaceClose = (string, close, replace, index) => {
3683
- let result = "", cursor = 0;
3684
- do {
3685
- result += string.substring(cursor, index) + replace;
3686
- cursor = index + close.length;
3687
- index = string.indexOf(close, cursor);
3688
- } while (~index);
3689
- return result + string.substring(cursor);
3690
- };
3691
- let createColors = (enabled = isColorSupported) => {
3692
- let f = enabled ? formatter : () => String;
3693
- return {
3694
- isColorSupported: enabled,
3695
- reset: f("\x1B[0m", "\x1B[0m"),
3696
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
3697
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
3698
- italic: f("\x1B[3m", "\x1B[23m"),
3699
- underline: f("\x1B[4m", "\x1B[24m"),
3700
- inverse: f("\x1B[7m", "\x1B[27m"),
3701
- hidden: f("\x1B[8m", "\x1B[28m"),
3702
- strikethrough: f("\x1B[9m", "\x1B[29m"),
3703
- black: f("\x1B[30m", "\x1B[39m"),
3704
- red: f("\x1B[31m", "\x1B[39m"),
3705
- green: f("\x1B[32m", "\x1B[39m"),
3706
- yellow: f("\x1B[33m", "\x1B[39m"),
3707
- blue: f("\x1B[34m", "\x1B[39m"),
3708
- magenta: f("\x1B[35m", "\x1B[39m"),
3709
- cyan: f("\x1B[36m", "\x1B[39m"),
3710
- white: f("\x1B[37m", "\x1B[39m"),
3711
- gray: f("\x1B[90m", "\x1B[39m"),
3712
- bgBlack: f("\x1B[40m", "\x1B[49m"),
3713
- bgRed: f("\x1B[41m", "\x1B[49m"),
3714
- bgGreen: f("\x1B[42m", "\x1B[49m"),
3715
- bgYellow: f("\x1B[43m", "\x1B[49m"),
3716
- bgBlue: f("\x1B[44m", "\x1B[49m"),
3717
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
3718
- bgCyan: f("\x1B[46m", "\x1B[49m"),
3719
- bgWhite: f("\x1B[47m", "\x1B[49m"),
3720
- blackBright: f("\x1B[90m", "\x1B[39m"),
3721
- redBright: f("\x1B[91m", "\x1B[39m"),
3722
- greenBright: f("\x1B[92m", "\x1B[39m"),
3723
- yellowBright: f("\x1B[93m", "\x1B[39m"),
3724
- blueBright: f("\x1B[94m", "\x1B[39m"),
3725
- magentaBright: f("\x1B[95m", "\x1B[39m"),
3726
- cyanBright: f("\x1B[96m", "\x1B[39m"),
3727
- whiteBright: f("\x1B[97m", "\x1B[39m"),
3728
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
3729
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
3730
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
3731
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
3732
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
3733
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
3734
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
3735
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
3736
- };
3737
- };
3738
- module.exports = createColors();
3739
- module.exports.createColors = createColors;
3740
- }));
3741
-
3742
3743
  //#endregion
3743
3744
  //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
3744
3745
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
@@ -11445,7 +11446,7 @@ async function resolveConfig$1(source, options, sourceOptions = {}) {
11445
11446
  }
11446
11447
  const _merger = options.merger || defu;
11447
11448
  if (options.giget !== false && GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
11448
- const { downloadTemplate } = await import("./dist-WXDcqMwg.mjs");
11449
+ const { downloadTemplate } = await import("./dist-D141EqSt.mjs");
11449
11450
  const { digest } = await import("./dist-Chcd8TDR.mjs");
11450
11451
  const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
11451
11452
  let cloneDir;
@@ -15049,7 +15050,6 @@ const pipelineType = ZodPipeline.create;
15049
15050
 
15050
15051
  //#endregion
15051
15052
  //#region ../core/src/config.ts
15052
- var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
15053
15053
  const configSchema = objectType({
15054
15054
  content: stringType().default("./content"),
15055
15055
  locales: arrayType(stringType()).min(1).default(["en"]),
@@ -15147,7 +15147,7 @@ async function checkSelfUpdate() {
15147
15147
  });
15148
15148
  if (!res.ok) return;
15149
15149
  const { version: latest } = await res.json();
15150
- const current = "0.5.13";
15150
+ const current = "0.5.14";
15151
15151
  if (latest !== current) console.log(import_picocolors.default.yellow("⚠") + import_picocolors.default.dim(` new CLI version available: `) + import_picocolors.default.cyan(latest) + import_picocolors.default.dim(` (current: ${current}) — run `) + import_picocolors.default.cyan("npm i -g @ahmedrowaihi/8n") + import_picocolors.default.dim(" to update"));
15152
15152
  } catch {}
15153
15153
  }
@@ -15220,10 +15220,42 @@ async function prepareSudocs(options) {
15220
15220
  dir: sudocsDir
15221
15221
  };
15222
15222
  }
15223
+ function syncPublicDir(projectDir, sudocsDir) {
15224
+ const src = join(projectDir, "public");
15225
+ if (!existsSync(src)) return;
15226
+ cpSync(src, join(sudocsDir, "public", "_assets"), {
15227
+ recursive: true,
15228
+ force: true
15229
+ });
15230
+ }
15231
+ function watchPublicDir(projectDir, sudocsDir) {
15232
+ const src = join(projectDir, "public");
15233
+ if (!existsSync(src)) return;
15234
+ watch(src, { recursive: true }, () => {
15235
+ cpSync(src, join(sudocsDir, "public", "_assets"), {
15236
+ recursive: true,
15237
+ force: true
15238
+ });
15239
+ });
15240
+ }
15223
15241
  function getSudocsBin(sudocsDir, name) {
15224
15242
  return join(sudocsDir, "node_modules", ".bin", name);
15225
15243
  }
15226
- function buildEnv(config, contentDir) {
15244
+ async function resolveProject() {
15245
+ const config = await resolveConfig();
15246
+ return {
15247
+ config,
15248
+ contentDir: resolve(process.cwd(), config.content ?? "./content")
15249
+ };
15250
+ }
15251
+ async function runNext(sudocsDir, cmd, env) {
15252
+ await R(getSudocsBin(sudocsDir, "next"), [cmd], { nodeOptions: {
15253
+ cwd: sudocsDir,
15254
+ stdio: "inherit",
15255
+ env
15256
+ } });
15257
+ }
15258
+ function buildEnv({ config, contentDir, staticExport = false }) {
15227
15259
  const ghRepo = process.env.GITHUB_REPOSITORY;
15228
15260
  const ghServer = process.env.GITHUB_SERVER_URL ?? "https://github.com";
15229
15261
  const ghPagesUrl = ghRepo ? `${ghServer}/${ghRepo}` : void 0;
@@ -15237,68 +15269,63 @@ function buildEnv(config, contentDir) {
15237
15269
  SECTIONS: JSON.stringify(config.sections ?? {}),
15238
15270
  NEXT_PUBLIC_NAV_LINKS: JSON.stringify(config.nav?.links ?? []),
15239
15271
  NEXT_PUBLIC_ANIMATIONS: config.animations === false ? "false" : "true",
15240
- NEXT_BASE_PATH: config.basePath ?? ghPagesBasePath ?? ""
15272
+ NEXT_BASE_PATH: config.basePath ?? ghPagesBasePath ?? "",
15273
+ NEXT_STATIC_EXPORT: staticExport ? "true" : "false"
15241
15274
  };
15242
15275
  }
15243
15276
 
15244
15277
  //#endregion
15245
15278
  //#region src/commands/dev.ts
15246
15279
  async function dev() {
15247
- const config = await resolveConfig();
15248
- const contentDir = resolve(process.cwd(), config.content ?? "./content");
15280
+ const { config, contentDir } = await resolveProject();
15249
15281
  console.log(import_picocolors.default.cyan("8n") + import_picocolors.default.dim(` dev → ${contentDir}`));
15282
+ let sudocsDir;
15250
15283
  if (process.env.SUDOCS_LOCAL) {
15251
- const { dir: sudocsDir } = await prepareSudocs({ version: config.version });
15284
+ sudocsDir = (await prepareSudocs({ version: config.version })).dir;
15252
15285
  console.log(import_picocolors.default.yellow("⚑") + import_picocolors.default.dim(` using local starter → ${sudocsDir}`));
15253
- await R(getSudocsBin(sudocsDir, "next"), ["dev"], { nodeOptions: {
15254
- cwd: sudocsDir,
15255
- stdio: "inherit",
15256
- env: buildEnv(config, contentDir)
15257
- } });
15258
- return;
15259
- }
15260
- console.log(import_picocolors.default.dim(" checking for updates..."));
15261
- checkSelfUpdate();
15262
- let sudocsDir;
15263
- try {
15264
- const result = await prepareSudocs({ version: config.version });
15265
- sudocsDir = result.dir;
15266
- const v = result.version;
15267
- if (result.updated) console.log(import_picocolors.default.green("✓") + ` starter updated to ${import_picocolors.default.cyan(v)}`);
15268
- else console.log(import_picocolors.default.green("") + import_picocolors.default.dim(` already on latest (${v})`));
15269
- } catch (err) {
15270
- const cached = findAnyCachedStarterDir();
15271
- if (cached) {
15272
- console.log(import_picocolors.default.yellow("⚠") + import_picocolors.default.dim(" update check failed — using cached starter"));
15273
- console.log(import_picocolors.default.dim(` ${err.message}`));
15274
- sudocsDir = cached;
15275
- } else {
15276
- console.error(import_picocolors.default.red("✗") + " failed to download starter and no cache found");
15277
- console.error(import_picocolors.default.dim(` ${err.message}`));
15278
- process.exit(1);
15286
+ } else {
15287
+ console.log(import_picocolors.default.dim(" checking for updates..."));
15288
+ checkSelfUpdate();
15289
+ try {
15290
+ const result = await prepareSudocs({ version: config.version });
15291
+ sudocsDir = result.dir;
15292
+ if (result.updated) console.log(import_picocolors.default.green("✓") + ` starter updated to ${import_picocolors.default.cyan(result.version)}`);
15293
+ else console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` already on latest (${result.version})`));
15294
+ } catch (err) {
15295
+ const cached = findAnyCachedStarterDir();
15296
+ if (cached) {
15297
+ console.log(import_picocolors.default.yellow("⚠") + import_picocolors.default.dim(" update check failed using cached starter"));
15298
+ console.log(import_picocolors.default.dim(` ${err.message}`));
15299
+ sudocsDir = cached;
15300
+ } else {
15301
+ console.error(import_picocolors.default.red("") + " failed to download starter and no cache found");
15302
+ console.error(import_picocolors.default.dim(` ${err.message}`));
15303
+ process.exit(1);
15304
+ }
15279
15305
  }
15280
15306
  }
15281
- await R(getSudocsBin(sudocsDir, "next"), ["dev"], { nodeOptions: {
15282
- cwd: sudocsDir,
15283
- stdio: "inherit",
15284
- env: buildEnv(config, contentDir)
15285
- } });
15307
+ syncPublicDir(process.cwd(), sudocsDir);
15308
+ watchPublicDir(process.cwd(), sudocsDir);
15309
+ await runNext(sudocsDir, "dev", buildEnv({
15310
+ config,
15311
+ contentDir
15312
+ }));
15286
15313
  }
15287
15314
 
15288
15315
  //#endregion
15289
15316
  //#region src/commands/build.ts
15290
15317
  async function build() {
15291
- const config = await resolveConfig();
15292
- const contentDir = resolve(process.cwd(), config.content ?? "./content");
15318
+ const { config, contentDir } = await resolveProject();
15293
15319
  console.log(import_picocolors.default.cyan("8n") + import_picocolors.default.dim(` build → ${contentDir}`));
15294
15320
  if (!process.env.SUDOCS_LOCAL) console.log(import_picocolors.default.dim(" checking for updates..."));
15295
15321
  const { version, dir: sudocsDir } = await prepareSudocs({ version: config.version });
15296
15322
  console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` starter ${version}`));
15297
- await R(getSudocsBin(sudocsDir, "next"), ["build"], { nodeOptions: {
15298
- cwd: sudocsDir,
15299
- stdio: "inherit",
15300
- env: buildEnv(config, contentDir)
15301
- } });
15323
+ syncPublicDir(process.cwd(), sudocsDir);
15324
+ await runNext(sudocsDir, "build", buildEnv({
15325
+ config,
15326
+ contentDir,
15327
+ staticExport: true
15328
+ }));
15302
15329
  const src = join(sudocsDir, "out");
15303
15330
  const outDir = join(process.cwd(), "out");
15304
15331
  if (existsSync(outDir)) rmSync(outDir, {
@@ -15321,15 +15348,20 @@ async function build() {
15321
15348
  //#endregion
15322
15349
  //#region src/commands/start.ts
15323
15350
  async function start() {
15324
- const config = await resolveConfig();
15325
- const contentDir = resolve(process.cwd(), config.content ?? "./content");
15326
- console.log(import_picocolors.default.cyan("8n") + import_picocolors.default.dim(" start"));
15327
- const { dir: sudocsDir } = await prepareSudocs({ version: config.version });
15328
- await R(getSudocsBin(sudocsDir, "next"), ["start"], { nodeOptions: {
15329
- cwd: sudocsDir,
15330
- stdio: "inherit",
15331
- env: buildEnv(config, contentDir)
15332
- } });
15351
+ const { config, contentDir } = await resolveProject();
15352
+ console.log(import_picocolors.default.cyan("8n") + import_picocolors.default.dim(` start → ${contentDir}`));
15353
+ if (!process.env.SUDOCS_LOCAL) console.log(import_picocolors.default.dim(" checking for updates..."));
15354
+ const { version, dir: sudocsDir } = await prepareSudocs({ version: config.version });
15355
+ console.log(import_picocolors.default.green("") + import_picocolors.default.dim(` starter ${version}`));
15356
+ syncPublicDir(process.cwd(), sudocsDir);
15357
+ await runNext(sudocsDir, "build", buildEnv({
15358
+ config,
15359
+ contentDir
15360
+ }));
15361
+ await runNext(sudocsDir, "start", buildEnv({
15362
+ config,
15363
+ contentDir
15364
+ }));
15333
15365
  }
15334
15366
 
15335
15367
  //#endregion
@@ -15453,15 +15485,50 @@ async function init() {
15453
15485
  scaffold(targetDir);
15454
15486
  }
15455
15487
 
15488
+ //#endregion
15489
+ //#region src/commands/prune.ts
15490
+ async function prune() {
15491
+ const base = join(getCacheBase(), "starter");
15492
+ if (!existsSync(base)) {
15493
+ console.log(import_picocolors.default.dim(" nothing to prune"));
15494
+ return;
15495
+ }
15496
+ const versions = readdirSync(base).filter((v) => existsSync(join(base, v, "package.json")));
15497
+ if (versions.length === 0) {
15498
+ console.log(import_picocolors.default.dim(" nothing to prune"));
15499
+ return;
15500
+ }
15501
+ let latest;
15502
+ try {
15503
+ latest = await getLatestVersion();
15504
+ } catch {
15505
+ latest = versions.at(-1);
15506
+ }
15507
+ const stale = versions.filter((v) => v !== latest);
15508
+ if (stale.length === 0) {
15509
+ console.log(import_picocolors.default.dim(` nothing to prune — only ${import_picocolors.default.cyan(latest)} cached`));
15510
+ return;
15511
+ }
15512
+ for (const v of stale) {
15513
+ rmSync(join(base, v), {
15514
+ recursive: true,
15515
+ force: true
15516
+ });
15517
+ console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` removed ${v}`));
15518
+ }
15519
+ console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` kept ${latest}`));
15520
+ }
15521
+
15456
15522
  //#endregion
15457
15523
  //#region src/index.ts
15458
- const program = new Command().name("8n").description("Run your Thmanyah docs site").version("0.5.13").addOption(new Option("--debug").hideHelp()).hook("preAction", (cmd) => {
15524
+ const program = new Command().name("8n").description("Run your Thmanyah docs site").version("0.5.14").addOption(new Option("--debug").hideHelp()).hook("preAction", (cmd) => {
15459
15525
  if (cmd.opts().debug) process.env.DEBUG_8N = "1";
15460
15526
  });
15461
15527
  program.command("init").description("Scaffold a new docs project in the current directory").action(init);
15462
15528
  program.command("dev").description("Start the dev server").action(dev);
15463
15529
  program.command("build").description("Build for production").action(build);
15464
- program.command("start").description("Start the production server").action(start);
15530
+ program.command("start").description("Start the production server with AI support").action(start);
15531
+ program.command("prune").description("Remove stale cached starter versions").action(prune);
15465
15532
  program.parse();
15466
15533
 
15467
15534
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahmedrowaihi/8n",
3
- "version": "0.5.13",
3
+ "version": "0.5.14",
4
4
  "description": "Thmanyah Docs — run your docs site from your content directory",
5
5
  "type": "module",
6
6
  "bin": {