create-routify 1.5.3 → 1.5.5
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/package.json +1 -1
- package/src/index.js +39 -5
- package/src/utils/patcher/test/index.js +1 -2
- package/src/utils/repos.js +2 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -206,8 +206,6 @@ const copy = async (options) => {
|
|
|
206
206
|
await cp(options.template.dir, options.projectDir, {
|
|
207
207
|
recursive: true,
|
|
208
208
|
});
|
|
209
|
-
if (existsSync(join(options.projectDir, 'manifest.js')))
|
|
210
|
-
await rm(join(options.projectDir, 'manifest.js'));
|
|
211
209
|
s.stop('Copied template to project directory');
|
|
212
210
|
};
|
|
213
211
|
|
|
@@ -230,7 +228,7 @@ const install = async (options) => {
|
|
|
230
228
|
});
|
|
231
229
|
});
|
|
232
230
|
|
|
233
|
-
s.stop('Installed via
|
|
231
|
+
s.stop('Installed via ' + packageManager);
|
|
234
232
|
}
|
|
235
233
|
};
|
|
236
234
|
|
|
@@ -281,6 +279,24 @@ const normalizeOptions = async (options, configs) => {
|
|
|
281
279
|
p.cancel(`Template ${options.starterTemplate} not found`);
|
|
282
280
|
};
|
|
283
281
|
|
|
282
|
+
const normalizeManifest = (manifest) => ({
|
|
283
|
+
features: [],
|
|
284
|
+
preInstall: () => null,
|
|
285
|
+
postInstall: () => null,
|
|
286
|
+
exclude: [
|
|
287
|
+
'node_modules',
|
|
288
|
+
'package-lock.json',
|
|
289
|
+
'pnpm-lock.yaml',
|
|
290
|
+
'yarn.lock',
|
|
291
|
+
'dist',
|
|
292
|
+
'.pnpmfile.cjs',
|
|
293
|
+
'manifest.js',
|
|
294
|
+
'.routify',
|
|
295
|
+
],
|
|
296
|
+
test: { tests: [] },
|
|
297
|
+
...manifest,
|
|
298
|
+
});
|
|
299
|
+
|
|
284
300
|
/**
|
|
285
301
|
*
|
|
286
302
|
* @param {TemplateConfig} configs
|
|
@@ -295,6 +311,21 @@ const setTemplates = async (configs, options) => {
|
|
|
295
311
|
);
|
|
296
312
|
};
|
|
297
313
|
|
|
314
|
+
const removeExcludedFiles = async (options) => {
|
|
315
|
+
console.log('options.template.manifest.exclude');
|
|
316
|
+
console.log(options);
|
|
317
|
+
const exclude = options.template.manifest.exclude.map((file) =>
|
|
318
|
+
join(options.projectDir, file),
|
|
319
|
+
);
|
|
320
|
+
await Promise.all(
|
|
321
|
+
exclude.map(async (file) => {
|
|
322
|
+
if (existsSync(file)) {
|
|
323
|
+
await rm(file, { recursive: true, force: true });
|
|
324
|
+
}
|
|
325
|
+
}),
|
|
326
|
+
);
|
|
327
|
+
};
|
|
328
|
+
|
|
298
329
|
export const run = async (options) => {
|
|
299
330
|
const s = p.spinner();
|
|
300
331
|
emitter.on('download', (url) => s.start(`Downloading ${url}`));
|
|
@@ -307,12 +338,15 @@ export const run = async (options) => {
|
|
|
307
338
|
if (!options.headless) await runPrompts(options, configs);
|
|
308
339
|
else await normalizeOptions(options, configs);
|
|
309
340
|
|
|
341
|
+
options.template.manifest = normalizeManifest(options.template.manifest);
|
|
342
|
+
|
|
310
343
|
await copy(options);
|
|
311
344
|
await handleFeatures(options);
|
|
312
345
|
const { preInstall, postInstall } = options.template.manifest;
|
|
313
|
-
|
|
346
|
+
await preInstall(options, tools);
|
|
314
347
|
await install(options);
|
|
315
|
-
|
|
348
|
+
await postInstall(options, tools);
|
|
349
|
+
await removeExcludedFiles(options);
|
|
316
350
|
|
|
317
351
|
p.note(
|
|
318
352
|
prompts.nextSteps(options.dir, options.packageManager) +
|
|
@@ -29,8 +29,7 @@ let router
|
|
|
29
29
|
beforeAll(async () => {
|
|
30
30
|
await import('../.routify/routify-init.js')
|
|
31
31
|
router = globalThis.__routify.routers[0]
|
|
32
|
-
await router.
|
|
33
|
-
await router.activeRoute.get().rendered
|
|
32
|
+
await router.rendered()
|
|
34
33
|
})
|
|
35
34
|
|
|
36
35
|
${tests.map(resolveTestTemplate).join('\n\n')}
|
package/src/utils/repos.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readdir } from 'fs/promises';
|
|
2
2
|
import { dirname, join, resolve } from 'path';
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
4
|
-
import { existsSync } from 'fs';
|
|
4
|
+
import { existsSync, rmSync } from 'fs';
|
|
5
5
|
import { createRequire } from 'module';
|
|
6
6
|
import download from 'download-git-repo';
|
|
7
7
|
import { emitter } from './index.js';
|
|
@@ -22,6 +22,7 @@ const ensureRepo = async (url, force, onDownload) => {
|
|
|
22
22
|
|
|
23
23
|
// if repo doesn't exist, download it
|
|
24
24
|
if (!existsSync(repoPath) || force) {
|
|
25
|
+
rmSync(repoPath, { recursive: true, force: true });
|
|
25
26
|
emitter.emit('download', url);
|
|
26
27
|
if (onDownload) onDownload();
|
|
27
28
|
await new Promise((resolve, reject) =>
|