@stdout-design/cli 0.1.1 → 0.1.2
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/index.mjs +16 -99
- package/dist/schema.mjs +1 -1
- package/package.json +15 -22
- package/dist/cache-BdS9VgtQ.mjs +0 -22
- package/dist/dev-DoEMJ8Qi.mjs +0 -25
- package/dist/dist-CZVUmY-d.mjs +0 -590
- package/dist/dist-Dm76-R-V.mjs +0 -1187
- package/dist/init-CfgXE-J9.mjs +0 -195
- package/dist/lint-CacX6_Ob.mjs +0 -7
- package/dist/render-BhTeMXMX.mjs +0 -120
- package/dist/validation-CMTs74Vm-C3_d2dBv.mjs +0 -14
package/dist/index.mjs
CHANGED
|
@@ -1,115 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
//#region src/lib/display.ts
|
|
4
|
-
const formatBytes = (bytes) => {
|
|
5
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
6
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
7
|
-
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
8
|
-
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
9
|
-
};
|
|
10
|
-
const formatCacheStats = (stats) => {
|
|
11
|
-
return [
|
|
12
|
-
"",
|
|
13
|
-
"Cache Statistics",
|
|
14
|
-
"━━━━━━━━━━━━━━━━",
|
|
15
|
-
` Location: ${stats.cacheDir}`,
|
|
16
|
-
` Compiled: ${stats.compiled.entries} entries (in-memory compile cache)`,
|
|
17
|
-
` Pixel: ${stats.pixels.entries} entries`,
|
|
18
|
-
` Disk used: ${formatBytes(stats.pixels.sizeBytes)}`,
|
|
19
|
-
` Disk limit: ${formatBytes(stats.pixels.maxSizeBytes)}`,
|
|
20
|
-
""
|
|
21
|
-
].join("\n");
|
|
22
|
-
};
|
|
23
|
-
const formatManifestSummary = (manifest) => {
|
|
24
|
-
const { completedCount, totalCount, succeeded, failed } = manifest;
|
|
25
|
-
const cacheHits = succeeded.filter((s) => s.cacheHit).length;
|
|
26
|
-
const lines = [
|
|
27
|
-
"",
|
|
28
|
-
"Batch Render Complete",
|
|
29
|
-
"━━━━━━━━━━━━━━━━━━━━",
|
|
30
|
-
` Status: ${manifest.status}`,
|
|
31
|
-
` Total: ${totalCount}`,
|
|
32
|
-
` Completed: ${completedCount}`,
|
|
33
|
-
` Cache: ${cacheHits} hits, ${succeeded.length - cacheHits} renders`,
|
|
34
|
-
` Failed: ${failed.length}`,
|
|
35
|
-
""
|
|
36
|
-
];
|
|
37
|
-
if (succeeded.length > 0 && succeeded.length <= 10) {
|
|
38
|
-
lines.push("Output files:");
|
|
39
|
-
for (const entry of succeeded) lines.push(` ${entry.outputPath}`);
|
|
40
|
-
lines.push("");
|
|
41
|
-
}
|
|
42
|
-
if (failed.length > 0) {
|
|
43
|
-
lines.push("Failures:");
|
|
44
|
-
for (const f of failed) lines.push(` Row ${f.rowIndex}, ${f.locale}, ${f.preset}: ${f.error}`);
|
|
45
|
-
lines.push("");
|
|
46
|
-
}
|
|
47
|
-
return lines.join("\n");
|
|
48
|
-
};
|
|
49
4
|
const formatError = (error) => {
|
|
50
5
|
if (error instanceof Error) return `Error: ${error.message}`;
|
|
51
6
|
return `Error: ${String(error)}`;
|
|
52
7
|
};
|
|
53
|
-
const formatCacheCleanResult = (freedBytes) => `Cache cleared. Freed ${formatBytes(freedBytes)}.`;
|
|
54
8
|
//#endregion
|
|
55
|
-
//#region src/
|
|
56
|
-
const
|
|
57
|
-
program.name("studio").description("Social media design tool — render, preview, batch").version("0.0.0");
|
|
58
|
-
program.command("dev").description("Start the studio dev server with live preview").argument("[rootDir]", "Project root directory (default: cwd)").option("-p, --port <number>", "Port to run on", "3000").option("--open", "Open browser on start").action(async (rootDir, options) => {
|
|
9
|
+
//#region src/lib/runner.ts
|
|
10
|
+
const run = (moduleName, handlerName) => async (...args) => {
|
|
59
11
|
try {
|
|
60
|
-
const
|
|
61
|
-
await
|
|
12
|
+
const mod = await import(`../commands/${moduleName}.js`);
|
|
13
|
+
await (handlerName ? mod[handlerName] : mod[moduleName])(...args);
|
|
62
14
|
} catch (error) {
|
|
63
15
|
console.error(formatError(error));
|
|
64
16
|
process.exit(1);
|
|
65
17
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/index.ts
|
|
21
|
+
const program = new Command().allowExcessArguments(true);
|
|
22
|
+
program.name("studio").description("Social media design tool — render, preview, batch").version("0.0.0");
|
|
23
|
+
program.command("dev").description("Start the studio dev server with live preview").argument("[rootDir]", "Project root directory (default: cwd)").option("-p, --port <number>", "Port to run on", "3000").option("--open", "Open browser on start").action(run("dev"));
|
|
24
|
+
program.command("render").description("Render a template — single or batch with --data").argument("<template>", "Template ID from studio.config.ts").argument("[props...]", "Props as key=value pairs (e.g. title=\"Hello\")").option("--data <path>", "CSV or JSON data file for batch rendering").option("--preset <ids>", "Comma-separated preset IDs").option("--locale <locales>", "Comma-separated locale codes").option("--out-dir <path>", "Output directory").option("--concurrency <n>", "Max concurrent renders in batch mode", "4").option("--fail-fast", "Stop batch on first error").option("--json", "Output results as JSON").action(run("render"));
|
|
76
25
|
const cacheCmd = program.command("cache").description("Manage the render cache");
|
|
77
|
-
cacheCmd.command("stats").description("Show cache statistics").option("--json", "Output as JSON").argument("[rootDir]", "Project root directory (default: cwd)").action(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} catch (error) {
|
|
82
|
-
console.error(formatError(error));
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
cacheCmd.command("clean").description("Clear the render cache").option("--json", "Output as JSON").argument("[rootDir]", "Project root directory (default: cwd)").action(async (rootDir, options) => {
|
|
87
|
-
try {
|
|
88
|
-
const { cacheClean } = await import("./cache-BdS9VgtQ.mjs");
|
|
89
|
-
await cacheClean(rootDir, options);
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.error(formatError(error));
|
|
92
|
-
process.exit(1);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
program.command("lint").description("Check templates for compatibility (coming soon)").argument("[rootDir]", "Project root directory (default: cwd)").action(async (rootDir) => {
|
|
96
|
-
try {
|
|
97
|
-
const { lint } = await import("./lint-CacX6_Ob.mjs");
|
|
98
|
-
await lint(rootDir);
|
|
99
|
-
} catch (error) {
|
|
100
|
-
console.error(formatError(error));
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
program.command("init").description("Scaffold a new studio project").argument("[projectDir]", "Project directory (default: cwd)").option("-y, --yes", "Skip prompts, use defaults").action(async (projectDir, options) => {
|
|
105
|
-
try {
|
|
106
|
-
const { init } = await import("./init-CfgXE-J9.mjs");
|
|
107
|
-
await init(projectDir, { yes: options.yes ?? false });
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error(formatError(error));
|
|
110
|
-
process.exit(1);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
26
|
+
cacheCmd.command("stats").description("Show cache statistics").option("--json", "Output as JSON").argument("[rootDir]", "Project root directory (default: cwd)").action(run("cache", "cacheStats"));
|
|
27
|
+
cacheCmd.command("clean").description("Clear the render cache").option("--json", "Output as JSON").argument("[rootDir]", "Project root directory (default: cwd)").action(run("cache", "cacheClean"));
|
|
28
|
+
program.command("lint").description("Check templates for compatibility (coming soon)").argument("[rootDir]", "Project root directory (default: cwd)").action(run("lint"));
|
|
29
|
+
program.command("init").description("Scaffold a new studio project").argument("[projectDir]", "Project directory (default: cwd)").option("-y, --yes", "Skip prompts, use defaults").action(run("init"));
|
|
113
30
|
program.parse();
|
|
114
31
|
//#endregion
|
|
115
|
-
export {
|
|
32
|
+
export {};
|
package/dist/schema.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineSchema } from "@stdout-design/core/schema";
|
|
2
2
|
export { defineSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdout-design/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "stdout-design CLI — shallow front door to @stdout-design/core and @stdout-design/dev-server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -53,30 +53,23 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@clack/prompts": "^1.7.0",
|
|
56
|
-
"@
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"vite": "^8.0.12",
|
|
71
|
-
"vite-node": "^6.0.0",
|
|
72
|
-
"write-file-atomic": "^8.0.0",
|
|
73
|
-
"zod": "^4.4.3"
|
|
56
|
+
"@stdout-design/core": "^0.1.1",
|
|
57
|
+
"commander": "^15.0.0"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@stdout-design/dev-server": "^0.1.1",
|
|
61
|
+
"@stdout-design/web-ui": "^0.1.1"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@stdout-design/dev-server": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"@stdout-design/web-ui": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
74
70
|
},
|
|
75
71
|
"devDependencies": {
|
|
76
72
|
"@stdout-design/config": "workspace:*",
|
|
77
|
-
"@stdout-design/core": "workspace:*",
|
|
78
|
-
"@stdout-design/dev-server": "workspace:*",
|
|
79
|
-
"@types/react": "19.2.17",
|
|
80
73
|
"tsdown": "^0.22.4",
|
|
81
74
|
"typescript": "^7"
|
|
82
75
|
}
|
package/dist/cache-BdS9VgtQ.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { n as formatCacheStats, t as formatCacheCleanResult } from "./index.mjs";
|
|
2
|
-
import { r as RenderCache } from "./dist-Dm76-R-V.mjs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
//#region src/commands/cache.ts
|
|
5
|
-
const cacheStats = async (rootDir, options) => {
|
|
6
|
-
const cache = new RenderCache({ cacheDir: path.resolve(rootDir ?? process.cwd(), ".studio-cache") });
|
|
7
|
-
await cache.init();
|
|
8
|
-
const stats = await cache.stats();
|
|
9
|
-
cache.close();
|
|
10
|
-
if (options.json) console.log(JSON.stringify(stats, null, 2));
|
|
11
|
-
else console.log(formatCacheStats(stats));
|
|
12
|
-
};
|
|
13
|
-
const cacheClean = async (rootDir, options) => {
|
|
14
|
-
const cache = new RenderCache({ cacheDir: path.resolve(rootDir ?? process.cwd(), ".studio-cache") });
|
|
15
|
-
await cache.init();
|
|
16
|
-
const result = await cache.clean();
|
|
17
|
-
cache.close();
|
|
18
|
-
if (options.json) console.log(JSON.stringify(result));
|
|
19
|
-
else console.log(formatCacheCleanResult(result.freedBytes));
|
|
20
|
-
};
|
|
21
|
-
//#endregion
|
|
22
|
-
export { cacheClean, cacheStats };
|
package/dist/dev-DoEMJ8Qi.mjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region src/commands/dev.ts
|
|
2
|
-
const dev = async (rootDir, options) => {
|
|
3
|
-
const { createDevServer } = await import("./dist-CZVUmY-d.mjs");
|
|
4
|
-
const resolvedRoot = rootDir ?? process.cwd();
|
|
5
|
-
const port = Number(options.port ?? "3000");
|
|
6
|
-
console.log(`Starting studio dev server for ${resolvedRoot}...`);
|
|
7
|
-
const server = await createDevServer({
|
|
8
|
-
port,
|
|
9
|
-
rootDir: resolvedRoot
|
|
10
|
-
});
|
|
11
|
-
Bun.serve({
|
|
12
|
-
fetch: server.app.fetch,
|
|
13
|
-
port: server.port
|
|
14
|
-
});
|
|
15
|
-
console.log(`Studio dev server running on http://localhost:${server.port}`);
|
|
16
|
-
const shutdown = async () => {
|
|
17
|
-
console.log("\nShutting down...");
|
|
18
|
-
await server.close();
|
|
19
|
-
process.exit(0);
|
|
20
|
-
};
|
|
21
|
-
process.on("SIGINT", shutdown);
|
|
22
|
-
process.on("SIGTERM", shutdown);
|
|
23
|
-
};
|
|
24
|
-
//#endregion
|
|
25
|
-
export { dev };
|