create-specment 0.2.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.
Files changed (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +314 -0
  3. package/bin/commands/create.d.ts +3 -0
  4. package/bin/commands/create.d.ts.map +1 -0
  5. package/bin/commands/create.js +30 -0
  6. package/bin/commands/create.js.map +1 -0
  7. package/bin/constants/languages.d.ts +15 -0
  8. package/bin/constants/languages.d.ts.map +1 -0
  9. package/bin/constants/languages.js +14 -0
  10. package/bin/constants/languages.js.map +1 -0
  11. package/bin/core/interactive-setup.d.ts +15 -0
  12. package/bin/core/interactive-setup.d.ts.map +1 -0
  13. package/bin/core/interactive-setup.js +171 -0
  14. package/bin/core/interactive-setup.js.map +1 -0
  15. package/bin/core/interactive-setup.test.d.ts +2 -0
  16. package/bin/core/interactive-setup.test.d.ts.map +1 -0
  17. package/bin/core/interactive-setup.test.js +97 -0
  18. package/bin/core/interactive-setup.test.js.map +1 -0
  19. package/bin/core/project-generator.d.ts +12 -0
  20. package/bin/core/project-generator.d.ts.map +1 -0
  21. package/bin/core/project-generator.js +83 -0
  22. package/bin/core/project-generator.js.map +1 -0
  23. package/bin/features/index.d.ts +3 -0
  24. package/bin/features/index.d.ts.map +1 -0
  25. package/bin/features/index.js +47 -0
  26. package/bin/features/index.js.map +1 -0
  27. package/bin/generators/docusaurus-config.d.ts +3 -0
  28. package/bin/generators/docusaurus-config.d.ts.map +1 -0
  29. package/bin/generators/docusaurus-config.js +285 -0
  30. package/bin/generators/docusaurus-config.js.map +1 -0
  31. package/bin/generators/package-json.d.ts +3 -0
  32. package/bin/generators/package-json.d.ts.map +1 -0
  33. package/bin/generators/package-json.js +98 -0
  34. package/bin/generators/package-json.js.map +1 -0
  35. package/bin/generators/template-files.d.ts +3 -0
  36. package/bin/generators/template-files.d.ts.map +1 -0
  37. package/bin/generators/template-files.js +370 -0
  38. package/bin/generators/template-files.js.map +1 -0
  39. package/bin/index.d.ts +5 -0
  40. package/bin/index.d.ts.map +1 -0
  41. package/bin/index.js +37 -0
  42. package/bin/index.js.map +1 -0
  43. package/bin/plugins/i18n-integration.d.ts +25 -0
  44. package/bin/plugins/i18n-integration.d.ts.map +1 -0
  45. package/bin/plugins/i18n-integration.js +309 -0
  46. package/bin/plugins/i18n-integration.js.map +1 -0
  47. package/bin/plugins/plantuml-integration.d.ts +17 -0
  48. package/bin/plugins/plantuml-integration.d.ts.map +1 -0
  49. package/bin/plugins/plantuml-integration.js +111 -0
  50. package/bin/plugins/plantuml-integration.js.map +1 -0
  51. package/bin/plugins/redoc-integration.d.ts +25 -0
  52. package/bin/plugins/redoc-integration.d.ts.map +1 -0
  53. package/bin/plugins/redoc-integration.js +372 -0
  54. package/bin/plugins/redoc-integration.js.map +1 -0
  55. package/bin/plugins/search-integration.d.ts +20 -0
  56. package/bin/plugins/search-integration.d.ts.map +1 -0
  57. package/bin/plugins/search-integration.js +165 -0
  58. package/bin/plugins/search-integration.js.map +1 -0
  59. package/bin/templates/index.d.ts +4 -0
  60. package/bin/templates/index.d.ts.map +1 -0
  61. package/bin/templates/index.js +60 -0
  62. package/bin/templates/index.js.map +1 -0
  63. package/bin/templates/template-definitions.d.ts +10 -0
  64. package/bin/templates/template-definitions.d.ts.map +1 -0
  65. package/bin/templates/template-definitions.js +296 -0
  66. package/bin/templates/template-definitions.js.map +1 -0
  67. package/bin/tests/integration.test.d.ts +2 -0
  68. package/bin/tests/integration.test.d.ts.map +1 -0
  69. package/bin/tests/integration.test.js +171 -0
  70. package/bin/tests/integration.test.js.map +1 -0
  71. package/bin/types/index.d.ts +44 -0
  72. package/bin/types/index.d.ts.map +1 -0
  73. package/bin/types/index.js +2 -0
  74. package/bin/types/index.js.map +1 -0
  75. package/bin/utils/config-merger.d.ts +32 -0
  76. package/bin/utils/config-merger.d.ts.map +1 -0
  77. package/bin/utils/config-merger.js +216 -0
  78. package/bin/utils/config-merger.js.map +1 -0
  79. package/bin/utils/errors.d.ts +9 -0
  80. package/bin/utils/errors.d.ts.map +1 -0
  81. package/bin/utils/errors.js +22 -0
  82. package/bin/utils/errors.js.map +1 -0
  83. package/bin/utils/install.d.ts +5 -0
  84. package/bin/utils/install.d.ts.map +1 -0
  85. package/bin/utils/install.js +38 -0
  86. package/bin/utils/install.js.map +1 -0
  87. package/bin/utils/message-formatter.d.ts +15 -0
  88. package/bin/utils/message-formatter.d.ts.map +1 -0
  89. package/bin/utils/message-formatter.js +85 -0
  90. package/bin/utils/message-formatter.js.map +1 -0
  91. package/bin/utils/template-processor.d.ts +54 -0
  92. package/bin/utils/template-processor.d.ts.map +1 -0
  93. package/bin/utils/template-processor.js +139 -0
  94. package/bin/utils/template-processor.js.map +1 -0
  95. package/bin/utils/template-processor.test.d.ts +2 -0
  96. package/bin/utils/template-processor.test.d.ts.map +1 -0
  97. package/bin/utils/template-processor.test.js +120 -0
  98. package/bin/utils/template-processor.test.js.map +1 -0
  99. package/bin/utils/version.d.ts +2 -0
  100. package/bin/utils/version.d.ts.map +1 -0
  101. package/bin/utils/version.js +10 -0
  102. package/bin/utils/version.js.map +1 -0
  103. package/package.json +67 -0
  104. package/templates/classic-spec/docusaurus.config.js.template +106 -0
  105. package/templates/classic-spec/package.json.template +36 -0
  106. package/templates/external-design/docusaurus.config.js.template +123 -0
  107. package/templates/external-design/package.json.template +36 -0
  108. package/templates/internal-design/docusaurus.config.js.template +123 -0
  109. package/templates/internal-design/package.json.template +36 -0
  110. package/templates/project-analysis/docusaurus.config.js.template +113 -0
  111. package/templates/project-analysis/package.json.template +36 -0
  112. package/templates/requirements/docusaurus.config.js.template +119 -0
  113. package/templates/requirements/package.json.template +36 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 plenarc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,314 @@
1
+ # create-specment
2
+
3
+ [![NPM Package](.github/images/icons/npm-badge.svg)](https://www.npmjs.com/package/@plenarc/create-specment)
4
+ [![MIT License](.github/images/icons/license-badge.svg)](LICENSE)
5
+
6
+ [English](README.md) | [日本語](README-jp.md)
7
+
8
+ Demo: https://plenarc.github.io/specment/
9
+
10
+ Interactive project generator specialized for creating Docusaurus-based specification documentation
11
+
12
+ ## Overview
13
+
14
+ `create-specment` is a CLI tool that easily generates Docusaurus projects specialized for specification documentation. It provides Storybook-like ease of use and create-better-t-stack-like interactive setup, integrating all the features needed for specification documentation creation.
15
+
16
+ ## Features
17
+
18
+ 1. 🚀 **Interactive Setup**: Generate projects by simply answering questions
19
+ 1. 📋 **4 Specialized Templates**: Choose optimal templates based on your use case
20
+ 1. 🔧 **Feature Selection**: Select PlantUML, Redoc, search, multilingual support, and more
21
+ 1. 📝 **Variable Substitution**: Automatically replace project names and author information
22
+ 1. 🎨 **Docusaurus Compatible**: Fully compatible with the existing Docusaurus ecosystem
23
+
24
+ ## Installation Guide
25
+
26
+ ### Prerequisites
27
+
28
+ The following software must be installed:
29
+
30
+ 1. **WSL (for Windows environments)**
31
+ 1. For Windows environments, we strongly recommend using Windows Subsystem for Linux (WSL)
32
+ 1. Ubuntu 22.04 LTS or higher is recommended
33
+
34
+ ```bash
35
+ # Install WSL (run in Windows PowerShell with administrator privileges)
36
+ wsl --install
37
+ ```
38
+
39
+ 1. **mise (development environment management tool)**
40
+
41
+ ```bash
42
+ # Install mise (Linux/macOS/WSL)
43
+ curl https://mise.run | sh
44
+
45
+ # Update shell configuration
46
+ echo 'eval "$(mise activate bash)"' >> ~/.bashrc
47
+ source ~/.bashrc
48
+ ```
49
+
50
+ 1. **Node.js (LTS or higher recommended, installation via mise recommended)**
51
+
52
+ ```bash
53
+ # Install Node.js using mise
54
+ mise install node@lts
55
+ mise use node@lts
56
+
57
+ # Check version
58
+ node --version
59
+ ```
60
+
61
+ 1. **ni (package manager unification tool)**
62
+
63
+ ```bash
64
+ # Install ni using mise
65
+ mise use npm:@antfu/ni@latest
66
+
67
+ # Check version
68
+ ni --version
69
+ ```
70
+
71
+ ### Installation Methods
72
+
73
+ #### Method 1: Using ni (Recommended)
74
+
75
+ ```bash
76
+ # Create project using ni
77
+ nlx create-specment@latest my-docs
78
+ cd my-docs
79
+
80
+ # Install dependencies using ni
81
+ ni
82
+
83
+ # Start development server using ni
84
+ nr start
85
+ ```
86
+
87
+ #### Method 2: Using npx
88
+
89
+ ```bash
90
+ # Create project using the latest version
91
+ npx create-specment@latest my-docs
92
+
93
+ # Specify a specific template
94
+ npx create-specment@latest my-docs --template api-spec
95
+ ```
96
+
97
+ #### Method 3: Global Installation
98
+
99
+ ```bash
100
+ # Install globally
101
+ npm install -g create-specment
102
+
103
+ # Create project
104
+ create-specment my-docs
105
+ ```
106
+
107
+ ### Basic Usage
108
+
109
+ 1. **Create Project**
110
+
111
+ ```bash
112
+ nlx create-specment@latest my-docs
113
+ cd my-docs
114
+ ```
115
+
116
+ 1. **Interactive Setup**
117
+
118
+ Configure your project by answering the following questions:
119
+
120
+ 1. **Language Selection**: Choose display language (English/Japanese)
121
+ 1. **Project Name**: Name of your documentation site
122
+ 1. **Template Selection**: Choose templates based on your use case (multiple selection)
123
+ 1. **Feature Selection**: Select the features you need
124
+
125
+ 1. **Start Development Server**
126
+
127
+ ```bash
128
+ # Install dependencies (if not automatically executed)
129
+ ni
130
+
131
+ # Start development server
132
+ nr start
133
+ ```
134
+
135
+ 1. **Build and Deploy**
136
+
137
+ ```bash
138
+ # Production build
139
+ nr build
140
+
141
+ # Local preview
142
+ nr serve
143
+ ```
144
+
145
+ ## Template List
146
+
147
+ ### 1. Classic Specification (classic-spec)
148
+ General-purpose specification template. Provides basic document structure.
149
+
150
+ **Use Cases**:
151
+ 1. General technical specifications
152
+ 1. Product specifications
153
+ 1. Basic documentation creation
154
+
155
+ ### 2. API Specification (api-spec)
156
+ API specification template. Specialized for API documentation and OpenAPI specifications.
157
+
158
+ **Use Cases**:
159
+ 1. REST API documentation
160
+ 1. OpenAPI specifications
161
+ 1. API reference guides
162
+
163
+ ### 3. Technical Specification (technical-spec)
164
+ Technical specification template. Focused on detailed technical documentation and system design.
165
+
166
+ **Use Cases**:
167
+ 1. System requirements documentation
168
+ 1. Functional specifications
169
+ 1. EARS format requirement descriptions
170
+
171
+ ### 4. Enterprise Specification (enterprise-spec)
172
+ Enterprise specification template. Designed for large-scale enterprise documentation with comprehensive structure.
173
+
174
+ **Use Cases**:
175
+ 1. Enterprise system architecture documentation
176
+ 1. Comprehensive project documentation
177
+ 1. Multi-stakeholder documentation
178
+
179
+ ## Feature Selection
180
+
181
+ ### PlantUML Integration
182
+ Easily create UML diagrams and sequence diagrams.
183
+
184
+ ```plantuml
185
+ @startuml
186
+ Alice -> Bob: Hello
187
+ Bob -> Alice: Hi!
188
+ @enduml
189
+ ```
190
+
191
+ ### Redoc Integration
192
+ Beautifully display OpenAPI specifications.
193
+
194
+ ### Multilingual Support
195
+ Support for creating documentation in multiple languages.
196
+
197
+ ## Command Line Options
198
+
199
+ ```bash
200
+ create-specment [project-name] [options]
201
+
202
+ Options:
203
+ --template <template> Template to use (classic-spec|api-spec|technical-spec|enterprise-spec)
204
+ --skip-install Skip dependency installation
205
+ --verbose Show detailed logs
206
+ -h, --help Show help
207
+ -V, --version Show version
208
+ ```
209
+
210
+ ## Troubleshooting
211
+
212
+ ### Common Issues
213
+
214
+ #### 1. Node.js Version Error
215
+
216
+ ```bash
217
+ Error: Node.js version 20.0 or higher is required
218
+ ```
219
+
220
+ **Solution**:
221
+
222
+ ```bash
223
+ # Check Node.js version
224
+ node --version
225
+
226
+ # Update Node.js using mise
227
+ mise install node@latest
228
+ mise use node@latest
229
+ ```
230
+
231
+ #### 2. Package Installation Error
232
+
233
+ ```bash
234
+ Error: Failed to install dependencies
235
+ ```
236
+
237
+ **Solution**:
238
+
239
+ ```bash
240
+ # Clear cache
241
+ ni clean
242
+ # Or manually clear
243
+ npm cache clean --force
244
+
245
+ # Reinstall
246
+ ni
247
+ ```
248
+
249
+ #### 3. Port Conflict Error
250
+
251
+ ```bash
252
+ Error: Port 3000 is already in use
253
+ ```
254
+
255
+ **Solution**:
256
+
257
+ ```bash
258
+ # Specify a different port
259
+ nr start -- --port 3001
260
+ ```
261
+
262
+ ### Notes for Windows Environment
263
+
264
+ 1. **Strongly recommend using WSL**
265
+ 1. For Windows environments, we strongly recommend using WSL (Windows Subsystem for Linux)
266
+ 1. Operation in PowerShell or Command Prompt is not guaranteed
267
+ 1. Ubuntu 22.04 LTS or higher is recommended
268
+ 1. **Unified Development Environment**
269
+ 1. The combination of mise + ni minimizes environment differences
270
+ 1. Running as a Linux environment within WSL provides an experience equivalent to macOS/Linux
271
+
272
+ ## Development Environment Setup
273
+
274
+ To participate in project development:
275
+
276
+ ```bash
277
+ # Clone repository
278
+ git clone https://github.com/plenarc/create-specment.git
279
+ cd create-specment
280
+
281
+ # Install dependencies
282
+ ni
283
+
284
+ # Run in development mode
285
+ nr dev
286
+
287
+ # Run tests
288
+ nr test
289
+
290
+ # Build
291
+ nr build
292
+ ```
293
+
294
+ ## License
295
+
296
+ MIT License - See the [LICENSE](LICENSE) file for details.
297
+
298
+ ## Contributing
299
+
300
+ We welcome contributions to the project! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
301
+
302
+ ## Support
303
+
304
+ 1. 🐛 **Bug Reports**: [GitHub Issues](https://github.com/plenarc/create-specment/issues)
305
+ 1. 💡 **Feature Requests**: [GitHub Discussions](https://github.com/plenarc/create-specment/discussions)
306
+ 1. 📖 **Documentation**: [Official Documentation](https://create-specment.dev)
307
+
308
+ ## Related Projects
309
+
310
+ 1. [Docusaurus](https://docusaurus.io/) - Static site generator
311
+ 1. [mise](https://mise.jdx.dev/) - Development environment management tool
312
+ 1. [ni](https://github.com/antfu/ni) - Package manager unification tool
313
+ 1. [PlantUML](https://plantuml.com/) - UML diagram creation tool
314
+ 1. [Redoc](https://redocly.github.io/redoc/) - OpenAPI specification display tool
@@ -0,0 +1,3 @@
1
+ import type { CreateSpecmentOptions } from '../types/index.js';
2
+ export declare function createSpecmentProject(projectName: string | undefined, options: CreateSpecmentOptions): Promise<void>;
3
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM/D,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
@@ -0,0 +1,30 @@
1
+ import { outro } from '@clack/prompts';
2
+ import { InteractiveSetup } from '../core/interactive-setup.js';
3
+ import { ProjectGenerator } from '../core/project-generator.js';
4
+ import { MessageFormatter } from '../utils/message-formatter.js';
5
+ import { UserCancelledError, CLIError, handleError } from '../utils/errors.js';
6
+ export async function createSpecmentProject(projectName, options) {
7
+ try {
8
+ const setup = new InteractiveSetup(options);
9
+ const selections = await setup.run(projectName);
10
+ const generator = new ProjectGenerator(selections, options);
11
+ await generator.generate();
12
+ // Show completion message
13
+ outro('🎉 プロジェクトが正常に作成されました!');
14
+ MessageFormatter.completion(selections.projectName, setup.language);
15
+ }
16
+ catch (error) {
17
+ if (error instanceof UserCancelledError) {
18
+ // Exit cleanly without showing error message
19
+ return;
20
+ }
21
+ if (error instanceof CLIError) {
22
+ handleError(error.message);
23
+ throw error;
24
+ }
25
+ const message = error instanceof Error ? error.message : 'Unknown error';
26
+ handleError(message, 'エラー');
27
+ throw error;
28
+ }
29
+ }
30
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAU,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE/E,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,WAA+B,EAC/B,OAA8B;IAE9B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAEhD,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;QAE3B,0BAA0B;QAC1B,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAE/B,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEtE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,kBAAkB,EAAE,CAAC;YACxC,6CAA6C;YAC7C,OAAO;QACT,CAAC;QAED,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;YAC9B,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC3B,MAAM,KAAK,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QACzE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC5B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Language constants for consistent usage across the application
3
+ */
4
+ export declare const LANG: {
5
+ readonly EN: {
6
+ readonly code: "en";
7
+ readonly label: "English";
8
+ };
9
+ readonly JP: {
10
+ readonly code: "jp";
11
+ readonly label: "日本語";
12
+ };
13
+ };
14
+ export type Language = typeof LANG[keyof typeof LANG]['code'];
15
+ //# sourceMappingURL=languages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/constants/languages.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;;CASP,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,OAAO,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Language constants for consistent usage across the application
3
+ */
4
+ export const LANG = {
5
+ EN: {
6
+ code: 'en',
7
+ label: 'English'
8
+ },
9
+ JP: {
10
+ code: 'jp',
11
+ label: '日本語'
12
+ }
13
+ };
14
+ //# sourceMappingURL=languages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.js","sourceRoot":"","sources":["../../src/constants/languages.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,EAAE,EAAE;QACF,IAAI,EAAE,IAAa;QACnB,KAAK,EAAE,SAAS;KACjB;IACD,EAAE,EAAE;QACF,IAAI,EAAE,IAAa;QACnB,KAAK,EAAE,KAAK;KACb;CACO,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { CreateSpecmentOptions, UserSelections } from '../types/index.js';
2
+ import { type Language } from '../constants/languages.js';
3
+ export declare class InteractiveSetup {
4
+ private options;
5
+ private selectedLanguage;
6
+ constructor(options: CreateSpecmentOptions);
7
+ get language(): Language;
8
+ run(initialProjectName?: string): Promise<UserSelections>;
9
+ private selectLanguage;
10
+ private showWelcome;
11
+ private getProjectName;
12
+ private getTemplateSelection;
13
+ private getFeatureSelections;
14
+ }
15
+ //# sourceMappingURL=interactive-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactive-setup.d.ts","sourceRoot":"","sources":["../../src/core/interactive-setup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAkC,MAAM,mBAAmB,CAAC;AAG/G,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGhE,qBAAa,gBAAgB;IAGf,OAAO,CAAC,OAAO;IAF3B,OAAO,CAAC,gBAAgB,CAA0B;gBAE9B,OAAO,EAAE,qBAAqB;IAElD,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAEK,GAAG,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;YAmBjD,cAAc;IAgB5B,OAAO,CAAC,WAAW;YAYL,cAAc;YAwCd,oBAAoB;YAwDpB,oBAAoB;CA4CnC"}
@@ -0,0 +1,171 @@
1
+ import { select, isCancel, intro, text, multiselect, note } from '@clack/prompts';
2
+ import { getAvailableTemplates } from '../templates/index.js';
3
+ import { getAvailableFeatures } from '../features/index.js';
4
+ import { LANG } from '../constants/languages.js';
5
+ import { UserCancelledError } from '../utils/errors.js';
6
+ export class InteractiveSetup {
7
+ options;
8
+ selectedLanguage = LANG.EN.code;
9
+ constructor(options) {
10
+ this.options = options;
11
+ }
12
+ get language() {
13
+ return this.selectedLanguage;
14
+ }
15
+ async run(initialProjectName) {
16
+ // Language selection
17
+ await this.selectLanguage();
18
+ // Welcome
19
+ this.showWelcome();
20
+ // Start the interactive flow
21
+ const projectName = await this.getProjectName(initialProjectName);
22
+ const templates = await this.getTemplateSelection();
23
+ const features = await this.getFeatureSelections(templates);
24
+ return {
25
+ projectName,
26
+ templates,
27
+ features
28
+ };
29
+ }
30
+ async selectLanguage() {
31
+ const language = await select({
32
+ message: 'Please select display language / 表示言語を選択してください:',
33
+ options: [
34
+ { value: LANG.EN.code, label: LANG.EN.label },
35
+ { value: LANG.JP.code, label: LANG.JP.label }
36
+ ]
37
+ });
38
+ if (isCancel(language)) {
39
+ throw new UserCancelledError();
40
+ }
41
+ this.selectedLanguage = language;
42
+ }
43
+ showWelcome() {
44
+ console.log();
45
+ const isEn = this.selectedLanguage === LANG.EN.code;
46
+ if (isEn) {
47
+ intro('🚀 Welcome to create-specment!');
48
+ console.log('Creating a new Docusaurus-based specification documentation project...\n');
49
+ }
50
+ else {
51
+ intro('🚀 create-specmentへようこそ!');
52
+ console.log('Docusaurusベースの仕様書ドキュメントプロジェクトを作成します...\n');
53
+ }
54
+ }
55
+ async getProjectName(initialName) {
56
+ // Non-interactive mode with template option - still validate the name
57
+ if (initialName && this.options.template) {
58
+ // Validate the provided name
59
+ if (!/^[a-zA-Z0-9-_]+$/.test(initialName)) {
60
+ throw new Error(`Invalid project name: ${initialName}. Only alphanumeric characters, hyphens, and underscores are allowed`);
61
+ }
62
+ return initialName;
63
+ }
64
+ // If initialName is provided but no template, still validate
65
+ if (initialName) {
66
+ if (!/^[a-zA-Z0-9-_]+$/.test(initialName)) {
67
+ throw new Error(`Invalid project name: ${initialName}. Only alphanumeric characters, hyphens, and underscores are allowed`);
68
+ }
69
+ }
70
+ const isEn = this.selectedLanguage === LANG.EN.code;
71
+ const projectName = await text({
72
+ message: isEn ? 'Project name:' : 'プロジェクト名を入力してください:',
73
+ defaultValue: initialName || 'docs',
74
+ validate: (value) => {
75
+ if (!value.trim()) {
76
+ return isEn ? 'Project name is required' : 'プロジェクト名は必須です';
77
+ }
78
+ if (!/^[a-zA-Z0-9-_]+$/.test(value)) {
79
+ return isEn
80
+ ? 'Only alphanumeric characters, hyphens, and underscores are allowed'
81
+ : '英数字、ハイフン、アンダースコアのみ使用可能です';
82
+ }
83
+ }
84
+ });
85
+ if (isCancel(projectName)) {
86
+ throw new UserCancelledError();
87
+ }
88
+ return projectName;
89
+ }
90
+ async getTemplateSelection() {
91
+ if (this.options.template) {
92
+ const templates = getAvailableTemplates(this.selectedLanguage);
93
+ const template = templates.find(t => t.name === this.options.template);
94
+ if (!template) {
95
+ throw new Error(`Template "${this.options.template}" not found`);
96
+ }
97
+ return [template];
98
+ }
99
+ const templates = getAvailableTemplates(this.selectedLanguage);
100
+ if (templates.length === 0) {
101
+ throw new Error('No templates available');
102
+ }
103
+ const isEn = this.selectedLanguage === LANG.EN.code;
104
+ const selectedTemplateNames = await multiselect({
105
+ message: isEn
106
+ ? 'Which templates would you like to use? (Multiple selection)'
107
+ : 'どのテンプレートを使用しますか?(複数選択可)',
108
+ options: templates.map(template => ({
109
+ value: template.name,
110
+ label: template.displayName,
111
+ hint: template.description
112
+ })),
113
+ required: true
114
+ });
115
+ if (isCancel(selectedTemplateNames)) {
116
+ throw new UserCancelledError();
117
+ }
118
+ const selectedTemplates = templates.filter(t => selectedTemplateNames.includes(t.name));
119
+ if (selectedTemplates.length === 0) {
120
+ throw new Error('No templates selected');
121
+ }
122
+ // Show supported features for all selected templates
123
+ const allFeatures = new Set();
124
+ for (const template of selectedTemplates) {
125
+ for (const feature of template.features) {
126
+ allFeatures.add(feature);
127
+ }
128
+ }
129
+ note(Array.from(allFeatures).map(feature => `• ${feature}`).join('\n'), isEn
130
+ ? 'Features supported by selected templates:'
131
+ : '選択したテンプレートがサポートする機能:');
132
+ return selectedTemplates;
133
+ }
134
+ async getFeatureSelections(templates) {
135
+ const availableFeatures = getAvailableFeatures();
136
+ // Get all supported features from all selected templates
137
+ const allSupportedFeatures = new Set();
138
+ for (const template of templates) {
139
+ for (const feature of template.features) {
140
+ allSupportedFeatures.add(feature);
141
+ }
142
+ }
143
+ const supportedFeatures = availableFeatures.filter(feature => allSupportedFeatures.has(feature.name));
144
+ if (supportedFeatures.length === 0) {
145
+ return availableFeatures.map(feature => ({
146
+ ...feature,
147
+ enabled: false
148
+ }));
149
+ }
150
+ const isEn = this.selectedLanguage === LANG.EN.code;
151
+ const selectedFeatures = await multiselect({
152
+ message: isEn
153
+ ? 'Which additional features would you like to include?'
154
+ : 'どの追加機能を含めますか?',
155
+ options: supportedFeatures.map(feature => ({
156
+ value: feature.name,
157
+ label: feature.displayName,
158
+ hint: feature.description
159
+ })),
160
+ required: false
161
+ });
162
+ if (isCancel(selectedFeatures)) {
163
+ throw new UserCancelledError();
164
+ }
165
+ return availableFeatures.map(feature => ({
166
+ ...feature,
167
+ enabled: selectedFeatures.includes(feature.name)
168
+ }));
169
+ }
170
+ }
171
+ //# sourceMappingURL=interactive-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactive-setup.js","sourceRoot":"","sources":["../../src/core/interactive-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAElF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAiB,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE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AAO,CAAC,EAAE,CAAC,CAAC;YACvC,GAAG,OAAO;YACV,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;SACjD,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interactive-setup.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactive-setup.test.d.ts","sourceRoot":"","sources":["../../src/core/interactive-setup.test.ts"],"names":[],"mappings":""}