-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.js
76 lines (67 loc) · 2.07 KB
/
constants.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const path = require('path');
const pkg = require('./package.json');
const globby = require('globby');
const root = path.resolve(__dirname);
const resolve = (part) => path.normalize(`${path.resolve(root, part)}/`);
const pkgVersion = process.env.NPM_PKG_VERSION || pkg.version;
const createBrands = (brandsPath, buildPath) => {
const brands = globby.sync('**', {
deep: 1,
cwd: brandsPath,
onlyFiles: false,
});
return brands.reduce((accum, brand) => {
const themes = globby.sync('**', {
deep: 1,
cwd: `${constants.paths.src.brands}${brand}`,
onlyFiles: false,
});
accum[brand] = {};
themes.forEach((theme) => {
accum[brand][theme] = {
src: `${constants.paths.src.brands}${brand}/${theme}/`,
build:
theme === 'default'
? `${constants.paths.build.root}${brand}/`
: `${constants.paths.build.root}${brand}/themes/${theme}/`,
};
});
return accum;
}, {});
};
const constants = {
namespace: {
prefix: 'dts',
global: 'DTS',
},
pkg: {
name: pkg.name,
version: pkgVersion,
},
paths: {
root: resolve(root),
build: {
root: resolve('build'),
},
scripts: {
root: resolve('scripts'),
lib: resolve('scripts/lib'),
changelog: resolve('scripts/changelog'),
docs: resolve('scripts/docs'),
tailwind: resolve('scripts/tailwind'),
styleDictionary: resolve('scripts/style-dictionary'),
filters: resolve('scripts/style-dictionary/filters'),
transforms: resolve('scripts/style-dictionary/transforms'),
},
src: {
root: resolve('src'),
brands: resolve('src/brands'),
global: resolve('src/global'),
},
},
};
constants.brands = createBrands(
constants.paths.src.brands,
constants.paths.src.build
);
module.exports = constants;