@timeax/scaffold 0.0.5 → 0.0.6

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.d.ts CHANGED
@@ -1,349 +1,5 @@
1
- /**
2
- * Common options that can be applied to both files and directories
3
- * in the scaffold structure.
4
- *
5
- * These options are *declarative* — they do not enforce behavior by
6
- * themselves; they are consumed by the core engine.
7
- */
8
- interface BaseEntryOptions {
9
- /**
10
- * Glob patterns relative to the group root or project root
11
- * (depending on how the engine is called).
12
- *
13
- * If provided, at least one pattern must match the entry path
14
- * for the entry to be considered.
15
- */
16
- include?: string[];
17
- /**
18
- * Glob patterns relative to the group root or project root.
19
- *
20
- * If any pattern matches the entry path, the entry will be ignored.
21
- */
22
- exclude?: string[];
23
- /**
24
- * Name of the stub to use when creating this file or directory’s
25
- * content. For directories, this can act as an “inherited” stub
26
- * for child files if the engine chooses to support that behavior.
27
- */
28
- stub?: string;
29
- }
30
- /**
31
- * A single file entry in the structure tree.
32
- *
33
- * Paths are always stored as POSIX-style forward-slash paths
34
- * relative to the group root / project root.
35
- */
36
- interface FileEntry extends BaseEntryOptions {
37
- type: 'file';
38
- /**
39
- * File path (e.g. "src/index.ts", "Models/User.php").
40
- * Paths should never end with a trailing slash.
41
- */
42
- path: string;
43
- }
44
- /**
45
- * A directory entry in the structure tree.
46
- *
47
- * Paths should *logically* represent directories and may end
48
- * with a trailing slash for readability (the engine can normalize).
49
- */
50
- interface DirEntry extends BaseEntryOptions {
51
- type: 'dir';
52
- /**
53
- * Directory path (e.g. "src/", "src/schema/", "Models/").
54
- * It is recommended (but not strictly required) that directory
55
- * paths end with a trailing slash.
56
- */
57
- path: string;
58
- /**
59
- * Nested structure entries for files and subdirectories.
60
- */
61
- children?: StructureEntry[];
62
- }
63
- /**
64
- * A single node in the structure tree:
65
- * either a file or a directory.
66
- */
67
- type StructureEntry = FileEntry | DirEntry;
68
-
69
- /**
70
- * Lifecycle stages for non-stub (regular) hooks.
71
- *
72
- * These hooks are called around file operations (create/delete).
73
- */
74
- type RegularHookKind = 'preCreateFile' | 'postCreateFile' | 'preDeleteFile' | 'postDeleteFile';
75
- /**
76
- * Lifecycle stages for stub-related hooks.
77
- *
78
- * These hooks are called around stub resolution for file content.
79
- */
80
- type StubHookKind = 'preStub' | 'postStub';
81
- /**
82
- * Context object passed to all hooks (both regular and stub).
83
- */
84
- interface HookContext {
85
- /**
86
- * Absolute path to the group root / project root that this
87
- * scaffold run is targeting.
88
- */
89
- projectRoot: string;
90
- /**
91
- * Path of the file or directory relative to the project root
92
- * used for this run (or group root, if grouped).
93
- *
94
- * Example: "src/index.ts", "Http/Controllers/Controller.php".
95
- */
96
- targetPath: string;
97
- /**
98
- * Absolute path to the file or directory on disk.
99
- */
100
- absolutePath: string;
101
- /**
102
- * Whether the target is a directory.
103
- * (For now, most hooks will be for files, but this is future-proofing.)
104
- */
105
- isDirectory: boolean;
106
- /**
107
- * The stub name associated with the file (if any).
108
- *
109
- * For regular hooks, this can be used to detect which stub
110
- * produced a given file.
111
- */
112
- stubName?: string;
113
- }
114
- /**
115
- * Common filter options used by both regular and stub hooks.
116
- *
117
- * Filters are evaluated against the `targetPath`.
118
- */
119
- interface HookFilter {
120
- /**
121
- * Glob patterns which must match for the hook to run.
122
- * If provided, at least one pattern must match.
123
- */
124
- include?: string[];
125
- /**
126
- * Glob patterns which, if any match, will prevent the hook
127
- * from running.
128
- */
129
- exclude?: string[];
130
- /**
131
- * Additional patterns or explicit file paths, treated similarly
132
- * to `include` — mainly a convenience alias.
133
- */
134
- files?: string[];
135
- }
136
- /**
137
- * Function signature for regular hooks.
138
- */
139
- type RegularHookFn = (ctx: HookContext) => void | Promise<void>;
140
- /**
141
- * Function signature for stub hooks.
142
- */
143
- type StubHookFn = (ctx: HookContext) => void | Promise<void>;
144
- /**
145
- * Configuration for a regular hook instance.
146
- *
147
- * Each hook category (e.g. `preCreateFile`) can have an array
148
- * of these, each with its own filter.
149
- */
150
- interface RegularHookConfig extends HookFilter {
151
- fn: RegularHookFn;
152
- }
153
- /**
154
- * Configuration for a stub hook instance.
155
- *
156
- * Each stub can have its own `preStub` / `postStub` hook arrays,
157
- * each with independent filters.
158
- */
159
- interface StubHookConfig extends HookFilter {
160
- fn: StubHookFn;
161
- }
162
- /**
163
- * Stub configuration, defining how file content is generated
164
- * and which stub-specific hooks apply.
165
- */
166
- interface StubConfig {
167
- /**
168
- * Unique name of this stub within the config.
169
- * This is referenced from structure entries via `stub: name`.
170
- */
171
- name: string;
172
- /**
173
- * Content generator for files that use this stub.
174
- *
175
- * If omitted, the scaffold engine may default to an empty file.
176
- */
177
- getContent?: (ctx: HookContext) => string | Promise<string>;
178
- /**
179
- * Stub-specific hooks called for files that reference this stub.
180
- */
181
- hooks?: {
182
- preStub?: StubHookConfig[];
183
- postStub?: StubHookConfig[];
184
- };
185
- }
186
-
187
- /**
188
- * Configuration for a single structure group.
189
- *
190
- * Groups allow you to clearly separate different roots in a project,
191
- * such as "app", "routes", "resources/js", etc., each with its own
192
- * structure definition.
193
- */
194
- interface StructureGroupConfig {
195
- /**
196
- * Human-readable identifier for the group (e.g. "app", "routes", "frontend").
197
- * Used mainly for logging and, optionally, cache metadata.
198
- */
199
- name: string;
200
- /**
201
- * Root directory for this group, relative to the overall project root.
202
- *
203
- * Example: "app", "routes", "resources/js".
204
- *
205
- * All paths produced from this group's structure are resolved
206
- * relative to this directory.
207
- */
208
- root: string;
209
- /**
210
- * Optional inline structure entries for this group.
211
- * If present and non-empty, these take precedence over `structureFile`.
212
- */
213
- structure?: StructureEntry[];
214
- /**
215
- * Name of the structure file inside the scaffold directory for this group.
216
- *
217
- * Example: "app.txt", "routes.txt".
218
- *
219
- * If omitted, the default is `<name>.txt` within the scaffold directory.
220
- */
221
- structureFile?: string;
222
- }
223
- /**
224
- * Root configuration object for @timeax/scaffold.
225
- *
226
- * This is what you export from `scaffold/config.ts` in a consuming
227
- * project, or from any programmatic usage of the library.
228
- */
229
- interface ScaffoldConfig {
230
- /**
231
- * Absolute or relative project root (where files are created).
232
- *
233
- * If omitted, the engine will treat `process.cwd()` as the root.
234
- */
235
- root?: string;
236
- /**
237
- * Base directory where structures are applied and files/folders
238
- * are actually created.
239
- *
240
- * This is resolved relative to `root` (not CWD).
241
- *
242
- * Default: same as `root`.
243
- *
244
- * Examples:
245
- * - base: '.' with root: '.' → apply to <cwd>
246
- * - base: 'src' with root: '.' → apply to <cwd>/src
247
- * - base: '..' with root: 'tools' → apply to <cwd>/tools/..
248
- */
249
- base?: string;
250
- /**
251
- * Path to the scaffold cache file, relative to `root`.
252
- *
253
- * Default: ".scaffold-cache.json"
254
- */
255
- cacheFile?: string;
256
- /**
257
- * File size threshold (in bytes) above which deletions become
258
- * interactive (e.g. ask "are you sure?").
259
- *
260
- * Default is determined by the core engine (e.g. 128 KB).
261
- */
262
- sizePromptThreshold?: number;
263
- /**
264
- * Optional single-root structure (legacy or simple mode).
265
- *
266
- * If `groups` is defined and non-empty, this is ignored.
267
- * Paths are relative to `root` in this mode.
268
- */
269
- structure?: StructureEntry[];
270
- /**
271
- * Name of the single structure file in the scaffold directory
272
- * for legacy mode.
273
- *
274
- * If `groups` is empty and `structure` is not provided, this
275
- * file name is used (default: "structure.txt").
276
- */
277
- structureFile?: string;
278
- /**
279
- * Multiple structure groups (recommended).
280
- *
281
- * When provided and non-empty, the engine will iterate over each
282
- * group and apply its structure relative to each group's `root`.
283
- */
284
- groups?: StructureGroupConfig[];
285
- /**
286
- * Hook configuration for file lifecycle events.
287
- *
288
- * Each category (e.g. "preCreateFile") is an array of hook configs,
289
- * each with its own `include` / `exclude` / `files` filters.
290
- */
291
- hooks?: {
292
- [K in RegularHookKind]?: RegularHookConfig[];
293
- };
294
- /**
295
- * Stub definitions keyed by stub name.
296
- *
297
- * These are referenced from structure entries by `stub: name`.
298
- */
299
- stubs?: Record<string, StubConfig>;
300
- /**
301
- * When true, the CLI or consuming code may choose to start scaffold
302
- * in watch mode by default (implementation-specific).
303
- *
304
- * This flag itself does not start watch mode; it is a hint to the
305
- * runner / CLI.
306
- */
307
- watch?: boolean;
308
- /**
309
- * Number of spaces per indent level in structure files.
310
- * Default: 2.
311
- *
312
- * Examples:
313
- * - 2 → "··entry"
314
- * - 4 → "····entry"
315
- */
316
- indentStep?: number;
317
- }
318
- /**
319
- * Options when scanning an existing directory into a structure.txt tree.
320
- */
321
- interface ScanStructureOptions {
322
- /**
323
- * Glob patterns (relative to the scanned root) to ignore.
324
- */
325
- ignore?: string[];
326
- /**
327
- * Maximum depth to traverse (0 = only that dir).
328
- * Default: Infinity (no limit).
329
- */
330
- maxDepth?: number;
331
- }
332
- /**
333
- * Options when scanning based on the scaffold config/groups.
334
- */
335
- interface ScanFromConfigOptions extends ScanStructureOptions {
336
- /**
337
- * If provided, only scan these group names (by `StructureGroupConfig.name`).
338
- * If omitted, all groups are scanned (or single-root mode).
339
- */
340
- groups?: string[];
341
- /**
342
- * Optional override for scaffold directory; normally you can let
343
- * loadScaffoldConfig resolve this from "<cwd>/scaffold".
344
- */
345
- scaffoldDir?: string;
346
- }
1
+ import { S as ScaffoldConfig, a as ScanStructureOptions, b as ScanFromConfigOptions, c as StructureEntry } from './config-C0067l3c.js';
2
+ export { B as BaseEntryOptions, D as DirEntry, F as FileEntry, l as FormatConfig, k as FormatMode, H as HookContext, e as HookFilter, h as RegularHookConfig, f as RegularHookFn, R as RegularHookKind, m as StructureGroupConfig, j as StubConfig, i as StubHookConfig, g as StubHookFn, d as StubHookKind } from './config-C0067l3c.js';
347
3
 
348
4
  declare const SCAFFOLD_ROOT_DIR = ".scaffold";
349
5
 
@@ -399,6 +55,11 @@ interface RunOptions {
399
55
  */
400
56
  scaffoldDir?: string;
401
57
  configPath?: string;
58
+ /**
59
+ * If true, force formatting even if config.format?.enabled === false.
60
+ * This is what `--format` will use.
61
+ */
62
+ format?: boolean;
402
63
  }
403
64
  /**
404
65
  * Run scaffold once for the current working directory.
@@ -519,4 +180,4 @@ declare function ensureStructureFilesFromConfig(cwd: string, options?: {
519
180
  */
520
181
  declare function parseStructureText(text: string, indentStep?: number): StructureEntry[];
521
182
 
522
- export { type BaseEntryOptions, type DirEntry, type EnsureStructuresResult, type FileEntry, type HookContext, type HookFilter, type LoadScaffoldConfigOptions, type LoadScaffoldConfigResult, type RegularHookConfig, type RegularHookFn, type RegularHookKind, type RunOptions, SCAFFOLD_ROOT_DIR, type ScaffoldConfig, type ScanFromConfigOptions, type ScanFromConfigResult, type ScanStructureOptions, type StructureEntry, type StructureGroupConfig, type StubConfig, type StubHookConfig, type StubHookFn, type StubHookKind, ensureStructureFilesFromConfig, loadScaffoldConfig, parseStructureText, runOnce, scanDirectoryToStructureText, scanProjectFromConfig, writeScannedStructuresFromConfig };
183
+ export { type EnsureStructuresResult, type LoadScaffoldConfigOptions, type LoadScaffoldConfigResult, type RunOptions, SCAFFOLD_ROOT_DIR, ScaffoldConfig, ScanFromConfigOptions, type ScanFromConfigResult, ScanStructureOptions, StructureEntry, ensureStructureFilesFromConfig, loadScaffoldConfig, parseStructureText, runOnce, scanDirectoryToStructureText, scanProjectFromConfig, writeScannedStructuresFromConfig };