|
1 | 1 | /** |
2 | 2 | * Template Paths |
3 | | - * Utilities for setup scripts in .template/setup/ |
| 3 | + * Shared helper for setup scripts in .template/setup/ |
4 | 4 | */ |
5 | 5 |
|
6 | | -import path from 'path'; |
7 | | -import { fileURLToPath } from 'url'; |
| 6 | +import path from 'node:path'; |
| 7 | +import { fileURLToPath } from 'node:url'; |
8 | 8 |
|
9 | | -const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
10 | | -const rootDir = path.resolve(__dirname, '../'); |
| 9 | +const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../'); |
11 | 10 |
|
12 | | -// Directory names (mirrors gulp/configs/paths.js) |
13 | | -const folders = { |
14 | | - src: 'src', |
15 | | - styles: 'styles', |
16 | | - scripts: 'scripts', |
17 | | - html: 'html', |
18 | | - layouts: 'layouts', |
19 | | - pages: 'pages', |
20 | | - components: 'components', |
21 | | -}; |
22 | | - |
23 | | -// ───────────────────────────────────────────────────────────── |
24 | | -// Path Helpers |
25 | | -// ───────────────────────────────────────────────────────────── |
26 | | - |
27 | | -/** |
28 | | - * Path relative to project root |
29 | | - */ |
| 11 | +/** Path relative to the project root */ |
30 | 12 | export const resolvePath = (...parts) => path.join(rootDir, ...parts); |
31 | | - |
32 | | -/** |
33 | | - * Path to source files |
34 | | - */ |
35 | | -export const srcPath = (...parts) => resolvePath(folders.src, ...parts); |
36 | | - |
37 | | -/** |
38 | | - * Path to gulp tasks |
39 | | - */ |
40 | | -export const gulpPath = (...parts) => resolvePath('gulp', ...parts); |
41 | | - |
42 | | -// ───────────────────────────────────────────────────────────── |
43 | | -// Export |
44 | | -// ───────────────────────────────────────────────────────────── |
45 | | - |
46 | | -export const templatePaths = { |
47 | | - root: rootDir, |
48 | | - template: __dirname, |
49 | | - |
50 | | - // Computed paths |
51 | | - src: srcPath(), |
52 | | - srcStyles: srcPath(folders.styles), |
53 | | - srcScripts: srcPath(folders.scripts), |
54 | | - srcHtml: srcPath(folders.html), |
55 | | - srcHtmlLayouts: srcPath(folders.html, folders.layouts), |
56 | | - srcHtmlPages: srcPath(folders.html, folders.pages), |
57 | | - srcHtmlComponents: srcPath(folders.html, folders.components), |
58 | | - |
59 | | - // Gulp |
60 | | - gulpTasks: gulpPath('tasks'), |
61 | | - gulpConfigs: gulpPath('configs'), |
62 | | - gulpUtils: gulpPath('utils'), |
63 | | - |
64 | | - // Helpers |
65 | | - resolvePath, |
66 | | - srcPath, |
67 | | - gulpPath, |
68 | | -}; |
0 commit comments