@libria/scaffold 0.3.0 → 0.3.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/.clean-publish.hash +1 -1
- package/README.md +104 -50
- package/dist/cli/cli.mjs +3 -439
- package/dist/cli/cli.mjs.map +1 -1
- package/dist/cli/index.cjs +2 -217
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +8 -1
- package/dist/cli/index.d.cts.map +1 -1
- package/dist/cli/index.d.mts +8 -1
- package/dist/cli/index.d.mts.map +1 -1
- package/dist/cli/index.mjs +2 -175
- package/dist/cli/index.mjs.map +1 -1
- package/package.json +6 -5
package/.clean-publish.hash
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
2472a6e3ba70550c0b82c61756bff6c19b7aaff133029d11d0f84a4fe63175eb
|
package/README.md
CHANGED
|
@@ -9,10 +9,11 @@ Forge your next project with lightning-fast scaffolding. A pluggable CLI that tr
|
|
|
9
9
|
|
|
10
10
|
- **Interactive CLI**: Guided project creation with sensible defaults
|
|
11
11
|
- **Plugin System**: Extensible architecture for custom templates
|
|
12
|
-
- **Configuration File**: Register custom plugin directories via `.lbscaffold`
|
|
12
|
+
- **Configuration File**: Register custom plugin directories and npm packages via `.lbscaffold.json`
|
|
13
|
+
- **NPM Package Support**: Load templates from npm packages
|
|
13
14
|
- **Dry Run Mode**: Preview what will be generated before committing
|
|
14
15
|
- **Force Overwrite**: Safely regenerate existing projects
|
|
15
|
-
- **
|
|
16
|
+
- **Template Plugins**: Angular, NestJS, TypeScript libraries, and workspaces
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
18
19
|
|
|
@@ -23,7 +24,7 @@ npm install -g @libria/scaffold
|
|
|
23
24
|
Or use with npx:
|
|
24
25
|
|
|
25
26
|
```bash
|
|
26
|
-
npx lb-scaffold
|
|
27
|
+
npx lb-scaffold new
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
## CLI Usage
|
|
@@ -33,54 +34,59 @@ npx lb-scaffold create
|
|
|
33
34
|
Create a new project interactively:
|
|
34
35
|
|
|
35
36
|
```bash
|
|
36
|
-
lb-scaffold
|
|
37
|
+
lb-scaffold new
|
|
37
38
|
```
|
|
38
39
|
|
|
39
|
-
You'll be prompted
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
- Whether to initialize git and install dependencies
|
|
40
|
+
You'll be prompted to select a template, and then enter:
|
|
41
|
+
- Project name (required)
|
|
42
|
+
- Additional template-specific options (e.g., framework version, styles format)
|
|
43
|
+
- Whether to skip git initialization (if supported)
|
|
44
44
|
|
|
45
45
|
### Non-Interactive Mode
|
|
46
46
|
|
|
47
47
|
Pass all options up-front for CI/CD or scripting:
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
-
lb-scaffold
|
|
50
|
+
lb-scaffold new ts-lib my-awesome-lib --dry-run
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
### Options
|
|
54
54
|
|
|
55
55
|
| Option | Description | Default |
|
|
56
56
|
|--------|-------------|---------|
|
|
57
|
-
|
|
|
58
|
-
| `-n, --name <project-name>` | Name of the new project folder | (prompted, required) |
|
|
57
|
+
| `<name>` | Name of the new project folder | (required) |
|
|
59
58
|
| `--dry-run` | Show what would be generated without writing files | `false` |
|
|
60
59
|
| `--force` | Overwrite existing project folder if it exists | `false` |
|
|
61
|
-
|
|
60
|
+
|
|
61
|
+
Template-specific options are available per template and will be shown in `--help`.
|
|
62
62
|
|
|
63
63
|
### Examples
|
|
64
64
|
|
|
65
65
|
Create a TypeScript library:
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
lb-scaffold
|
|
68
|
+
lb-scaffold new ts-lib my-utils
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
Preview generation without files:
|
|
72
72
|
|
|
73
73
|
```bash
|
|
74
|
-
lb-scaffold
|
|
74
|
+
lb-scaffold new ts-lib my-utils --dry-run
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
Force overwrite an existing project:
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
lb-scaffold
|
|
80
|
+
lb-scaffold new ts-lib my-utils --force
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Create a new Angular application with specific options:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
lb-scaffold new angular my-app --version 20 --style scss --routing --ssr
|
|
81
87
|
```
|
|
82
88
|
|
|
83
|
-
##
|
|
89
|
+
## Optional Templates
|
|
84
90
|
|
|
85
91
|
### ts-lib
|
|
86
92
|
|
|
@@ -105,7 +111,7 @@ A complete Angular application template using the official Angular CLI. Supports
|
|
|
105
111
|
- Dependency installation (optional)
|
|
106
112
|
|
|
107
113
|
```bash
|
|
108
|
-
lb-scaffold
|
|
114
|
+
lb-scaffold new angular my-angular-app
|
|
109
115
|
```
|
|
110
116
|
|
|
111
117
|
**Interactive prompts:**
|
|
@@ -129,7 +135,7 @@ A production-ready NestJS backend application using the official NestJS CLI. Inc
|
|
|
129
135
|
- Dependency installation (optional)
|
|
130
136
|
|
|
131
137
|
```bash
|
|
132
|
-
lb-scaffold
|
|
138
|
+
lb-scaffold new nestjs my-nest-api
|
|
133
139
|
```
|
|
134
140
|
|
|
135
141
|
**Interactive prompts:**
|
|
@@ -138,14 +144,34 @@ lb-scaffold create -t nestjs -n my-nest-api
|
|
|
138
144
|
- Skip git initialization?
|
|
139
145
|
- Skip package installation?
|
|
140
146
|
|
|
147
|
+
### ts-workspace
|
|
148
|
+
|
|
149
|
+
A TypeScript workspace (monorepo) template using pnpm workspaces. Creates a monorepo with multiple project types:
|
|
150
|
+
|
|
151
|
+
- TypeScript libraries (ts-lib)
|
|
152
|
+
- Angular applications
|
|
153
|
+
- NestJS backends
|
|
154
|
+
- Shared packages
|
|
155
|
+
- pnpm workspace configuration
|
|
156
|
+
- Turbo or Nx for monorepo tooling (optional)
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
lb-scaffold new ts-workspace my-monorepo
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Interactive prompts:**
|
|
163
|
+
- Project types to include
|
|
164
|
+
- Monorepo tool (Turbo, Nx, or none)
|
|
165
|
+
- Skip git initialization?
|
|
166
|
+
- Skip package installation?
|
|
141
167
|
|
|
142
168
|
## Configuration
|
|
143
169
|
|
|
144
|
-
The scaffold CLI supports a configuration file (`.lbscaffold`) that allows you to register custom plugin directories. This enables you to use your own templates alongside the built-in ones.
|
|
170
|
+
The scaffold CLI supports a configuration file (`.lbscaffold.json`) that allows you to register custom plugin directories and npm packages. This enables you to use your own templates alongside the built-in ones.
|
|
145
171
|
|
|
146
172
|
### Config File Location
|
|
147
173
|
|
|
148
|
-
The CLI searches for `.lbscaffold` starting from the current directory and walking up the directory tree. This allows you to have project-specific or workspace-level configurations.
|
|
174
|
+
The CLI searches for `.lbscaffold.json` starting from the current directory and walking up the directory tree. This allows you to have project-specific or workspace-level configurations.
|
|
149
175
|
|
|
150
176
|
### Config Commands
|
|
151
177
|
|
|
@@ -155,11 +181,12 @@ Initialize a new config file:
|
|
|
155
181
|
lb-scaffold config init
|
|
156
182
|
```
|
|
157
183
|
|
|
158
|
-
This creates a `.lbscaffold` file with a default plugin path:
|
|
184
|
+
This creates a `.lbscaffold.json` file with a default plugin path:
|
|
159
185
|
|
|
160
186
|
```json
|
|
161
187
|
{
|
|
162
|
-
"plugins": ["./plugins/**"]
|
|
188
|
+
"plugins": ["./plugins/**"],
|
|
189
|
+
"packages": []
|
|
163
190
|
}
|
|
164
191
|
```
|
|
165
192
|
|
|
@@ -189,7 +216,7 @@ lb-scaffold config show
|
|
|
189
216
|
|
|
190
217
|
### Config File Format
|
|
191
218
|
|
|
192
|
-
The `.lbscaffold` config file is a JSON file with the following structure:
|
|
219
|
+
The `.lbscaffold.json` config file is a JSON file with the following structure:
|
|
193
220
|
|
|
194
221
|
```json
|
|
195
222
|
{
|
|
@@ -197,6 +224,10 @@ The `.lbscaffold` config file is a JSON file with the following structure:
|
|
|
197
224
|
"./plugins/**",
|
|
198
225
|
"./custom-templates/**",
|
|
199
226
|
"/absolute/path/to/plugins/**"
|
|
227
|
+
],
|
|
228
|
+
"packages": [
|
|
229
|
+
"@libria/scaffold-plugin-angular",
|
|
230
|
+
"@libria/scaffold-plugin-nestjs"
|
|
200
231
|
]
|
|
201
232
|
}
|
|
202
233
|
```
|
|
@@ -205,6 +236,28 @@ The `plugins` array contains glob patterns pointing to directories containing te
|
|
|
205
236
|
- **Relative**: Resolved relative to the config file location
|
|
206
237
|
- **Absolute**: Used as-is
|
|
207
238
|
|
|
239
|
+
The `packages` array contains npm package names that provide scaffold template plugins. These packages will be loaded via node_modules.
|
|
240
|
+
|
|
241
|
+
### Adding NPM Packages
|
|
242
|
+
|
|
243
|
+
Add an npm package as a plugin source:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
lb-scaffold config add-package @your-org/scaffold-plugin-my-template
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Remove an npm package:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
lb-scaffold config remove-package @your-org/scaffold-plugin-my-template
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
List all configured npm packages:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
lb-scaffold config list-packages
|
|
259
|
+
```
|
|
260
|
+
|
|
208
261
|
### Plugin Override Behavior
|
|
209
262
|
|
|
210
263
|
When a user plugin has the same name as a built-in plugin, the user plugin takes precedence. This allows you to customize or replace built-in templates.
|
|
@@ -225,7 +278,7 @@ When a user plugin has the same name as a built-in plugin, the user plugin takes
|
|
|
225
278
|
|
|
226
279
|
4. Your template will now appear in the template selection:
|
|
227
280
|
```bash
|
|
228
|
-
lb-scaffold
|
|
281
|
+
lb-scaffold new
|
|
229
282
|
```
|
|
230
283
|
|
|
231
284
|
## Creating Custom Template Plugins
|
|
@@ -262,7 +315,10 @@ templates/
|
|
|
262
315
|
### Step 2: Define Types (types.ts)
|
|
263
316
|
|
|
264
317
|
```typescript
|
|
265
|
-
import {
|
|
318
|
+
import {
|
|
319
|
+
ScaffoldTemplatePluginOptions,
|
|
320
|
+
ScaffoldTemplatePluginOption,
|
|
321
|
+
} from "@libria/scaffold-core";
|
|
266
322
|
|
|
267
323
|
export type MyTemplateOptions = ScaffoldTemplatePluginOptions & {
|
|
268
324
|
packageName: string;
|
|
@@ -277,7 +333,6 @@ export type MyTemplateOptions = ScaffoldTemplatePluginOptions & {
|
|
|
277
333
|
import path from 'path';
|
|
278
334
|
import { fileURLToPath } from 'url';
|
|
279
335
|
import fs from 'fs-extra';
|
|
280
|
-
import { input, confirm } from '@inquirer/prompts';
|
|
281
336
|
import { definePlugin } from '@libria/plugin-loader';
|
|
282
337
|
import { SCAFFOLD_TEMPLATE_PLUGIN_TYPE, ScaffoldTemplatePlugin } from '@libria/scaffold-core';
|
|
283
338
|
import { MyTemplateOptions } from './types';
|
|
@@ -291,36 +346,35 @@ export default definePlugin<ScaffoldTemplatePlugin>(
|
|
|
291
346
|
{
|
|
292
347
|
argument: 'my-template',
|
|
293
348
|
async execute(options: ScaffoldTemplatePluginOptions): Promise<void> {
|
|
294
|
-
// Collect user input
|
|
295
|
-
const userOptions =
|
|
349
|
+
// Collect user input (via getOptions - see ScaffoldTemplatePlugin)
|
|
350
|
+
const userOptions = options as MyTemplateOptions;
|
|
296
351
|
// Generate the project
|
|
297
352
|
await generateProject(userOptions);
|
|
298
353
|
// Post-processing
|
|
299
354
|
await postProcess(userOptions);
|
|
300
|
-
}
|
|
355
|
+
},
|
|
356
|
+
async getOptions(options: ScaffoldTemplatePluginOptions): Promise<Record<string, ScaffoldTemplatePluginOption>> {
|
|
357
|
+
return {
|
|
358
|
+
packageName: {
|
|
359
|
+
flags: '-p, --package-name <name>',
|
|
360
|
+
description: 'Package name',
|
|
361
|
+
defaultValue: options.name,
|
|
362
|
+
},
|
|
363
|
+
description: {
|
|
364
|
+
flags: '-d, --description <text>',
|
|
365
|
+
description: 'Project description',
|
|
366
|
+
},
|
|
367
|
+
framework: {
|
|
368
|
+
flags: '-f, --framework <name>',
|
|
369
|
+
description: 'Framework',
|
|
370
|
+
defaultValue: 'react',
|
|
371
|
+
choices: ['react', 'vue', 'svelte'],
|
|
372
|
+
},
|
|
373
|
+
};
|
|
374
|
+
},
|
|
301
375
|
}
|
|
302
376
|
);
|
|
303
377
|
|
|
304
|
-
async function getInitialOptions(
|
|
305
|
-
options: ScaffoldTemplatePluginOptions
|
|
306
|
-
): Promise<MyTemplateOptions> {
|
|
307
|
-
const packageName = await input({
|
|
308
|
-
message: 'Package name:',
|
|
309
|
-
default: options.name,
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
const description = await input({
|
|
313
|
-
message: 'Description:',
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
const framework = await input({
|
|
317
|
-
message: 'Framework (react/vue/svelte):',
|
|
318
|
-
default: 'react',
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
return { packageName, description, framework, ...options };
|
|
322
|
-
}
|
|
323
|
-
|
|
324
378
|
async function generateProject(options: MyTemplateOptions): Promise<void> {
|
|
325
379
|
const { name, dryRun, force } = options;
|
|
326
380
|
const targetDir = path.resolve(process.cwd(), name);
|