@autono/open-pages 0.6.0 → 0.7.0
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/{build-6hM9Ga2d.js → build-CCoxDxL-.js} +11 -10
- package/dist/cli/bin.d.ts +1 -1
- package/dist/cli/bin.js +427 -30
- package/dist/{config-CBbwLHOo.js → config-D_U_aCQz.js} +484 -460
- package/dist/{config-C-sasGou.d.ts → config-p-TWNXbv.d.ts} +4 -4
- package/dist/{design-C13iz9_4.js → design-Cpqx7SJs.js} +1 -2
- package/dist/{dev-BO0cHiYy.js → dev-CTrB263u.js} +40 -20
- package/dist/{export-DbVwSmKW.js → export-enKL9R7x.js} +7 -10
- package/dist/index.d.ts +6 -8
- package/dist/index.js +2 -3
- package/dist/locale/index.d.ts +8 -14
- package/dist/locale/index.js +67 -32
- package/dist/{open-pages-plugin-C0poXLsx.js → open-pages-plugin-C8cFhMB9.js} +23 -38
- package/dist/preview-Dmzyd1cf.js +24 -0
- package/dist/{sync-ui-CDydLpY4.js → sync-ui-BzRiAGCK.js} +3 -5
- package/dist/{types-BzxkFHhd.d.ts → types-DDdUFUIS.d.ts} +19 -6
- package/dist/{update-D1U8TVwd.js → update-CWaCKlnl.js} +4 -7
- package/dist/{update-package-D9zws9nc.js → update-package-GaNsVdr8.js} +44 -22
- package/dist/{version-B6AiiGvT.js → version-DZrXLoAD.js} +19 -3
- package/dist/vite/index.d.ts +3 -7
- package/dist/vite/index.js +2 -7
- package/package.json +22 -21
- package/src/app/app.tsx +19 -14
- package/src/app/assets/autono-social.png +0 -0
- package/src/app/assets/autono.svg +7 -0
- package/src/app/components/asset-view.tsx +510 -26
- package/src/app/components/command/command-menu.tsx +5 -1
- package/src/app/components/command/command.tsx +4 -2
- package/src/app/components/command/home-command-menu.tsx +6 -6
- package/src/app/components/icon-tooltip.tsx +24 -15
- package/src/app/components/sidebar/folder-item.tsx +46 -19
- package/src/app/components/sidebar/icon-picker.tsx +1 -1
- package/src/app/components/sidebar/sidebar-footer.tsx +18 -7
- package/src/app/components/sidebar/sidebar.tsx +91 -64
- package/src/app/components/theme-toggle.tsx +4 -5
- package/src/app/components/themes/theme-detail.tsx +6 -3
- package/src/app/components/themes/themes-gallery.tsx +12 -7
- package/src/app/index.html +33 -2
- package/src/app/lib/assets.ts +33 -0
- package/src/app/lib/last-home-location.ts +18 -0
- package/src/app/main.tsx +10 -1
- package/src/app/routes/home-shell.tsx +82 -61
- package/src/app/routes/home.tsx +42 -39
- package/src/app/routes/page.tsx +18 -3
- package/src/app/routes/themes.tsx +6 -8
- package/src/app/styles.css +40 -4
- package/src/app/virtual.d.ts +1 -0
- package/src/locale/en.ts +17 -6
- package/src/locale/ja.ts +18 -6
- package/src/locale/types.ts +17 -4
- package/src/locale/zh-cn.ts +19 -8
- package/src/locale/zh-tw.ts +17 -6
- package/src/shared/update-package.ts +193 -0
- package/workspace/deps.json +1 -1
- package/dist/export-BsK6OCpc.js +0 -4
- package/dist/preview-sOKhzyWB.js +0 -21
- package/dist/sync-Be_hxSOF.js +0 -139
- package/dist/sync-lKEXyPOh.js +0 -3
- package/dist/version-CeffgdfZ.js +0 -3
- package/src/app/components/language-toggle.tsx +0 -46
- package/src/app/favicon.ico +0 -0
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
5
|
-
import {
|
|
6
|
-
import { buildPage } from "./export-DbVwSmKW.js";
|
|
1
|
+
import { r as readCoreVersion } from "./version-DZrXLoAD.js";
|
|
2
|
+
import { r as printHeader, t as createCliLogger } from "./cli/bin.js";
|
|
3
|
+
import { i as loadUserConfig, n as findPages } from "./open-pages-plugin-C8cFhMB9.js";
|
|
4
|
+
import { t as createViteConfig } from "./config-D_U_aCQz.js";
|
|
5
|
+
import { buildPage } from "./export-enKL9R7x.js";
|
|
7
6
|
import path from "node:path";
|
|
8
7
|
import { build as build$1, mergeConfig } from "vite";
|
|
9
|
-
|
|
10
8
|
//#region src/cli/build.ts
|
|
11
9
|
async function build(opts = {}) {
|
|
10
|
+
printHeader("building for production");
|
|
12
11
|
const userCwd = process.cwd();
|
|
13
12
|
const config = await loadUserConfig(userCwd);
|
|
14
13
|
const outDir = path.resolve(userCwd, opts.outDir ?? "dist");
|
|
@@ -17,7 +16,10 @@ async function build(opts = {}) {
|
|
|
17
16
|
config,
|
|
18
17
|
mode: "build"
|
|
19
18
|
});
|
|
20
|
-
await build$1(mergeConfig(base, {
|
|
19
|
+
await build$1(mergeConfig(base, {
|
|
20
|
+
customLogger: createCliLogger(),
|
|
21
|
+
build: { outDir }
|
|
22
|
+
}));
|
|
21
23
|
const htmlPages = (await findPages(userCwd, config.pagesDir ?? "pages")).filter((e) => e.kind === "html");
|
|
22
24
|
const coreVersion = readCoreVersion();
|
|
23
25
|
const siteBase = config.base ?? "/";
|
|
@@ -30,6 +32,5 @@ async function build(opts = {}) {
|
|
|
30
32
|
base: `${siteBase.replace(/\/$/, "")}/__page/${entry.id}/`
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
|
-
|
|
34
35
|
//#endregion
|
|
35
|
-
export { build };
|
|
36
|
+
export { build };
|
package/dist/cli/bin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/cli/bin.js
CHANGED
|
@@ -1,19 +1,412 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { n as detectPackageManager } from "../update-package-GaNsVdr8.js";
|
|
5
3
|
import path from "node:path";
|
|
6
4
|
import * as readline from "node:readline/promises";
|
|
7
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import chalk from "chalk";
|
|
8
7
|
import { Command, Option } from "commander";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
9
|
+
import { cp, lstat, mkdir, readFile, readdir, readlink, rm, symlink } from "node:fs/promises";
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
import * as readline$1 from "node:readline";
|
|
12
|
+
import { stripVTControlCharacters } from "node:util";
|
|
13
|
+
//#region src/cli/preflight.ts
|
|
14
|
+
const PAGES_URL = "https://pages.openpages.sh/quickstart";
|
|
15
|
+
const VITE_CONSUMERS = ["@vitejs/plugin-react", "@tailwindcss/vite"];
|
|
16
|
+
const DEPENDENCY_FIELDS = [
|
|
17
|
+
"dependencies",
|
|
18
|
+
"devDependencies",
|
|
19
|
+
"optionalDependencies",
|
|
20
|
+
"peerDependencies"
|
|
21
|
+
];
|
|
22
|
+
const PROJECT_ROOT_MARKERS = [
|
|
23
|
+
"pnpm-workspace.yaml",
|
|
24
|
+
"pnpm-lock.yaml",
|
|
25
|
+
"yarn.lock",
|
|
26
|
+
"bun.lock",
|
|
27
|
+
"bun.lockb",
|
|
28
|
+
"package-lock.json",
|
|
29
|
+
".git"
|
|
30
|
+
];
|
|
31
|
+
function locatePackage(name, fromDir) {
|
|
32
|
+
let dir = fromDir;
|
|
33
|
+
while (true) {
|
|
34
|
+
const candidate = path.join(dir, "node_modules", name);
|
|
35
|
+
const pkgPath = path.join(candidate, "package.json");
|
|
36
|
+
if (existsSync(pkgPath)) {
|
|
37
|
+
let version = "unknown";
|
|
38
|
+
try {
|
|
39
|
+
version = JSON.parse(readFileSync(pkgPath, "utf8")).version ?? version;
|
|
40
|
+
} catch {}
|
|
41
|
+
return {
|
|
42
|
+
dir: realpathSync(candidate),
|
|
43
|
+
root: dir,
|
|
44
|
+
version
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const parent = path.dirname(dir);
|
|
48
|
+
if (parent === dir) return null;
|
|
49
|
+
dir = parent;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function findViteMismatch(coreDir) {
|
|
53
|
+
const coreVite = locatePackage("vite", coreDir);
|
|
54
|
+
if (!coreVite) return null;
|
|
55
|
+
for (const consumer of VITE_CONSUMERS) {
|
|
56
|
+
const consumerPkg = locatePackage(consumer, coreDir);
|
|
57
|
+
if (!consumerPkg) continue;
|
|
58
|
+
const consumerVite = locatePackage("vite", consumerPkg.dir);
|
|
59
|
+
if (!consumerVite || consumerVite.version === coreVite.version) continue;
|
|
60
|
+
return {
|
|
61
|
+
consumer,
|
|
62
|
+
coreVite,
|
|
63
|
+
consumerVite
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
function declarationIn(dir) {
|
|
69
|
+
const file = path.join(dir, "package.json");
|
|
70
|
+
if (!existsSync(file)) return null;
|
|
71
|
+
try {
|
|
72
|
+
const pkg = JSON.parse(readFileSync(file, "utf8"));
|
|
73
|
+
for (const field of DEPENDENCY_FIELDS) {
|
|
74
|
+
const deps = pkg[field];
|
|
75
|
+
if (deps && Object.hasOwn(deps, "vite")) return {
|
|
76
|
+
file,
|
|
77
|
+
field
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
} catch {}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
function isProjectRoot(dir) {
|
|
84
|
+
return PROJECT_ROOT_MARKERS.some((marker) => existsSync(path.join(dir, marker)));
|
|
85
|
+
}
|
|
86
|
+
function isAncestorOrSelf(ancestor, dir) {
|
|
87
|
+
const rel = path.relative(ancestor, dir);
|
|
88
|
+
return !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
89
|
+
}
|
|
90
|
+
function findViteDeclaration(cwd, installRoot) {
|
|
91
|
+
if (installRoot && (isAncestorOrSelf(installRoot, cwd) || isAncestorOrSelf(cwd, installRoot))) {
|
|
92
|
+
const owner = declarationIn(installRoot);
|
|
93
|
+
if (owner) return owner;
|
|
94
|
+
}
|
|
95
|
+
const stopAt = installRoot && isAncestorOrSelf(installRoot, cwd) ? installRoot : null;
|
|
96
|
+
let dir = cwd;
|
|
97
|
+
while (dir !== stopAt) {
|
|
98
|
+
const found = declarationIn(dir);
|
|
99
|
+
if (found) return found;
|
|
100
|
+
const parent = path.dirname(dir);
|
|
101
|
+
if (parent === dir || !stopAt && isProjectRoot(dir)) return null;
|
|
102
|
+
dir = parent;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
function removeCommand(pm) {
|
|
107
|
+
return pm === "npm" ? "npm uninstall vite" : `${pm} remove vite`;
|
|
16
108
|
}
|
|
109
|
+
function formatViteMismatch(mismatch, { cwd = process.cwd(), packageManager = "npm", declaration = null } = {}) {
|
|
110
|
+
const rel = (p) => path.relative(cwd, p) || p;
|
|
111
|
+
const want = chalk.bold(`vite@${mismatch.coreVite.version}`);
|
|
112
|
+
const got = chalk.bold(`vite@${mismatch.consumerVite.version}`);
|
|
113
|
+
const from = chalk.dim(rel(mismatch.consumerVite.dir));
|
|
114
|
+
const command = (cmd) => [
|
|
115
|
+
"",
|
|
116
|
+
` ${chalk.dim("$")} ${chalk.cyan(cmd)}`,
|
|
117
|
+
""
|
|
118
|
+
];
|
|
119
|
+
const footer = `${chalk.dim("Pages")} ${chalk.cyan.underline(PAGES_URL)}`;
|
|
120
|
+
if (!declaration) return [
|
|
121
|
+
chalk.bold("Conflicting vite versions in node_modules"),
|
|
122
|
+
"",
|
|
123
|
+
`open-pages ships ${want}, but ${mismatch.consumer} is loading ${got}`,
|
|
124
|
+
`from ${from}. Make sure no package.json lists vite, then reinstall:`,
|
|
125
|
+
...command(`${packageManager} install`),
|
|
126
|
+
footer
|
|
127
|
+
].join("\n");
|
|
128
|
+
const dir = path.dirname(declaration.file);
|
|
129
|
+
const cd = path.resolve(dir) === path.resolve(cwd) ? "" : `cd ${rel(dir)} && `;
|
|
130
|
+
return [
|
|
131
|
+
chalk.bold(`Remove ${chalk.yellow("vite")} from your package.json`),
|
|
132
|
+
"",
|
|
133
|
+
`${chalk.bold(declaration.field)} in ${chalk.dim(rel(declaration.file))} still lists vite, a leftover from an older template.`,
|
|
134
|
+
`It shadows the ${want} bundled with open-pages: ${mismatch.consumer}`,
|
|
135
|
+
`is loading ${got} from ${from} instead.`,
|
|
136
|
+
...command(cd + removeCommand(packageManager)),
|
|
137
|
+
footer
|
|
138
|
+
].join("\n");
|
|
139
|
+
}
|
|
140
|
+
async function assertViteResolvesToCore(cwd = process.cwd()) {
|
|
141
|
+
const mismatch = findViteMismatch(realpathSync(path.dirname(fileURLToPath(import.meta.url))));
|
|
142
|
+
if (!mismatch) return;
|
|
143
|
+
const declaration = findViteDeclaration(cwd, mismatch.consumerVite.root);
|
|
144
|
+
const packageManager = await detectPackageManager(declaration ? path.dirname(declaration.file) : cwd);
|
|
145
|
+
throw new Error(formatViteMismatch(mismatch, {
|
|
146
|
+
cwd,
|
|
147
|
+
packageManager,
|
|
148
|
+
declaration
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/cli/sync.ts
|
|
153
|
+
async function detectSkillsDrift(skillsDir) {
|
|
154
|
+
if (!existsSync(skillsDir)) return [];
|
|
155
|
+
const cwd = process.cwd();
|
|
156
|
+
const agentsSkillsDir = path.join(cwd, ".agents", "skills");
|
|
157
|
+
const skillNames = (await readdir(skillsDir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
158
|
+
const results = [];
|
|
159
|
+
for (const name of skillNames) {
|
|
160
|
+
const src = path.join(skillsDir, name);
|
|
161
|
+
const dst = path.join(agentsSkillsDir, name);
|
|
162
|
+
const srcHash = await hashDir(src);
|
|
163
|
+
const dstHash = existsSync(dst) ? await hashDir(dst) : null;
|
|
164
|
+
let status;
|
|
165
|
+
if (dstHash === null) status = "added";
|
|
166
|
+
else if (dstHash !== srcHash) status = "updated";
|
|
167
|
+
else status = "unchanged";
|
|
168
|
+
results.push({
|
|
169
|
+
name,
|
|
170
|
+
status
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return results;
|
|
174
|
+
}
|
|
175
|
+
async function syncSkills(skillsDir, opts = {}) {
|
|
176
|
+
const { dryRun = false } = opts;
|
|
177
|
+
if (!existsSync(skillsDir)) throw new Error(`Built-in skills directory missing at ${skillsDir}. The @autono/open-pages package may be corrupt — try reinstalling.`);
|
|
178
|
+
const cwd = process.cwd();
|
|
179
|
+
const agentsSkillsDir = path.join(cwd, ".agents", "skills");
|
|
180
|
+
const claudeSkillsDir = path.join(cwd, ".claude", "skills");
|
|
181
|
+
const results = await detectSkillsDrift(skillsDir);
|
|
182
|
+
if (results.length === 0) {
|
|
183
|
+
process.stdout.write(chalk.yellow("No skills found to sync.\n"));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
for (const { name, status } of results) {
|
|
187
|
+
const src = path.join(skillsDir, name);
|
|
188
|
+
const dst = path.join(agentsSkillsDir, name);
|
|
189
|
+
if (dryRun) continue;
|
|
190
|
+
if (status === "unchanged") {
|
|
191
|
+
await ensureClaudeSymlink(claudeSkillsDir, name);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
await mkdir(path.dirname(dst), { recursive: true });
|
|
195
|
+
if (existsSync(dst)) await rm(dst, {
|
|
196
|
+
recursive: true,
|
|
197
|
+
force: true
|
|
198
|
+
});
|
|
199
|
+
await cp(src, dst, { recursive: true });
|
|
200
|
+
await ensureClaudeSymlink(claudeSkillsDir, name);
|
|
201
|
+
}
|
|
202
|
+
printSummary(results, dryRun);
|
|
203
|
+
}
|
|
204
|
+
async function ensureClaudeSymlink(claudeSkillsDir, name) {
|
|
205
|
+
await mkdir(claudeSkillsDir, { recursive: true });
|
|
206
|
+
const linkPath = path.join(claudeSkillsDir, name);
|
|
207
|
+
const target = path.join("..", "..", ".agents", "skills", name);
|
|
208
|
+
if (existsSync(linkPath)) try {
|
|
209
|
+
if ((await lstat(linkPath)).isSymbolicLink()) {
|
|
210
|
+
if (await readlink(linkPath) === target) return;
|
|
211
|
+
}
|
|
212
|
+
await rm(linkPath, {
|
|
213
|
+
recursive: true,
|
|
214
|
+
force: true
|
|
215
|
+
});
|
|
216
|
+
} catch {
|
|
217
|
+
await rm(linkPath, {
|
|
218
|
+
recursive: true,
|
|
219
|
+
force: true
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
await symlink(target, linkPath, "dir");
|
|
224
|
+
} catch (err) {
|
|
225
|
+
const code = err.code;
|
|
226
|
+
if (code === "EPERM" || code === "EEXIST") {
|
|
227
|
+
const absoluteTarget = path.resolve(claudeSkillsDir, target);
|
|
228
|
+
await cp(absoluteTarget, linkPath, { recursive: true });
|
|
229
|
+
} else throw err;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
async function hashDir(dir) {
|
|
233
|
+
const hash = createHash("sha256");
|
|
234
|
+
const files = await collectFiles(dir);
|
|
235
|
+
files.sort();
|
|
236
|
+
for (const rel of files) {
|
|
237
|
+
const abs = path.join(dir, rel);
|
|
238
|
+
const data = await readFile(abs);
|
|
239
|
+
hash.update(rel);
|
|
240
|
+
hash.update("\0");
|
|
241
|
+
hash.update(data);
|
|
242
|
+
hash.update("\0");
|
|
243
|
+
}
|
|
244
|
+
return hash.digest("hex");
|
|
245
|
+
}
|
|
246
|
+
async function collectFiles(dir, prefix = "") {
|
|
247
|
+
const out = [];
|
|
248
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
249
|
+
for (const entry of entries) {
|
|
250
|
+
const rel = prefix ? path.join(prefix, entry.name) : entry.name;
|
|
251
|
+
if (entry.isDirectory()) out.push(...await collectFiles(path.join(dir, entry.name), rel));
|
|
252
|
+
else if (entry.isFile()) out.push(rel);
|
|
253
|
+
}
|
|
254
|
+
return out;
|
|
255
|
+
}
|
|
256
|
+
function printSummary(results, dryRun) {
|
|
257
|
+
const symbols = {
|
|
258
|
+
added: chalk.green("+"),
|
|
259
|
+
updated: chalk.yellow("~"),
|
|
260
|
+
unchanged: chalk.dim("=")
|
|
261
|
+
};
|
|
262
|
+
const labels = {
|
|
263
|
+
added: chalk.green("added"),
|
|
264
|
+
updated: chalk.yellow("updated"),
|
|
265
|
+
unchanged: chalk.dim("unchanged")
|
|
266
|
+
};
|
|
267
|
+
const header = dryRun ? chalk.bold("Dry run — no files written:") : chalk.bold("Synced built-in skills:");
|
|
268
|
+
process.stdout.write(`${header}\n`);
|
|
269
|
+
for (const { name, status } of results) process.stdout.write(` ${symbols[status]} ${name} ${chalk.dim(`(${labels[status]})`)}\n`);
|
|
270
|
+
const counts = results.reduce((acc, { status }) => {
|
|
271
|
+
acc[status] += 1;
|
|
272
|
+
return acc;
|
|
273
|
+
}, {
|
|
274
|
+
added: 0,
|
|
275
|
+
updated: 0,
|
|
276
|
+
unchanged: 0
|
|
277
|
+
});
|
|
278
|
+
process.stdout.write(chalk.dim(`\n${counts.added} added, ${counts.updated} updated, ${counts.unchanged} unchanged.\n`));
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/cli/ui.ts
|
|
282
|
+
const UNICODE = process.platform !== "win32" || Boolean(process.env.WT_SESSION) || process.env.TERM_PROGRAM === "vscode";
|
|
283
|
+
const glyph = {
|
|
284
|
+
bar: UNICODE ? "┃" : "|",
|
|
285
|
+
warn: UNICODE ? "▲" : "!",
|
|
286
|
+
cross: UNICODE ? "✖" : "x"
|
|
287
|
+
};
|
|
288
|
+
function readVersion() {
|
|
289
|
+
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
290
|
+
while (dir !== path.dirname(dir)) {
|
|
291
|
+
const pkgPath = path.join(dir, "package.json");
|
|
292
|
+
if (existsSync(pkgPath)) {
|
|
293
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
294
|
+
if (pkg.name === "@autono/open-pages" && pkg.version) return pkg.version;
|
|
295
|
+
}
|
|
296
|
+
dir = path.dirname(dir);
|
|
297
|
+
}
|
|
298
|
+
return "0.0.0";
|
|
299
|
+
}
|
|
300
|
+
function brand() {
|
|
301
|
+
return chalk.inverse.bold(" open-pages ");
|
|
302
|
+
}
|
|
303
|
+
function printHeader(status) {
|
|
304
|
+
const parts = [brand(), chalk.dim(`v${readVersion()}`)];
|
|
305
|
+
if (status) parts.push(chalk.dim(status));
|
|
306
|
+
process.stdout.write(`\n ${parts.join(" ")}\n\n`);
|
|
307
|
+
}
|
|
308
|
+
function startupDuration() {
|
|
309
|
+
return `ready in ${Math.round(process.uptime() * 1e3)} ms`;
|
|
310
|
+
}
|
|
311
|
+
function printUrls(urls, host) {
|
|
312
|
+
if (!urls) return;
|
|
313
|
+
const rows = [];
|
|
314
|
+
for (const url of urls.local) rows.push(urlRow("Local", chalk.cyan(url)));
|
|
315
|
+
urls.network.forEach((url, index) => {
|
|
316
|
+
const iface = urls.networkInterfaceNames?.[index];
|
|
317
|
+
rows.push(urlRow("Network", chalk.cyan(url) + (iface ? ` ${chalk.dim(iface)}` : "")));
|
|
318
|
+
});
|
|
319
|
+
if (urls.network.length === 0 && host === void 0) rows.push(urlRow("Network", chalk.dim("use --host to expose")));
|
|
320
|
+
process.stdout.write(`${rows.join("\n")}\n`);
|
|
321
|
+
}
|
|
322
|
+
function urlRow(label, value) {
|
|
323
|
+
return ` ${chalk.dim(glyph.bar)} ${chalk.bold(label.padEnd(8))} ${value}`;
|
|
324
|
+
}
|
|
325
|
+
function shortcutsEnabled() {
|
|
326
|
+
return Boolean(process.stdin.isTTY) && !process.env.CI;
|
|
327
|
+
}
|
|
328
|
+
function printShortcutsHint() {
|
|
329
|
+
process.stdout.write(`\n ${chalk.dim("press")} ${chalk.bold("h + enter")} ${chalk.dim("for shortcuts")}\n`);
|
|
330
|
+
}
|
|
331
|
+
function formatError(message) {
|
|
332
|
+
const [first, ...rest] = message.split("\n");
|
|
333
|
+
const body = rest.map((line) => line ? `\n ${line}` : "\n").join("");
|
|
334
|
+
return `\n ${chalk.red(glyph.cross)} ${first}${body}\n\n`;
|
|
335
|
+
}
|
|
336
|
+
const DROPPED = [/^vite v\d+\.\d+\.\d+ building /];
|
|
337
|
+
const REWRITES = [
|
|
338
|
+
[/hmr update /, "updated "],
|
|
339
|
+
[/hmr invalidate /, "invalidated "],
|
|
340
|
+
[/trigger page reload /, "full reload "],
|
|
341
|
+
[/page reload/, "full reload"],
|
|
342
|
+
[/server restarted\./, "server restarted"],
|
|
343
|
+
[/optimized dependencies changed\. reloading/, "dependencies changed, reloading"],
|
|
344
|
+
[/Re-optimizing dependencies because vite config has changed/, "config changed, re-bundling"],
|
|
345
|
+
[/Re-optimizing dependencies because lockfile has changed/, "lockfile changed, re-bundling"],
|
|
346
|
+
[/Forced re-optimization of dependencies/, "re-bundling dependencies"],
|
|
347
|
+
[/\[plugin builtin:vite-[a-z-]+\] ?\n?/, ""],
|
|
348
|
+
[/\[vite\] ?/g, ""]
|
|
349
|
+
];
|
|
350
|
+
function rewriteViteMessage(msg) {
|
|
351
|
+
const plain = stripVTControlCharacters(msg);
|
|
352
|
+
if (DROPPED.some((re) => re.test(plain))) return null;
|
|
353
|
+
let out = msg;
|
|
354
|
+
for (const [re, replacement] of REWRITES) out = out.replace(re, replacement);
|
|
355
|
+
return out;
|
|
356
|
+
}
|
|
357
|
+
function timestamp() {
|
|
358
|
+
return (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hourCycle: "h23" });
|
|
359
|
+
}
|
|
360
|
+
function formatLine(type, text, opts) {
|
|
361
|
+
if (!opts?.timestamp) return text;
|
|
362
|
+
const mark = type === "warn" ? `${chalk.yellow(glyph.warn)} ` : type === "error" ? `${chalk.red(glyph.cross)} ` : "";
|
|
363
|
+
return ` ${chalk.dim(timestamp())} ${mark}${text}`;
|
|
364
|
+
}
|
|
365
|
+
function clearTerminal() {
|
|
366
|
+
if (!process.stdout.isTTY || process.env.CI) return;
|
|
367
|
+
const blank = "\n".repeat(Math.max(process.stdout.rows - 2, 0));
|
|
368
|
+
console.log(blank);
|
|
369
|
+
readline$1.cursorTo(process.stdout, 0, 0);
|
|
370
|
+
readline$1.clearScreenDown(process.stdout);
|
|
371
|
+
}
|
|
372
|
+
function createCliLogger() {
|
|
373
|
+
const loggedErrors = /* @__PURE__ */ new WeakSet();
|
|
374
|
+
const warnedOnce = /* @__PURE__ */ new Set();
|
|
375
|
+
const write = (type, msg, opts) => {
|
|
376
|
+
const text = rewriteViteMessage(msg);
|
|
377
|
+
if (text === null) return;
|
|
378
|
+
console[type === "info" ? "log" : type](formatLine(type, text, opts));
|
|
379
|
+
};
|
|
380
|
+
const logger = {
|
|
381
|
+
hasWarned: false,
|
|
382
|
+
info(msg, opts) {
|
|
383
|
+
write("info", msg, opts);
|
|
384
|
+
},
|
|
385
|
+
warn(msg, opts) {
|
|
386
|
+
logger.hasWarned = true;
|
|
387
|
+
write("warn", msg, opts);
|
|
388
|
+
},
|
|
389
|
+
warnOnce(msg, opts) {
|
|
390
|
+
if (warnedOnce.has(msg)) return;
|
|
391
|
+
warnedOnce.add(msg);
|
|
392
|
+
logger.warn(msg, opts);
|
|
393
|
+
},
|
|
394
|
+
error(msg, opts) {
|
|
395
|
+
logger.hasWarned = true;
|
|
396
|
+
if (opts?.error) loggedErrors.add(opts.error);
|
|
397
|
+
write("error", msg, opts);
|
|
398
|
+
},
|
|
399
|
+
clearScreen() {
|
|
400
|
+
clearTerminal();
|
|
401
|
+
},
|
|
402
|
+
hasErrorLogged(error) {
|
|
403
|
+
return loggedErrors.has(error);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
return logger;
|
|
407
|
+
}
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/cli/run.ts
|
|
17
410
|
function parsePort(value) {
|
|
18
411
|
const n = Number(value);
|
|
19
412
|
if (!Number.isInteger(n) || n < 0 || n > 65535) throw new Error(`Invalid port: ${value}`);
|
|
@@ -31,8 +424,9 @@ async function runSkillsDriftCheck(skillsDir) {
|
|
|
31
424
|
if (stale.length === 0) return;
|
|
32
425
|
const names = stale.map((d) => d.name).join(", ");
|
|
33
426
|
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
427
|
+
const notice = `${chalk.yellow(glyph.warn)} Built-in skills are out of date: ${chalk.bold(names)}`;
|
|
34
428
|
if (!interactive) {
|
|
35
|
-
process.stderr.write(
|
|
429
|
+
process.stderr.write(`\n ${notice}\n ${chalk.dim("Run `open-pages sync:skills` to update.")}\n`);
|
|
36
430
|
return;
|
|
37
431
|
}
|
|
38
432
|
const rl = readline.createInterface({
|
|
@@ -40,9 +434,11 @@ async function runSkillsDriftCheck(skillsDir) {
|
|
|
40
434
|
output: process.stdout
|
|
41
435
|
});
|
|
42
436
|
try {
|
|
43
|
-
const answer = (await rl.question(
|
|
44
|
-
if (answer === "" || answer === "y" || answer === "yes")
|
|
45
|
-
|
|
437
|
+
const answer = (await rl.question(`\n ${notice}\n Sync now? ${chalk.dim("(Y/n)")} `)).trim().toLowerCase();
|
|
438
|
+
if (answer === "" || answer === "y" || answer === "yes") {
|
|
439
|
+
process.stdout.write("\n");
|
|
440
|
+
await syncSkills(skillsDir);
|
|
441
|
+
} else process.stdout.write(chalk.dim(" Skipped. Run `open-pages sync:skills` later to update.\n"));
|
|
46
442
|
} finally {
|
|
47
443
|
rl.close();
|
|
48
444
|
}
|
|
@@ -56,40 +452,42 @@ function resolveBuiltinSkillsDir() {
|
|
|
56
452
|
return path.resolve(here, "..", "..", "skills");
|
|
57
453
|
}
|
|
58
454
|
async function run(argv) {
|
|
59
|
-
const version =
|
|
455
|
+
const version = readVersion();
|
|
60
456
|
const program = new Command();
|
|
61
|
-
program.name("open-pages").description("Author web pages —
|
|
457
|
+
program.name("open-pages").description("Author web pages in React — open-pages runs the rest.").version(version, "-v, --version", "print version").helpOption("-h, --help", "show help").showHelpAfterError(chalk.dim("(run `open-pages --help` for usage)"));
|
|
62
458
|
program.command("dev").description("Start the dev server").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").option("--no-skills-check", "skip the built-in skills drift check").action(async (flags) => {
|
|
63
459
|
if (flags.skillsCheck !== false) await runSkillsDriftCheck(resolveBuiltinSkillsDir());
|
|
64
|
-
|
|
460
|
+
await assertViteResolvesToCore();
|
|
461
|
+
const { dev } = await import("../dev-CTrB263u.js");
|
|
65
462
|
await dev(flags);
|
|
66
463
|
});
|
|
67
464
|
program.command("build").description("Build the workspace as a static site").option("--out-dir <dir>", "output directory (defaults to `dist`)").action(async (flags) => {
|
|
68
|
-
|
|
465
|
+
await assertViteResolvesToCore();
|
|
466
|
+
const { build } = await import("../build-CCoxDxL-.js");
|
|
69
467
|
await build(flags);
|
|
70
468
|
});
|
|
71
469
|
program.command("preview").description("Preview the production build").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").action(async (flags) => {
|
|
72
|
-
|
|
470
|
+
await assertViteResolvesToCore();
|
|
471
|
+
const { preview } = await import("../preview-Dmzyd1cf.js");
|
|
73
472
|
await preview(flags);
|
|
74
473
|
});
|
|
75
474
|
program.command("export").description("Build pages into self-contained static folders (one per page)").argument("[pages...]", "page ids to export (default: all)").option("--out-dir <dir>", "output directory (defaults to `export`)").action(async (pages, flags) => {
|
|
76
|
-
|
|
475
|
+
await assertViteResolvesToCore();
|
|
476
|
+
const { exportPages } = await import("../export-enKL9R7x.js");
|
|
77
477
|
await exportPages({
|
|
78
478
|
pages,
|
|
79
479
|
outDir: flags.outDir
|
|
80
480
|
});
|
|
81
481
|
});
|
|
82
482
|
program.command("sync:skills").description("Sync built-in skills from @autono/open-pages into this workspace").option("--dry-run", "show what would change without writing").action(async (flags) => {
|
|
83
|
-
|
|
84
|
-
await syncSkills$1(resolveBuiltinSkillsDir(), flags);
|
|
483
|
+
await syncSkills(resolveBuiltinSkillsDir(), flags);
|
|
85
484
|
});
|
|
86
485
|
program.command("sync:ui").description("Sync ui/, lib/, and hooks/ from @autono/open-pages — files you edited are kept").option("--dry-run", "show what would change without writing").option("--force", "overwrite files even where you have edited them").action(async (flags) => {
|
|
87
|
-
const { printUiSummary, syncUi } = await import("../sync-ui-
|
|
88
|
-
|
|
89
|
-
printUiSummary(result, flags.dryRun ?? false);
|
|
486
|
+
const { printUiSummary, syncUi } = await import("../sync-ui-BzRiAGCK.js");
|
|
487
|
+
printUiSummary(await syncUi(process.cwd(), resolveWorkspaceSetDir(), flags), flags.dryRun ?? false);
|
|
90
488
|
});
|
|
91
489
|
program.command("update").description("Update @autono/open-pages to the latest version and sync skills").option("--force", "reinstall even if already on the latest version").option("--no-skills", "skip the skills sync after updating").option("--no-ui", "skip the ui set sync after updating").action(async (flags) => {
|
|
92
|
-
const { update } = await import("../update-
|
|
490
|
+
const { update } = await import("../update-CWaCKlnl.js");
|
|
93
491
|
await update({
|
|
94
492
|
current: version,
|
|
95
493
|
...flags
|
|
@@ -97,13 +495,12 @@ async function run(argv) {
|
|
|
97
495
|
});
|
|
98
496
|
await program.parseAsync(argv, { from: "user" });
|
|
99
497
|
}
|
|
100
|
-
|
|
101
498
|
//#endregion
|
|
102
499
|
//#region src/cli/bin.ts
|
|
103
500
|
run(process.argv.slice(2)).catch((err) => {
|
|
104
501
|
const message = err instanceof Error ? err.message : String(err);
|
|
105
|
-
process.stderr.write(
|
|
502
|
+
process.stderr.write(formatError(message));
|
|
106
503
|
process.exit(1);
|
|
107
504
|
});
|
|
108
|
-
|
|
109
|
-
|
|
505
|
+
//#endregion
|
|
506
|
+
export { printUrls as a, printShortcutsHint as i, formatError as n, shortcutsEnabled as o, printHeader as r, startupDuration as s, createCliLogger as t };
|