forked from joewestcott/fontkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.js
93 lines (75 loc) · 2.4 KB
/
Makefile.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// https://github.com/shelljs/shelljs#command-reference
// https://devhints.io/shelljs
// https://github.com/shelljs/shelljs/wiki/The-make-utility
require('shelljs/make');
config.fatal = true;
config.verbose = true;
const { execFileSync } = require('child_process');
const packageJson = require('./package.json');
target.all = () => {
target.clean();
target.generateTrieJson();
target.rollupESM();
target.rollupESMMin();
target.rollupUMD();
target.rollupUMDMin();
};
target.generateTrieJson = () => {
env.MODULE_TYPE = 'commonjs';
exec('babel-node src/opentype/shapers/generate-data.js');
exec('babel-node src/opentype/shapers/gen-use.js');
exec('babel-node src/opentype/shapers/gen-indic.js');
};
target.rollupESM = () => {
target.generateTrieJson();
env.UGLIFY = false;
env.MODULE_TYPE = 'esm';
exec('rollup -c rollup.config.js -o dist/fontkit.es.js');
};
target.rollupESMMin = () => {
target.generateTrieJson();
env.UGLIFY = true;
env.MODULE_TYPE = 'esm';
exec('rollup -c rollup.config.js -o dist/fontkit.es.min.js');
};
target.rollupUMD = () => {
target.generateTrieJson();
env.UGLIFY = false;
env.MODULE_TYPE = 'umd';
exec('rollup -c rollup.config.js -o dist/fontkit.umd.js');
};
target.rollupUMDMin = () => {
target.generateTrieJson();
env.UGLIFY = true;
env.MODULE_TYPE = 'umd';
exec('rollup -c rollup.config.js -o dist/fontkit.umd.min.js');
};
target.clean = () => {
rm(
'-rf',
'dist',
'src/opentype/shapers/trie.json',
'src/opentype/shapers/trieUse.json',
'src/opentype/shapers/trieIndic.json',
'src/opentype/shapers/indic.json',
'src/opentype/shapers/use.json',
);
};
/* =============================== Release ================================== */
target.releaseNext = () => {
const version = `${packageJson.version}@next`;
console.log('Releasing version', version);
target.all();
execFileSync('yarn', ['publish', '--tag', 'next', '--access', 'public'], { stdio: 'inherit' });
};
target.releaseLatest = async () => {
const currentBranch = exec('git rev-parse --abbrev-ref HEAD').stdout.trim();
if (currentBranch !== 'master') {
console.error('Must be on `master` branch to cut an @latest release.');
return;
}
const version = `${packageJson.version}@latest`;
console.log('Releasing version', version);
target.all();
execFileSync('yarn', ['publish', '--tag', 'latest', '--access', 'public'], { stdio: 'inherit' });
};