uniweb 0.2.13 → 0.2.15

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.
@@ -153,11 +153,17 @@ async function processFile(sourcePath, targetPath, data, options = {}) {
153
153
  * @param {Object} data - Template variables
154
154
  * @param {Object} options - Processing options
155
155
  * @param {string|null} options.variant - Template variant to use
156
+ * @param {string|null} options.basePath - Base template to merge with (files copied first)
156
157
  * @param {Function} options.onWarning - Warning callback
157
158
  * @param {Function} options.onProgress - Progress callback
158
159
  */
159
160
  export async function copyTemplateDirectory(sourcePath, targetPath, data, options = {}) {
160
- const { variant = null, onWarning, onProgress } = options
161
+ const { variant = null, basePath = null, onWarning, onProgress } = options
162
+
163
+ // If a base template is specified, copy it first (without the basePath option to avoid recursion)
164
+ if (basePath && existsSync(basePath)) {
165
+ await copyTemplateDirectory(basePath, targetPath, data, { variant, onWarning, onProgress })
166
+ }
161
167
 
162
168
  await fs.mkdir(targetPath, { recursive: true })
163
169
  const entries = await fs.readdir(sourcePath, { withFileTypes: true })
@@ -173,6 +179,9 @@ export async function copyTemplateDirectory(sourcePath, targetPath, data, option
173
179
  }
174
180
  }
175
181
 
182
+ // Options for recursive calls (without basePath to avoid re-copying base at each level)
183
+ const recursionOptions = { variant, onWarning, onProgress }
184
+
176
185
  for (const entry of entries) {
177
186
  const sourceName = entry.name
178
187
 
@@ -199,7 +208,7 @@ export async function copyTemplateDirectory(sourcePath, targetPath, data, option
199
208
  const sourceFullPath = path.join(sourcePath, sourceName)
200
209
  const targetFullPath = path.join(targetPath, baseName)
201
210
 
202
- await copyTemplateDirectory(sourceFullPath, targetFullPath, data, options)
211
+ await copyTemplateDirectory(sourceFullPath, targetFullPath, data, recursionOptions)
203
212
  } else {
204
213
  // Regular directory - skip if a variant override exists and we're using that variant
205
214
  if (variant && variantBases.has(sourceName)) {
@@ -210,10 +219,15 @@ export async function copyTemplateDirectory(sourcePath, targetPath, data, option
210
219
  const sourceFullPath = path.join(sourcePath, sourceName)
211
220
  const targetFullPath = path.join(targetPath, sourceName)
212
221
 
213
- await copyTemplateDirectory(sourceFullPath, targetFullPath, data, options)
222
+ await copyTemplateDirectory(sourceFullPath, targetFullPath, data, recursionOptions)
214
223
  }
215
224
  } else {
216
225
  // File processing
226
+ // Skip template.json as it's metadata for the template, not for the output
227
+ if (sourceName === 'template.json') {
228
+ continue
229
+ }
230
+
217
231
  // Remove .hbs extension for target filename
218
232
  const targetName = sourceName.endsWith('.hbs')
219
233
  ? sourceName.slice(0, -4)
@@ -2,8 +2,8 @@
2
2
  * Template resolver - parses template identifiers and determines source type
3
3
  */
4
4
 
5
- // Built-in templates that are generated programmatically
6
- export const BUILTIN_TEMPLATES = ['single', 'multi']
5
+ // Built-in templates (file-based in cli/templates/)
6
+ export const BUILTIN_TEMPLATES = ['single', 'multi', 'template']
7
7
 
8
8
  // Official templates from @uniweb/templates package
9
9
  export const OFFICIAL_TEMPLATES = ['marketing', 'docs', 'learning']