create-gen-app 0.8.0 → 0.9.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.
|
@@ -81,10 +81,11 @@ export class TemplateScaffolder {
|
|
|
81
81
|
}
|
|
82
82
|
const branch = options.branch ?? this.config.defaultBranch;
|
|
83
83
|
const resolvedTemplate = this.resolveTemplatePath(template);
|
|
84
|
+
const useBoilerplatesConfig = options.useBoilerplatesConfig ?? true;
|
|
84
85
|
if (this.isLocalPath(resolvedTemplate) && fs.existsSync(resolvedTemplate)) {
|
|
85
|
-
return this.inspectLocal(resolvedTemplate, options.fromPath);
|
|
86
|
+
return this.inspectLocal(resolvedTemplate, options.fromPath, useBoilerplatesConfig);
|
|
86
87
|
}
|
|
87
|
-
return this.inspectRemote(resolvedTemplate, branch, options.fromPath);
|
|
88
|
+
return this.inspectRemote(resolvedTemplate, branch, options.fromPath, useBoilerplatesConfig);
|
|
88
89
|
}
|
|
89
90
|
/**
|
|
90
91
|
* Read the .boilerplates.json configuration from a template repository root.
|
|
@@ -136,8 +137,8 @@ export class TemplateScaffolder {
|
|
|
136
137
|
getTemplatizer() {
|
|
137
138
|
return this.templatizer;
|
|
138
139
|
}
|
|
139
|
-
inspectLocal(templateDir, fromPath) {
|
|
140
|
-
const { fromPath: resolvedFromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, fromPath);
|
|
140
|
+
inspectLocal(templateDir, fromPath, useBoilerplatesConfig = true) {
|
|
141
|
+
const { fromPath: resolvedFromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, fromPath, useBoilerplatesConfig);
|
|
141
142
|
const config = this.readBoilerplateConfig(resolvedTemplatePath);
|
|
142
143
|
return {
|
|
143
144
|
templateDir,
|
|
@@ -148,7 +149,7 @@ export class TemplateScaffolder {
|
|
|
148
149
|
config,
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
|
-
inspectRemote(templateUrl, branch, fromPath) {
|
|
152
|
+
inspectRemote(templateUrl, branch, fromPath, useBoilerplatesConfig = true) {
|
|
152
153
|
const normalizedUrl = this.gitCloner.normalizeUrl(templateUrl);
|
|
153
154
|
const cacheKey = this.cacheManager.createKey(normalizedUrl, branch);
|
|
154
155
|
const expiredMetadata = this.cacheManager.checkExpiration(cacheKey);
|
|
@@ -172,7 +173,7 @@ export class TemplateScaffolder {
|
|
|
172
173
|
this.cacheManager.set(cacheKey, tempDest);
|
|
173
174
|
templateDir = tempDest;
|
|
174
175
|
}
|
|
175
|
-
const { fromPath: resolvedFromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, fromPath);
|
|
176
|
+
const { fromPath: resolvedFromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, fromPath, useBoilerplatesConfig);
|
|
176
177
|
const config = this.readBoilerplateConfig(resolvedTemplatePath);
|
|
177
178
|
return {
|
|
178
179
|
templateDir,
|
|
@@ -184,7 +185,7 @@ export class TemplateScaffolder {
|
|
|
184
185
|
};
|
|
185
186
|
}
|
|
186
187
|
async scaffoldFromLocal(templateDir, options) {
|
|
187
|
-
const { fromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, options.fromPath);
|
|
188
|
+
const { fromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, options.fromPath, options.useBoilerplatesConfig ?? true);
|
|
188
189
|
const boilerplateConfig = this.readBoilerplateConfig(resolvedTemplatePath);
|
|
189
190
|
const result = await this.templatizer.process(templateDir, options.outputDir, {
|
|
190
191
|
argv: options.answers,
|
|
@@ -226,7 +227,7 @@ export class TemplateScaffolder {
|
|
|
226
227
|
this.cacheManager.set(cacheKey, tempDest);
|
|
227
228
|
templateDir = tempDest;
|
|
228
229
|
}
|
|
229
|
-
const { fromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, options.fromPath);
|
|
230
|
+
const { fromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, options.fromPath, options.useBoilerplatesConfig ?? true);
|
|
230
231
|
const boilerplateConfig = this.readBoilerplateConfig(resolvedTemplatePath);
|
|
231
232
|
const result = await this.templatizer.process(templateDir, options.outputDir, {
|
|
232
233
|
argv: options.answers,
|
|
@@ -249,10 +250,14 @@ export class TemplateScaffolder {
|
|
|
249
250
|
*
|
|
250
251
|
* Resolution order:
|
|
251
252
|
* 1. If explicit fromPath is provided and exists, use it directly
|
|
252
|
-
* 2. If .boilerplates.json exists with a dir field, prepend it to fromPath
|
|
253
|
+
* 2. If useBoilerplatesConfig is true and .boilerplates.json exists with a dir field, prepend it to fromPath
|
|
253
254
|
* 3. Return the fromPath as-is
|
|
255
|
+
*
|
|
256
|
+
* @param templateDir - The template repository root directory
|
|
257
|
+
* @param fromPath - The subdirectory path to resolve
|
|
258
|
+
* @param useBoilerplatesConfig - Whether to use .boilerplates.json for fallback resolution (default: true)
|
|
254
259
|
*/
|
|
255
|
-
resolveFromPath(templateDir, fromPath) {
|
|
260
|
+
resolveFromPath(templateDir, fromPath, useBoilerplatesConfig = true) {
|
|
256
261
|
if (!fromPath) {
|
|
257
262
|
return {
|
|
258
263
|
fromPath: undefined,
|
|
@@ -268,14 +273,17 @@ export class TemplateScaffolder {
|
|
|
268
273
|
resolvedTemplatePath: directPath,
|
|
269
274
|
};
|
|
270
275
|
}
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
const
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
276
|
+
// Only check .boilerplates.json if useBoilerplatesConfig is true
|
|
277
|
+
if (useBoilerplatesConfig) {
|
|
278
|
+
const rootConfig = this.readBoilerplatesConfig(templateDir);
|
|
279
|
+
if (rootConfig?.dir) {
|
|
280
|
+
const configBasedPath = path.join(templateDir, rootConfig.dir, fromPath);
|
|
281
|
+
if (fs.existsSync(configBasedPath) && fs.statSync(configBasedPath).isDirectory()) {
|
|
282
|
+
return {
|
|
283
|
+
fromPath: path.join(rootConfig.dir, fromPath),
|
|
284
|
+
resolvedTemplatePath: configBasedPath,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
279
287
|
}
|
|
280
288
|
}
|
|
281
289
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-gen-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Clone and customize template repositories with variable replacement",
|
|
6
6
|
"main": "index.js",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"appstash": "0.2.6",
|
|
32
|
-
"inquirerer": "2.
|
|
32
|
+
"inquirerer": "2.4.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"copyfiles": "^2.4.1",
|
|
36
36
|
"makage": "0.1.8"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [],
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "3d31881a64d8eb1c88d9540871f72bc255da446c"
|
|
40
40
|
}
|
|
@@ -78,8 +78,12 @@ export declare class TemplateScaffolder {
|
|
|
78
78
|
*
|
|
79
79
|
* Resolution order:
|
|
80
80
|
* 1. If explicit fromPath is provided and exists, use it directly
|
|
81
|
-
* 2. If .boilerplates.json exists with a dir field, prepend it to fromPath
|
|
81
|
+
* 2. If useBoilerplatesConfig is true and .boilerplates.json exists with a dir field, prepend it to fromPath
|
|
82
82
|
* 3. Return the fromPath as-is
|
|
83
|
+
*
|
|
84
|
+
* @param templateDir - The template repository root directory
|
|
85
|
+
* @param fromPath - The subdirectory path to resolve
|
|
86
|
+
* @param useBoilerplatesConfig - Whether to use .boilerplates.json for fallback resolution (default: true)
|
|
83
87
|
*/
|
|
84
88
|
private resolveFromPath;
|
|
85
89
|
private isLocalPath;
|
|
@@ -117,10 +117,11 @@ class TemplateScaffolder {
|
|
|
117
117
|
}
|
|
118
118
|
const branch = options.branch ?? this.config.defaultBranch;
|
|
119
119
|
const resolvedTemplate = this.resolveTemplatePath(template);
|
|
120
|
+
const useBoilerplatesConfig = options.useBoilerplatesConfig ?? true;
|
|
120
121
|
if (this.isLocalPath(resolvedTemplate) && fs.existsSync(resolvedTemplate)) {
|
|
121
|
-
return this.inspectLocal(resolvedTemplate, options.fromPath);
|
|
122
|
+
return this.inspectLocal(resolvedTemplate, options.fromPath, useBoilerplatesConfig);
|
|
122
123
|
}
|
|
123
|
-
return this.inspectRemote(resolvedTemplate, branch, options.fromPath);
|
|
124
|
+
return this.inspectRemote(resolvedTemplate, branch, options.fromPath, useBoilerplatesConfig);
|
|
124
125
|
}
|
|
125
126
|
/**
|
|
126
127
|
* Read the .boilerplates.json configuration from a template repository root.
|
|
@@ -172,8 +173,8 @@ class TemplateScaffolder {
|
|
|
172
173
|
getTemplatizer() {
|
|
173
174
|
return this.templatizer;
|
|
174
175
|
}
|
|
175
|
-
inspectLocal(templateDir, fromPath) {
|
|
176
|
-
const { fromPath: resolvedFromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, fromPath);
|
|
176
|
+
inspectLocal(templateDir, fromPath, useBoilerplatesConfig = true) {
|
|
177
|
+
const { fromPath: resolvedFromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, fromPath, useBoilerplatesConfig);
|
|
177
178
|
const config = this.readBoilerplateConfig(resolvedTemplatePath);
|
|
178
179
|
return {
|
|
179
180
|
templateDir,
|
|
@@ -184,7 +185,7 @@ class TemplateScaffolder {
|
|
|
184
185
|
config,
|
|
185
186
|
};
|
|
186
187
|
}
|
|
187
|
-
inspectRemote(templateUrl, branch, fromPath) {
|
|
188
|
+
inspectRemote(templateUrl, branch, fromPath, useBoilerplatesConfig = true) {
|
|
188
189
|
const normalizedUrl = this.gitCloner.normalizeUrl(templateUrl);
|
|
189
190
|
const cacheKey = this.cacheManager.createKey(normalizedUrl, branch);
|
|
190
191
|
const expiredMetadata = this.cacheManager.checkExpiration(cacheKey);
|
|
@@ -208,7 +209,7 @@ class TemplateScaffolder {
|
|
|
208
209
|
this.cacheManager.set(cacheKey, tempDest);
|
|
209
210
|
templateDir = tempDest;
|
|
210
211
|
}
|
|
211
|
-
const { fromPath: resolvedFromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, fromPath);
|
|
212
|
+
const { fromPath: resolvedFromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, fromPath, useBoilerplatesConfig);
|
|
212
213
|
const config = this.readBoilerplateConfig(resolvedTemplatePath);
|
|
213
214
|
return {
|
|
214
215
|
templateDir,
|
|
@@ -220,7 +221,7 @@ class TemplateScaffolder {
|
|
|
220
221
|
};
|
|
221
222
|
}
|
|
222
223
|
async scaffoldFromLocal(templateDir, options) {
|
|
223
|
-
const { fromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, options.fromPath);
|
|
224
|
+
const { fromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, options.fromPath, options.useBoilerplatesConfig ?? true);
|
|
224
225
|
const boilerplateConfig = this.readBoilerplateConfig(resolvedTemplatePath);
|
|
225
226
|
const result = await this.templatizer.process(templateDir, options.outputDir, {
|
|
226
227
|
argv: options.answers,
|
|
@@ -262,7 +263,7 @@ class TemplateScaffolder {
|
|
|
262
263
|
this.cacheManager.set(cacheKey, tempDest);
|
|
263
264
|
templateDir = tempDest;
|
|
264
265
|
}
|
|
265
|
-
const { fromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, options.fromPath);
|
|
266
|
+
const { fromPath, resolvedTemplatePath } = this.resolveFromPath(templateDir, options.fromPath, options.useBoilerplatesConfig ?? true);
|
|
266
267
|
const boilerplateConfig = this.readBoilerplateConfig(resolvedTemplatePath);
|
|
267
268
|
const result = await this.templatizer.process(templateDir, options.outputDir, {
|
|
268
269
|
argv: options.answers,
|
|
@@ -285,10 +286,14 @@ class TemplateScaffolder {
|
|
|
285
286
|
*
|
|
286
287
|
* Resolution order:
|
|
287
288
|
* 1. If explicit fromPath is provided and exists, use it directly
|
|
288
|
-
* 2. If .boilerplates.json exists with a dir field, prepend it to fromPath
|
|
289
|
+
* 2. If useBoilerplatesConfig is true and .boilerplates.json exists with a dir field, prepend it to fromPath
|
|
289
290
|
* 3. Return the fromPath as-is
|
|
291
|
+
*
|
|
292
|
+
* @param templateDir - The template repository root directory
|
|
293
|
+
* @param fromPath - The subdirectory path to resolve
|
|
294
|
+
* @param useBoilerplatesConfig - Whether to use .boilerplates.json for fallback resolution (default: true)
|
|
290
295
|
*/
|
|
291
|
-
resolveFromPath(templateDir, fromPath) {
|
|
296
|
+
resolveFromPath(templateDir, fromPath, useBoilerplatesConfig = true) {
|
|
292
297
|
if (!fromPath) {
|
|
293
298
|
return {
|
|
294
299
|
fromPath: undefined,
|
|
@@ -304,14 +309,17 @@ class TemplateScaffolder {
|
|
|
304
309
|
resolvedTemplatePath: directPath,
|
|
305
310
|
};
|
|
306
311
|
}
|
|
307
|
-
|
|
308
|
-
if (
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
// Only check .boilerplates.json if useBoilerplatesConfig is true
|
|
313
|
+
if (useBoilerplatesConfig) {
|
|
314
|
+
const rootConfig = this.readBoilerplatesConfig(templateDir);
|
|
315
|
+
if (rootConfig?.dir) {
|
|
316
|
+
const configBasedPath = path.join(templateDir, rootConfig.dir, fromPath);
|
|
317
|
+
if (fs.existsSync(configBasedPath) && fs.statSync(configBasedPath).isDirectory()) {
|
|
318
|
+
return {
|
|
319
|
+
fromPath: path.join(rootConfig.dir, fromPath),
|
|
320
|
+
resolvedTemplatePath: configBasedPath,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
315
323
|
}
|
|
316
324
|
}
|
|
317
325
|
return {
|
package/scaffolder/types.d.ts
CHANGED
|
@@ -47,6 +47,14 @@ export interface ScaffoldOptions {
|
|
|
47
47
|
* Can be a direct path or a variant name that gets resolved via .boilerplates.json
|
|
48
48
|
*/
|
|
49
49
|
fromPath?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to use .boilerplates.json for path resolution fallback.
|
|
52
|
+
* When true (default), if fromPath doesn't exist directly, the resolver
|
|
53
|
+
* will check .boilerplates.json for a base directory to prepend.
|
|
54
|
+
* When false, .boilerplates.json is ignored and fromPath is used as-is.
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
useBoilerplatesConfig?: boolean;
|
|
50
58
|
/**
|
|
51
59
|
* Output directory for the generated project
|
|
52
60
|
*/
|
|
@@ -142,6 +150,14 @@ export interface InspectOptions {
|
|
|
142
150
|
* Can be a direct path or a variant name that gets resolved via .boilerplates.json
|
|
143
151
|
*/
|
|
144
152
|
fromPath?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Whether to use .boilerplates.json for path resolution fallback.
|
|
155
|
+
* When true (default), if fromPath doesn't exist directly, the resolver
|
|
156
|
+
* will check .boilerplates.json for a base directory to prepend.
|
|
157
|
+
* When false, .boilerplates.json is ignored and fromPath is used as-is.
|
|
158
|
+
* @default true
|
|
159
|
+
*/
|
|
160
|
+
useBoilerplatesConfig?: boolean;
|
|
145
161
|
}
|
|
146
162
|
/**
|
|
147
163
|
* Result of inspecting a template.
|