js-build-tools 6.5.0 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -674
- package/README.md +762 -692
- package/babel.config.js +28 -28
- package/dist/build.js +75 -75
- package/dist/bundle.js +19 -19
- package/dist/bundleMinify.js +7 -7
- package/dist/compileReadme.js +4 -4
- package/dist/copyFiles.js +17 -17
- package/dist/copyFonts.js +4 -4
- package/dist/default.js +5 -5
- package/dist/dist.js +4 -4
- package/dist/distMinify.js +4 -4
- package/dist/docs.js +7 -7
- package/dist/images.js +4 -4
- package/dist/jsdocDocs.js +6 -6
- package/dist/lint.js +16 -16
- package/dist/partials/addToReadme.js +9 -9
- package/dist/partials/beginWatcher.js +4 -4
- package/dist/partials/clean.js +5 -5
- package/dist/partials/copyFor.js +9 -9
- package/dist/partials/distFor.js +6 -6
- package/dist/partials/distForSrc.js +5 -5
- package/dist/partials/distSeries.js +7 -7
- package/dist/partials/imagesFor.js +93 -56
- package/dist/partials/jsdocDocsFor.js +46 -46
- package/dist/partials/lintSource.js +51 -51
- package/dist/partials/loadPeer.js +99 -99
- package/dist/partials/loadPlaywright.js +14 -14
- package/dist/partials/minifyFor.js +20 -20
- package/dist/partials/neostandardLint.js +175 -175
- package/dist/partials/readmeTemplate.js +4 -4
- package/dist/partials/removeDirectory.js +11 -11
- package/dist/partials/resolveDocsMethod.js +6 -6
- package/dist/partials/runOnChange.js +31 -31
- package/dist/partials/sassFor.js +6 -6
- package/dist/partials/serveStatic.js +9 -9
- package/dist/partials/tsFor.js +32 -32
- package/dist/partials/typeDocsFor.js +57 -51
- package/dist/partials.js +176 -176
- package/dist/sourceLint.js +18 -18
- package/dist/test-helpers/isolateGulpCache.js +24 -24
- package/dist/test-helpers/setUp.js +4 -4
- package/dist/testFull.js +5 -5
- package/dist/testQuick.js +5 -5
- package/dist/typeDocs.js +5 -5
- package/dist/typeScript.js +4 -4
- package/dist/utilities/convertMjsFilesForDocs.js +12 -12
- package/dist/utilities/dotGet.js +54 -54
- package/dist/utilities/dotNotate.js +79 -79
- package/dist/utilities/dotSet.js +45 -45
- package/dist/utilities/esmNamedExportsToCjs.js +15 -15
- package/dist/utilities/getBundleConfigs.js +9 -9
- package/dist/utilities/isObject.js +6 -6
- package/dist/utilities/strAfter.js +7 -7
- package/dist/utilities/strBefore.js +7 -7
- package/dist/watchFull.js +4 -4
- package/dist/watchTest.js +4 -4
- package/functions/build.mjs +72 -72
- package/functions/build.test.mjs +763 -759
- package/functions/bundle.mjs +44 -44
- package/functions/bundle.test.mjs +219 -219
- package/functions/bundleMinify.mjs +16 -16
- package/functions/bundleMinify.test.mjs +37 -37
- package/functions/compileReadme.mjs +9 -9
- package/functions/compileReadme.test.mjs +18 -18
- package/functions/copyFiles.mjs +32 -32
- package/functions/copyFiles.test.mjs +78 -78
- package/functions/copyFonts.mjs +9 -9
- package/functions/copyFonts.test.mjs +32 -32
- package/functions/default.mjs +12 -12
- package/functions/default.test.mjs +33 -33
- package/functions/dist.mjs +8 -8
- package/functions/dist.test.mjs +44 -44
- package/functions/distMinify.mjs +9 -9
- package/functions/distMinify.test.mjs +15 -15
- package/functions/docs.mjs +13 -13
- package/functions/docs.test.mjs +45 -45
- package/functions/gulpConfigEntries.test.mjs +23 -23
- package/functions/images.mjs +8 -8
- package/functions/images.test.mjs +142 -142
- package/functions/jsdocDocs.mjs +10 -10
- package/functions/jsdocEsmExports.test.mjs +24 -24
- package/functions/lint.mjs +9 -9
- package/functions/partials/addToReadme.mjs +25 -25
- package/functions/partials/addToReadme.test.mjs +34 -34
- package/functions/partials/beginWatcher.mjs +9 -9
- package/functions/partials/beginWatcher.test.mjs +19 -19
- package/functions/partials/clean.mjs +13 -13
- package/functions/partials/clean.test.mjs +22 -22
- package/functions/partials/copyFor.mjs +15 -15
- package/functions/partials/copyFor.test.mjs +53 -53
- package/functions/partials/distFor.mjs +22 -22
- package/functions/partials/distFor.test.mjs +195 -195
- package/functions/partials/distForSrc.mjs +11 -11
- package/functions/partials/distForSrc.test.mjs +18 -18
- package/functions/partials/distSeries.mjs +21 -21
- package/functions/partials/distSeries.test.mjs +34 -34
- package/functions/partials/imagesFor.mjs +83 -50
- package/functions/partials/imagesFor.test.mjs +287 -229
- package/functions/partials/jsdocDocsFor.mjs +163 -152
- package/functions/partials/jsdocDocsFor.test.mjs +182 -152
- package/functions/partials/lintSource.mjs +41 -41
- package/functions/partials/loadPeer.mjs +76 -76
- package/functions/partials/loadPeer.test.mjs +58 -58
- package/functions/partials/loadPlaywright.mjs +23 -23
- package/functions/partials/loadPlaywright.test.mjs +70 -70
- package/functions/partials/minifyFor.mjs +15 -15
- package/functions/partials/minifyFor.test.mjs +49 -49
- package/functions/partials/neostandardLint.mjs +142 -142
- package/functions/partials/neostandardLint.test.mjs +131 -131
- package/functions/partials/readmeTemplate.mjs +12 -12
- package/functions/partials/readmeTemplate.test.mjs +34 -34
- package/functions/partials/removeDirectory.mjs +34 -34
- package/functions/partials/removeDirectory.test.mjs +72 -72
- package/functions/partials/resolveDocsMethod.mjs +10 -10
- package/functions/partials/resolveDocsMethod.test.mjs +33 -33
- package/functions/partials/runOnChange.mjs +54 -54
- package/functions/partials/runOnChange.test.mjs +95 -95
- package/functions/partials/sassFor.mjs +25 -25
- package/functions/partials/sassFor.test.mjs +81 -81
- package/functions/partials/serveStatic.mjs +47 -47
- package/functions/partials/serveStatic.test.mjs +71 -71
- package/functions/partials/tsFor.mjs +92 -92
- package/functions/partials/tsFor.test.mjs +88 -88
- package/functions/partials/typeDocsFor.mjs +231 -227
- package/functions/partials/typeDocsFor.test.mjs +263 -252
- package/functions/partials.mjs +31 -31
- package/functions/partials.test.mjs +7 -7
- package/functions/sass.mjs +4 -4
- package/functions/sass.test.mjs +31 -31
- package/functions/sourceLint.mjs +13 -13
- package/functions/sourceLint.test.mjs +166 -166
- package/functions/test-helpers/isolateGulpCache.mjs +16 -16
- package/functions/test-helpers/neostandardLintWithRealNeostandard.mjs +40 -40
- package/functions/test-helpers/setUp.mjs +100 -100
- package/functions/test-helpers/setUp.test.mjs +19 -19
- package/functions/testFull.mjs +17 -17
- package/functions/testFull.test.mjs +17 -17
- package/functions/testHelpers.mjs +10 -10
- package/functions/testHelpers.test.mjs +7 -7
- package/functions/testQuick.mjs +17 -17
- package/functions/testQuick.test.mjs +17 -17
- package/functions/typeDocs.mjs +9 -9
- package/functions/typeDocs.test.mjs +11 -11
- package/functions/typeScript.mjs +8 -8
- package/functions/typeScript.test.mjs +11 -11
- package/functions/utilities/convertMjsFilesForDocs.mjs +34 -34
- package/functions/utilities/convertMjsFilesForDocs.test.mjs +58 -58
- package/functions/utilities/dotGet.mjs +49 -49
- package/functions/utilities/dotNotate.mjs +73 -73
- package/functions/utilities/dotNotate.test.mjs +41 -41
- package/functions/utilities/dotSet.mjs +40 -40
- package/functions/utilities/esmNamedExportsToCjs.mjs +30 -30
- package/functions/utilities/esmNamedExportsToCjs.test.mjs +47 -47
- package/functions/utilities/getBundleConfigs.mjs +30 -30
- package/functions/utilities/isObject.mjs +8 -8
- package/functions/utilities/strAfter.mjs +12 -12
- package/functions/utilities/strBefore.mjs +12 -12
- package/functions/watchFull.mjs +9 -9
- package/functions/watchFull.test.mjs +41 -41
- package/functions/watchTest.mjs +10 -10
- package/functions/watchTest.test.mjs +49 -49
- package/gulp.config.js +4 -4
- package/gulp.config.mjs +344 -327
- package/gulpfile.base.js +51 -51
- package/gulpfile.base.mjs +29 -29
- package/jsdoc.base.js +16 -16
- package/jsdoc.esmExports.js +17 -17
- package/package.json +146 -145
package/functions/build.test.mjs
CHANGED
|
@@ -1,759 +1,763 @@
|
|
|
1
|
-
/* eslint-disable no-template-curly-in-string -- fixture source code, the ${...} is meant to stay literal */
|
|
2
|
-
import fs from 'fs'
|
|
3
|
-
import * as setUp from './test-helpers/setUp.mjs'
|
|
4
|
-
import { build } from './build.mjs'
|
|
5
|
-
import { clean } from './partials/clean.mjs'
|
|
6
|
-
import { sourceLint } from './sourceLint.mjs'
|
|
7
|
-
import { testFull } from './testFull.mjs'
|
|
8
|
-
import { typeDocs } from './typeDocs.mjs'
|
|
9
|
-
import { jsdocDocs } from './jsdocDocs.mjs'
|
|
10
|
-
import { countMatches } from 'test-filesystem'
|
|
11
|
-
import { isolateGulpCache } from './test-helpers/isolateGulpCache.mjs'
|
|
12
|
-
|
|
13
|
-
setUp.setDefaults('test-build')
|
|
14
|
-
const clearImageCache = isolateGulpCache('build')
|
|
15
|
-
const gulpConfig = setUp.gulpConfig
|
|
16
|
-
|
|
17
|
-
const genericFunction = () => Promise.resolve(true)
|
|
18
|
-
|
|
19
|
-
jest.mock('./partials/clean.mjs', () => ({ clean: jest.fn(genericFunction) }))
|
|
20
|
-
jest.mock('./testFull.mjs', () => ({ testFull: jest.fn(genericFunction) }))
|
|
21
|
-
// Real linting is covered by sourceLint.test.mjs. Here it would run a fresh neostandard subprocess for every source
|
|
22
|
-
// file in every test, which pushed these tests past their timeout whenever the whole suite ran in parallel.
|
|
23
|
-
jest.mock('./sourceLint.mjs', () => ({ sourceLint: jest.fn(genericFunction) }))
|
|
24
|
-
// The documentation is generated by TypeDoc or jsdoc, whose own tests cover that (see typeDocsFor.test.mjs /
|
|
25
|
-
// jsdocDocsFor.test.mjs) - jsdocDocs in particular shells out to a real CLI, far too slow for a build.mjs unit
|
|
26
|
-
// test to actually run.
|
|
27
|
-
jest.mock('./typeDocs.mjs', () => ({ typeDocs: jest.fn(genericFunction) }))
|
|
28
|
-
jest.mock('./jsdocDocs.mjs', () => ({ jsdocDocs: jest.fn(genericFunction) }))
|
|
29
|
-
// tsFor's real implementation loads gulp-ts-compile (a genuine ESM-only package) via a dynamic import() hidden
|
|
30
|
-
// from babel's static analysis - necessary for production correctness (see tsFor.mjs's own comments), but this
|
|
31
|
-
// project's current CommonJS-transform-based Jest setup can't execute a real dynamic import at all: it doesn't
|
|
32
|
-
// just fail cleanly, it segfaults the whole Jest worker. Replace the whole module here with a fake that does
|
|
33
|
-
// real (not mocked-away) TypeScript transpilation via `ts.transpileModule`, so the typescript.enabled tests
|
|
34
|
-
// below still exercise genuine compile behavior end to end - gulp-ts-compile's own test suite separately covers
|
|
35
|
-
// its whole-program/cross-file-import behavior.
|
|
36
|
-
jest.mock('./partials/tsFor.mjs', () => ({
|
|
37
|
-
tsFor: (srcPath, distPath) => (done) => {
|
|
38
|
-
const nodeFs = require('fs')
|
|
39
|
-
const nodePath = require('path')
|
|
40
|
-
const glob = require('glob')
|
|
41
|
-
const ts = require('typescript')
|
|
42
|
-
nodeFs.mkdirSync(distPath, { recursive: true })
|
|
43
|
-
for (const file of glob.globSync(srcPath)) {
|
|
44
|
-
const contents = nodeFs.readFileSync(file).toString()
|
|
45
|
-
const { outputText } = ts.transpileModule(contents, { compilerOptions: { declaration: true } })
|
|
46
|
-
const base = nodePath.basename(file).replace(/\.tsx?$/, '')
|
|
47
|
-
nodeFs.writeFileSync(`${distPath}/${base}.js`, outputText)
|
|
48
|
-
nodeFs.writeFileSync(`${distPath}/${base}.d.ts`, '')
|
|
49
|
-
}
|
|
50
|
-
done()
|
|
51
|
-
}
|
|
52
|
-
}))
|
|
53
|
-
|
|
54
|
-
const file1Contents = '/**\n' +
|
|
55
|
-
' * Console log out a greeting with given input.\n' +
|
|
56
|
-
' * @param {string} input\n' +
|
|
57
|
-
' */\n' +
|
|
58
|
-
'const file1 = input => console.log(`Hello from file1 with ${input}`)\n' +
|
|
59
|
-
'\n' +
|
|
60
|
-
'module.exports = file1\n'
|
|
61
|
-
|
|
62
|
-
const file2Contents = '/**\n' +
|
|
63
|
-
' * Farewell with a summation of two numbers returned.\n' +
|
|
64
|
-
' * @param {number} a\n' +
|
|
65
|
-
' * @param {number} b\n' +
|
|
66
|
-
' * @returns {number}\n' +
|
|
67
|
-
' */\n' +
|
|
68
|
-
'const file2 = (a, b) => {\n' +
|
|
69
|
-
' const sum = a + b\n' +
|
|
70
|
-
' console.log(`Good-bye from file2 with sum ${sum}`)\n' +
|
|
71
|
-
' return sum\n' +
|
|
72
|
-
'}\n' +
|
|
73
|
-
'\n' +
|
|
74
|
-
'module.exports = file2\n'
|
|
75
|
-
|
|
76
|
-
const mainTypescript = '/**\n' +
|
|
77
|
-
' * A salutation and summation.\n' +
|
|
78
|
-
' * @param {number} a\n' +
|
|
79
|
-
' * @param {number} b\n' +
|
|
80
|
-
' * @returns {number}\n' +
|
|
81
|
-
' */\n' +
|
|
82
|
-
'const main = (a: number, b: number): number => {\n' +
|
|
83
|
-
' const sum = a + b\n' +
|
|
84
|
-
' console.log(`Greetings from typescript ${sum}`)\n' +
|
|
85
|
-
' return sum\n' +
|
|
86
|
-
'}\n' +
|
|
87
|
-
'\n' +
|
|
88
|
-
'module.exports = main\n'
|
|
89
|
-
|
|
90
|
-
const mainFileContents = '/**\n' +
|
|
91
|
-
' * Some test functions for usage with build tests.\n' +
|
|
92
|
-
' * @file\n' +
|
|
93
|
-
' * @author John Doe <john.doe@example.com>\n' +
|
|
94
|
-
' * @version 3.0.0\n' +
|
|
95
|
-
' * @module test-build\n' +
|
|
96
|
-
' */\n' +
|
|
97
|
-
'\n' +
|
|
98
|
-
'const file1 = require(\'./sources/file1\')\n' +
|
|
99
|
-
'const file2 = require(\'./sources/file2\')\n' +
|
|
100
|
-
'\n' +
|
|
101
|
-
'module.exports = {\n' +
|
|
102
|
-
' file1,\n' +
|
|
103
|
-
' file2,\n' +
|
|
104
|
-
'}\n'
|
|
105
|
-
|
|
106
|
-
const mainMd = '# Welcome\n' +
|
|
107
|
-
'This is the top of the README.md.\n' +
|
|
108
|
-
'\n'
|
|
109
|
-
|
|
110
|
-
const tsConfigContents = '{\n' +
|
|
111
|
-
' "files": ["test-build/src/**/*.ts"],\n' +
|
|
112
|
-
' "compilerOptions": {\n' +
|
|
113
|
-
' "noImplicitAny": true,\n' +
|
|
114
|
-
' "target": "es6",\n' +
|
|
115
|
-
' "moduleResolution": "node",\n' +
|
|
116
|
-
' "declaration": true,\n' +
|
|
117
|
-
' }\n' +
|
|
118
|
-
'}'
|
|
119
|
-
|
|
120
|
-
const fontContent = 'comic sans'
|
|
121
|
-
|
|
122
|
-
const fontPath = gulpConfig.get('srcPath') + '/fonts'
|
|
123
|
-
|
|
124
|
-
const imageContent = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' +
|
|
125
|
-
'<!-- Created with Inkscape (http://www.inkscape.org/) -->\n' +
|
|
126
|
-
'\n' +
|
|
127
|
-
'<svg\n' +
|
|
128
|
-
' xmlns:dc="http://purl.org/dc/elements/1.1/"\n' +
|
|
129
|
-
' xmlns:cc="http://creativecommons.org/ns#"\n' +
|
|
130
|
-
' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n' +
|
|
131
|
-
' xmlns:svg="http://www.w3.org/2000/svg"\n' +
|
|
132
|
-
' xmlns="http://www.w3.org/2000/svg"\n' +
|
|
133
|
-
' xmlns:xlink="http://www.w3.org/1999/xlink"\n' +
|
|
134
|
-
' xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n' +
|
|
135
|
-
' xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n' +
|
|
136
|
-
' id="svg2"\n' +
|
|
137
|
-
' version="1.1"\n' +
|
|
138
|
-
' inkscape:version="0.91 r13725"\n' +
|
|
139
|
-
' width="600"\n' +
|
|
140
|
-
' height="600"\n' +
|
|
141
|
-
' viewBox="0 0 600 600"\n' +
|
|
142
|
-
' sodipodi:docname="logo.svg">\n' +
|
|
143
|
-
' <metadata\n' +
|
|
144
|
-
' id="metadata8">\n' +
|
|
145
|
-
' <rdf:RDF>\n' +
|
|
146
|
-
' <cc:Work\n' +
|
|
147
|
-
' rdf:about="">\n' +
|
|
148
|
-
' <dc:format>image/svg+xml</dc:format>\n' +
|
|
149
|
-
' <dc:type\n' +
|
|
150
|
-
' rdf:resource="http://purl.org/dc/dcmitype/StillImage" />\n' +
|
|
151
|
-
' <dc:title></dc:title>\n' +
|
|
152
|
-
' </cc:Work>\n' +
|
|
153
|
-
' </rdf:RDF>\n' +
|
|
154
|
-
' </metadata>\n' +
|
|
155
|
-
' <defs\n' +
|
|
156
|
-
' id="defs6" />\n' +
|
|
157
|
-
' <sodipodi:namedview\n' +
|
|
158
|
-
' pagecolor="#ffffff"\n' +
|
|
159
|
-
' bordercolor="#666666"\n' +
|
|
160
|
-
' borderopacity="1"\n' +
|
|
161
|
-
' objecttolerance="10"\n' +
|
|
162
|
-
' gridtolerance="10"\n' +
|
|
163
|
-
' guidetolerance="10"\n' +
|
|
164
|
-
' inkscape:pageopacity="0"\n' +
|
|
165
|
-
' inkscape:pageshadow="2"\n' +
|
|
166
|
-
' inkscape:window-width="1280"\n' +
|
|
167
|
-
' inkscape:window-height="737"\n' +
|
|
168
|
-
' id="namedview4"\n' +
|
|
169
|
-
' showgrid="false"\n' +
|
|
170
|
-
' inkscape:zoom="0.39333333"\n' +
|
|
171
|
-
' inkscape:cx="300"\n' +
|
|
172
|
-
' inkscape:cy="300"\n' +
|
|
173
|
-
' inkscape:window-x="-8"\n' +
|
|
174
|
-
' inkscape:window-y="-8"\n' +
|
|
175
|
-
' inkscape:window-maximized="1"\n' +
|
|
176
|
-
' inkscape:current-layer="svg2" />\n' +
|
|
177
|
-
' <image\n' +
|
|
178
|
-
' width="600"\n' +
|
|
179
|
-
' height="600"\n' +
|
|
180
|
-
' preserveAspectRatio="none"\n' +
|
|
181
|
-
' xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAYAAACLz2ctAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n' +
|
|
182
|
-
'AAADsQAAA7EB9YPtSQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAhrSURB\n' +
|
|
183
|
-
'VHic7d3fi1x3Gcfx97M7TdKYYNPYbLaxlVZrUaK1iviToiIpeNFIwQuLBW8UEQTv9C/wSvDS+yKo\n' +
|
|
184
|
-
'CFopiFe2QVpqMKVYf0DaRmibZnfTRp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llAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAl\n' +
|
|
220
|
-
'lAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAllAIooRRACaUASigFUEL9D1MqMi7YkUEVAAAAAElF\n' +
|
|
221
|
-
'TkSuQmCC\n' +
|
|
222
|
-
'"\n' +
|
|
223
|
-
' id="image10"\n' +
|
|
224
|
-
' x="0"\n' +
|
|
225
|
-
' y="0" />\n' +
|
|
226
|
-
' <path\n' +
|
|
227
|
-
' style="fill:#000000"\n' +
|
|
228
|
-
' d="M 19.039097,494.38241 C 2.0018627,482.75861 -2.8301068,468.02182 5.0071177,451.587 8.2776829,444.72855 15.162733,436.35919 20.307229,432.98839 c 8.904129,-5.83422 9.948263,-5.67522 21.727331,3.30915 28.014638,21.3678 44.091105,18.882 51.54879,-7.97059 C 99.533959,406.9008 98.83533,123.18555 92.8125,115.28305 90.196335,111.85041 81.496733,108.63382 73.125,108.00381 58.734191,106.92084 58.077731,106.30388 56.961131,92.8125 L 55.797259,78.75 l 163.053411,0 163.05342,0 2.57381,11.71845 c 2.93006,13.34047 -1.71086,18.13302 -17.64754,18.22413 C 347.54041,108.80285 345,115.82292 345,169.01786 l 0,48.48214 67.5,0 67.5,0 0,-48.1688 c 0,-41.90267 -0.89209,-48.97614 -6.85778,-54.37499 C 469.37044,111.54279 462.75847,108.75 458.44894,108.75 443.44309,108.75 438.75,104.6341 438.75,91.473791 l 0,-12.723791 80.85139,0 80.85135,0 -1.16385,14.0625 c -1.13201,13.67745 -1.60515,14.09431 -17.27948,15.22432 -13.44982,0.96964 -16.73767,2.79799 -19.87627,11.0531 -5.80185,15.26002 -2.83763,249.42009 3.25016,256.74719 2.61705,3.14985 11.47643,6.80123 19.6875,8.11425 14.52533,2.32268 14.9292,2.79386 14.9292,17.41755 l 0,15.03026 -79.6875,-1.01208 -79.6875,-1.01209 -1.1367,-13.60684 c -1.13565,-13.59401 -1.11975,-13.60939 16.875,-16.30515 9.90645,-1.4841 19.25149,-4.64227 20.76679,-7.01816 1.5153,-2.37593 2.78092,-30.05423 2.8125,-61.50735 L 480,258.75 l -67.59289,0 -67.5929,0 1.0304,60.9375 1.03039,60.9375 19.6875,3.3399 c 20.4921,3.4764 22.16576,5.78036 17.32391,23.8476 -2.25337,8.40847 -2.53065,8.4375 -80.57378,8.4375 l -78.31263,0 0,-14.95567 c 0,-14.53673 0.41823,-15.02258 14.9292,-17.34297 8.21107,-1.31302 17.07044,-4.96657 19.6875,-8.11909 3.63727,-4.38139 4.7583,-35.56081 4.7583,-132.34294 0,-69.63615 -1.23091,-127.84279 -2.73535,-129.3481 -9.73748,-9.7431 -68.9232,-8.34789 -79.15408,1.86593 -3.08612,3.08097 -4.99292,46.77065 -6.52417,149.48557 -1.45514,97.60931 -3.64592,149.67975 -6.6905,159.01994 -13.55129,41.57292 -61.40288,74.9124 -111.000242,77.33685 -22.754302,1.11229 -28.166407,0.0821 -39.231561,-7.46711 z"\n' +
|
|
229
|
-
' id="path3338"\n' +
|
|
230
|
-
' inkscape:connector-curvature="0" />\n' +
|
|
231
|
-
'</svg>\n'
|
|
232
|
-
|
|
233
|
-
const imageCompressed = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="600" height="600"><image width="600" height="600" preserveAspectRatio="none" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAYAAACLz2ctAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz AAADsQAAA7EB9YPtSQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAhrSURB VHic7d3fi1x3Gcfx97M7TdKYYNPYbLaxlVZrUaK1iviToiIpeNFIwQuLBW8UEQTv9C/wSvDS+yKo CFopiFe2QVpqMKVYf0DaRmibZnfTRpNs9lez+3hxzq7T3ZnZmXO+3/PMmf284DDJzJznPGfOZ79n zpmzs+buiESZim5A9jYFUEIpgBJKAZRQCqCEUgAllAIooRRACaUASigFUEIpgBJKA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Lu04n62e4m8ITCN7mmgLuimxjgyQpH3dIiHXZeqz8OHHjK3Z+P bkTy6pDuHF0qDvzG3c9GNyL5TQEXopvosg78QuHbOzrAq9FNlK4Cv3L3l6MbkeZ03P2qmV1mhC+U yeAcxQHHcmAPEmDzk5AzQcu/QXGa5ZcK395kxe9qg5mdAk41tNw14FngaXdfamiZMoa2AghgZl8H vphxee9Q/E7G0+6+mHE50hLbA2jA14CHSHt6Zg54EfiLu9f5ZRuZMO8K4NadxdeHPUzx7UZVP8+9 TBG6F919vnKHMtF6BnDrQbNZ4LMU3yY1w84v7naKX6C+QXFRwhubk7vfyNGwTJaBAdzxZLMDwBGK g4glYMVHKSCyzUgBFEmtzd+OJRNAAZRQCqCEUgAllAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAl lAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAllAIooRRACaUASigFUEL9D1MqMi7YkUEVAAAAAElF TkSuQmCC"/><path style="fill:#000" d="M19.04 494.382C2.001 482.76-2.83 468.022 5.006 451.587c3.27-6.858 10.156-15.228 15.3-18.599 8.904-5.834 9.948-5.675 21.728 3.31 28.014 21.367 44.09 18.882 51.548-7.971 5.951-21.426 5.252-305.141-.77-313.044-2.617-3.433-11.316-6.65-19.688-7.28-14.39-1.082-15.047-1.7-16.164-15.19L55.797 78.75h326.107l2.574 11.718c2.93 13.34-1.711 18.133-17.648 18.225-19.29.11-21.83 7.13-21.83 60.325V217.5h135v-48.169c0-41.902-.892-48.976-6.858-54.375-3.772-3.413-10.384-6.206-14.693-6.206-15.006 0-19.699-4.116-19.699-17.276V78.75h161.703l-1.164 14.063c-1.132 13.677-1.605 14.094-17.28 15.224-13.45.97-16.737 2.798-19.876 11.053-5.802 15.26-2.837 249.42 3.25 256.747 2.617 3.15 11.477 6.801 19.688 8.114C599.596 386.274 600 386.745 600 401.37v15.03l-79.687-1.012-79.688-1.012-1.137-13.607c-1.135-13.594-1.12-13.61 16.875-16.305 9.907-1.484 19.252-4.642 20.767-7.018 1.515-2.376 2.781-30.054 2.813-61.508L480 258.75H344.814l1.03 60.938 1.031 60.937 19.688 3.34c20.492 3.476 22.165 5.78 17.323 23.848-2.253 8.408-2.53 8.437-80.573 8.437H225v-14.956c0-14.536.418-15.022 14.93-17.343 8.21-1.313 17.07-4.966 19.687-8.119 3.637-4.381 4.758-35.56 4.758-132.343 0-69.636-1.23-127.842-2.735-129.348-9.738-9.743-68.924-8.348-79.154 1.866-3.087 3.081-4.993 46.77-6.525 149.486-1.455 97.609-3.646 149.68-6.69 159.02-13.551 41.573-61.403 74.912-111 77.337-22.755 1.112-28.167.082-39.232-7.468z"/></svg>'
|
|
234
|
-
|
|
235
|
-
const imagePath = gulpConfig.get('srcPath') + '/img'
|
|
236
|
-
|
|
237
|
-
const sassContents = 'html\n' +
|
|
238
|
-
' font-size: 62.5%\n' +
|
|
239
|
-
' color: #444\n' +
|
|
240
|
-
' font-size: 1em\n' +
|
|
241
|
-
' line-height: 1.4\n' +
|
|
242
|
-
' background-color: #fff\n' +
|
|
243
|
-
'\n' +
|
|
244
|
-
'html, body\n' +
|
|
245
|
-
' width: 100%\n' +
|
|
246
|
-
' height: 100%\n' +
|
|
247
|
-
' margin: 0\n' +
|
|
248
|
-
' padding: 0\n' +
|
|
249
|
-
' position: absolute\n' +
|
|
250
|
-
' text-align: center\n' +
|
|
251
|
-
'\n' +
|
|
252
|
-
'a\n' +
|
|
253
|
-
' outline: none\n' +
|
|
254
|
-
' text-decoration: none'
|
|
255
|
-
|
|
256
|
-
const sassPath = gulpConfig.get('sass.path')
|
|
257
|
-
|
|
258
|
-
// The cache outlives a run, so clear it or a stale result from an older imagemin can pass
|
|
259
|
-
beforeEach(
|
|
260
|
-
() => clearImageCache()
|
|
261
|
-
.then(setUp.beforeEach)
|
|
262
|
-
.then(
|
|
263
|
-
async () => {
|
|
264
|
-
const srcPath = gulpConfig.get('srcPath')
|
|
265
|
-
const readmePath = gulpConfig.get('readme.to')
|
|
266
|
-
const sourcesPath = `${srcPath}/sources`
|
|
267
|
-
await fs.mkdirSync(sourcesPath)
|
|
268
|
-
await fs.mkdirSync(fontPath, { recursive: true })
|
|
269
|
-
await fs.mkdirSync(imagePath, { recursive: true })
|
|
270
|
-
await fs.mkdirSync(sassPath, { recursive: true })
|
|
271
|
-
return fs.writeFileSync(`${readmePath}/MAIN.md`, mainMd)
|
|
272
|
-
}
|
|
273
|
-
)
|
|
274
|
-
)
|
|
275
|
-
|
|
276
|
-
afterEach(setUp.afterEach)
|
|
277
|
-
|
|
278
|
-
describe('build', () => {
|
|
279
|
-
test('when browser.enabled false: calls clean, sourceLint, distSeries, distMinify, compileReadme, testFull', done => {
|
|
280
|
-
const srcPath = gulpConfig.get('srcPath')
|
|
281
|
-
const sourcesPath = `${srcPath}/sources`
|
|
282
|
-
const distPath = gulpConfig.get('dist.to')
|
|
283
|
-
const distSourcesPath = `${distPath}/sources`
|
|
284
|
-
const readmePath = gulpConfig.get('readme.to')
|
|
285
|
-
const readmeFile = gulpConfig.get('readme.file')
|
|
286
|
-
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
287
|
-
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
288
|
-
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
289
|
-
gulpConfig.set('browser.enabled', false)
|
|
290
|
-
expect.assertions(13)
|
|
291
|
-
build(() => {
|
|
292
|
-
// Called 'clean'
|
|
293
|
-
expect(clean).toHaveBeenCalled()
|
|
294
|
-
|
|
295
|
-
// Created dist directory (distSeries)
|
|
296
|
-
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
297
|
-
|
|
298
|
-
// Minify the dist files (distMinify)
|
|
299
|
-
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
300
|
-
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
301
|
-
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
302
|
-
|
|
303
|
-
expect(fs.existsSync(`${distSourcesPath}/file1.min.js`)).toBeTruthy()
|
|
304
|
-
const babelifiedFile1 = fs.readFileSync(`${distSourcesPath}/file1.js`).toString()
|
|
305
|
-
expect(babelifiedFile1.includes('use strict')).toBe(true)
|
|
306
|
-
|
|
307
|
-
expect(fs.existsSync(`${distSourcesPath}/file2.min.js`)).toBeTruthy()
|
|
308
|
-
const babelifiedFile2 = fs.readFileSync(`${distSourcesPath}/file2.js`).toString()
|
|
309
|
-
expect(babelifiedFile2.includes('use strict')).toBe(true)
|
|
310
|
-
|
|
311
|
-
// Generated README.md (compileReadme)
|
|
312
|
-
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
313
|
-
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
314
|
-
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
315
|
-
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
316
|
-
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
317
|
-
|
|
318
|
-
// Ran 'testFull'
|
|
319
|
-
expect(testFull).toHaveBeenCalled()
|
|
320
|
-
done()
|
|
321
|
-
})
|
|
322
|
-
}, 30000)
|
|
323
|
-
|
|
324
|
-
test('when browser.enabled true: calls clean, sourceLint, distSeries, distMinify, bundle, bundleMinify, compileReadme, testFull', done => {
|
|
325
|
-
const srcPath = gulpConfig.get('srcPath')
|
|
326
|
-
const sourcesPath = `${srcPath}/sources`
|
|
327
|
-
const distPath = gulpConfig.get('dist.to')
|
|
328
|
-
const browserFile = gulpConfig.get('browser.name')
|
|
329
|
-
const browserPath = gulpConfig.get('browser.to')
|
|
330
|
-
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
331
|
-
const readmePath = gulpConfig.get('readme.to')
|
|
332
|
-
const readmeFile = gulpConfig.get('readme.file')
|
|
333
|
-
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
334
|
-
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
335
|
-
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
336
|
-
gulpConfig.set('browser.enabled', true)
|
|
337
|
-
expect.assertions(13)
|
|
338
|
-
build(() => {
|
|
339
|
-
// Called 'clean'
|
|
340
|
-
expect(clean).toHaveBeenCalled()
|
|
341
|
-
|
|
342
|
-
// Created dist directory (distSeries)
|
|
343
|
-
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
344
|
-
|
|
345
|
-
// Minify the dist files (distMinify)
|
|
346
|
-
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
347
|
-
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
348
|
-
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
349
|
-
|
|
350
|
-
// Created browser directory (bundle)
|
|
351
|
-
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
352
|
-
|
|
353
|
-
// Minify the browser files (bundleMinify)
|
|
354
|
-
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
355
|
-
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
356
|
-
expect(countMatches(bundledContents, 'file1')).toEqual(7)
|
|
357
|
-
expect(countMatches(bundledContents, 'file2')).toEqual(7)
|
|
358
|
-
|
|
359
|
-
// Generated README.md (compileReadme)
|
|
360
|
-
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
361
|
-
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
362
|
-
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
363
|
-
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
364
|
-
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
365
|
-
|
|
366
|
-
// Ran 'testFull'
|
|
367
|
-
expect(testFull).toHaveBeenCalled()
|
|
368
|
-
done()
|
|
369
|
-
})
|
|
370
|
-
}, 30000)
|
|
371
|
-
|
|
372
|
-
test('when browser.enabled true and fonts.enabled true: calls clean, sourceLint, distSeries, distMinify, bundle, bundleMinify, compileReadme, testFull, copyFonts', done => {
|
|
373
|
-
const srcPath = gulpConfig.get('srcPath')
|
|
374
|
-
const sourcesPath = `${srcPath}/sources`
|
|
375
|
-
const distPath = gulpConfig.get('dist.to')
|
|
376
|
-
const browserFile = gulpConfig.get('browser.name')
|
|
377
|
-
const browserPath = gulpConfig.get('browser.to')
|
|
378
|
-
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
379
|
-
const readmePath = gulpConfig.get('readme.to')
|
|
380
|
-
const readmeFile = gulpConfig.get('readme.file')
|
|
381
|
-
const fontFile = `${fontPath}/comic-sans.woff`
|
|
382
|
-
fs.writeFileSync(fontFile, fontContent)
|
|
383
|
-
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
384
|
-
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
385
|
-
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
386
|
-
gulpConfig.set('browser.enabled', true)
|
|
387
|
-
gulpConfig.set('fonts.enabled', true)
|
|
388
|
-
expect.assertions(14)
|
|
389
|
-
build(() => {
|
|
390
|
-
// Called 'clean'
|
|
391
|
-
expect(clean).toHaveBeenCalled()
|
|
392
|
-
|
|
393
|
-
// Created dist directory (distSeries)
|
|
394
|
-
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
395
|
-
|
|
396
|
-
// Minify the dist files (distMinify)
|
|
397
|
-
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
398
|
-
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
399
|
-
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
400
|
-
|
|
401
|
-
// Created browser directory (bundle)
|
|
402
|
-
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
403
|
-
|
|
404
|
-
// Minify the browser files (bundleMinify)
|
|
405
|
-
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
406
|
-
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
407
|
-
expect(countMatches(bundledContents, 'file1')).toEqual(7)
|
|
408
|
-
expect(countMatches(bundledContents, 'file2')).toEqual(7)
|
|
409
|
-
|
|
410
|
-
// Generated README.md (compileReadme)
|
|
411
|
-
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
412
|
-
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
413
|
-
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
414
|
-
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
415
|
-
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
416
|
-
|
|
417
|
-
// Ran 'testFull'
|
|
418
|
-
expect(testFull).toHaveBeenCalled()
|
|
419
|
-
|
|
420
|
-
// Ran 'fonts'
|
|
421
|
-
const fontDest = gulpConfig.get('fonts.to')
|
|
422
|
-
const movedFont = fs.readFileSync(`${fontDest}/comic-sans.woff`).toString()
|
|
423
|
-
expect(movedFont).toEqual(fontContent)
|
|
424
|
-
|
|
425
|
-
done()
|
|
426
|
-
})
|
|
427
|
-
}, 30000)
|
|
428
|
-
|
|
429
|
-
test('when browser.enabled true and images.enabled true: calls clean, sourceLint, distSeries, distMinify, bundle, bundleMinify, compileReadme, testFull, images', done => {
|
|
430
|
-
const srcPath = gulpConfig.get('srcPath')
|
|
431
|
-
const sourcesPath = `${srcPath}/sources`
|
|
432
|
-
const distPath = gulpConfig.get('dist.to')
|
|
433
|
-
const browserFile = gulpConfig.get('browser.name')
|
|
434
|
-
const browserPath = gulpConfig.get('browser.to')
|
|
435
|
-
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
436
|
-
const readmePath = gulpConfig.get('readme.to')
|
|
437
|
-
const readmeFile = gulpConfig.get('readme.file')
|
|
438
|
-
const imageFile = `${imagePath}/logo.svg`
|
|
439
|
-
fs.writeFileSync(imageFile, imageContent)
|
|
440
|
-
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
441
|
-
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
442
|
-
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
443
|
-
gulpConfig.set('browser.enabled', true)
|
|
444
|
-
gulpConfig.set('images.enabled', true)
|
|
445
|
-
expect.assertions(14)
|
|
446
|
-
build(() => {
|
|
447
|
-
// Called 'clean'
|
|
448
|
-
expect(clean).toHaveBeenCalled()
|
|
449
|
-
|
|
450
|
-
// Created dist directory (distSeries)
|
|
451
|
-
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
452
|
-
|
|
453
|
-
// Minify the dist files (distMinify)
|
|
454
|
-
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
455
|
-
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
456
|
-
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
457
|
-
|
|
458
|
-
// Created browser directory (bundle)
|
|
459
|
-
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
460
|
-
|
|
461
|
-
// Minify the browser files (bundleMinify)
|
|
462
|
-
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
463
|
-
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
464
|
-
expect(countMatches(bundledContents, 'file1')).toEqual(7)
|
|
465
|
-
expect(countMatches(bundledContents, 'file2')).toEqual(7)
|
|
466
|
-
|
|
467
|
-
// Generated README.md (compileReadme)
|
|
468
|
-
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
469
|
-
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
470
|
-
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
471
|
-
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
472
|
-
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
473
|
-
|
|
474
|
-
// Ran 'testFull'
|
|
475
|
-
expect(testFull).toHaveBeenCalled()
|
|
476
|
-
|
|
477
|
-
// Ran 'images'
|
|
478
|
-
const imageDest = gulpConfig.get('images.to')
|
|
479
|
-
const movedImage = fs.readFileSync(`${imageDest}/logo.svg`).toString()
|
|
480
|
-
expect(movedImage).toEqual(imageCompressed)
|
|
481
|
-
|
|
482
|
-
done()
|
|
483
|
-
})
|
|
484
|
-
}, 30000)
|
|
485
|
-
|
|
486
|
-
test('when browser.enabled true and sass.enabled true: calls clean, sourceLint, distSeries, distMinify, bundle, bundleMinify, compileReadme, testFull, sass', done => {
|
|
487
|
-
const srcPath = gulpConfig.get('srcPath')
|
|
488
|
-
const sourcesPath = `${srcPath}/sources`
|
|
489
|
-
const distPath = gulpConfig.get('dist.to')
|
|
490
|
-
const browserFile = gulpConfig.get('browser.name')
|
|
491
|
-
const browserPath = gulpConfig.get('browser.to')
|
|
492
|
-
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
493
|
-
const readmePath = gulpConfig.get('readme.to')
|
|
494
|
-
const readmeFile = gulpConfig.get('readme.file')
|
|
495
|
-
const sassFile = `${sassPath}/sassFor.sass`
|
|
496
|
-
fs.writeFileSync(sassFile, sassContents)
|
|
497
|
-
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
498
|
-
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
499
|
-
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
500
|
-
gulpConfig.set('browser.enabled', true)
|
|
501
|
-
gulpConfig.set('sass.enabled', true)
|
|
502
|
-
expect.assertions(16)
|
|
503
|
-
build(() => {
|
|
504
|
-
// Called 'clean'
|
|
505
|
-
expect(clean).toHaveBeenCalled()
|
|
506
|
-
|
|
507
|
-
// Created dist directory (distSeries)
|
|
508
|
-
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
509
|
-
|
|
510
|
-
// Minify the dist files (distMinify)
|
|
511
|
-
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
512
|
-
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
513
|
-
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
514
|
-
|
|
515
|
-
// Created browser directory (bundle)
|
|
516
|
-
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
517
|
-
|
|
518
|
-
// Minify the browser files (bundleMinify)
|
|
519
|
-
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
520
|
-
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
521
|
-
expect(countMatches(bundledContents, 'file1')).toEqual(7)
|
|
522
|
-
expect(countMatches(bundledContents, 'file2')).toEqual(7)
|
|
523
|
-
|
|
524
|
-
// Generated README.md (compileReadme)
|
|
525
|
-
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
526
|
-
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
527
|
-
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
528
|
-
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
529
|
-
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
530
|
-
|
|
531
|
-
// Ran 'testFull'
|
|
532
|
-
expect(testFull).toHaveBeenCalled()
|
|
533
|
-
|
|
534
|
-
// Ran 'sass'
|
|
535
|
-
const cssPath = gulpConfig.get('sass.to')
|
|
536
|
-
const cssContents = fs.readFileSync(`${cssPath}/sassFor.css`).toString()
|
|
537
|
-
expect(countMatches(cssContents, ';')).toEqual(13)
|
|
538
|
-
expect(countMatches(cssContents, '{')).toEqual(3)
|
|
539
|
-
expect(countMatches(cssContents, '}')).toEqual(3)
|
|
540
|
-
|
|
541
|
-
done()
|
|
542
|
-
})
|
|
543
|
-
}, 30000)
|
|
544
|
-
|
|
545
|
-
test('when browser.enabled false and typescript.enabled set: calls clean, sourceLint, tsFor, distFor, distMinify, compileReadme, testFull', done => {
|
|
546
|
-
const srcPath = gulpConfig.get('srcPath')
|
|
547
|
-
const rootPath = gulpConfig.get('rootPath')
|
|
548
|
-
const tsConfig = `${rootPath}/tsconfig.json`
|
|
549
|
-
const distPath = gulpConfig.get('dist.to')
|
|
550
|
-
const readmePath = gulpConfig.get('readme.to')
|
|
551
|
-
const readmeFile = gulpConfig.get('readme.file')
|
|
552
|
-
fs.writeFileSync(`${srcPath}/main.ts`, mainTypescript)
|
|
553
|
-
fs.writeFileSync(tsConfig, tsConfigContents)
|
|
554
|
-
gulpConfig.set('browser.enabled', false)
|
|
555
|
-
gulpConfig.set('typescript.config', tsConfig)
|
|
556
|
-
gulpConfig.set('typescript.enabled', true)
|
|
557
|
-
gulpConfig.set('readme.from', `${distPath}/**/*.js`)
|
|
558
|
-
expect.assertions(8)
|
|
559
|
-
build(() => {
|
|
560
|
-
// Called 'clean'
|
|
561
|
-
expect(clean).toHaveBeenCalled()
|
|
562
|
-
|
|
563
|
-
// Created dist directory (distSeries)
|
|
564
|
-
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
565
|
-
// Created declaration file
|
|
566
|
-
expect(fs.existsSync(`${distPath}/main.d.ts`)).toBeTruthy()
|
|
567
|
-
|
|
568
|
-
// Minify the dist files (distMinify)
|
|
569
|
-
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
570
|
-
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
571
|
-
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
572
|
-
|
|
573
|
-
// Generated README.md (compileReadme)
|
|
574
|
-
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
575
|
-
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
576
|
-
expect(countMatches(readmeContents, 'main')).toEqual(2)
|
|
577
|
-
|
|
578
|
-
// Ran 'testFull'
|
|
579
|
-
expect(testFull).toHaveBeenCalled()
|
|
580
|
-
done()
|
|
581
|
-
})
|
|
582
|
-
}, 30000)
|
|
583
|
-
|
|
584
|
-
test('when browser.enabled true and typescript.enabled set: calls clean, sourceLint, tsFor, distFor, distMinify, bundle, bundleMinify, compileReadme, testFull', done => {
|
|
585
|
-
const srcPath = gulpConfig.get('srcPath')
|
|
586
|
-
const rootPath = gulpConfig.get('rootPath')
|
|
587
|
-
const tsConfig = `${rootPath}/tsconfig.json`
|
|
588
|
-
const distPath = gulpConfig.get('dist.to')
|
|
589
|
-
const browserFile = gulpConfig.get('browser.name')
|
|
590
|
-
const browserPath = gulpConfig.get('browser.to')
|
|
591
|
-
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
592
|
-
const readmePath = gulpConfig.get('readme.to')
|
|
593
|
-
const readmeFile = gulpConfig.get('readme.file')
|
|
594
|
-
fs.writeFileSync(`${srcPath}/main.ts`, mainTypescript)
|
|
595
|
-
fs.writeFileSync(tsConfig, tsConfigContents)
|
|
596
|
-
gulpConfig.set('browser.enabled', true)
|
|
597
|
-
gulpConfig.set('typescript.config', tsConfig)
|
|
598
|
-
gulpConfig.set('typescript.enabled', true)
|
|
599
|
-
gulpConfig.set('readme.from', `${distPath}/**/*.js`)
|
|
600
|
-
expect.assertions(11)
|
|
601
|
-
build(() => {
|
|
602
|
-
// Called 'clean'
|
|
603
|
-
expect(clean).toHaveBeenCalled()
|
|
604
|
-
|
|
605
|
-
// Created dist directory (distSeries)
|
|
606
|
-
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
607
|
-
// Created declaration file
|
|
608
|
-
expect(fs.existsSync(`${distPath}/main.d.ts`)).toBeTruthy()
|
|
609
|
-
|
|
610
|
-
// Minify the dist files (distMinify)
|
|
611
|
-
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
612
|
-
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
613
|
-
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
614
|
-
|
|
615
|
-
// Created browser directory (bundle)
|
|
616
|
-
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
617
|
-
|
|
618
|
-
// Minify the browser files (bundleMinify)
|
|
619
|
-
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
620
|
-
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
621
|
-
expect(countMatches(bundledContents, 'main')).toEqual(2)
|
|
622
|
-
|
|
623
|
-
// Generated README.md (compileReadme)
|
|
624
|
-
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
625
|
-
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
626
|
-
expect(countMatches(readmeContents, 'main')).toEqual(2)
|
|
627
|
-
|
|
628
|
-
// Ran 'testFull'
|
|
629
|
-
expect(testFull).toHaveBeenCalled()
|
|
630
|
-
done()
|
|
631
|
-
})
|
|
632
|
-
}, 30000)
|
|
633
|
-
|
|
634
|
-
test('when docs.enabled is set: generates the documentation from the TypeScript source instead of the readme', done => {
|
|
635
|
-
const srcPath = gulpConfig.get('srcPath')
|
|
636
|
-
const rootPath = gulpConfig.get('rootPath')
|
|
637
|
-
const tsConfig = `${rootPath}/tsconfig.json`
|
|
638
|
-
const readmePath = gulpConfig.get('readme.to')
|
|
639
|
-
const readmeFile = gulpConfig.get('readme.file')
|
|
640
|
-
fs.writeFileSync(`${srcPath}/main.ts`, mainTypescript)
|
|
641
|
-
fs.writeFileSync(tsConfig, tsConfigContents)
|
|
642
|
-
fs.rmSync(`${readmePath}/${readmeFile}`, { force: true })
|
|
643
|
-
typeDocs.mockClear()
|
|
644
|
-
gulpConfig.set('browser.enabled', false)
|
|
645
|
-
gulpConfig.set('typescript.config', tsConfig)
|
|
646
|
-
gulpConfig.set('typescript.enabled', true)
|
|
647
|
-
gulpConfig.set('docs.enabled', true)
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
expect(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
gulpConfig.set('
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
expect(
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
gulpConfig.set('
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
expect(
|
|
697
|
-
expect(
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
gulpConfig.set('
|
|
714
|
-
|
|
715
|
-
gulpConfig.set('
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
events.push('
|
|
741
|
-
resolve(true)
|
|
742
|
-
},
|
|
743
|
-
|
|
744
|
-
events.push('
|
|
745
|
-
|
|
746
|
-
})
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
gulpConfig.set('
|
|
753
|
-
gulpConfig.set('
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
1
|
+
/* eslint-disable no-template-curly-in-string -- fixture source code, the ${...} is meant to stay literal */
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import * as setUp from './test-helpers/setUp.mjs'
|
|
4
|
+
import { build } from './build.mjs'
|
|
5
|
+
import { clean } from './partials/clean.mjs'
|
|
6
|
+
import { sourceLint } from './sourceLint.mjs'
|
|
7
|
+
import { testFull } from './testFull.mjs'
|
|
8
|
+
import { typeDocs } from './typeDocs.mjs'
|
|
9
|
+
import { jsdocDocs } from './jsdocDocs.mjs'
|
|
10
|
+
import { countMatches } from 'test-filesystem'
|
|
11
|
+
import { isolateGulpCache } from './test-helpers/isolateGulpCache.mjs'
|
|
12
|
+
|
|
13
|
+
setUp.setDefaults('test-build')
|
|
14
|
+
const clearImageCache = isolateGulpCache('build')
|
|
15
|
+
const gulpConfig = setUp.gulpConfig
|
|
16
|
+
|
|
17
|
+
const genericFunction = () => Promise.resolve(true)
|
|
18
|
+
|
|
19
|
+
jest.mock('./partials/clean.mjs', () => ({ clean: jest.fn(genericFunction) }))
|
|
20
|
+
jest.mock('./testFull.mjs', () => ({ testFull: jest.fn(genericFunction) }))
|
|
21
|
+
// Real linting is covered by sourceLint.test.mjs. Here it would run a fresh neostandard subprocess for every source
|
|
22
|
+
// file in every test, which pushed these tests past their timeout whenever the whole suite ran in parallel.
|
|
23
|
+
jest.mock('./sourceLint.mjs', () => ({ sourceLint: jest.fn(genericFunction) }))
|
|
24
|
+
// The documentation is generated by TypeDoc or jsdoc, whose own tests cover that (see typeDocsFor.test.mjs /
|
|
25
|
+
// jsdocDocsFor.test.mjs) - jsdocDocs in particular shells out to a real CLI, far too slow for a build.mjs unit
|
|
26
|
+
// test to actually run.
|
|
27
|
+
jest.mock('./typeDocs.mjs', () => ({ typeDocs: jest.fn(genericFunction) }))
|
|
28
|
+
jest.mock('./jsdocDocs.mjs', () => ({ jsdocDocs: jest.fn(genericFunction) }))
|
|
29
|
+
// tsFor's real implementation loads gulp-ts-compile (a genuine ESM-only package) via a dynamic import() hidden
|
|
30
|
+
// from babel's static analysis - necessary for production correctness (see tsFor.mjs's own comments), but this
|
|
31
|
+
// project's current CommonJS-transform-based Jest setup can't execute a real dynamic import at all: it doesn't
|
|
32
|
+
// just fail cleanly, it segfaults the whole Jest worker. Replace the whole module here with a fake that does
|
|
33
|
+
// real (not mocked-away) TypeScript transpilation via `ts.transpileModule`, so the typescript.enabled tests
|
|
34
|
+
// below still exercise genuine compile behavior end to end - gulp-ts-compile's own test suite separately covers
|
|
35
|
+
// its whole-program/cross-file-import behavior.
|
|
36
|
+
jest.mock('./partials/tsFor.mjs', () => ({
|
|
37
|
+
tsFor: (srcPath, distPath) => (done) => {
|
|
38
|
+
const nodeFs = require('fs')
|
|
39
|
+
const nodePath = require('path')
|
|
40
|
+
const glob = require('glob')
|
|
41
|
+
const ts = require('typescript')
|
|
42
|
+
nodeFs.mkdirSync(distPath, { recursive: true })
|
|
43
|
+
for (const file of glob.globSync(srcPath)) {
|
|
44
|
+
const contents = nodeFs.readFileSync(file).toString()
|
|
45
|
+
const { outputText } = ts.transpileModule(contents, { compilerOptions: { declaration: true } })
|
|
46
|
+
const base = nodePath.basename(file).replace(/\.tsx?$/, '')
|
|
47
|
+
nodeFs.writeFileSync(`${distPath}/${base}.js`, outputText)
|
|
48
|
+
nodeFs.writeFileSync(`${distPath}/${base}.d.ts`, '')
|
|
49
|
+
}
|
|
50
|
+
done()
|
|
51
|
+
}
|
|
52
|
+
}))
|
|
53
|
+
|
|
54
|
+
const file1Contents = '/**\n' +
|
|
55
|
+
' * Console log out a greeting with given input.\n' +
|
|
56
|
+
' * @param {string} input\n' +
|
|
57
|
+
' */\n' +
|
|
58
|
+
'const file1 = input => console.log(`Hello from file1 with ${input}`)\n' +
|
|
59
|
+
'\n' +
|
|
60
|
+
'module.exports = file1\n'
|
|
61
|
+
|
|
62
|
+
const file2Contents = '/**\n' +
|
|
63
|
+
' * Farewell with a summation of two numbers returned.\n' +
|
|
64
|
+
' * @param {number} a\n' +
|
|
65
|
+
' * @param {number} b\n' +
|
|
66
|
+
' * @returns {number}\n' +
|
|
67
|
+
' */\n' +
|
|
68
|
+
'const file2 = (a, b) => {\n' +
|
|
69
|
+
' const sum = a + b\n' +
|
|
70
|
+
' console.log(`Good-bye from file2 with sum ${sum}`)\n' +
|
|
71
|
+
' return sum\n' +
|
|
72
|
+
'}\n' +
|
|
73
|
+
'\n' +
|
|
74
|
+
'module.exports = file2\n'
|
|
75
|
+
|
|
76
|
+
const mainTypescript = '/**\n' +
|
|
77
|
+
' * A salutation and summation.\n' +
|
|
78
|
+
' * @param {number} a\n' +
|
|
79
|
+
' * @param {number} b\n' +
|
|
80
|
+
' * @returns {number}\n' +
|
|
81
|
+
' */\n' +
|
|
82
|
+
'const main = (a: number, b: number): number => {\n' +
|
|
83
|
+
' const sum = a + b\n' +
|
|
84
|
+
' console.log(`Greetings from typescript ${sum}`)\n' +
|
|
85
|
+
' return sum\n' +
|
|
86
|
+
'}\n' +
|
|
87
|
+
'\n' +
|
|
88
|
+
'module.exports = main\n'
|
|
89
|
+
|
|
90
|
+
const mainFileContents = '/**\n' +
|
|
91
|
+
' * Some test functions for usage with build tests.\n' +
|
|
92
|
+
' * @file\n' +
|
|
93
|
+
' * @author John Doe <john.doe@example.com>\n' +
|
|
94
|
+
' * @version 3.0.0\n' +
|
|
95
|
+
' * @module test-build\n' +
|
|
96
|
+
' */\n' +
|
|
97
|
+
'\n' +
|
|
98
|
+
'const file1 = require(\'./sources/file1\')\n' +
|
|
99
|
+
'const file2 = require(\'./sources/file2\')\n' +
|
|
100
|
+
'\n' +
|
|
101
|
+
'module.exports = {\n' +
|
|
102
|
+
' file1,\n' +
|
|
103
|
+
' file2,\n' +
|
|
104
|
+
'}\n'
|
|
105
|
+
|
|
106
|
+
const mainMd = '# Welcome\n' +
|
|
107
|
+
'This is the top of the README.md.\n' +
|
|
108
|
+
'\n'
|
|
109
|
+
|
|
110
|
+
const tsConfigContents = '{\n' +
|
|
111
|
+
' "files": ["test-build/src/**/*.ts"],\n' +
|
|
112
|
+
' "compilerOptions": {\n' +
|
|
113
|
+
' "noImplicitAny": true,\n' +
|
|
114
|
+
' "target": "es6",\n' +
|
|
115
|
+
' "moduleResolution": "node",\n' +
|
|
116
|
+
' "declaration": true,\n' +
|
|
117
|
+
' }\n' +
|
|
118
|
+
'}'
|
|
119
|
+
|
|
120
|
+
const fontContent = 'comic sans'
|
|
121
|
+
|
|
122
|
+
const fontPath = gulpConfig.get('srcPath') + '/fonts'
|
|
123
|
+
|
|
124
|
+
const imageContent = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' +
|
|
125
|
+
'<!-- Created with Inkscape (http://www.inkscape.org/) -->\n' +
|
|
126
|
+
'\n' +
|
|
127
|
+
'<svg\n' +
|
|
128
|
+
' xmlns:dc="http://purl.org/dc/elements/1.1/"\n' +
|
|
129
|
+
' xmlns:cc="http://creativecommons.org/ns#"\n' +
|
|
130
|
+
' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n' +
|
|
131
|
+
' xmlns:svg="http://www.w3.org/2000/svg"\n' +
|
|
132
|
+
' xmlns="http://www.w3.org/2000/svg"\n' +
|
|
133
|
+
' xmlns:xlink="http://www.w3.org/1999/xlink"\n' +
|
|
134
|
+
' xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n' +
|
|
135
|
+
' xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n' +
|
|
136
|
+
' id="svg2"\n' +
|
|
137
|
+
' version="1.1"\n' +
|
|
138
|
+
' inkscape:version="0.91 r13725"\n' +
|
|
139
|
+
' width="600"\n' +
|
|
140
|
+
' height="600"\n' +
|
|
141
|
+
' viewBox="0 0 600 600"\n' +
|
|
142
|
+
' sodipodi:docname="logo.svg">\n' +
|
|
143
|
+
' <metadata\n' +
|
|
144
|
+
' id="metadata8">\n' +
|
|
145
|
+
' <rdf:RDF>\n' +
|
|
146
|
+
' <cc:Work\n' +
|
|
147
|
+
' rdf:about="">\n' +
|
|
148
|
+
' <dc:format>image/svg+xml</dc:format>\n' +
|
|
149
|
+
' <dc:type\n' +
|
|
150
|
+
' rdf:resource="http://purl.org/dc/dcmitype/StillImage" />\n' +
|
|
151
|
+
' <dc:title></dc:title>\n' +
|
|
152
|
+
' </cc:Work>\n' +
|
|
153
|
+
' </rdf:RDF>\n' +
|
|
154
|
+
' </metadata>\n' +
|
|
155
|
+
' <defs\n' +
|
|
156
|
+
' id="defs6" />\n' +
|
|
157
|
+
' <sodipodi:namedview\n' +
|
|
158
|
+
' pagecolor="#ffffff"\n' +
|
|
159
|
+
' bordercolor="#666666"\n' +
|
|
160
|
+
' borderopacity="1"\n' +
|
|
161
|
+
' objecttolerance="10"\n' +
|
|
162
|
+
' gridtolerance="10"\n' +
|
|
163
|
+
' guidetolerance="10"\n' +
|
|
164
|
+
' inkscape:pageopacity="0"\n' +
|
|
165
|
+
' inkscape:pageshadow="2"\n' +
|
|
166
|
+
' inkscape:window-width="1280"\n' +
|
|
167
|
+
' inkscape:window-height="737"\n' +
|
|
168
|
+
' id="namedview4"\n' +
|
|
169
|
+
' showgrid="false"\n' +
|
|
170
|
+
' inkscape:zoom="0.39333333"\n' +
|
|
171
|
+
' inkscape:cx="300"\n' +
|
|
172
|
+
' inkscape:cy="300"\n' +
|
|
173
|
+
' inkscape:window-x="-8"\n' +
|
|
174
|
+
' inkscape:window-y="-8"\n' +
|
|
175
|
+
' inkscape:window-maximized="1"\n' +
|
|
176
|
+
' inkscape:current-layer="svg2" />\n' +
|
|
177
|
+
' <image\n' +
|
|
178
|
+
' width="600"\n' +
|
|
179
|
+
' height="600"\n' +
|
|
180
|
+
' preserveAspectRatio="none"\n' +
|
|
181
|
+
' xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAYAAACLz2ctAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n' +
|
|
182
|
+
'AAADsQA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mHE50hLbA2jA14CHSHt6Zg54EfiLu9f5ZRuZMO8K4NadxdeHPUzx7UZVP8+9\n' +
|
|
218
|
+
'TBG6F919vnKHMtF6BnDrQbNZ4LMU3yY1w84v7naKX6C+QXFRwhubk7vfyNGwTJaBAdzxZLMDwBGK\n' +
|
|
219
|
+
'g4glYMVHKSCyzUgBFEmtzd+OJRNAAZRQCqCEUgAllAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAl\n' +
|
|
220
|
+
'lAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAllAIooRRACaUASigFUEL9D1MqMi7YkUEVAAAAAElF\n' +
|
|
221
|
+
'TkSuQmCC\n' +
|
|
222
|
+
'"\n' +
|
|
223
|
+
' id="image10"\n' +
|
|
224
|
+
' x="0"\n' +
|
|
225
|
+
' y="0" />\n' +
|
|
226
|
+
' <path\n' +
|
|
227
|
+
' style="fill:#000000"\n' +
|
|
228
|
+
' d="M 19.039097,494.38241 C 2.0018627,482.75861 -2.8301068,468.02182 5.0071177,451.587 8.2776829,444.72855 15.162733,436.35919 20.307229,432.98839 c 8.904129,-5.83422 9.948263,-5.67522 21.727331,3.30915 28.014638,21.3678 44.091105,18.882 51.54879,-7.97059 C 99.533959,406.9008 98.83533,123.18555 92.8125,115.28305 90.196335,111.85041 81.496733,108.63382 73.125,108.00381 58.734191,106.92084 58.077731,106.30388 56.961131,92.8125 L 55.797259,78.75 l 163.053411,0 163.05342,0 2.57381,11.71845 c 2.93006,13.34047 -1.71086,18.13302 -17.64754,18.22413 C 347.54041,108.80285 345,115.82292 345,169.01786 l 0,48.48214 67.5,0 67.5,0 0,-48.1688 c 0,-41.90267 -0.89209,-48.97614 -6.85778,-54.37499 C 469.37044,111.54279 462.75847,108.75 458.44894,108.75 443.44309,108.75 438.75,104.6341 438.75,91.473791 l 0,-12.723791 80.85139,0 80.85135,0 -1.16385,14.0625 c -1.13201,13.67745 -1.60515,14.09431 -17.27948,15.22432 -13.44982,0.96964 -16.73767,2.79799 -19.87627,11.0531 -5.80185,15.26002 -2.83763,249.42009 3.25016,256.74719 2.61705,3.14985 11.47643,6.80123 19.6875,8.11425 14.52533,2.32268 14.9292,2.79386 14.9292,17.41755 l 0,15.03026 -79.6875,-1.01208 -79.6875,-1.01209 -1.1367,-13.60684 c -1.13565,-13.59401 -1.11975,-13.60939 16.875,-16.30515 9.90645,-1.4841 19.25149,-4.64227 20.76679,-7.01816 1.5153,-2.37593 2.78092,-30.05423 2.8125,-61.50735 L 480,258.75 l -67.59289,0 -67.5929,0 1.0304,60.9375 1.03039,60.9375 19.6875,3.3399 c 20.4921,3.4764 22.16576,5.78036 17.32391,23.8476 -2.25337,8.40847 -2.53065,8.4375 -80.57378,8.4375 l -78.31263,0 0,-14.95567 c 0,-14.53673 0.41823,-15.02258 14.9292,-17.34297 8.21107,-1.31302 17.07044,-4.96657 19.6875,-8.11909 3.63727,-4.38139 4.7583,-35.56081 4.7583,-132.34294 0,-69.63615 -1.23091,-127.84279 -2.73535,-129.3481 -9.73748,-9.7431 -68.9232,-8.34789 -79.15408,1.86593 -3.08612,3.08097 -4.99292,46.77065 -6.52417,149.48557 -1.45514,97.60931 -3.64592,149.67975 -6.6905,159.01994 -13.55129,41.57292 -61.40288,74.9124 -111.000242,77.33685 -22.754302,1.11229 -28.166407,0.0821 -39.231561,-7.46711 z"\n' +
|
|
229
|
+
' id="path3338"\n' +
|
|
230
|
+
' inkscape:connector-curvature="0" />\n' +
|
|
231
|
+
'</svg>\n'
|
|
232
|
+
|
|
233
|
+
const imageCompressed = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="600" height="600"><image width="600" height="600" preserveAspectRatio="none" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAYAAACLz2ctAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz AAADsQAAA7EB9YPtSQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAhrSURB V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aEu4/6925PUu9zzW5/TFRHxsTWLri8 gvVx+l8JfBT4gZl9fsRlpLqy+DV3/1eiWjImut8DnqYY6QbpAI+a2eNmtn+34uWu+/4a/XXT6DeB OgDlZeKfG2G+B4ATZvZbdz/f6wlmdj/F7jyFl/otR9rN3B0z+z5wb8Ual4CzwBvAMsWVxg9S7HpT fPrxNvCzKgdAMv46Znac6uGD4tLu04n62e4m8ITCN7mmgLuimxjgyQpH3dIiHXZeqz8OHHjK3Z+P bkTy6pDuHF0qDvzG3c9GNyL5TQEXopvosg78QuHbOzrAq9FNlK4Cv3L3l6MbkeZ03P2qmV1mhC+U yeAcxQHHcmAPEmDzk5AzQcu/QXGa5ZcK395kxe9qg5mdAk41tNw14FngaXdfamiZMoa2AghgZl8H vphxee9Q/E7G0+6+mHE50hLbA2jA14CHSHt6Zg54EfiLu9f5ZRuZMO8K4NadxdeHPUzx7UZVP8+9 TBG6F919vnKHMtF6BnDrQbNZ4LMU3yY1w84v7naKX6C+QXFRwhubk7vfyNGwTJaBAdzxZLMDwBGK g4glYMVHKSCyzUgBFEmtzd+OJRNAAZRQCqCEUgAllAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAl lAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAllAIooRRACaUASigFUEL9D1MqMi7YkUEVAAAAAElF TkSuQmCC"/><path style="fill:#000" d="M19.04 494.382C2.001 482.76-2.83 468.022 5.006 451.587c3.27-6.858 10.156-15.228 15.3-18.599 8.904-5.834 9.948-5.675 21.728 3.31 28.014 21.367 44.09 18.882 51.548-7.971 5.951-21.426 5.252-305.141-.77-313.044-2.617-3.433-11.316-6.65-19.688-7.28-14.39-1.082-15.047-1.7-16.164-15.19L55.797 78.75h326.107l2.574 11.718c2.93 13.34-1.711 18.133-17.648 18.225-19.29.11-21.83 7.13-21.83 60.325V217.5h135v-48.169c0-41.902-.892-48.976-6.858-54.375-3.772-3.413-10.384-6.206-14.693-6.206-15.006 0-19.699-4.116-19.699-17.276V78.75h161.703l-1.164 14.063c-1.132 13.677-1.605 14.094-17.28 15.224-13.45.97-16.737 2.798-19.876 11.053-5.802 15.26-2.837 249.42 3.25 256.747 2.617 3.15 11.477 6.801 19.688 8.114C599.596 386.274 600 386.745 600 401.37v15.03l-79.687-1.012-79.688-1.012-1.137-13.607c-1.135-13.594-1.12-13.61 16.875-16.305 9.907-1.484 19.252-4.642 20.767-7.018 1.515-2.376 2.781-30.054 2.813-61.508L480 258.75H344.814l1.03 60.938 1.031 60.937 19.688 3.34c20.492 3.476 22.165 5.78 17.323 23.848-2.253 8.408-2.53 8.437-80.573 8.437H225v-14.956c0-14.536.418-15.022 14.93-17.343 8.21-1.313 17.07-4.966 19.687-8.119 3.637-4.381 4.758-35.56 4.758-132.343 0-69.636-1.23-127.842-2.735-129.348-9.738-9.743-68.924-8.348-79.154 1.866-3.087 3.081-4.993 46.77-6.525 149.486-1.455 97.609-3.646 149.68-6.69 159.02-13.551 41.573-61.403 74.912-111 77.337-22.755 1.112-28.167.082-39.232-7.468z"/></svg>'
|
|
234
|
+
|
|
235
|
+
const imagePath = gulpConfig.get('srcPath') + '/img'
|
|
236
|
+
|
|
237
|
+
const sassContents = 'html\n' +
|
|
238
|
+
' font-size: 62.5%\n' +
|
|
239
|
+
' color: #444\n' +
|
|
240
|
+
' font-size: 1em\n' +
|
|
241
|
+
' line-height: 1.4\n' +
|
|
242
|
+
' background-color: #fff\n' +
|
|
243
|
+
'\n' +
|
|
244
|
+
'html, body\n' +
|
|
245
|
+
' width: 100%\n' +
|
|
246
|
+
' height: 100%\n' +
|
|
247
|
+
' margin: 0\n' +
|
|
248
|
+
' padding: 0\n' +
|
|
249
|
+
' position: absolute\n' +
|
|
250
|
+
' text-align: center\n' +
|
|
251
|
+
'\n' +
|
|
252
|
+
'a\n' +
|
|
253
|
+
' outline: none\n' +
|
|
254
|
+
' text-decoration: none'
|
|
255
|
+
|
|
256
|
+
const sassPath = gulpConfig.get('sass.path')
|
|
257
|
+
|
|
258
|
+
// The cache outlives a run, so clear it or a stale result from an older imagemin can pass
|
|
259
|
+
beforeEach(
|
|
260
|
+
() => clearImageCache()
|
|
261
|
+
.then(setUp.beforeEach)
|
|
262
|
+
.then(
|
|
263
|
+
async () => {
|
|
264
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
265
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
266
|
+
const sourcesPath = `${srcPath}/sources`
|
|
267
|
+
await fs.mkdirSync(sourcesPath)
|
|
268
|
+
await fs.mkdirSync(fontPath, { recursive: true })
|
|
269
|
+
await fs.mkdirSync(imagePath, { recursive: true })
|
|
270
|
+
await fs.mkdirSync(sassPath, { recursive: true })
|
|
271
|
+
return fs.writeFileSync(`${readmePath}/MAIN.md`, mainMd)
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
afterEach(setUp.afterEach)
|
|
277
|
+
|
|
278
|
+
describe('build', () => {
|
|
279
|
+
test('when browser.enabled false: calls clean, sourceLint, distSeries, distMinify, compileReadme, testFull', done => {
|
|
280
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
281
|
+
const sourcesPath = `${srcPath}/sources`
|
|
282
|
+
const distPath = gulpConfig.get('dist.to')
|
|
283
|
+
const distSourcesPath = `${distPath}/sources`
|
|
284
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
285
|
+
const readmeFile = gulpConfig.get('readme.file')
|
|
286
|
+
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
287
|
+
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
288
|
+
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
289
|
+
gulpConfig.set('browser.enabled', false)
|
|
290
|
+
expect.assertions(13)
|
|
291
|
+
build(() => {
|
|
292
|
+
// Called 'clean'
|
|
293
|
+
expect(clean).toHaveBeenCalled()
|
|
294
|
+
|
|
295
|
+
// Created dist directory (distSeries)
|
|
296
|
+
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
297
|
+
|
|
298
|
+
// Minify the dist files (distMinify)
|
|
299
|
+
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
300
|
+
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
301
|
+
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
302
|
+
|
|
303
|
+
expect(fs.existsSync(`${distSourcesPath}/file1.min.js`)).toBeTruthy()
|
|
304
|
+
const babelifiedFile1 = fs.readFileSync(`${distSourcesPath}/file1.js`).toString()
|
|
305
|
+
expect(babelifiedFile1.includes('use strict')).toBe(true)
|
|
306
|
+
|
|
307
|
+
expect(fs.existsSync(`${distSourcesPath}/file2.min.js`)).toBeTruthy()
|
|
308
|
+
const babelifiedFile2 = fs.readFileSync(`${distSourcesPath}/file2.js`).toString()
|
|
309
|
+
expect(babelifiedFile2.includes('use strict')).toBe(true)
|
|
310
|
+
|
|
311
|
+
// Generated README.md (compileReadme)
|
|
312
|
+
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
313
|
+
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
314
|
+
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
315
|
+
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
316
|
+
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
317
|
+
|
|
318
|
+
// Ran 'testFull'
|
|
319
|
+
expect(testFull).toHaveBeenCalled()
|
|
320
|
+
done()
|
|
321
|
+
})
|
|
322
|
+
}, 30000)
|
|
323
|
+
|
|
324
|
+
test('when browser.enabled true: calls clean, sourceLint, distSeries, distMinify, bundle, bundleMinify, compileReadme, testFull', done => {
|
|
325
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
326
|
+
const sourcesPath = `${srcPath}/sources`
|
|
327
|
+
const distPath = gulpConfig.get('dist.to')
|
|
328
|
+
const browserFile = gulpConfig.get('browser.name')
|
|
329
|
+
const browserPath = gulpConfig.get('browser.to')
|
|
330
|
+
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
331
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
332
|
+
const readmeFile = gulpConfig.get('readme.file')
|
|
333
|
+
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
334
|
+
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
335
|
+
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
336
|
+
gulpConfig.set('browser.enabled', true)
|
|
337
|
+
expect.assertions(13)
|
|
338
|
+
build(() => {
|
|
339
|
+
// Called 'clean'
|
|
340
|
+
expect(clean).toHaveBeenCalled()
|
|
341
|
+
|
|
342
|
+
// Created dist directory (distSeries)
|
|
343
|
+
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
344
|
+
|
|
345
|
+
// Minify the dist files (distMinify)
|
|
346
|
+
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
347
|
+
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
348
|
+
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
349
|
+
|
|
350
|
+
// Created browser directory (bundle)
|
|
351
|
+
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
352
|
+
|
|
353
|
+
// Minify the browser files (bundleMinify)
|
|
354
|
+
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
355
|
+
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
356
|
+
expect(countMatches(bundledContents, 'file1')).toEqual(7)
|
|
357
|
+
expect(countMatches(bundledContents, 'file2')).toEqual(7)
|
|
358
|
+
|
|
359
|
+
// Generated README.md (compileReadme)
|
|
360
|
+
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
361
|
+
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
362
|
+
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
363
|
+
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
364
|
+
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
365
|
+
|
|
366
|
+
// Ran 'testFull'
|
|
367
|
+
expect(testFull).toHaveBeenCalled()
|
|
368
|
+
done()
|
|
369
|
+
})
|
|
370
|
+
}, 30000)
|
|
371
|
+
|
|
372
|
+
test('when browser.enabled true and fonts.enabled true: calls clean, sourceLint, distSeries, distMinify, bundle, bundleMinify, compileReadme, testFull, copyFonts', done => {
|
|
373
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
374
|
+
const sourcesPath = `${srcPath}/sources`
|
|
375
|
+
const distPath = gulpConfig.get('dist.to')
|
|
376
|
+
const browserFile = gulpConfig.get('browser.name')
|
|
377
|
+
const browserPath = gulpConfig.get('browser.to')
|
|
378
|
+
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
379
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
380
|
+
const readmeFile = gulpConfig.get('readme.file')
|
|
381
|
+
const fontFile = `${fontPath}/comic-sans.woff`
|
|
382
|
+
fs.writeFileSync(fontFile, fontContent)
|
|
383
|
+
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
384
|
+
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
385
|
+
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
386
|
+
gulpConfig.set('browser.enabled', true)
|
|
387
|
+
gulpConfig.set('fonts.enabled', true)
|
|
388
|
+
expect.assertions(14)
|
|
389
|
+
build(() => {
|
|
390
|
+
// Called 'clean'
|
|
391
|
+
expect(clean).toHaveBeenCalled()
|
|
392
|
+
|
|
393
|
+
// Created dist directory (distSeries)
|
|
394
|
+
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
395
|
+
|
|
396
|
+
// Minify the dist files (distMinify)
|
|
397
|
+
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
398
|
+
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
399
|
+
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
400
|
+
|
|
401
|
+
// Created browser directory (bundle)
|
|
402
|
+
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
403
|
+
|
|
404
|
+
// Minify the browser files (bundleMinify)
|
|
405
|
+
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
406
|
+
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
407
|
+
expect(countMatches(bundledContents, 'file1')).toEqual(7)
|
|
408
|
+
expect(countMatches(bundledContents, 'file2')).toEqual(7)
|
|
409
|
+
|
|
410
|
+
// Generated README.md (compileReadme)
|
|
411
|
+
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
412
|
+
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
413
|
+
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
414
|
+
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
415
|
+
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
416
|
+
|
|
417
|
+
// Ran 'testFull'
|
|
418
|
+
expect(testFull).toHaveBeenCalled()
|
|
419
|
+
|
|
420
|
+
// Ran 'fonts'
|
|
421
|
+
const fontDest = gulpConfig.get('fonts.to')
|
|
422
|
+
const movedFont = fs.readFileSync(`${fontDest}/comic-sans.woff`).toString()
|
|
423
|
+
expect(movedFont).toEqual(fontContent)
|
|
424
|
+
|
|
425
|
+
done()
|
|
426
|
+
})
|
|
427
|
+
}, 30000)
|
|
428
|
+
|
|
429
|
+
test('when browser.enabled true and images.enabled true: calls clean, sourceLint, distSeries, distMinify, bundle, bundleMinify, compileReadme, testFull, images', done => {
|
|
430
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
431
|
+
const sourcesPath = `${srcPath}/sources`
|
|
432
|
+
const distPath = gulpConfig.get('dist.to')
|
|
433
|
+
const browserFile = gulpConfig.get('browser.name')
|
|
434
|
+
const browserPath = gulpConfig.get('browser.to')
|
|
435
|
+
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
436
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
437
|
+
const readmeFile = gulpConfig.get('readme.file')
|
|
438
|
+
const imageFile = `${imagePath}/logo.svg`
|
|
439
|
+
fs.writeFileSync(imageFile, imageContent)
|
|
440
|
+
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
441
|
+
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
442
|
+
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
443
|
+
gulpConfig.set('browser.enabled', true)
|
|
444
|
+
gulpConfig.set('images.enabled', true)
|
|
445
|
+
expect.assertions(14)
|
|
446
|
+
build(() => {
|
|
447
|
+
// Called 'clean'
|
|
448
|
+
expect(clean).toHaveBeenCalled()
|
|
449
|
+
|
|
450
|
+
// Created dist directory (distSeries)
|
|
451
|
+
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
452
|
+
|
|
453
|
+
// Minify the dist files (distMinify)
|
|
454
|
+
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
455
|
+
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
456
|
+
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
457
|
+
|
|
458
|
+
// Created browser directory (bundle)
|
|
459
|
+
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
460
|
+
|
|
461
|
+
// Minify the browser files (bundleMinify)
|
|
462
|
+
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
463
|
+
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
464
|
+
expect(countMatches(bundledContents, 'file1')).toEqual(7)
|
|
465
|
+
expect(countMatches(bundledContents, 'file2')).toEqual(7)
|
|
466
|
+
|
|
467
|
+
// Generated README.md (compileReadme)
|
|
468
|
+
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
469
|
+
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
470
|
+
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
471
|
+
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
472
|
+
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
473
|
+
|
|
474
|
+
// Ran 'testFull'
|
|
475
|
+
expect(testFull).toHaveBeenCalled()
|
|
476
|
+
|
|
477
|
+
// Ran 'images'
|
|
478
|
+
const imageDest = gulpConfig.get('images.to')
|
|
479
|
+
const movedImage = fs.readFileSync(`${imageDest}/logo.svg`).toString()
|
|
480
|
+
expect(movedImage).toEqual(imageCompressed)
|
|
481
|
+
|
|
482
|
+
done()
|
|
483
|
+
})
|
|
484
|
+
}, 30000)
|
|
485
|
+
|
|
486
|
+
test('when browser.enabled true and sass.enabled true: calls clean, sourceLint, distSeries, distMinify, bundle, bundleMinify, compileReadme, testFull, sass', done => {
|
|
487
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
488
|
+
const sourcesPath = `${srcPath}/sources`
|
|
489
|
+
const distPath = gulpConfig.get('dist.to')
|
|
490
|
+
const browserFile = gulpConfig.get('browser.name')
|
|
491
|
+
const browserPath = gulpConfig.get('browser.to')
|
|
492
|
+
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
493
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
494
|
+
const readmeFile = gulpConfig.get('readme.file')
|
|
495
|
+
const sassFile = `${sassPath}/sassFor.sass`
|
|
496
|
+
fs.writeFileSync(sassFile, sassContents)
|
|
497
|
+
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
498
|
+
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
499
|
+
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
500
|
+
gulpConfig.set('browser.enabled', true)
|
|
501
|
+
gulpConfig.set('sass.enabled', true)
|
|
502
|
+
expect.assertions(16)
|
|
503
|
+
build(() => {
|
|
504
|
+
// Called 'clean'
|
|
505
|
+
expect(clean).toHaveBeenCalled()
|
|
506
|
+
|
|
507
|
+
// Created dist directory (distSeries)
|
|
508
|
+
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
509
|
+
|
|
510
|
+
// Minify the dist files (distMinify)
|
|
511
|
+
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
512
|
+
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
513
|
+
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
514
|
+
|
|
515
|
+
// Created browser directory (bundle)
|
|
516
|
+
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
517
|
+
|
|
518
|
+
// Minify the browser files (bundleMinify)
|
|
519
|
+
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
520
|
+
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
521
|
+
expect(countMatches(bundledContents, 'file1')).toEqual(7)
|
|
522
|
+
expect(countMatches(bundledContents, 'file2')).toEqual(7)
|
|
523
|
+
|
|
524
|
+
// Generated README.md (compileReadme)
|
|
525
|
+
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
526
|
+
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
527
|
+
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
528
|
+
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
529
|
+
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
530
|
+
|
|
531
|
+
// Ran 'testFull'
|
|
532
|
+
expect(testFull).toHaveBeenCalled()
|
|
533
|
+
|
|
534
|
+
// Ran 'sass'
|
|
535
|
+
const cssPath = gulpConfig.get('sass.to')
|
|
536
|
+
const cssContents = fs.readFileSync(`${cssPath}/sassFor.css`).toString()
|
|
537
|
+
expect(countMatches(cssContents, ';')).toEqual(13)
|
|
538
|
+
expect(countMatches(cssContents, '{')).toEqual(3)
|
|
539
|
+
expect(countMatches(cssContents, '}')).toEqual(3)
|
|
540
|
+
|
|
541
|
+
done()
|
|
542
|
+
})
|
|
543
|
+
}, 30000)
|
|
544
|
+
|
|
545
|
+
test('when browser.enabled false and typescript.enabled set: calls clean, sourceLint, tsFor, distFor, distMinify, compileReadme, testFull', done => {
|
|
546
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
547
|
+
const rootPath = gulpConfig.get('rootPath')
|
|
548
|
+
const tsConfig = `${rootPath}/tsconfig.json`
|
|
549
|
+
const distPath = gulpConfig.get('dist.to')
|
|
550
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
551
|
+
const readmeFile = gulpConfig.get('readme.file')
|
|
552
|
+
fs.writeFileSync(`${srcPath}/main.ts`, mainTypescript)
|
|
553
|
+
fs.writeFileSync(tsConfig, tsConfigContents)
|
|
554
|
+
gulpConfig.set('browser.enabled', false)
|
|
555
|
+
gulpConfig.set('typescript.config', tsConfig)
|
|
556
|
+
gulpConfig.set('typescript.enabled', true)
|
|
557
|
+
gulpConfig.set('readme.from', `${distPath}/**/*.js`)
|
|
558
|
+
expect.assertions(8)
|
|
559
|
+
build(() => {
|
|
560
|
+
// Called 'clean'
|
|
561
|
+
expect(clean).toHaveBeenCalled()
|
|
562
|
+
|
|
563
|
+
// Created dist directory (distSeries)
|
|
564
|
+
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
565
|
+
// Created declaration file
|
|
566
|
+
expect(fs.existsSync(`${distPath}/main.d.ts`)).toBeTruthy()
|
|
567
|
+
|
|
568
|
+
// Minify the dist files (distMinify)
|
|
569
|
+
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
570
|
+
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
571
|
+
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
572
|
+
|
|
573
|
+
// Generated README.md (compileReadme)
|
|
574
|
+
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
575
|
+
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
576
|
+
expect(countMatches(readmeContents, 'main')).toEqual(2)
|
|
577
|
+
|
|
578
|
+
// Ran 'testFull'
|
|
579
|
+
expect(testFull).toHaveBeenCalled()
|
|
580
|
+
done()
|
|
581
|
+
})
|
|
582
|
+
}, 30000)
|
|
583
|
+
|
|
584
|
+
test('when browser.enabled true and typescript.enabled set: calls clean, sourceLint, tsFor, distFor, distMinify, bundle, bundleMinify, compileReadme, testFull', done => {
|
|
585
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
586
|
+
const rootPath = gulpConfig.get('rootPath')
|
|
587
|
+
const tsConfig = `${rootPath}/tsconfig.json`
|
|
588
|
+
const distPath = gulpConfig.get('dist.to')
|
|
589
|
+
const browserFile = gulpConfig.get('browser.name')
|
|
590
|
+
const browserPath = gulpConfig.get('browser.to')
|
|
591
|
+
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
592
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
593
|
+
const readmeFile = gulpConfig.get('readme.file')
|
|
594
|
+
fs.writeFileSync(`${srcPath}/main.ts`, mainTypescript)
|
|
595
|
+
fs.writeFileSync(tsConfig, tsConfigContents)
|
|
596
|
+
gulpConfig.set('browser.enabled', true)
|
|
597
|
+
gulpConfig.set('typescript.config', tsConfig)
|
|
598
|
+
gulpConfig.set('typescript.enabled', true)
|
|
599
|
+
gulpConfig.set('readme.from', `${distPath}/**/*.js`)
|
|
600
|
+
expect.assertions(11)
|
|
601
|
+
build(() => {
|
|
602
|
+
// Called 'clean'
|
|
603
|
+
expect(clean).toHaveBeenCalled()
|
|
604
|
+
|
|
605
|
+
// Created dist directory (distSeries)
|
|
606
|
+
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
607
|
+
// Created declaration file
|
|
608
|
+
expect(fs.existsSync(`${distPath}/main.d.ts`)).toBeTruthy()
|
|
609
|
+
|
|
610
|
+
// Minify the dist files (distMinify)
|
|
611
|
+
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
612
|
+
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
613
|
+
expect(babelifiedMain.includes('use strict')).toBe(true)
|
|
614
|
+
|
|
615
|
+
// Created browser directory (bundle)
|
|
616
|
+
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
617
|
+
|
|
618
|
+
// Minify the browser files (bundleMinify)
|
|
619
|
+
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
620
|
+
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
621
|
+
expect(countMatches(bundledContents, 'main')).toEqual(2)
|
|
622
|
+
|
|
623
|
+
// Generated README.md (compileReadme)
|
|
624
|
+
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
625
|
+
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
626
|
+
expect(countMatches(readmeContents, 'main')).toEqual(2)
|
|
627
|
+
|
|
628
|
+
// Ran 'testFull'
|
|
629
|
+
expect(testFull).toHaveBeenCalled()
|
|
630
|
+
done()
|
|
631
|
+
})
|
|
632
|
+
}, 30000)
|
|
633
|
+
|
|
634
|
+
test('when docs.enabled is set: generates the documentation from the TypeScript source instead of the readme', done => {
|
|
635
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
636
|
+
const rootPath = gulpConfig.get('rootPath')
|
|
637
|
+
const tsConfig = `${rootPath}/tsconfig.json`
|
|
638
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
639
|
+
const readmeFile = gulpConfig.get('readme.file')
|
|
640
|
+
fs.writeFileSync(`${srcPath}/main.ts`, mainTypescript)
|
|
641
|
+
fs.writeFileSync(tsConfig, tsConfigContents)
|
|
642
|
+
fs.rmSync(`${readmePath}/${readmeFile}`, { force: true })
|
|
643
|
+
typeDocs.mockClear()
|
|
644
|
+
gulpConfig.set('browser.enabled', false)
|
|
645
|
+
gulpConfig.set('typescript.config', tsConfig)
|
|
646
|
+
gulpConfig.set('typescript.enabled', true)
|
|
647
|
+
gulpConfig.set('docs.enabled', true)
|
|
648
|
+
// Set explicitly: the project's own build-tools.config.json has docs.inBuild off
|
|
649
|
+
gulpConfig.set('docs.inBuild', true)
|
|
650
|
+
expect.assertions(3)
|
|
651
|
+
build(() => {
|
|
652
|
+
gulpConfig.set('docs.enabled', false)
|
|
653
|
+
gulpConfig.set('typescript.enabled', false)
|
|
654
|
+
expect(typeDocs).toHaveBeenCalledTimes(1)
|
|
655
|
+
// The readme is not generated, it is written by hand
|
|
656
|
+
expect(fs.existsSync(`${readmePath}/${readmeFile}`)).toBe(false)
|
|
657
|
+
expect(testFull).toHaveBeenCalled()
|
|
658
|
+
done()
|
|
659
|
+
})
|
|
660
|
+
}, 30000)
|
|
661
|
+
|
|
662
|
+
test('when docs.enabled is set without typescript.enabled: generates the documentation with jsdoc, inferred from docs.method being unset', done => {
|
|
663
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
664
|
+
const readmeFile = gulpConfig.get('readme.file')
|
|
665
|
+
fs.rmSync(`${readmePath}/${readmeFile}`, { force: true })
|
|
666
|
+
jsdocDocs.mockClear()
|
|
667
|
+
gulpConfig.set('browser.enabled', false)
|
|
668
|
+
gulpConfig.set('typescript.enabled', false)
|
|
669
|
+
gulpConfig.set('docs.enabled', true)
|
|
670
|
+
gulpConfig.set('docs.inBuild', true)
|
|
671
|
+
expect.assertions(3)
|
|
672
|
+
build(() => {
|
|
673
|
+
gulpConfig.set('docs.enabled', false)
|
|
674
|
+
expect(jsdocDocs).toHaveBeenCalledTimes(1)
|
|
675
|
+
// The readme is not generated, it is written by hand - same as the TypeDoc path above
|
|
676
|
+
expect(fs.existsSync(`${readmePath}/${readmeFile}`)).toBe(false)
|
|
677
|
+
expect(testFull).toHaveBeenCalled()
|
|
678
|
+
done()
|
|
679
|
+
})
|
|
680
|
+
}, 30000)
|
|
681
|
+
|
|
682
|
+
test('with docs.inBuild off, build generates neither the documentation nor the readme', done => {
|
|
683
|
+
const readmePath = gulpConfig.get('readme.to')
|
|
684
|
+
const readmeFile = gulpConfig.get('readme.file')
|
|
685
|
+
fs.rmSync(`${readmePath}/${readmeFile}`, { force: true })
|
|
686
|
+
typeDocs.mockClear()
|
|
687
|
+
jsdocDocs.mockClear()
|
|
688
|
+
gulpConfig.set('browser.enabled', false)
|
|
689
|
+
gulpConfig.set('typescript.enabled', false)
|
|
690
|
+
gulpConfig.set('docs.enabled', true)
|
|
691
|
+
gulpConfig.set('docs.inBuild', false)
|
|
692
|
+
expect.assertions(4)
|
|
693
|
+
build(() => {
|
|
694
|
+
gulpConfig.set('docs.enabled', false)
|
|
695
|
+
gulpConfig.set('docs.inBuild', true)
|
|
696
|
+
expect(jsdocDocs).not.toHaveBeenCalled()
|
|
697
|
+
expect(typeDocs).not.toHaveBeenCalled()
|
|
698
|
+
// The readme is still written by hand while docs.enabled is on
|
|
699
|
+
expect(fs.existsSync(`${readmePath}/${readmeFile}`)).toBe(false)
|
|
700
|
+
expect(testFull).toHaveBeenCalled()
|
|
701
|
+
done()
|
|
702
|
+
})
|
|
703
|
+
}, 30000)
|
|
704
|
+
|
|
705
|
+
test('docs.method overrides the typescript.enabled inference either way', done => {
|
|
706
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
707
|
+
const rootPath = gulpConfig.get('rootPath')
|
|
708
|
+
const tsConfig = `${rootPath}/tsconfig.json`
|
|
709
|
+
fs.writeFileSync(`${srcPath}/main.ts`, mainTypescript)
|
|
710
|
+
fs.writeFileSync(tsConfig, tsConfigContents)
|
|
711
|
+
typeDocs.mockClear()
|
|
712
|
+
jsdocDocs.mockClear()
|
|
713
|
+
gulpConfig.set('browser.enabled', false)
|
|
714
|
+
gulpConfig.set('typescript.config', tsConfig)
|
|
715
|
+
gulpConfig.set('typescript.enabled', true)
|
|
716
|
+
gulpConfig.set('docs.enabled', true)
|
|
717
|
+
gulpConfig.set('docs.inBuild', true)
|
|
718
|
+
// typescript.enabled is true, which would normally infer 'typedoc' - method forces 'jsdoc' instead.
|
|
719
|
+
gulpConfig.set('docs.method', 'jsdoc')
|
|
720
|
+
expect.assertions(2)
|
|
721
|
+
build(() => {
|
|
722
|
+
gulpConfig.set('docs.enabled', false)
|
|
723
|
+
gulpConfig.set('docs.method', false)
|
|
724
|
+
gulpConfig.set('typescript.enabled', false)
|
|
725
|
+
expect(jsdocDocs).toHaveBeenCalledTimes(1)
|
|
726
|
+
expect(typeDocs).not.toHaveBeenCalled()
|
|
727
|
+
done()
|
|
728
|
+
})
|
|
729
|
+
}, 30000)
|
|
730
|
+
|
|
731
|
+
test('finishes clean and sourceLint before starting the tasks that write into the output folders', done => {
|
|
732
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
733
|
+
const sourcesPath = `${srcPath}/sources`
|
|
734
|
+
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
735
|
+
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
736
|
+
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
737
|
+
expect.assertions(1)
|
|
738
|
+
const events = []
|
|
739
|
+
clean.mockImplementationOnce(() => new Promise(resolve => setTimeout(() => {
|
|
740
|
+
events.push('clean finished')
|
|
741
|
+
resolve(true)
|
|
742
|
+
}, 100)))
|
|
743
|
+
sourceLint.mockImplementationOnce(() => new Promise(resolve => setTimeout(() => {
|
|
744
|
+
events.push('sourceLint finished')
|
|
745
|
+
resolve(true)
|
|
746
|
+
}, 50)))
|
|
747
|
+
testFull.mockImplementationOnce(() => {
|
|
748
|
+
events.push('testFull started')
|
|
749
|
+
return Promise.resolve(true)
|
|
750
|
+
})
|
|
751
|
+
// Earlier tests leave these enabled, so state them explicitly to keep this test independent of test order.
|
|
752
|
+
gulpConfig.set('browser.enabled', false)
|
|
753
|
+
gulpConfig.set('fonts.enabled', false)
|
|
754
|
+
gulpConfig.set('images.enabled', false)
|
|
755
|
+
gulpConfig.set('sass.enabled', false)
|
|
756
|
+
gulpConfig.set('typescript.enabled', false)
|
|
757
|
+
gulpConfig.set('docs.enabled', false)
|
|
758
|
+
build(() => {
|
|
759
|
+
expect(events).toEqual(['sourceLint finished', 'clean finished', 'testFull started'])
|
|
760
|
+
done()
|
|
761
|
+
})
|
|
762
|
+
}, 30000)
|
|
763
|
+
})
|