This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanager.js
44 lines (37 loc) · 1.5 KB
/
manager.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
//--------------------------------------------------------
//-- Manager
//--------------------------------------------------------
'use strict';
const cssVarsFromJSON = require('css-vars-from-json');
const pkgDir = require('pkg-dir');
const fss = require('@absolunet/fss');
const jsonToScss = require('@absolunet/json-to-scss');
const { manager } = require('@absolunet/manager');
manager.init({
repositoryType: 'single-package',
dist: {
node: true
},
tasks: {
build: {
postRun: ({ terminal }) => {
terminal.print('Build guidelines').spacer();
const root = pkgDir.sync(__dirname);
const dist = `${root}/dist`;
const guidelines = fss.readYaml(`${root}/guidelines.yaml`);
// JSON
fss.writeJson(`${dist}/guidelines.json`, guidelines, { space: 2 });
// CSS
const baseCss = fss.readFile(`${root}/resources/guidelines.css`, 'utf8');
const cssVariables = cssVarsFromJSON({ 'valtech-guidelines': guidelines }).replaceAll(';', ';\n\t');
fss.writeFile(`${dist}/guidelines.css`, baseCss.replace('/* variables */', cssVariables));
// SCSS
const baseScss = fss.readFile(`${root}/resources/guidelines.scss`, 'utf8');
guidelines.font.content = `"${guidelines.font.content}"`;
guidelines.font.safe = `"${guidelines.font.safe}"`;
guidelines.font.code = `"${guidelines.font.code}"`;
fss.writeFile(`${dist}/guidelines.scss`, `${jsonToScss.convert(JSON.stringify({ '-guidelines': guidelines }))}\n\n${baseScss}`);
}
}
}
});