@stdout-design/cli 0.1.0 → 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 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/index.ts
56
- const program = new Command().allowExcessArguments(true);
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 { dev } = await import("./dev-DoEMJ8Qi.mjs");
61
- await dev(rootDir, options);
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
- 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(async (template, props, options) => {
68
- try {
69
- const { render } = await import("./render-BhTeMXMX.mjs");
70
- await render(template, props, options);
71
- } catch (error) {
72
- console.error(formatError(error));
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(async (rootDir, options) => {
78
- try {
79
- const { cacheStats } = await import("./cache-BdS9VgtQ.mjs");
80
- await cacheStats(rootDir, options);
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 { formatCacheStats as n, formatManifestSummary as r, formatCacheCleanResult as t };
32
+ export {};
package/dist/schema.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as defineSchema } from "./validation-CMTs74Vm-C3_d2dBv.mjs";
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.0",
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",
@@ -10,14 +10,14 @@
10
10
  "takumi",
11
11
  "tsx"
12
12
  ],
13
- "homepage": "https://github.com/stdout/studio#readme",
13
+ "homepage": "https://github.com/m7md1alaa/stdout-design#readme",
14
14
  "bugs": {
15
- "url": "https://github.com/stdout/studio/issues"
15
+ "url": "https://github.com/m7md1alaa/stdout-design/issues"
16
16
  },
17
17
  "license": "MIT",
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "git+https://github.com/stdout/studio.git"
20
+ "url": "git+https://github.com/m7md1alaa/stdout-design/studio.git"
21
21
  },
22
22
  "bin": {
23
23
  "studio": "./dist/index.mjs"
@@ -53,30 +53,23 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@clack/prompts": "^1.7.0",
56
- "@takumi-rs/core": "^2.0.0",
57
- "@takumi-rs/helpers": "^2.0.0",
58
- "@vitejs/plugin-react": "^6.0.1",
59
- "chokidar": "^5.0.0",
60
- "commander": "^15.0.0",
61
- "csv-parse": "^7.0.1",
62
- "hono": "^4.12.26",
63
- "kysely": "^0.29.3",
64
- "kysely-bun-sqlite": "^0.4.0",
65
- "ora": "^9.4.1",
66
- "p-limit": "^7.0.0",
67
- "proper-lockfile": "^4.1.2",
68
- "react": "19.2.7",
69
- "takumi-js": "^2.0.0",
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
  }
@@ -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 };
@@ -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 };