@pixpilot/scaffoldfy 0.4.0
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/LICENSE +21 -0
- package/README.md +431 -0
- package/dist/cli.cjs +2 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +2 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +468 -0
- package/dist/index.d.ts +468 -0
- package/dist/index.js +1 -0
- package/dist/src-Cn-rEwSc.js +13 -0
- package/dist/src-eu70b3xC.cjs +13 -0
- package/package.json +72 -0
- package/schema/tasks.schema.json +337 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 pixpilot
|
|
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,431 @@
|
|
|
1
|
+
# @pixpilot/scaffoldfy
|
|
2
|
+
|
|
3
|
+
A flexible and powerful template initialization utility for automating project setup, cleanup, and configuration tasks.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔄 **9 Task Types** - update-json, template, regex-replace, replace-in-file, delete, conditional-delete, rename, git-init, exec
|
|
8
|
+
- 🧩 **Template Inheritance** - Extend base templates for code reuse
|
|
9
|
+
- 🔍 **Dry-Run Mode with Diff** - Preview exact changes before applying
|
|
10
|
+
- 🔌 **Plugin System** - Create custom task types and lifecycle hooks
|
|
11
|
+
- 💬 **Interactive Prompts** - Collect user input with input, select, confirm, number, and password prompts
|
|
12
|
+
- 📦 **JSON/TypeScript Config** - Define tasks in JSON or TypeScript files
|
|
13
|
+
- 🔗 **Task Dependencies** - Ensure tasks run in the correct order
|
|
14
|
+
- ✅ **Type-Safe** - Full TypeScript support with JSON schema validation
|
|
15
|
+
- 🎯 **Template Variables** - Use `{{variable}}` syntax for dynamic configuration
|
|
16
|
+
- 📝 **Handlebars Support** - Advanced templating with conditionals, loops, and helpers
|
|
17
|
+
- ⚡ **CLI & Programmatic** - Use as a command-line tool or import as a library
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pnpm add @pixpilot/scaffoldfy
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### CLI Usage
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
# Basic usage with default task file
|
|
31
|
+
scaffoldfy
|
|
32
|
+
|
|
33
|
+
# With custom tasks file
|
|
34
|
+
scaffoldfy --tasks-file ./my-tasks.json
|
|
35
|
+
|
|
36
|
+
# TypeScript tasks file
|
|
37
|
+
scaffoldfy --tasks-ts ./my-tasks.ts
|
|
38
|
+
|
|
39
|
+
# Preview changes (dry run)
|
|
40
|
+
scaffoldfy --dry-run
|
|
41
|
+
|
|
42
|
+
# Force re-initialization
|
|
43
|
+
scaffoldfy --force
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### CLI Options
|
|
47
|
+
|
|
48
|
+
| Option | Description |
|
|
49
|
+
| --------------------- | ------------------------------------------------------------- |
|
|
50
|
+
| `--tasks-file <path>` | Path to JSON task file (default: `./template-tasks.json`) |
|
|
51
|
+
| `--tasks-ts <path>` | Path to TypeScript task file (default: `./template-tasks.ts`) |
|
|
52
|
+
| `--dry-run` | Preview changes without applying them |
|
|
53
|
+
| `--force` | Force re-initialization |
|
|
54
|
+
| `--keep-tasks-file` | Keep task file after completion (default: remove) |
|
|
55
|
+
| `-h, --help` | Show help message |
|
|
56
|
+
| `-v, --version` | Show version |
|
|
57
|
+
|
|
58
|
+
### Programmatic API
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { runWithTasks } from '@pixpilot/scaffoldfy';
|
|
62
|
+
|
|
63
|
+
await runWithTasks(tasks, {
|
|
64
|
+
dryRun: false,
|
|
65
|
+
force: false,
|
|
66
|
+
keepTasksFile: true,
|
|
67
|
+
tasksFilePath: './my-tasks.json',
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Core Concepts
|
|
72
|
+
|
|
73
|
+
### Task Types
|
|
74
|
+
|
|
75
|
+
9 built-in task types for common operations:
|
|
76
|
+
|
|
77
|
+
| Type | Purpose |
|
|
78
|
+
| -------------------- | -------------------------------------------------- |
|
|
79
|
+
| `update-json` | Update JSON files (supports nested properties) |
|
|
80
|
+
| `template` | Create files from templates (simple or Handlebars) |
|
|
81
|
+
| `regex-replace` | Find and replace with regex |
|
|
82
|
+
| `replace-in-file` | Simple find and replace |
|
|
83
|
+
| `delete` | Remove files/directories |
|
|
84
|
+
| `conditional-delete` | Remove based on conditions |
|
|
85
|
+
| `rename` | Rename or move files |
|
|
86
|
+
| `git-init` | Initialize git repository |
|
|
87
|
+
| `exec` | Execute shell commands |
|
|
88
|
+
|
|
89
|
+
📖 **[Complete Task Types Reference →](docs/TASK_TYPES.md)**
|
|
90
|
+
|
|
91
|
+
### Interactive Prompts
|
|
92
|
+
|
|
93
|
+
Collect custom user input directly in your task definitions:
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"id": "setup",
|
|
98
|
+
"prompts": [
|
|
99
|
+
{
|
|
100
|
+
"id": "projectName",
|
|
101
|
+
"type": "input",
|
|
102
|
+
"message": "What is your project name?",
|
|
103
|
+
"required": true,
|
|
104
|
+
"global": true
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"id": "useTypeScript",
|
|
108
|
+
"type": "confirm",
|
|
109
|
+
"message": "Use TypeScript?",
|
|
110
|
+
"default": true
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"config": {
|
|
114
|
+
"file": "package.json",
|
|
115
|
+
"updates": {
|
|
116
|
+
"name": "{{projectName}}"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Supported prompt types:** `input`, `password`, `number`, `select`, `confirm`
|
|
123
|
+
|
|
124
|
+
**Global prompts:** Mark prompts with `"global": true` to share values across all tasks
|
|
125
|
+
|
|
126
|
+
💬 **[Full Prompts Guide →](docs/PROMPTS.md)** | 📋 **[Quick Reference →](docs/PROMPTS_QUICK_REFERENCE.md)**
|
|
127
|
+
|
|
128
|
+
### Template Variables
|
|
129
|
+
|
|
130
|
+
Use `{{variable}}` syntax anywhere in your task configs:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"updates": {
|
|
135
|
+
"name": "{{repoName}}",
|
|
136
|
+
"author": "{{author}}",
|
|
137
|
+
"repository": "{{repoUrl}}"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Built-in variables:** `repoName`, `repoOwner`, `repoUrl`, `author`, `baseRepoUrl`, `orgName`
|
|
143
|
+
|
|
144
|
+
**Custom variables:** Any prompt values you define (e.g., `{{projectName}}`, `{{port}}`)
|
|
145
|
+
|
|
146
|
+
### Handlebars Templates
|
|
147
|
+
|
|
148
|
+
Create powerful file templates with Handlebars support. Files with `.hbs` extension automatically use Handlebars templating:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"id": "readme-from-template",
|
|
153
|
+
"name": "Generate README",
|
|
154
|
+
"type": "template",
|
|
155
|
+
"config": {
|
|
156
|
+
"file": "README.md",
|
|
157
|
+
"templateFile": "templates/readme.hbs"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Automatic detection:** Any template file ending in `.hbs` uses Handlebars. Other files use simple `{{variable}}` interpolation.
|
|
163
|
+
|
|
164
|
+
**Template file** (`templates/readme.hbs`):
|
|
165
|
+
|
|
166
|
+
```handlebars
|
|
167
|
+
#
|
|
168
|
+
{{repoName}}
|
|
169
|
+
|
|
170
|
+
{{#if description}}
|
|
171
|
+
>
|
|
172
|
+
{{description}}
|
|
173
|
+
{{else}}
|
|
174
|
+
> A modern TypeScript project
|
|
175
|
+
{{/if}}
|
|
176
|
+
|
|
177
|
+
## Features
|
|
178
|
+
|
|
179
|
+
{{#each features}}
|
|
180
|
+
-
|
|
181
|
+
{{this}}
|
|
182
|
+
{{/each}}
|
|
183
|
+
|
|
184
|
+
{{#if author}}
|
|
185
|
+
## Author
|
|
186
|
+
|
|
187
|
+
{{author}}
|
|
188
|
+
{{/if}}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Key features:**
|
|
192
|
+
|
|
193
|
+
- **File-based only:** Handlebars is only supported for external template files (`.hbs` extension)
|
|
194
|
+
- **Automatic detection:** No configuration needed - just use `.hbs` files
|
|
195
|
+
- **Conditionals:** `{{#if}}`, `{{#unless}}`, `{{else}}`
|
|
196
|
+
- **Loops:** `{{#each}}`, `{{#with}}`
|
|
197
|
+
- **Comments:** `{{!-- This won't appear in output --}}`
|
|
198
|
+
|
|
199
|
+
📝 **[Complete Handlebars Guide →](docs/HANDLEBARS_TEMPLATES.md)**
|
|
200
|
+
|
|
201
|
+
### Template Inheritance
|
|
202
|
+
|
|
203
|
+
Extend base templates to promote code reuse:
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"extends": "./base-template.json",
|
|
208
|
+
"tasks": [
|
|
209
|
+
{
|
|
210
|
+
"id": "custom-task",
|
|
211
|
+
"name": "Custom Task",
|
|
212
|
+
"description": "Project-specific setup",
|
|
213
|
+
"required": true,
|
|
214
|
+
"enabled": true,
|
|
215
|
+
"type": "exec",
|
|
216
|
+
"config": { "command": "echo 'Custom setup'" }
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
You can extend multiple templates, override tasks by ID, and merge dependencies automatically.
|
|
223
|
+
|
|
224
|
+
🧬 **[Complete Inheritance Guide →](docs/TEMPLATE_INHERITANCE.md)**
|
|
225
|
+
|
|
226
|
+
### Dry-Run Mode with Diff Preview
|
|
227
|
+
|
|
228
|
+
Preview exactly what will change before applying:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
scaffoldfy --tasks-file ./tasks.json --dry-run
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
See color-coded diffs for all file modifications, deletions, and additions.
|
|
235
|
+
|
|
236
|
+
🔍 **[Dry-Run Documentation →](docs/DRY_RUN.md)**
|
|
237
|
+
|
|
238
|
+
### Plugin System
|
|
239
|
+
|
|
240
|
+
Create custom task types for specialized operations:
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import { createPlugin, registerPlugin } from '@pixpilot/scaffoldfy';
|
|
244
|
+
|
|
245
|
+
const myPlugin = createPlugin(
|
|
246
|
+
'my-plugin',
|
|
247
|
+
'custom-task',
|
|
248
|
+
async (task, config, options) => {
|
|
249
|
+
// Your custom logic here
|
|
250
|
+
},
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
registerPlugin(myPlugin);
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
🔌 **[Complete Plugin Guide →](docs/PLUGINS.md)**
|
|
257
|
+
|
|
258
|
+
### Task Dependencies
|
|
259
|
+
|
|
260
|
+
Control execution order:
|
|
261
|
+
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"tasks": [
|
|
265
|
+
{ "id": "clean", "type": "delete", "config": { "paths": ["dist"] } },
|
|
266
|
+
{
|
|
267
|
+
"id": "build",
|
|
268
|
+
"dependencies": ["clean"],
|
|
269
|
+
"type": "exec",
|
|
270
|
+
"config": { "command": "pnpm build" }
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Example Configuration
|
|
277
|
+
|
|
278
|
+
### Simple Example
|
|
279
|
+
|
|
280
|
+
```json
|
|
281
|
+
{
|
|
282
|
+
"tasks": [
|
|
283
|
+
{
|
|
284
|
+
"id": "update-package",
|
|
285
|
+
"name": "Update package.json",
|
|
286
|
+
"description": "Update repository information",
|
|
287
|
+
"required": true,
|
|
288
|
+
"enabled": true,
|
|
289
|
+
"type": "update-json",
|
|
290
|
+
"config": {
|
|
291
|
+
"file": "package.json",
|
|
292
|
+
"updates": {
|
|
293
|
+
"name": "{{repoName}}",
|
|
294
|
+
"author": "{{author}}"
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### With Prompts
|
|
303
|
+
|
|
304
|
+
```json
|
|
305
|
+
{
|
|
306
|
+
"tasks": [
|
|
307
|
+
{
|
|
308
|
+
"id": "setup-project",
|
|
309
|
+
"name": "Setup Project",
|
|
310
|
+
"description": "Configure project settings",
|
|
311
|
+
"required": true,
|
|
312
|
+
"enabled": true,
|
|
313
|
+
"type": "update-json",
|
|
314
|
+
"prompts": [
|
|
315
|
+
{
|
|
316
|
+
"id": "projectName",
|
|
317
|
+
"type": "input",
|
|
318
|
+
"message": "Project name?",
|
|
319
|
+
"required": true
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"id": "includeTests",
|
|
323
|
+
"type": "confirm",
|
|
324
|
+
"message": "Include tests?",
|
|
325
|
+
"default": true
|
|
326
|
+
}
|
|
327
|
+
],
|
|
328
|
+
"config": {
|
|
329
|
+
"file": "package.json",
|
|
330
|
+
"updates": {
|
|
331
|
+
"name": "{{projectName}}",
|
|
332
|
+
"scripts": {
|
|
333
|
+
"test": "{{includeTests ? 'vitest' : 'echo \"No tests\"'}}"
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
📁 **[More Examples →](examples/)**
|
|
343
|
+
|
|
344
|
+
## Documentation
|
|
345
|
+
|
|
346
|
+
📚 **[Complete Documentation](../../docs/README.md)** - Start here for comprehensive guides and references
|
|
347
|
+
|
|
348
|
+
### Quick Links
|
|
349
|
+
|
|
350
|
+
- **[Getting Started](../../docs/GETTING_STARTED.md)** - Installation, CLI usage, and examples
|
|
351
|
+
- **[Task Types Reference](../../docs/TASK_TYPES.md)** - All 9 built-in task types
|
|
352
|
+
- **[Interactive Prompts](../../docs/PROMPTS.md)** - Collect user input
|
|
353
|
+
- **[Advanced Features](../../docs/FEATURES.md)** - Conditional execution, global prompts, Handlebars
|
|
354
|
+
- **[Template Inheritance](../../docs/TEMPLATE_INHERITANCE.md)** - Extend and compose templates
|
|
355
|
+
- **[Plugin System](../../docs/PLUGINS.md)** - Create custom task types
|
|
356
|
+
- **[Dry-Run Mode](../../docs/DRY_RUN.md)** - Preview changes safely
|
|
357
|
+
|
|
358
|
+
### Resources
|
|
359
|
+
|
|
360
|
+
- **[JSON Schema](schema/tasks.schema.json)** - For IDE autocomplete and validation
|
|
361
|
+
- **[Example Files](examples/)** - Sample task configurations
|
|
362
|
+
|
|
363
|
+
### 📁 Project Structure
|
|
364
|
+
|
|
365
|
+
```
|
|
366
|
+
scaffoldfy (monorepo)/
|
|
367
|
+
├── docs/ # Complete documentation
|
|
368
|
+
│ ├── README.md # Documentation index
|
|
369
|
+
│ ├── GETTING_STARTED.md # Getting started guide
|
|
370
|
+
│ ├── FEATURES.md # Advanced features
|
|
371
|
+
│ ├── TASK_TYPES.md # Task types reference
|
|
372
|
+
│ ├── PROMPTS.md # Prompts guide
|
|
373
|
+
│ ├── PROMPTS_QUICK_REFERENCE.md # Quick reference
|
|
374
|
+
│ ├── TEMPLATE_INHERITANCE.md # Inheritance guide
|
|
375
|
+
│ ├── HANDLEBARS_TEMPLATES.md # Handlebars guide
|
|
376
|
+
│ ├── PLUGINS.md # Plugin system
|
|
377
|
+
│ ├── DRY_RUN.md # Dry-run mode
|
|
378
|
+
│ └── EXECUTABLE_DEFAULTS_REFERENCE.md
|
|
379
|
+
└── packages/
|
|
380
|
+
└── scaffoldfy/ # Main package
|
|
381
|
+
├── src/
|
|
382
|
+
│ ├── cli.ts # CLI entry point
|
|
383
|
+
│ ├── types.ts # TypeScript definitions
|
|
384
|
+
│ ├── config.ts # Configuration
|
|
385
|
+
│ ├── prompts.ts # Prompt handling
|
|
386
|
+
│ ├── task-executors.ts # Task execution
|
|
387
|
+
│ ├── task-resolver.ts # Dependency resolution
|
|
388
|
+
│ └── utils.ts # Utilities
|
|
389
|
+
├── schema/
|
|
390
|
+
│ └── tasks.schema.json # JSON schema
|
|
391
|
+
├── examples/ # Example configurations
|
|
392
|
+
└── test/ # Test files
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
## JSON Schema Support
|
|
396
|
+
|
|
397
|
+
Enable autocomplete and validation in your IDE:
|
|
398
|
+
|
|
399
|
+
```json
|
|
400
|
+
{
|
|
401
|
+
"$schema": "node_modules/@pixpilot/scaffoldfy/schema/tasks.schema.json",
|
|
402
|
+
"tasks": []
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## Contributing
|
|
407
|
+
|
|
408
|
+
Contributions are welcome! Please check out the [Contributing Guide](../../CONTRIBUTING.md) for guidelines.
|
|
409
|
+
|
|
410
|
+
### Development
|
|
411
|
+
|
|
412
|
+
```sh
|
|
413
|
+
# Install dependencies
|
|
414
|
+
pnpm install
|
|
415
|
+
|
|
416
|
+
# Run tests
|
|
417
|
+
pnpm test
|
|
418
|
+
|
|
419
|
+
# Run tests in watch mode
|
|
420
|
+
pnpm test --watch
|
|
421
|
+
|
|
422
|
+
# Build
|
|
423
|
+
pnpm build
|
|
424
|
+
|
|
425
|
+
# Type check
|
|
426
|
+
pnpm typecheck
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## License
|
|
430
|
+
|
|
431
|
+
MIT
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const e=require(`./src-eu70b3xC.cjs`);let t=require(`node:fs`);t=e.Y(t);let n=require(`node:path`);n=e.Y(n);let r=require(`node:process`);r=e.Y(r);let i=require(`commander`);i=e.Y(i);const a=1,o=new i.Command,s=n.default.join(__dirname,`..`,`package.json`);let c=`0.0.0`;try{c=JSON.parse(t.default.readFileSync(s,`utf-8`)).version??`0.0.0`}catch{}o.name(`scaffoldfy`).description(`Initialize and configure project templates with customizable tasks`).version(c),o.option(`--dry-run`,`Run in dry mode without making any changes`).option(`--force`,`Force re-initialization even if already initialized`).option(`--keep-tasks-file`,`Keep the tasks file after successful initialization (default: remove)`,!1).option(`--tasks-file <path>`,`Path to JSON file containing task definitions`,`./template-tasks.json`).option(`--tasks-ts <path>`,`Path to TypeScript file exporting tasks`,`./template-tasks.ts`).action(async i=>{try{let a=[],o;if(i.tasksTs!=null&&i.tasksTs!==``){let s=n.default.resolve(r.default.cwd(),i.tasksTs);if(t.default.existsSync(s)){e.G(`Loading tasks from TypeScript file: ${i.tasksTs}`,`info`),o=s;try{let t=await import(s);a=t.default??t.tasks??[],(!Array.isArray(a)||a.length===0)&&(e.G(`⚠️ No tasks found in TypeScript file or invalid format`,`warn`),e.G(`Expected default export or named export "tasks" with TaskDefinition[]`,`info`))}catch(t){e.G(`Failed to load TypeScript tasks file: ${i.tasksTs}`,`error`),t instanceof Error&&e.G(` Error: ${t.message}`,`error`),r.default.exit(1)}}}if(a.length===0&&i.tasksFile!=null&&i.tasksFile!==``){let s=n.default.resolve(r.default.cwd(),i.tasksFile);if(t.default.existsSync(s)){o=s;try{a=await e.a(s),Array.isArray(a)||(e.G(`❌ Invalid tasks file format`,`error`),e.G(`Expected JSON with { "tasks": [...] } structure`,`info`),r.default.exit(1))}catch(t){e.G(`Failed to load JSON tasks file: ${i.tasksFile}`,`error`),t instanceof Error&&e.G(` Error: ${t.message}`,`error`),r.default.exit(1)}}else e.G(`Tasks file not found: ${i.tasksFile}`,`warn`)}a.length===0&&(e.G(`❌ No tasks defined`,`error`),console.log(``),e.G(`Please provide tasks using one of these methods:`,`info`),e.G(` 1. Create a template-tasks.json file in the current directory`,`info`),e.G(` 2. Create a template-tasks.ts file in the current directory`,`info`),e.G(` 3. Use --tasks-file option to specify a different JSON file`,`info`),e.G(` 4. Use --tasks-ts option to specify a different TypeScript file`,`info`),console.log(``),e.G(`Example JSON structure:`,`info`),console.log(JSON.stringify({tasks:[{id:`update-package`,name:`Update package.json`,description:`Update package.json with repository information`,required:!0,enabled:!0,type:`update-json`,prompts:[{id:`projectName`,type:`input`,message:`What is your project name?`,default:`my-project`,required:!0},{id:`includeTests`,type:`confirm`,message:`Include test files?`,default:!0}],config:{file:`package.json`,updates:{name:`{{projectName}}`,author:`{{author}}`}}}]},null,2)),console.log(``),r.default.exit(1)),console.log(``),e.G(`Loaded ${a.length} task(s)`,`success`),console.log(``),await e.n(a,{dryRun:i.dryRun,force:i.force,keepTasksFile:i.keepTasksFile,tasksFilePath:o})}catch(t){if(e.G(`❌ CLI execution failed`,`error`),t instanceof Error){e.G(`Error: ${t.message}`,`error`);let n=r.default.env.DEBUG;n!=null&&n!==``&&console.error(t.stack)}else console.error(t);r.default.exit(1)}}),o.parse(r.default.argv);
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{G as e,a as t,n}from"./src-Cn-rEwSc.js";import r from"node:path";import{fileURLToPath as i}from"node:url";import a from"node:fs";import o from"node:process";import{Command as s}from"commander";const c=()=>i(import.meta.url),l=(()=>r.dirname(c()))(),u=new s,d=r.join(l,`..`,`package.json`);let f=`0.0.0`;try{f=JSON.parse(a.readFileSync(d,`utf-8`)).version??`0.0.0`}catch{}u.name(`scaffoldfy`).description(`Initialize and configure project templates with customizable tasks`).version(f),u.option(`--dry-run`,`Run in dry mode without making any changes`).option(`--force`,`Force re-initialization even if already initialized`).option(`--keep-tasks-file`,`Keep the tasks file after successful initialization (default: remove)`,!1).option(`--tasks-file <path>`,`Path to JSON file containing task definitions`,`./template-tasks.json`).option(`--tasks-ts <path>`,`Path to TypeScript file exporting tasks`,`./template-tasks.ts`).action(async i=>{try{let s=[],c;if(i.tasksTs!=null&&i.tasksTs!==``){let t=r.resolve(o.cwd(),i.tasksTs);if(a.existsSync(t)){e(`Loading tasks from TypeScript file: ${i.tasksTs}`,`info`),c=t;try{let n=await import(t);s=n.default??n.tasks??[],(!Array.isArray(s)||s.length===0)&&(e(`⚠️ No tasks found in TypeScript file or invalid format`,`warn`),e(`Expected default export or named export "tasks" with TaskDefinition[]`,`info`))}catch(t){e(`Failed to load TypeScript tasks file: ${i.tasksTs}`,`error`),t instanceof Error&&e(` Error: ${t.message}`,`error`),o.exit(1)}}}if(s.length===0&&i.tasksFile!=null&&i.tasksFile!==``){let n=r.resolve(o.cwd(),i.tasksFile);if(a.existsSync(n)){c=n;try{s=await t(n),Array.isArray(s)||(e(`❌ Invalid tasks file format`,`error`),e(`Expected JSON with { "tasks": [...] } structure`,`info`),o.exit(1))}catch(t){e(`Failed to load JSON tasks file: ${i.tasksFile}`,`error`),t instanceof Error&&e(` Error: ${t.message}`,`error`),o.exit(1)}}else e(`Tasks file not found: ${i.tasksFile}`,`warn`)}s.length===0&&(e(`❌ No tasks defined`,`error`),console.log(``),e(`Please provide tasks using one of these methods:`,`info`),e(` 1. Create a template-tasks.json file in the current directory`,`info`),e(` 2. Create a template-tasks.ts file in the current directory`,`info`),e(` 3. Use --tasks-file option to specify a different JSON file`,`info`),e(` 4. Use --tasks-ts option to specify a different TypeScript file`,`info`),console.log(``),e(`Example JSON structure:`,`info`),console.log(JSON.stringify({tasks:[{id:`update-package`,name:`Update package.json`,description:`Update package.json with repository information`,required:!0,enabled:!0,type:`update-json`,prompts:[{id:`projectName`,type:`input`,message:`What is your project name?`,default:`my-project`,required:!0},{id:`includeTests`,type:`confirm`,message:`Include test files?`,default:!0}],config:{file:`package.json`,updates:{name:`{{projectName}}`,author:`{{author}}`}}}]},null,2)),console.log(``),o.exit(1)),console.log(``),e(`Loaded ${s.length} task(s)`,`success`),console.log(``),await n(s,{dryRun:i.dryRun,force:i.force,keepTasksFile:i.keepTasksFile,tasksFilePath:c})}catch(t){if(e(`❌ CLI execution failed`,`error`),t instanceof Error){e(`Error: ${t.message}`,`error`);let n=o.env.DEBUG;n!=null&&n!==``&&console.error(t.stack)}else console.error(t);o.exit(1)}}),u.parse(o.argv);export{};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./src-eu70b3xC.cjs`);exports.callHook=e._,exports.clearPlugins=e.v,exports.clearTemplateCache=e.r,exports.collectConfig=e.B,exports.collectPrompts=e.p,exports.createPlugin=e.y,exports.displayTasksDiff=e.A,exports.evaluateCondition=e.H,exports.executePluginTask=e.b,exports.executeTask=e.l,exports.getDeleteDiff=e.j,exports.getExecDiff=e.M,exports.getGitInitDiff=e.N,exports.getGitRepoInfo=e.U,exports.getPlugin=e.x,exports.getPluginForTaskType=e.S,exports.getPluginTaskDiff=e.C,exports.getRegexReplaceDiff=e.P,exports.getRenameDiff=e.F,exports.getReplaceInFileDiff=e.I,exports.getTaskDiff=e.L,exports.getTemplateDiff=e.R,exports.getUpdateJsonDiff=e.z,exports.interpolateTemplate=e.W,exports.isPluginTaskType=e.w,exports.listPlugins=e.T,exports.loadAndMergeTemplate=e.i,exports.loadInitializationState=e.d,exports.loadTasksWithInheritance=e.a,exports.loadTemplate=e.o,exports.log=e.G,exports.main=e.t,exports.mergeTemplates=e.s,exports.prompt=e.K,exports.promptYesNo=e.q,exports.registerHooks=e.E,exports.registerPlugin=e.D,exports.resolveAllDefaultValues=e.m,exports.resolveDefaultValue=e.h,exports.runTask=e.u,exports.runWithTasks=e.n,exports.saveInitializationState=e.f,exports.setNestedProperty=e.J,exports.topologicalSort=e.c,exports.unregisterPlugin=e.O,exports.validateConfig=e.V,exports.validatePluginTask=e.k,exports.validatePrompts=e.g;
|