-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
prepareTemplates.js
61 lines (55 loc) · 1.97 KB
/
prepareTemplates.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// @ts-check
const fs = require('fs');
const path = require('path');
const cpy = require('cpy')
const SHARED_MOBILE_PATH = path.resolve(__dirname, './shared-mobile')
const SHARED_VISION_PATH = path.resolve(__dirname, './shared-vision')
const SHARED_VISION_ICONS_PATH = path.resolve(__dirname, './shared-vision-flavor-icons')
const FLAVORS = ['angular', 'react', 'solid', 'svelte', 'vue']
const PACKAGES_PATH = path.resolve(__dirname, './packages')
const entries = fs.readdirSync(PACKAGES_PATH, {
withFileTypes: true
})
for(const entry of entries) {
if(!entry.isDirectory()) {
continue;
}
prepareTemplate(path.resolve(PACKAGES_PATH, entry.name))
}
function prepareTemplate(templatePath) {
console.log('processing ', templatePath)
if (templatePath.indexOf('vision') > -1) {
// Copy shared resources into template
cpy(`**/*`, templatePath, {
cwd: SHARED_VISION_PATH,
overwrite: true,
dot: true,
parents: true
})
for (const flavor of FLAVORS) {
let pathSuffix = `-${flavor}`;
if (flavor === 'angular') {
pathSuffix = `-ng`;
}
if (templatePath.indexOf(pathSuffix) > -1) {
// Copy flavor specific Front icon into Assets
const visionIconPath = path.resolve(templatePath, 'App_Resources', 'visionOS', 'Assets.xcassets', 'AppIcon.solidimagestack');
const flavorFrontIconPath = path.resolve(SHARED_VISION_ICONS_PATH, flavor);
cpy(`**/*`, visionIconPath, {
cwd: flavorFrontIconPath,
overwrite: true,
dot: true,
parents: true
})
}
}
} else {
// Copy shared resources into template
cpy(`**/*`, templatePath, {
cwd: SHARED_MOBILE_PATH,
overwrite: false,
dot: true,
parents: true
})
}
}