-
Notifications
You must be signed in to change notification settings - Fork 161
/
gulpfile.js
182 lines (135 loc) · 5.16 KB
/
gulpfile.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
'use strict';
const del = require('del');
const gulp = require('gulp');
const process = require('process');
const fs = require('fs');
const argv = require('yargs').argv;
const sassdoc = require('sassdoc');
const path = require('path');
const { series } = require('gulp');
const slash = require('slash');
const DOCS_OUTPUT_PATH = slash(path.join(__dirname, 'dist', 'igniteui-angular', 'docs'));
module.exports.copyGitHooks = async (cb) => {
if (process.env.AZURE_PIPELINES || process.env.TRAVIS || process.env.CI || !fs.existsSync('.git')) {
return;
}
const gitHooksDir = './.git/hooks/';
const defaultCopyHookDir = gitHooksDir + 'scripts/';
const dirs = [
gitHooksDir,
defaultCopyHookDir,
defaultCopyHookDir + 'templates',
defaultCopyHookDir + 'templateValidators',
defaultCopyHookDir + 'utils'
];
dirs.forEach((dir) => {
if (!fs.existsSync(dir)) {
fs.mkdir(dir, (err) => {
if (err) {
throw err;
}
});
}
});
const defaultHookDir = './.hooks/scripts/';
fs.copyFileSync(defaultHookDir + 'templates/default.js',
defaultCopyHookDir + 'templates/default.js');
fs.copyFileSync(defaultHookDir + 'templateValidators/default-style-validator.js',
defaultCopyHookDir + 'templateValidators/default-style-validator.js');
fs.copyFileSync(defaultHookDir + 'utils/issue-validator.js',
defaultCopyHookDir + 'utils/issue-validator.js');
fs.copyFileSync(defaultHookDir + 'utils/line-limits.js',
defaultCopyHookDir + 'utils/line-limits.js');
fs.copyFileSync(defaultHookDir + 'common.js',
defaultCopyHookDir + 'common.js');
fs.copyFileSync(defaultHookDir + 'validate.js',
defaultCopyHookDir + 'validate.js');
fs.copyFileSync('./.hooks/prepare-commit-msg',
'./.git/hooks/prepare-commit-msg');
return await cb();
};
module.exports.copyMigrations = (cb) => {
gulp.src([
'./projects/igniteui-angular/migrations/**/*.json',
'!**/tsconfig.json'
]).pipe(gulp.dest('./dist/igniteui-angular/migrations'));
gulp.src([
'./projects/igniteui-angular/migrations/common/import-helper.js'
]).pipe(gulp.dest('./dist/igniteui-angular/migrations/common'));
cb();
};
module.exports.copySchematics = (cb) => {
gulp.src([
'./projects/igniteui-angular/schematics/**/*.json',
'!**/tsconfig.json'
]).pipe(gulp.dest('./dist/igniteui-angular/schematics'));
cb();
};
function createDocsOutputDirFn(cb) {
!fs.existsSync(DOCS_OUTPUT_PATH) && fs.mkdirSync(DOCS_OUTPUT_PATH);
cb();
}
const SASSDOC = {
PROJECT_PATHS: [
`${path.join(__dirname, 'projects', 'igniteui-angular', 'src', 'lib', 'core', 'styles')}/**/*.scss`,
`${path.join(__dirname, 'node_modules', 'igniteui-theming', 'sass')}/**/*.scss`
],
DEST: path.join(DOCS_OUTPUT_PATH, 'sass'),
OPTIONS: path.join(__dirname, '.sassdocrc'),
};
const sassdocCleanOutputDir = (cb) => {
del.sync(SASSDOC.DEST);
cb();
}
function sassdocBuildJson(cb) {
const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));
const { convert, exportDir } = argv;
options.convert = convert;
options.exportDir = exportDir;
gulp.src(SASSDOC.PROJECT_PATHS)
.pipe(sassdoc(options));
cb();
}
function sassdocImportJson(cb) {
const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));
const { render, importDir } = argv;
options.render = render;
options.json_dir = importDir;
options.shellStringsPath = path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json');
gulp.src(SASSDOC.PROJECT_PATHS)
.pipe(sassdoc(options));
cb();
}
function sassdocBuildJA(cb) {
const pathTranslations = path.join(__dirname, 'i18nRepo', 'sassdoc', 'ja');
const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));
options.lang = 'jp';
options.render = argv.render;
options.json_dir = pathTranslations;
options.shellStringsPath = path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json');
gulp.src(SASSDOC.PROJECT_PATHS)
.pipe(sassdoc(options));
cb();
}
function sassdocBuildEN(cb) {
const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));
options.lang = 'en';
options.shellStringsPath = path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json');
gulp.src(SASSDOC.PROJECT_PATHS)
.pipe(sassdoc(options));
cb();
}
module.exports.createDocsOutputDir = createDocsOutputDirFn;
/**
* Sassdoc build tasks
*/
module.exports.sassdocCleanOutputDir = sassdocCleanOutputDir;
module.exports.sassdocImportJson = sassdocImportJson;
module.exports.sassdocBuildJson = sassdocBuildJson;
module.exports.sassdocBuildJA = series(sassdocCleanOutputDir, sassdocBuildJA);
module.exports.sassdocBuildEN = series(sassdocCleanOutputDir, sassdocBuildEN);
module.exports.copyPackageForElements = (cb) => {
return gulp.src([
path.join(__dirname, 'projects/igniteui-angular-elements/package.json')
]).pipe(gulp.dest(path.join(__dirname, 'dist/igniteui-angular-elements/browser')));
};