forked from ckeditor/ckeditor5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
151 lines (117 loc) · 3.85 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
/**
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/
/* eslint-env node */
'use strict';
const path = require( 'path' );
const gulp = require( 'gulp' );
// Tests. ---------------------------------------------------------------------
gulp.task( 'test', () => {
return require( '@ckeditor/ckeditor5-dev-tests' )
.runAutomatedTests( getTestOptions() );
} );
gulp.task( 'test:manual', () => {
return require( '@ckeditor/ckeditor5-dev-tests' )
.runManualTests( getTestOptions() );
} );
function getTestOptions() {
return require( '@ckeditor/ckeditor5-dev-tests' )
.parseArguments( process.argv.slice( 2 ) );
}
// Documentation. -------------------------------------------------------------
gulp.task( 'docs', () => {
const skipLiveSnippets = process.argv.includes( '--skip-snippets' );
const skipApi = process.argv.includes( '--skip-api' );
const production = process.argv.includes( '--production' );
if ( skipApi ) {
const fs = require( 'fs' );
const apiJsonPath = './docs/api/output.json';
if ( fs.existsSync( apiJsonPath ) ) {
fs.unlinkSync( apiJsonPath );
}
return runUmberto( {
skipLiveSnippets,
skipApi,
production
} );
}
// Simple way to reuse existing api/output.json:
// return Promise.resolve()
return buildApiDocs()
.then( () => {
return runUmberto( {
skipLiveSnippets,
production
} );
} );
} );
gulp.task( 'docs:api', buildApiDocs );
function buildApiDocs() {
assertIsInstalled( '@ckeditor/ckeditor5-dev-docs' );
const ckeditor5Docs = require( '@ckeditor/ckeditor5-dev-docs' );
return ckeditor5Docs
.build( {
readmePath: path.join( process.cwd(), 'README.md' ),
sourceFiles: [
process.cwd() + '/packages/ckeditor5-*/src/**/*.@(js|jsdoc)',
'!' + process.cwd() + '/packages/ckeditor5-*/src/lib/**/*.js',
'!' + process.cwd() + '/packages/ckeditor5-build-*/src/**/*.js'
],
validateOnly: process.argv[ 3 ] == '--validate-only'
} );
}
function runUmberto( options ) {
assertIsInstalled( 'umberto' );
const umberto = require( 'umberto' );
return umberto.buildSingleProject( {
configDir: 'docs',
clean: true,
skipLiveSnippets: options.skipLiveSnippets,
snippetOptions: {
production: options.production
},
skipApi: options.skipApi
} );
}
// Translations. --------------------------------------------------------------
gulp.task( 'translations:collect', () => {
assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
return require( '@ckeditor/ckeditor5-dev-env' ).collectTranslations();
} );
gulp.task( 'translations:upload', () => {
assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
return require( '@ckeditor/ckeditor5-dev-env' ).uploadTranslations();
} );
gulp.task( 'translations:download', () => {
assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
return require( '@ckeditor/ckeditor5-dev-env' ).downloadTranslations();
} );
// Releasing. -----------------------------------------------------------------
gulp.task( 'changelog:dependencies', () => {
assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
return require( '@ckeditor/ckeditor5-dev-env' )
.generateChangelogForSubRepositories( {
cwd: process.cwd(),
packages: 'packages'
} );
} );
gulp.task( 'release:dependencies', () => {
assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
return require( '@ckeditor/ckeditor5-dev-env' )
.releaseSubRepositories( {
cwd: process.cwd(),
packages: 'packages'
} );
} );
// Utils. ---------------------------------------------------------------------
function assertIsInstalled( packageName ) {
try {
require( packageName + '/package.json' );
} catch ( err ) {
console.error( `Error: Cannot find package '${ packageName }'.\n` );
console.error( 'You need to install optional dependencies.' );
console.error( 'Run: \'npm run install-optional-dependencies\'.' );
process.exit( 1 );
}
}