flowbook 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/README.de.md CHANGED
@@ -12,11 +12,8 @@ Storybook für Flussdiagramme. Erkennt automatisch Mermaid-Diagrammdateien in Ih
12
12
  ## Schnellstart
13
13
 
14
14
  ```bash
15
- # Installieren
16
- npm install -D flowbook
17
-
18
15
  # Initialisieren — fügt Skripte + Beispieldatei hinzu
19
- npx flowbook init
16
+ npx flowbook@latest init
20
17
 
21
18
  # Entwicklungsserver starten
22
19
  npm run flowbook
package/README.es.md CHANGED
@@ -12,11 +12,8 @@ Storybook para diagramas de flujo. Descubre automáticamente archivos de diagram
12
12
  ## Inicio Rápido
13
13
 
14
14
  ```bash
15
- # Instalar
16
- npm install -D flowbook
17
-
18
15
  # Inicializar — agrega scripts + archivo de ejemplo
19
- npx flowbook init
16
+ npx flowbook@latest init
20
17
 
21
18
  # Iniciar servidor de desarrollo
22
19
  npm run flowbook
package/README.fr.md CHANGED
@@ -12,11 +12,8 @@ Storybook pour les diagrammes de flux. Découvre automatiquement les fichiers de
12
12
  ## Démarrage Rapide
13
13
 
14
14
  ```bash
15
- # Installer
16
- npm install -D flowbook
17
-
18
15
  # Initialiser — ajoute les scripts + fichier d'exemple
19
- npx flowbook init
16
+ npx flowbook@latest init
20
17
 
21
18
  # Démarrer le serveur de développement
22
19
  npm run flowbook
package/README.ja.md CHANGED
@@ -12,11 +12,8 @@
12
12
  ## クイックスタート
13
13
 
14
14
  ```bash
15
- # インストール
16
- npm install -D flowbook
17
-
18
15
  # 初期化 — スクリプト + サンプルファイルを追加
19
- npx flowbook init
16
+ npx flowbook@latest init
20
17
 
21
18
  # 開発サーバーを起動
22
19
  npm run flowbook
package/README.ko.md CHANGED
@@ -12,11 +12,8 @@
12
12
  ## 빠른 시작
13
13
 
14
14
  ```bash
15
- # 설치
16
- npm install -D flowbook
17
-
18
15
  # 초기화 — 스크립트 + 예제 파일 추가
19
- npx flowbook init
16
+ npx flowbook@latest init
20
17
 
21
18
  # 개발 서버 실행
22
19
  npm run flowbook
package/README.md CHANGED
@@ -12,11 +12,8 @@ Storybook for flowcharts. Auto-discovers Mermaid diagram files from your codebas
12
12
  ## Quick Start
13
13
 
14
14
  ```bash
15
- # Install
16
- npm install -D flowbook
17
-
18
15
  # Initialize — adds scripts + example file
19
- npx flowbook init
16
+ npx flowbook@latest init
20
17
 
21
18
  # Start dev server
22
19
  npm run flowbook
package/README.pt-BR.md CHANGED
@@ -12,11 +12,8 @@ Storybook para fluxogramas. Descobre automaticamente arquivos de diagramas Merma
12
12
  ## Início Rápido
13
13
 
14
14
  ```bash
15
- # Instalar
16
- npm install -D flowbook
17
-
18
15
  # Inicializar — adiciona scripts + arquivo de exemplo
19
- npx flowbook init
16
+ npx flowbook@latest init
20
17
 
21
18
  # Iniciar servidor de desenvolvimento
22
19
  npm run flowbook
package/README.ru.md CHANGED
@@ -12,11 +12,8 @@ Storybook для блок-схем. Автоматически обнаружи
12
12
  ## Быстрый Старт
13
13
 
14
14
  ```bash
15
- # Установка
16
- npm install -D flowbook
17
-
18
15
  # Инициализация — добавляет скрипты + файл-пример
19
- npx flowbook init
16
+ npx flowbook@latest init
20
17
 
21
18
  # Запуск сервера разработки
22
19
  npm run flowbook
package/README.zh-CN.md CHANGED
@@ -12,11 +12,8 @@
12
12
  ## 快速开始
13
13
 
14
14
  ```bash
15
- # 安装
16
- npm install -D flowbook
17
-
18
15
  # 初始化 — 添加脚本 + 示例文件
19
- npx flowbook init
16
+ npx flowbook@latest init
20
17
 
21
18
  # 启动开发服务器
22
19
  npm run flowbook
package/dist/cli.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // src/node/init.ts
4
4
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
5
5
  import { resolve } from "path";
6
+ import { execSync } from "child_process";
6
7
  var EXAMPLE_FLOW = `---
7
8
  title: Example Flow
8
9
  category: Getting Started
@@ -27,6 +28,15 @@ async function initFlowbook() {
27
28
  console.error(" No package.json found. Run 'npm init' first.");
28
29
  process.exit(1);
29
30
  }
31
+ const pm = detectPackageManager(cwd);
32
+ const installCmd = getInstallCommand(pm);
33
+ console.log(` Installing flowbook via ${pm}...`);
34
+ try {
35
+ execSync(installCmd, { cwd, stdio: "ignore" });
36
+ console.log(" \u2713 Installed flowbook as a dev dependency");
37
+ } catch {
38
+ console.error(` \u2717 Failed to run '${installCmd}'. Please install manually.`);
39
+ }
30
40
  const raw = readFileSync(pkgPath, "utf-8");
31
41
  const pkg = JSON.parse(raw);
32
42
  pkg.scripts = pkg.scripts ?? {};
@@ -54,12 +64,39 @@ async function initFlowbook() {
54
64
  } else {
55
65
  console.log(" \u2713 Example flow already exists");
56
66
  }
67
+ const gitignorePath = resolve(cwd, ".gitignore");
68
+ if (existsSync(gitignorePath)) {
69
+ const gitignore = readFileSync(gitignorePath, "utf-8");
70
+ if (!gitignore.includes("flowbook-static")) {
71
+ writeFileSync(gitignorePath, gitignore.trimEnd() + "\nflowbook-static\n");
72
+ console.log(" \u2713 Added flowbook-static to .gitignore");
73
+ }
74
+ }
75
+ const run = pm === "yarn" ? "yarn" : `${pm} run`;
57
76
  console.log("");
58
77
  console.log(" Next steps:");
59
- console.log(" npm run flowbook Start the dev server");
60
- console.log(" npm run build-flowbook Build static site");
78
+ console.log(` ${run} flowbook Start the dev server`);
79
+ console.log(` ${run} build-flowbook Build static site`);
61
80
  console.log("");
62
81
  }
82
+ function detectPackageManager(cwd) {
83
+ if (existsSync(resolve(cwd, "bun.lockb")) || existsSync(resolve(cwd, "bun.lock"))) return "bun";
84
+ if (existsSync(resolve(cwd, "pnpm-lock.yaml"))) return "pnpm";
85
+ if (existsSync(resolve(cwd, "yarn.lock"))) return "yarn";
86
+ return "npm";
87
+ }
88
+ function getInstallCommand(pm) {
89
+ switch (pm) {
90
+ case "bun":
91
+ return "bun add -D flowbook";
92
+ case "pnpm":
93
+ return "pnpm add -D flowbook";
94
+ case "yarn":
95
+ return "yarn add -D flowbook";
96
+ default:
97
+ return "npm install -D flowbook";
98
+ }
99
+ }
63
100
 
64
101
  // src/node/server.ts
65
102
  import { createServer, build } from "vite";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowbook",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "flowbook": "./dist/cli.js"
package/src/node/init.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
+ import { execSync } from "node:child_process";
3
4
 
4
5
  const EXAMPLE_FLOW = `---
5
6
  title: Example Flow
@@ -28,7 +29,18 @@ export async function initFlowbook() {
28
29
  process.exit(1);
29
30
  }
30
31
 
31
- // 1. Add scripts to package.json
32
+ // 1. Install flowbook as devDependency
33
+ const pm = detectPackageManager(cwd);
34
+ const installCmd = getInstallCommand(pm);
35
+ console.log(` Installing flowbook via ${pm}...`);
36
+ try {
37
+ execSync(installCmd, { cwd, stdio: "ignore" });
38
+ console.log(" ✓ Installed flowbook as a dev dependency");
39
+ } catch {
40
+ console.error(` ✗ Failed to run '${installCmd}'. Please install manually.`);
41
+ }
42
+
43
+ // 2. Add scripts to package.json
32
44
  const raw = readFileSync(pkgPath, "utf-8");
33
45
  const pkg = JSON.parse(raw);
34
46
  pkg.scripts = pkg.scripts ?? {};
@@ -51,7 +63,7 @@ export async function initFlowbook() {
51
63
  console.log(" ✓ Scripts already exist in package.json");
52
64
  }
53
65
 
54
- // 2. Create example flow file
66
+ // 3. Create example flow file
55
67
  const flowsDir = resolve(cwd, "flows");
56
68
  const examplePath = resolve(flowsDir, "example.flow.md");
57
69
 
@@ -63,9 +75,36 @@ export async function initFlowbook() {
63
75
  console.log(" ✓ Example flow already exists");
64
76
  }
65
77
 
78
+ // 4. Add flowbook-static to .gitignore
79
+ const gitignorePath = resolve(cwd, ".gitignore");
80
+ if (existsSync(gitignorePath)) {
81
+ const gitignore = readFileSync(gitignorePath, "utf-8");
82
+ if (!gitignore.includes("flowbook-static")) {
83
+ writeFileSync(gitignorePath, gitignore.trimEnd() + "\nflowbook-static\n");
84
+ console.log(" ✓ Added flowbook-static to .gitignore");
85
+ }
86
+ }
87
+
88
+ const run = pm === "yarn" ? "yarn" : `${pm} run`;
66
89
  console.log("");
67
90
  console.log(" Next steps:");
68
- console.log(" npm run flowbook Start the dev server");
69
- console.log(" npm run build-flowbook Build static site");
91
+ console.log(` ${run} flowbook Start the dev server`);
92
+ console.log(` ${run} build-flowbook Build static site`);
70
93
  console.log("");
71
94
  }
95
+
96
+ function detectPackageManager(cwd: string): "npm" | "yarn" | "pnpm" | "bun" {
97
+ if (existsSync(resolve(cwd, "bun.lockb")) || existsSync(resolve(cwd, "bun.lock"))) return "bun";
98
+ if (existsSync(resolve(cwd, "pnpm-lock.yaml"))) return "pnpm";
99
+ if (existsSync(resolve(cwd, "yarn.lock"))) return "yarn";
100
+ return "npm";
101
+ }
102
+
103
+ function getInstallCommand(pm: string): string {
104
+ switch (pm) {
105
+ case "bun": return "bun add -D flowbook";
106
+ case "pnpm": return "pnpm add -D flowbook";
107
+ case "yarn": return "yarn add -D flowbook";
108
+ default: return "npm install -D flowbook";
109
+ }
110
+ }