openspecui 0.9.0 → 0.9.1
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/cli.mjs +106 -91
- package/package.json +2 -1
package/dist/cli.mjs
CHANGED
|
@@ -2647,14 +2647,14 @@ function usage(yargs, shim$2) {
|
|
|
2647
2647
|
if (shim$2.process.stdColumns) return Math.min(maxWidth$1, shim$2.process.stdColumns);
|
|
2648
2648
|
else return maxWidth$1;
|
|
2649
2649
|
}
|
|
2650
|
-
let version = null;
|
|
2650
|
+
let version$1 = null;
|
|
2651
2651
|
self.version = (ver) => {
|
|
2652
|
-
version = ver;
|
|
2652
|
+
version$1 = ver;
|
|
2653
2653
|
};
|
|
2654
2654
|
self.showVersion = (level) => {
|
|
2655
2655
|
const logger = yargs.getInternalMethods().getLoggerInstance();
|
|
2656
2656
|
if (!level) level = "error";
|
|
2657
|
-
(typeof level === "function" ? level : logger[level])(version);
|
|
2657
|
+
(typeof level === "function" ? level : logger[level])(version$1);
|
|
2658
2658
|
};
|
|
2659
2659
|
self.reset = function reset(localLookup) {
|
|
2660
2660
|
failMessage = null;
|
|
@@ -4502,10 +4502,13 @@ function isYargsInstance(y) {
|
|
|
4502
4502
|
const Yargs = YargsFactory(esm_default);
|
|
4503
4503
|
var yargs_default = Yargs;
|
|
4504
4504
|
|
|
4505
|
+
//#endregion
|
|
4506
|
+
//#region package.json
|
|
4507
|
+
var version = "0.9.1";
|
|
4508
|
+
|
|
4505
4509
|
//#endregion
|
|
4506
4510
|
//#region src/export.ts
|
|
4507
4511
|
const __dirname$1 = dirname$1(fileURLToPath$1(import.meta.url));
|
|
4508
|
-
const WEB_PACKAGE_VERSION = "0.9.0";
|
|
4509
4512
|
/**
|
|
4510
4513
|
* Generate a complete data snapshot of the OpenSpec project
|
|
4511
4514
|
* (Kept for backwards compatibility and testing)
|
|
@@ -4585,7 +4588,7 @@ async function generateSnapshot(projectDir) {
|
|
|
4585
4588
|
return {
|
|
4586
4589
|
meta: {
|
|
4587
4590
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4588
|
-
version
|
|
4591
|
+
version,
|
|
4589
4592
|
projectDir
|
|
4590
4593
|
},
|
|
4591
4594
|
dashboard: {
|
|
@@ -4601,62 +4604,50 @@ async function generateSnapshot(projectDir) {
|
|
|
4601
4604
|
};
|
|
4602
4605
|
}
|
|
4603
4606
|
/**
|
|
4604
|
-
*
|
|
4607
|
+
* Check if running in local monorepo development mode
|
|
4608
|
+
* Returns the path to web package root if available, null otherwise
|
|
4605
4609
|
*/
|
|
4606
|
-
function
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
if (userAgent.includes("yarn")) return "yarn";
|
|
4610
|
-
if (userAgent.includes("bun")) return "bun";
|
|
4611
|
-
return "npm";
|
|
4610
|
+
function findLocalWebPackage() {
|
|
4611
|
+
if (existsSync(join$1(__dirname$1, "..", "..", "web", "package.json"))) return join$1(__dirname$1, "..", "..", "web");
|
|
4612
|
+
return null;
|
|
4612
4613
|
}
|
|
4613
4614
|
/**
|
|
4614
|
-
*
|
|
4615
|
+
* Run a command and wait for it to complete
|
|
4615
4616
|
*/
|
|
4616
|
-
function
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
cmd: "bunx",
|
|
4629
|
-
args: [packageSpec]
|
|
4630
|
-
};
|
|
4631
|
-
case "npm":
|
|
4632
|
-
default: return {
|
|
4633
|
-
cmd: "npx",
|
|
4634
|
-
args: [packageSpec]
|
|
4635
|
-
};
|
|
4636
|
-
}
|
|
4617
|
+
function runCommand(cmd, args, cwd) {
|
|
4618
|
+
return new Promise((resolvePromise, reject) => {
|
|
4619
|
+
const child = spawn(cmd, args, {
|
|
4620
|
+
stdio: "inherit",
|
|
4621
|
+
cwd
|
|
4622
|
+
});
|
|
4623
|
+
child.on("close", (code) => {
|
|
4624
|
+
if (code === 0) resolvePromise();
|
|
4625
|
+
else reject(/* @__PURE__ */ new Error(`Command failed with exit code ${code}`));
|
|
4626
|
+
});
|
|
4627
|
+
child.on("error", (err) => reject(err));
|
|
4628
|
+
});
|
|
4637
4629
|
}
|
|
4638
4630
|
/**
|
|
4639
|
-
*
|
|
4640
|
-
* Returns the path to local SSG CLI if available, null otherwise
|
|
4631
|
+
* Export as JSON only (data.json)
|
|
4641
4632
|
*/
|
|
4642
|
-
function
|
|
4643
|
-
const
|
|
4644
|
-
if (existsSync(
|
|
4645
|
-
|
|
4633
|
+
async function exportJson(options) {
|
|
4634
|
+
const { projectDir, outputDir, clean } = options;
|
|
4635
|
+
if (clean && existsSync(outputDir)) rmSync(outputDir, { recursive: true });
|
|
4636
|
+
mkdirSync(outputDir, { recursive: true });
|
|
4637
|
+
console.log("Generating data snapshot...");
|
|
4638
|
+
const snapshot = await generateSnapshot(projectDir);
|
|
4639
|
+
const dataJsonPath = join$1(outputDir, "data.json");
|
|
4640
|
+
writeFileSync(dataJsonPath, JSON.stringify(snapshot, null, 2));
|
|
4641
|
+
console.log(`\nExported to ${dataJsonPath}`);
|
|
4642
|
+
console.log(` Specs: ${snapshot.specs.length}`);
|
|
4643
|
+
console.log(` Changes: ${snapshot.changes.length}`);
|
|
4644
|
+
console.log(` Archives: ${snapshot.archives.length}`);
|
|
4646
4645
|
}
|
|
4647
4646
|
/**
|
|
4648
|
-
* Export
|
|
4649
|
-
*
|
|
4650
|
-
* This function:
|
|
4651
|
-
* 1. Generates a data snapshot from the openspec/ directory
|
|
4652
|
-
* 2. Writes data.json to the output directory
|
|
4653
|
-
* 3. Delegates to @openspecui/web's SSG CLI for rendering
|
|
4654
|
-
*
|
|
4655
|
-
* In development (monorepo), it uses the local web package.
|
|
4656
|
-
* In production, it uses npx/pnpm dlx to fetch the published package.
|
|
4647
|
+
* Export as static HTML site
|
|
4657
4648
|
*/
|
|
4658
|
-
async function
|
|
4659
|
-
const { projectDir, outputDir, basePath, clean, open, previewPort, previewHost } = options;
|
|
4649
|
+
async function exportHtml(options) {
|
|
4650
|
+
const { projectDir, outputDir, basePath = "/", clean, open, previewPort, previewHost } = options;
|
|
4660
4651
|
if (clean && existsSync(outputDir)) rmSync(outputDir, { recursive: true });
|
|
4661
4652
|
mkdirSync(outputDir, { recursive: true });
|
|
4662
4653
|
console.log("Generating data snapshot...");
|
|
@@ -4664,46 +4655,63 @@ async function exportStaticSite(options) {
|
|
|
4664
4655
|
const dataJsonPath = join$1(outputDir, "data.json");
|
|
4665
4656
|
writeFileSync(dataJsonPath, JSON.stringify(snapshot, null, 2));
|
|
4666
4657
|
console.log(`Data snapshot written to ${dataJsonPath}`);
|
|
4667
|
-
const
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
"
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
if (previewHost !== void 0) ssgOnlyArgs.push("--host", previewHost);
|
|
4678
|
-
}
|
|
4679
|
-
const localCli = findLocalSSGCli();
|
|
4680
|
-
let cmd;
|
|
4681
|
-
let args;
|
|
4682
|
-
if (localCli) {
|
|
4683
|
-
cmd = "npx";
|
|
4684
|
-
args = [
|
|
4658
|
+
const localWebPkg = findLocalWebPackage();
|
|
4659
|
+
if (localWebPkg) {
|
|
4660
|
+
console.log("\n[Local dev mode] Running SSG from local web package...");
|
|
4661
|
+
console.log("\nBuilding client assets...");
|
|
4662
|
+
await runCommand("pnpm", ["build:client"], localWebPkg);
|
|
4663
|
+
console.log("Building SSR bundle...");
|
|
4664
|
+
await runCommand("pnpm", ["build:server"], localWebPkg);
|
|
4665
|
+
console.log("Pre-rendering pages...");
|
|
4666
|
+
const clientDistDir = join$1(localWebPkg, "dist", "client");
|
|
4667
|
+
await runCommand("npx", [
|
|
4685
4668
|
"tsx",
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4669
|
+
"src/ssg/prerender.ts",
|
|
4670
|
+
"--data",
|
|
4671
|
+
dataJsonPath,
|
|
4672
|
+
"--output",
|
|
4673
|
+
clientDistDir,
|
|
4674
|
+
"--base-path",
|
|
4675
|
+
basePath
|
|
4676
|
+
], localWebPkg);
|
|
4677
|
+
console.log("\nCopying to output directory...");
|
|
4678
|
+
const { cpSync } = await import("node:fs");
|
|
4679
|
+
cpSync(clientDistDir, outputDir, { recursive: true });
|
|
4680
|
+
writeFileSync(join$1(outputDir, "data.json"), JSON.stringify(snapshot, null, 2));
|
|
4681
|
+
console.log(`\nExport complete: ${outputDir}`);
|
|
4689
4682
|
} else {
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4683
|
+
console.log("\nNote: HTML export requires @openspecui/web to be installed locally.");
|
|
4684
|
+
console.log("For production SSG, run these commands:");
|
|
4685
|
+
console.log(" npm install @openspecui/web");
|
|
4686
|
+
console.log(" cd node_modules/@openspecui/web");
|
|
4687
|
+
console.log(" pnpm build:ssg");
|
|
4688
|
+
console.log(` npx tsx src/ssg/prerender.ts --data ${dataJsonPath} --output ${outputDir}`);
|
|
4689
|
+
console.log("\nData exported to data.json. Run the above commands to generate HTML.");
|
|
4690
|
+
return;
|
|
4691
|
+
}
|
|
4692
|
+
if (open) {
|
|
4693
|
+
console.log("\nStarting preview server...");
|
|
4694
|
+
const previewArgs = [
|
|
4695
|
+
"vite",
|
|
4696
|
+
"preview",
|
|
4697
|
+
"--outDir",
|
|
4698
|
+
resolve$1(outputDir)
|
|
4699
|
+
];
|
|
4700
|
+
if (previewPort) previewArgs.push("--port", String(previewPort));
|
|
4701
|
+
if (previewHost) previewArgs.push("--host", previewHost);
|
|
4702
|
+
previewArgs.push("--open");
|
|
4703
|
+
await runCommand("npx", previewArgs, outputDir);
|
|
4693
4704
|
}
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
reject(/* @__PURE__ */ new Error(`Failed to start SSG CLI: ${err.message}`));
|
|
4705
|
-
});
|
|
4706
|
-
});
|
|
4705
|
+
}
|
|
4706
|
+
/**
|
|
4707
|
+
* Export the OpenSpec project
|
|
4708
|
+
*
|
|
4709
|
+
* @param options Export options
|
|
4710
|
+
* @param options.format 'html' (default) - full static site, 'json' - data only
|
|
4711
|
+
*/
|
|
4712
|
+
async function exportStaticSite(options) {
|
|
4713
|
+
if ((options.format || "html") === "json") await exportJson(options);
|
|
4714
|
+
else await exportHtml(options);
|
|
4707
4715
|
}
|
|
4708
4716
|
|
|
4709
4717
|
//#endregion
|
|
@@ -4778,12 +4786,18 @@ async function main() {
|
|
|
4778
4786
|
console.error("❌ Failed to start server:", error);
|
|
4779
4787
|
process.exit(1);
|
|
4780
4788
|
}
|
|
4781
|
-
}).command("export", "Export OpenSpec
|
|
4789
|
+
}).command("export", "Export OpenSpec project as static website or JSON data", (yargs) => {
|
|
4782
4790
|
return yargs.option("output", {
|
|
4783
4791
|
alias: "o",
|
|
4784
|
-
describe: "Output directory for
|
|
4792
|
+
describe: "Output directory for export",
|
|
4785
4793
|
type: "string",
|
|
4786
4794
|
demandOption: true
|
|
4795
|
+
}).option("format", {
|
|
4796
|
+
alias: "f",
|
|
4797
|
+
describe: "Export format",
|
|
4798
|
+
type: "string",
|
|
4799
|
+
choices: ["html", "json"],
|
|
4800
|
+
default: "html"
|
|
4787
4801
|
}).option("dir", {
|
|
4788
4802
|
alias: "d",
|
|
4789
4803
|
describe: "Project directory containing openspec/",
|
|
@@ -4813,6 +4827,7 @@ async function main() {
|
|
|
4813
4827
|
await exportStaticSite({
|
|
4814
4828
|
projectDir,
|
|
4815
4829
|
outputDir,
|
|
4830
|
+
format: argv.format,
|
|
4816
4831
|
basePath: argv["base-path"],
|
|
4817
4832
|
clean: argv.clean,
|
|
4818
4833
|
open: argv.open,
|
|
@@ -4824,7 +4839,7 @@ async function main() {
|
|
|
4824
4839
|
console.error("❌ Export failed:", error);
|
|
4825
4840
|
process.exit(1);
|
|
4826
4841
|
}
|
|
4827
|
-
}).example("$0", "Start server in current directory").example("$0 ./my-project", "Start server with specific project").example("$0 -p 8080", "Start server on custom port").example("$0 export -o ./dist", "Export to ./dist directory").example("$0 export
|
|
4842
|
+
}).example("$0", "Start server in current directory").example("$0 ./my-project", "Start server with specific project").example("$0 -p 8080", "Start server on custom port").example("$0 export -o ./dist", "Export HTML to ./dist directory").example("$0 export -o ./dist -f json", "Export JSON data only").example("$0 export -o ./dist --base-path=/docs/", "Export for subdirectory deployment").example("$0 export -o ./dist --clean", "Clean output directory before export").version(getVersion()).alias("v", "version").help().alias("h", "help").parse();
|
|
4828
4843
|
}
|
|
4829
4844
|
main();
|
|
4830
4845
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openspecui",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "OpenSpec UI - Visual interface for spec-driven development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"typescript": "^5.7.2",
|
|
32
32
|
"vitest": "^2.1.8",
|
|
33
33
|
"yargs": "^18.0.0",
|
|
34
|
+
"@openspecui/web": "0.9.0",
|
|
34
35
|
"@openspecui/server": "0.9.0"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|