-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgulpfile.js
More file actions
74 lines (67 loc) · 1.8 KB
/
gulpfile.js
File metadata and controls
74 lines (67 loc) · 1.8 KB
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
const path = require('path');
const gulp = require('gulp');
const execa = require('execa');
const fs = require('fs-extra');
async function cleanOutput() {
await fs.emptyDir(path.resolve(__dirname, 'build'));
await fs.emptyDir(path.resolve(__dirname, 'dist'));
}
function runTSBuild() {
return execa('yarn', ['tsc'], {
stdio: 'inherit',
});
}
function runWebpack() {
return execa('yarn', ['webpack'], {
stdio: 'inherit',
});
}
function copyBuildFiles() {
return fs.copy(
path.resolve(__dirname, 'build/index.js'),
path.resolve(__dirname, 'dist/build/index.js'),
);
}
async function copyOtherFiles() {
await fs.copy(
path.resolve(__dirname, 'src/themes/theme.scss'),
path.resolve(__dirname, 'dist/themes/theme.scss'),
);
await fs.copy(
path.resolve(__dirname, 'src/widgets/BuiltinWidget/styles.scss'),
path.resolve(__dirname, 'dist/widgets/BuiltinWidget/styles.scss'),
);
await fs.copy(
path.resolve(__dirname, 'src/global.d.ts'),
path.resolve(__dirname, 'dist/global.d.ts'),
);
await fs.copy(
path.resolve(__dirname, 'README.md'),
path.resolve(__dirname, 'dist/README.md'),
);
fs.cpSync(
path.resolve(__dirname, 'src/assets/'),
path.resolve(__dirname, 'dist/assets/'),
{ recursive: true },
);
}
async function generatePackage() {
const packageInfo = JSON.parse(
await fs.readFile(path.resolve(__dirname, 'package.json')),
);
delete packageInfo.scripts;
delete packageInfo.devDependencies;
packageInfo.main = 'index.js';
await fs.writeFile(
path.resolve(__dirname, 'dist/package.json'),
JSON.stringify(packageInfo, null, 2),
);
}
gulp.task('release', async () => {
await cleanOutput();
await runWebpack();
await runTSBuild();
await copyBuildFiles();
await copyOtherFiles();
await generatePackage();
});