@ahmedrowaihi/8n 0.5.13 → 0.5.15
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/adapter.cjs +47 -0
- package/dist/{dist-WXDcqMwg.mjs → dist-D141EqSt.mjs} +1 -1
- package/dist/index.mjs +202 -148
- package/package.json +2 -1
package/dist/adapter.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
let node_fs = require("node:fs");
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
|
|
4
|
+
//#region src/adapter.ts
|
|
5
|
+
const adapter = {
|
|
6
|
+
name: "8n",
|
|
7
|
+
modifyConfig(config, { phase }) {
|
|
8
|
+
if (phase !== "phase-production-build") return config;
|
|
9
|
+
const basePath = process.env.NEXT_BASE_PATH || "";
|
|
10
|
+
const staticExport = process.env.NEXT_STATIC_EXPORT === "true";
|
|
11
|
+
return {
|
|
12
|
+
...config,
|
|
13
|
+
...staticExport ? {
|
|
14
|
+
output: "export",
|
|
15
|
+
trailingSlash: true
|
|
16
|
+
} : {},
|
|
17
|
+
...basePath ? {
|
|
18
|
+
basePath,
|
|
19
|
+
assetPrefix: basePath
|
|
20
|
+
} : {}
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
async onBuildComplete({ projectDir }) {
|
|
24
|
+
const docsProjectDir = process.env.DOCS_PROJECT_DIR;
|
|
25
|
+
const staticExport = process.env.NEXT_STATIC_EXPORT === "true";
|
|
26
|
+
if (!docsProjectDir || !staticExport) return;
|
|
27
|
+
const src = (0, node_path.join)(projectDir, "out");
|
|
28
|
+
const dest = (0, node_path.join)(docsProjectDir, "out");
|
|
29
|
+
if ((0, node_fs.existsSync)(dest)) (0, node_fs.rmSync)(dest, {
|
|
30
|
+
recursive: true,
|
|
31
|
+
force: true
|
|
32
|
+
});
|
|
33
|
+
try {
|
|
34
|
+
(0, node_fs.renameSync)(src, dest);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
if (err.code !== "EXDEV") throw err;
|
|
37
|
+
(0, node_fs.cpSync)(src, dest, { recursive: true });
|
|
38
|
+
(0, node_fs.rmSync)(src, {
|
|
39
|
+
recursive: true,
|
|
40
|
+
force: true
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
module.exports = adapter;
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
@@ -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,
|
|
5
|
+
import fs, { appendFileSync, cpSync, existsSync, mkdirSync, promises, readFileSync, readdirSync, realpathSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
|
|
6
6
|
import process$1, { cwd } from "node:process";
|
|
7
|
-
import {
|
|
8
|
-
import c from "node:readline";
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
9
8
|
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
10
9
|
import { homedir } from "node:os";
|
|
10
|
+
import { parseTarGzip } from "nanotar";
|
|
11
|
+
import { PassThrough } from "node:stream";
|
|
12
|
+
import c from "node:readline";
|
|
11
13
|
import { createJiti } from "jiti";
|
|
12
|
-
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-
|
|
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.
|
|
15150
|
+
const current = "0.5.15";
|
|
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,43 @@ 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
|
|
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
|
+
const adapterPath = join(dirname(fileURLToPath(import.meta.url)), "adapter.cjs");
|
|
15259
|
+
function buildEnv({ config, contentDir, staticExport = false }) {
|
|
15227
15260
|
const ghRepo = process.env.GITHUB_REPOSITORY;
|
|
15228
15261
|
const ghServer = process.env.GITHUB_SERVER_URL ?? "https://github.com";
|
|
15229
15262
|
const ghPagesUrl = ghRepo ? `${ghServer}/${ghRepo}` : void 0;
|
|
@@ -15237,99 +15270,85 @@ function buildEnv(config, contentDir) {
|
|
|
15237
15270
|
SECTIONS: JSON.stringify(config.sections ?? {}),
|
|
15238
15271
|
NEXT_PUBLIC_NAV_LINKS: JSON.stringify(config.nav?.links ?? []),
|
|
15239
15272
|
NEXT_PUBLIC_ANIMATIONS: config.animations === false ? "false" : "true",
|
|
15240
|
-
NEXT_BASE_PATH: config.basePath ?? ghPagesBasePath ?? ""
|
|
15273
|
+
NEXT_BASE_PATH: config.basePath ?? ghPagesBasePath ?? "",
|
|
15274
|
+
NEXT_STATIC_EXPORT: staticExport ? "true" : "false",
|
|
15275
|
+
NEXT_ADAPTER_PATH: adapterPath,
|
|
15276
|
+
DOCS_PROJECT_DIR: process.cwd()
|
|
15241
15277
|
};
|
|
15242
15278
|
}
|
|
15243
15279
|
|
|
15244
15280
|
//#endregion
|
|
15245
15281
|
//#region src/commands/dev.ts
|
|
15246
15282
|
async function dev() {
|
|
15247
|
-
const config = await
|
|
15248
|
-
const contentDir = resolve(process.cwd(), config.content ?? "./content");
|
|
15283
|
+
const { config, contentDir } = await resolveProject();
|
|
15249
15284
|
console.log(import_picocolors.default.cyan("8n") + import_picocolors.default.dim(` dev → ${contentDir}`));
|
|
15285
|
+
let sudocsDir;
|
|
15250
15286
|
if (process.env.SUDOCS_LOCAL) {
|
|
15251
|
-
|
|
15287
|
+
sudocsDir = (await prepareSudocs({ version: config.version })).dir;
|
|
15252
15288
|
console.log(import_picocolors.default.yellow("⚑") + import_picocolors.default.dim(` using local starter → ${sudocsDir}`));
|
|
15253
|
-
|
|
15254
|
-
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
|
|
15258
|
-
|
|
15259
|
-
|
|
15260
|
-
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
|
|
15264
|
-
|
|
15265
|
-
|
|
15266
|
-
|
|
15267
|
-
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
|
|
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);
|
|
15289
|
+
} else {
|
|
15290
|
+
console.log(import_picocolors.default.dim(" checking for updates..."));
|
|
15291
|
+
checkSelfUpdate();
|
|
15292
|
+
try {
|
|
15293
|
+
const result = await prepareSudocs({ version: config.version });
|
|
15294
|
+
sudocsDir = result.dir;
|
|
15295
|
+
if (result.updated) console.log(import_picocolors.default.green("✓") + ` starter updated to ${import_picocolors.default.cyan(result.version)}`);
|
|
15296
|
+
else console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` already on latest (${result.version})`));
|
|
15297
|
+
} catch (err) {
|
|
15298
|
+
const cached = findAnyCachedStarterDir();
|
|
15299
|
+
if (cached) {
|
|
15300
|
+
console.log(import_picocolors.default.yellow("⚠") + import_picocolors.default.dim(" update check failed — using cached starter"));
|
|
15301
|
+
console.log(import_picocolors.default.dim(` ${err.message}`));
|
|
15302
|
+
sudocsDir = cached;
|
|
15303
|
+
} else {
|
|
15304
|
+
console.error(import_picocolors.default.red("✗") + " failed to download starter and no cache found");
|
|
15305
|
+
console.error(import_picocolors.default.dim(` ${err.message}`));
|
|
15306
|
+
process.exit(1);
|
|
15307
|
+
}
|
|
15279
15308
|
}
|
|
15280
15309
|
}
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
|
|
15310
|
+
syncPublicDir(process.cwd(), sudocsDir);
|
|
15311
|
+
watchPublicDir(process.cwd(), sudocsDir);
|
|
15312
|
+
await runNext(sudocsDir, "dev", buildEnv({
|
|
15313
|
+
config,
|
|
15314
|
+
contentDir
|
|
15315
|
+
}));
|
|
15286
15316
|
}
|
|
15287
15317
|
|
|
15288
15318
|
//#endregion
|
|
15289
15319
|
//#region src/commands/build.ts
|
|
15290
15320
|
async function build() {
|
|
15291
|
-
const config = await
|
|
15292
|
-
const contentDir = resolve(process.cwd(), config.content ?? "./content");
|
|
15321
|
+
const { config, contentDir } = await resolveProject();
|
|
15293
15322
|
console.log(import_picocolors.default.cyan("8n") + import_picocolors.default.dim(` build → ${contentDir}`));
|
|
15294
15323
|
if (!process.env.SUDOCS_LOCAL) console.log(import_picocolors.default.dim(" checking for updates..."));
|
|
15295
15324
|
const { version, dir: sudocsDir } = await prepareSudocs({ version: config.version });
|
|
15296
15325
|
console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` starter ${version}`));
|
|
15297
|
-
|
|
15298
|
-
|
|
15299
|
-
|
|
15300
|
-
|
|
15301
|
-
|
|
15302
|
-
|
|
15303
|
-
|
|
15304
|
-
if (existsSync(outDir)) rmSync(outDir, {
|
|
15305
|
-
recursive: true,
|
|
15306
|
-
force: true
|
|
15307
|
-
});
|
|
15308
|
-
try {
|
|
15309
|
-
renameSync(src, outDir);
|
|
15310
|
-
} catch (err) {
|
|
15311
|
-
if (err.code !== "EXDEV") throw err;
|
|
15312
|
-
cpSync(src, outDir, { recursive: true });
|
|
15313
|
-
rmSync(src, {
|
|
15314
|
-
recursive: true,
|
|
15315
|
-
force: true
|
|
15316
|
-
});
|
|
15317
|
-
}
|
|
15318
|
-
console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` build complete → ${outDir}`));
|
|
15326
|
+
syncPublicDir(process.cwd(), sudocsDir);
|
|
15327
|
+
await runNext(sudocsDir, "build", buildEnv({
|
|
15328
|
+
config,
|
|
15329
|
+
contentDir,
|
|
15330
|
+
staticExport: true
|
|
15331
|
+
}));
|
|
15332
|
+
console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` build complete → out/`));
|
|
15319
15333
|
}
|
|
15320
15334
|
|
|
15321
15335
|
//#endregion
|
|
15322
15336
|
//#region src/commands/start.ts
|
|
15323
15337
|
async function start() {
|
|
15324
|
-
const config = await
|
|
15325
|
-
|
|
15326
|
-
|
|
15327
|
-
const { dir: sudocsDir } = await prepareSudocs({ version: config.version });
|
|
15328
|
-
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
|
|
15332
|
-
|
|
15338
|
+
const { config, contentDir } = await resolveProject();
|
|
15339
|
+
console.log(import_picocolors.default.cyan("8n") + import_picocolors.default.dim(` start → ${contentDir}`));
|
|
15340
|
+
if (!process.env.SUDOCS_LOCAL) console.log(import_picocolors.default.dim(" checking for updates..."));
|
|
15341
|
+
const { version, dir: sudocsDir } = await prepareSudocs({ version: config.version });
|
|
15342
|
+
console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` starter ${version}`));
|
|
15343
|
+
syncPublicDir(process.cwd(), sudocsDir);
|
|
15344
|
+
await runNext(sudocsDir, "build", buildEnv({
|
|
15345
|
+
config,
|
|
15346
|
+
contentDir
|
|
15347
|
+
}));
|
|
15348
|
+
await runNext(sudocsDir, "start", buildEnv({
|
|
15349
|
+
config,
|
|
15350
|
+
contentDir
|
|
15351
|
+
}));
|
|
15333
15352
|
}
|
|
15334
15353
|
|
|
15335
15354
|
//#endregion
|
|
@@ -15453,15 +15472,50 @@ async function init() {
|
|
|
15453
15472
|
scaffold(targetDir);
|
|
15454
15473
|
}
|
|
15455
15474
|
|
|
15475
|
+
//#endregion
|
|
15476
|
+
//#region src/commands/prune.ts
|
|
15477
|
+
async function prune() {
|
|
15478
|
+
const base = join(getCacheBase(), "starter");
|
|
15479
|
+
if (!existsSync(base)) {
|
|
15480
|
+
console.log(import_picocolors.default.dim(" nothing to prune"));
|
|
15481
|
+
return;
|
|
15482
|
+
}
|
|
15483
|
+
const versions = readdirSync(base).filter((v) => existsSync(join(base, v, "package.json")));
|
|
15484
|
+
if (versions.length === 0) {
|
|
15485
|
+
console.log(import_picocolors.default.dim(" nothing to prune"));
|
|
15486
|
+
return;
|
|
15487
|
+
}
|
|
15488
|
+
let latest;
|
|
15489
|
+
try {
|
|
15490
|
+
latest = await getLatestVersion();
|
|
15491
|
+
} catch {
|
|
15492
|
+
latest = versions.at(-1);
|
|
15493
|
+
}
|
|
15494
|
+
const stale = versions.filter((v) => v !== latest);
|
|
15495
|
+
if (stale.length === 0) {
|
|
15496
|
+
console.log(import_picocolors.default.dim(` nothing to prune — only ${import_picocolors.default.cyan(latest)} cached`));
|
|
15497
|
+
return;
|
|
15498
|
+
}
|
|
15499
|
+
for (const v of stale) {
|
|
15500
|
+
rmSync(join(base, v), {
|
|
15501
|
+
recursive: true,
|
|
15502
|
+
force: true
|
|
15503
|
+
});
|
|
15504
|
+
console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` removed ${v}`));
|
|
15505
|
+
}
|
|
15506
|
+
console.log(import_picocolors.default.green("✓") + import_picocolors.default.dim(` kept ${latest}`));
|
|
15507
|
+
}
|
|
15508
|
+
|
|
15456
15509
|
//#endregion
|
|
15457
15510
|
//#region src/index.ts
|
|
15458
|
-
const program = new Command().name("8n").description("Run your Thmanyah docs site").version("0.5.
|
|
15511
|
+
const program = new Command().name("8n").description("Run your Thmanyah docs site").version("0.5.15").addOption(new Option("--debug").hideHelp()).hook("preAction", (cmd) => {
|
|
15459
15512
|
if (cmd.opts().debug) process.env.DEBUG_8N = "1";
|
|
15460
15513
|
});
|
|
15461
15514
|
program.command("init").description("Scaffold a new docs project in the current directory").action(init);
|
|
15462
15515
|
program.command("dev").description("Start the dev server").action(dev);
|
|
15463
15516
|
program.command("build").description("Build for production").action(build);
|
|
15464
|
-
program.command("start").description("Start the production server").action(start);
|
|
15517
|
+
program.command("start").description("Start the production server with AI support").action(start);
|
|
15518
|
+
program.command("prune").description("Remove stale cached starter versions").action(prune);
|
|
15465
15519
|
program.parse();
|
|
15466
15520
|
|
|
15467
15521
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahmedrowaihi/8n",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.15",
|
|
4
4
|
"description": "Thmanyah Docs — run your docs site from your content directory",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@types/node": "^22.0.0",
|
|
26
26
|
"c12": "^2.0.0",
|
|
27
27
|
"commander": "^14.0.0",
|
|
28
|
+
"next": "^16.2.0",
|
|
28
29
|
"nypm": "^0.3.0",
|
|
29
30
|
"picocolors": "^1.1.0",
|
|
30
31
|
"tinyexec": "^1.0.0",
|