js-build-tools 5.2.0 → 5.3.1
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/README.md +101 -10
- package/dist/build.js +63 -58
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +27 -27
- package/dist/bundleLint.js +16 -16
- package/dist/bundleMinify.js +13 -13
- package/dist/compileReadme.js +10 -10
- package/dist/copyFonts.js +13 -13
- package/dist/default.js +15 -15
- package/dist/dist.js +10 -10
- package/dist/distLint.js +16 -16
- package/dist/distMinify.js +13 -13
- package/dist/images.js +10 -10
- package/dist/partials/addToReadme.js +17 -17
- package/dist/partials/beginWatcher.js +12 -12
- package/dist/partials/clean.js +14 -14
- package/dist/partials/copyFor.js +12 -12
- package/dist/partials/distFor.js +21 -21
- package/dist/partials/distForSrc.js +11 -11
- package/dist/partials/distSeries.js +19 -19
- package/dist/partials/imagesFor.js +7 -13
- package/dist/partials/loadPeer.js +99 -0
- package/dist/partials/minifyFor.js +16 -16
- package/dist/partials/readmeTemplate.js +14 -14
- package/dist/partials/removeDirectory.js +29 -29
- package/dist/partials/runOnChange.js +28 -28
- package/dist/partials/sassFor.js +28 -28
- package/dist/partials/standardLint.js +3 -5
- package/dist/partials/tsFor.js +8 -20
- package/dist/partials/typeDocsFor.js +228 -0
- package/dist/partials.js +26 -0
- package/dist/partials.min.js +1 -1
- package/dist/sass.js +10 -10
- package/dist/test-helpers/setUp.js +89 -89
- package/dist/test-helpers/standardLintWithRealStandard.js +27 -27
- package/dist/testFull.js +20 -20
- package/dist/testHelpers.js +10 -10
- package/dist/testQuick.js +22 -22
- package/dist/typeDocs.js +14 -0
- package/dist/typeDocs.min.js +1 -0
- package/dist/typeScript.js +9 -9
- package/dist/utilities/dotGet.js +46 -46
- package/dist/utilities/dotNotate.js +46 -46
- package/dist/utilities/dotSet.js +37 -37
- package/dist/utilities/isObject.js +8 -8
- package/dist/utilities/strAfter.js +11 -11
- package/dist/utilities/strBefore.js +11 -11
- package/dist/watchFull.js +10 -10
- package/dist/watchTest.js +16 -16
- package/functions/build.mjs +7 -2
- package/functions/build.test.mjs +29 -0
- package/functions/partials/imagesFor.mjs +7 -13
- package/functions/partials/loadPeer.mjs +75 -0
- package/functions/partials/loadPeer.test.mjs +58 -0
- package/functions/partials/standardLint.mjs +3 -5
- package/functions/partials/tsFor.mjs +4 -20
- package/functions/partials/typeDocsFor.mjs +199 -0
- package/functions/partials/typeDocsFor.test.mjs +204 -0
- package/functions/partials.mjs +2 -0
- package/functions/partials.test.mjs +1 -1
- package/functions/typeDocs.mjs +9 -0
- package/functions/typeDocs.test.mjs +11 -0
- package/gulp.config.mjs +24 -2
- package/gulpfile.base.js +2 -0
- package/gulpfile.base.mjs +1 -0
- package/package.json +12 -7
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.runOnChange = void 0;
|
|
8
|
-
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
9
|
-
var _bundle = require("../bundle.js");
|
|
10
|
-
var _distSeries = require("./distSeries.js");
|
|
11
|
-
var _gulp = require("gulp");
|
|
12
|
-
var _testQuick = require("../testQuick.js");
|
|
13
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.runOnChange = void 0;
|
|
8
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
9
|
+
var _bundle = require("../bundle.js");
|
|
10
|
+
var _distSeries = require("./distSeries.js");
|
|
11
|
+
var _gulp = require("gulp");
|
|
12
|
+
var _testQuick = require("../testQuick.js");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
14
|
/**
|
|
15
15
|
* Run this function when the watched files are modified.
|
|
16
16
|
* 1. Find the sub-folders within src path
|
|
@@ -35,11 +35,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
35
35
|
* @memberOf module:partials
|
|
36
36
|
* @param {string} path
|
|
37
37
|
* @returns {stream.Stream}
|
|
38
|
-
*/
|
|
39
|
-
const runOnChange = path => {
|
|
40
|
-
const useTs = gulpConfig.get('typescript.enabled');
|
|
41
|
-
const distPath = gulpConfig.get('dist.to');
|
|
42
|
-
const srcPath = gulpConfig.get('srcPath');
|
|
38
|
+
*/
|
|
39
|
+
const runOnChange = path => {
|
|
40
|
+
const useTs = gulpConfig.get('typescript.enabled');
|
|
41
|
+
const distPath = gulpConfig.get('dist.to');
|
|
42
|
+
const srcPath = gulpConfig.get('srcPath');
|
|
43
43
|
/**
|
|
44
44
|
* 1. The original path comes in from src and is a .ts
|
|
45
45
|
* 2. Discover the outgoing dist path where that file should go
|
|
@@ -47,14 +47,14 @@ const runOnChange = path => {
|
|
|
47
47
|
* 4. Take the original path, convert to full file path in dist
|
|
48
48
|
* 5. Use the dist path found previously in #2
|
|
49
49
|
* 6. Use the full dist path and the dist outgoing path in distFor
|
|
50
|
-
*/
|
|
51
|
-
const pathRegex = new RegExp(`^${srcPath}(.*\\/)(.+)\\.(js|ts)$`, 'i');
|
|
52
|
-
const distPathResult = path.replace(pathRegex, `${distPath}$1`);
|
|
53
|
-
let distSrcPath = path;
|
|
54
|
-
if (useTs) {
|
|
55
|
-
distSrcPath = path.replace(pathRegex, `${distPath}$1$2.js`);
|
|
56
|
-
}
|
|
57
|
-
const runSeries = (0, _distSeries.distSeries)(distSrcPath, distPathResult, path);
|
|
58
|
-
return gulpConfig.get('browser.enabled') ? (0, _gulp.parallel)(_testQuick.testQuick, (0, _gulp.series)(runSeries, _bundle.bundle))() : (0, _gulp.series)(_testQuick.testQuick, runSeries)();
|
|
59
|
-
};
|
|
50
|
+
*/
|
|
51
|
+
const pathRegex = new RegExp(`^${srcPath}(.*\\/)(.+)\\.(js|ts)$`, 'i');
|
|
52
|
+
const distPathResult = path.replace(pathRegex, `${distPath}$1`);
|
|
53
|
+
let distSrcPath = path;
|
|
54
|
+
if (useTs) {
|
|
55
|
+
distSrcPath = path.replace(pathRegex, `${distPath}$1$2.js`);
|
|
56
|
+
}
|
|
57
|
+
const runSeries = (0, _distSeries.distSeries)(distSrcPath, distPathResult, path);
|
|
58
|
+
return gulpConfig.get('browser.enabled') ? (0, _gulp.parallel)(_testQuick.testQuick, (0, _gulp.series)(runSeries, _bundle.bundle))() : (0, _gulp.series)(_testQuick.testQuick, runSeries)();
|
|
59
|
+
};
|
|
60
60
|
exports.runOnChange = runOnChange;
|
package/dist/partials/sassFor.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.sassFor = void 0;
|
|
8
|
-
var _gulp = require("gulp");
|
|
9
|
-
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
10
|
-
var _autoprefixer = _interopRequireDefault(require("autoprefixer"));
|
|
11
|
-
var _cssnano = _interopRequireDefault(require("cssnano"));
|
|
12
|
-
var _gulpPostcss = _interopRequireDefault(require("gulp-postcss"));
|
|
13
|
-
var _gulpRename = _interopRequireDefault(require("gulp-rename"));
|
|
14
|
-
var sass = _interopRequireWildcard(require("sass"));
|
|
15
|
-
var _gulpSass = _interopRequireDefault(require("gulp-sass"));
|
|
16
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
-
const runSass = (0, _gulpSass.default)(sass);
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.sassFor = void 0;
|
|
8
|
+
var _gulp = require("gulp");
|
|
9
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
10
|
+
var _autoprefixer = _interopRequireDefault(require("autoprefixer"));
|
|
11
|
+
var _cssnano = _interopRequireDefault(require("cssnano"));
|
|
12
|
+
var _gulpPostcss = _interopRequireDefault(require("gulp-postcss"));
|
|
13
|
+
var _gulpRename = _interopRequireDefault(require("gulp-rename"));
|
|
14
|
+
var sass = _interopRequireWildcard(require("sass"));
|
|
15
|
+
var _gulpSass = _interopRequireDefault(require("gulp-sass"));
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
+
const runSass = (0, _gulpSass.default)(sass);
|
|
19
|
+
|
|
20
20
|
/**
|
|
21
21
|
* Build the CSS for a given source pattern.
|
|
22
22
|
* @memberOf module:partials
|
|
23
23
|
* @param {string|array} [srcSearch='src/config/path/sass/for']
|
|
24
24
|
* @param {string} [cssPath='css/config/path']
|
|
25
25
|
* @returns {stream.Stream}
|
|
26
|
-
*/
|
|
27
|
-
const sassFor = (srcSearch = gulpConfig.get('sass.from'), cssPath = gulpConfig.get('sass.to')) => (0, _gulp.src)(srcSearch).pipe(runSass().on('error', runSass.logError)) // Passes it through a gulp-sass, log errors to console
|
|
28
|
-
.pipe((0, _gulp.dest)(cssPath))
|
|
29
|
-
// add: false - the old gulp-cssnano only ever removed obsolete vendor prefixes, never added any; keep that.
|
|
30
|
-
.pipe((0, _gulpPostcss.default)([(0, _autoprefixer.default)({
|
|
31
|
-
add: false
|
|
32
|
-
}), (0, _cssnano.default)()])).pipe((0, _gulpRename.default)({
|
|
33
|
-
extname: '.min.css'
|
|
34
|
-
})).pipe((0, _gulp.dest)(cssPath));
|
|
26
|
+
*/
|
|
27
|
+
const sassFor = (srcSearch = gulpConfig.get('sass.from'), cssPath = gulpConfig.get('sass.to')) => (0, _gulp.src)(srcSearch).pipe(runSass().on('error', runSass.logError)) // Passes it through a gulp-sass, log errors to console
|
|
28
|
+
.pipe((0, _gulp.dest)(cssPath))
|
|
29
|
+
// add: false - the old gulp-cssnano only ever removed obsolete vendor prefixes, never added any; keep that.
|
|
30
|
+
.pipe((0, _gulpPostcss.default)([(0, _autoprefixer.default)({
|
|
31
|
+
add: false
|
|
32
|
+
}), (0, _cssnano.default)()])).pipe((0, _gulpRename.default)({
|
|
33
|
+
extname: '.min.css'
|
|
34
|
+
})).pipe((0, _gulp.dest)(cssPath));
|
|
35
35
|
exports.sassFor = sassFor;
|
|
@@ -8,12 +8,10 @@ require("core-js/modules/esnext.iterator.constructor.js");
|
|
|
8
8
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
9
9
|
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
10
|
var _through = _interopRequireDefault(require("through2"));
|
|
11
|
+
var _loadPeer = require("./loadPeer.js");
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
// `standard` (17+) ships ESM-only,
|
|
13
|
-
|
|
14
|
-
// inside a Function constructor keeps it a genuine dynamic import that works from either build (same escape hatch
|
|
15
|
-
// as tsFor.mjs uses for gulp-ts-compile).
|
|
16
|
-
const importStandard = new Function('return import(\'standard\')');
|
|
13
|
+
// `standard` (17+) ships ESM-only, see importModule for how it is imported.
|
|
14
|
+
const importStandard = () => (0, _loadPeer.importModule)('standard');
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* Print a file's lint messages, if it has any.
|
package/dist/partials/tsFor.js
CHANGED
|
@@ -8,18 +8,11 @@ exports.tsFor = exports.loadTypescript = void 0;
|
|
|
8
8
|
var _gulp = require("gulp");
|
|
9
9
|
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
10
|
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
11
|
-
var
|
|
11
|
+
var _loadPeer = require("./loadPeer.js");
|
|
12
12
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
// gulp-ts-compile ships ESM-only (no CJS build - see its own package.json)
|
|
15
|
-
|
|
16
|
-
// compiles itself to a CommonJS build (dist/*.js, this file's own compiled counterpart) for consumers using
|
|
17
|
-
// require() though, and even a dynamic `import()` gets downleveled by babel's CommonJS transform into a
|
|
18
|
-
// require() call - which can't load a real ES module. Hiding the import() call inside a Function constructor is
|
|
19
|
-
// the standard escape hatch: babel can't see (and so can't rewrite) an import expression that only exists as a
|
|
20
|
-
// runtime-evaluated string, so it survives as a genuine dynamic import, capable of loading gulp-ts-compile from
|
|
21
|
-
// either build.
|
|
22
|
-
const importGulpTsCompile = new Function('return import(\'gulp-ts-compile\')');
|
|
14
|
+
// gulp-ts-compile ships ESM-only (no CJS build - see its own package.json), see importModule for how it is imported.
|
|
15
|
+
const importGulpTsCompile = () => (0, _loadPeer.importModule)('gulp-ts-compile');
|
|
23
16
|
|
|
24
17
|
/**
|
|
25
18
|
* Wrap a stream in a promise that resolves once it finishes writing.
|
|
@@ -37,16 +30,11 @@ const installHint = 'Install it in your project with: npm install --save-dev typ
|
|
|
37
30
|
* @returns {Object} The TypeScript compiler API module.
|
|
38
31
|
* @throws {Error} With install instructions when typescript is not installed.
|
|
39
32
|
*/
|
|
40
|
-
const loadTypescript = (projectPath = process.cwd()) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
throw new Error(`The typescript task needs the optional peer dependency typescript, which is not installed. ${installHint}`);
|
|
46
|
-
}
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
33
|
+
const loadTypescript = (projectPath = process.cwd()) => (0, _loadPeer.requirePeer)('typescript', {
|
|
34
|
+
task: 'typescript',
|
|
35
|
+
installHint,
|
|
36
|
+
projectPath
|
|
37
|
+
});
|
|
50
38
|
exports.loadTypescript = loadTypescript;
|
|
51
39
|
const streamToPromise = stream => new Promise((resolve, reject) => {
|
|
52
40
|
stream.on('finish', resolve);
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.writeDocEntries = exports.typeDocsFor = exports.loadTypeDoc = exports.describeFolder = exports.describeExports = void 0;
|
|
8
|
+
require("core-js/modules/es.json.stringify.js");
|
|
9
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
10
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
11
|
+
require("core-js/modules/esnext.iterator.find.js");
|
|
12
|
+
require("core-js/modules/esnext.iterator.flat-map.js");
|
|
13
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
14
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
15
|
+
require("core-js/modules/esnext.iterator.some.js");
|
|
16
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
17
|
+
var _nodeOs = _interopRequireDefault(require("node:os"));
|
|
18
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
19
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
20
|
+
var _loadPeer = require("./loadPeer.js");
|
|
21
|
+
var _tsFor = require("./tsFor.js");
|
|
22
|
+
var _removeDirectory = require("./removeDirectory.js");
|
|
23
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
24
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
25
|
+
const installHint = 'Install it in your project with: npm install --save-dev typedoc';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Find the TypeDoc of the project being built (an optional peer dependency, only needed when the docs task is
|
|
29
|
+
* enabled) and load it, so projects which do not document TypeScript never need it installed.
|
|
30
|
+
* @memberOf module:partials
|
|
31
|
+
* @param {string} [projectPath=process.cwd()] The folder of the project (which has the package.json) being built.
|
|
32
|
+
* @returns {Promise<Object>} The TypeDoc module.
|
|
33
|
+
* @throws {Error} With install instructions when typedoc is not installed.
|
|
34
|
+
*/
|
|
35
|
+
const loadTypeDoc = (projectPath = process.cwd()) => (0, _loadPeer.importPeer)('typedoc', {
|
|
36
|
+
task: 'docs',
|
|
37
|
+
installHint,
|
|
38
|
+
projectPath
|
|
39
|
+
});
|
|
40
|
+
exports.loadTypeDoc = loadTypeDoc;
|
|
41
|
+
const isSource = fileName => /\.(ts|tsx|mts|cts)$/.test(fileName) && !/\.d\.[cm]?ts$/.test(fileName) && !/\.(test|spec)\./.test(fileName);
|
|
42
|
+
const listSources = dirPath => _nodeFs.default.readdirSync(dirPath, {
|
|
43
|
+
withFileTypes: true
|
|
44
|
+
}).flatMap(entry => {
|
|
45
|
+
const entryPath = _nodePath.default.join(dirPath, entry.name);
|
|
46
|
+
if (entry.isDirectory()) {
|
|
47
|
+
return entry.name === 'node_modules' ? [] : listSources(entryPath);
|
|
48
|
+
}
|
|
49
|
+
return isSource(entry.name) ? [entryPath] : [];
|
|
50
|
+
});
|
|
51
|
+
const toIdentifier = fileName => fileName.replace(/[^\w$]+(\w)?/g, (match, letter) => (letter || '').toUpperCase()).replace(/^(\d)/, '_$1');
|
|
52
|
+
const toModulePath = filePath => filePath.replace(/\.[cm]?tsx?$/, '').split(_nodePath.default.sep).join('/');
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Describe what a source file exports: whether it has a default export, and whether it has any named exports.
|
|
56
|
+
* @memberOf module:partials
|
|
57
|
+
* @param {Object} ts - The TypeScript compiler API.
|
|
58
|
+
* @param {string} filePath
|
|
59
|
+
* @returns {{hasDefault: boolean, hasNamed: boolean}}
|
|
60
|
+
*/
|
|
61
|
+
const describeExports = (ts, filePath) => {
|
|
62
|
+
const source = ts.createSourceFile(filePath, _nodeFs.default.readFileSync(filePath, 'utf8'), ts.ScriptTarget.Latest);
|
|
63
|
+
let hasDefault = false;
|
|
64
|
+
let hasNamed = false;
|
|
65
|
+
source.statements.forEach(statement => {
|
|
66
|
+
if (ts.isExportAssignment(statement)) {
|
|
67
|
+
hasDefault = hasDefault || !statement.isExportEquals;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (ts.isExportDeclaration(statement)) {
|
|
71
|
+
const names = statement.exportClause && ts.isNamedExports(statement.exportClause) ? statement.exportClause.elements : null;
|
|
72
|
+
if (names && names.some(element => element.name.text === 'default')) {
|
|
73
|
+
hasDefault = true;
|
|
74
|
+
}
|
|
75
|
+
if (!names || names.some(element => element.name.text !== 'default')) {
|
|
76
|
+
hasNamed = true;
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) || [] : [];
|
|
81
|
+
if (modifiers.some(modifier => modifier.kind === ts.SyntaxKind.ExportKeyword)) {
|
|
82
|
+
if (modifiers.some(modifier => modifier.kind === ts.SyntaxKind.DefaultKeyword)) {
|
|
83
|
+
hasDefault = true;
|
|
84
|
+
} else {
|
|
85
|
+
hasNamed = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
hasDefault,
|
|
91
|
+
hasNamed
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The description of a folder for its module: the first doc comment of the folder's index file, without its tags
|
|
97
|
+
* (@module, @file, ...), or an empty string when there is none.
|
|
98
|
+
* @memberOf module:partials
|
|
99
|
+
* @param {string} folderPath
|
|
100
|
+
* @returns {string}
|
|
101
|
+
*/
|
|
102
|
+
exports.describeExports = describeExports;
|
|
103
|
+
const describeFolder = folderPath => {
|
|
104
|
+
const indexFile = ['index.ts', 'index.tsx', 'index.mts', 'index.cts'].map(name => _nodePath.default.join(folderPath, name)).find(file => _nodeFs.default.existsSync(file));
|
|
105
|
+
const comment = indexFile && _nodeFs.default.readFileSync(indexFile, 'utf8').match(/^\s*\/\*\*([\s\S]*?)\*\//);
|
|
106
|
+
if (!comment) {
|
|
107
|
+
return '';
|
|
108
|
+
}
|
|
109
|
+
const lines = comment[1].split('\n').map(line => line.replace(/^\s*\* ?/, '').trimEnd());
|
|
110
|
+
const tagAt = lines.findIndex(line => /^@\w+/.test(line));
|
|
111
|
+
return (tagAt === -1 ? lines : lines.slice(0, tagAt)).join('\n').trim();
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Write one entry file per folder of the source directory into the entry directory. TypeDoc makes a module of every
|
|
116
|
+
* entry file, so the modules of the documentation mirror the folders. The default export of each source file is
|
|
117
|
+
* re-exported under the name of the file (the source files hold one function each), and anything else a file exports
|
|
118
|
+
* is re-exported as it is (that is where the types.ts files go). Index files (the barrels), tests and declaration
|
|
119
|
+
* files are left out, but the first doc comment of a folder's index file becomes the description of its module. A source directory with no folders gets a single entry called index.
|
|
120
|
+
* @memberOf module:partials
|
|
121
|
+
* @param {Object} ts - The TypeScript compiler API.
|
|
122
|
+
* @param {string} srcDir - The directory holding the TypeScript source.
|
|
123
|
+
* @param {string} entryDir - The directory to write the entry files into.
|
|
124
|
+
* @returns {Array<string>} The paths of the entry files.
|
|
125
|
+
*/
|
|
126
|
+
exports.describeFolder = describeFolder;
|
|
127
|
+
const writeDocEntries = (ts, srcDir, entryDir) => {
|
|
128
|
+
const absoluteSrc = _nodePath.default.resolve(srcDir);
|
|
129
|
+
_nodeFs.default.mkdirSync(entryDir, {
|
|
130
|
+
recursive: true
|
|
131
|
+
});
|
|
132
|
+
const folders = _nodeFs.default.readdirSync(absoluteSrc, {
|
|
133
|
+
withFileTypes: true
|
|
134
|
+
}).filter(entry => entry.isDirectory() && entry.name !== 'node_modules').map(entry => ({
|
|
135
|
+
name: entry.name,
|
|
136
|
+
path: _nodePath.default.join(absoluteSrc, entry.name),
|
|
137
|
+
files: listSources(_nodePath.default.join(absoluteSrc, entry.name))
|
|
138
|
+
})).filter(folder => folder.files.length);
|
|
139
|
+
const groups = folders.length ? folders : [{
|
|
140
|
+
name: 'index',
|
|
141
|
+
path: absoluteSrc,
|
|
142
|
+
files: listSources(absoluteSrc).filter(file => !/^(index|main)\./.test(_nodePath.default.basename(file)))
|
|
143
|
+
}];
|
|
144
|
+
return groups.map(group => {
|
|
145
|
+
const lines = group.files.filter(file => !/^index\./.test(_nodePath.default.basename(file))).sort().flatMap(file => {
|
|
146
|
+
const modulePath = toModulePath(file);
|
|
147
|
+
const {
|
|
148
|
+
hasDefault,
|
|
149
|
+
hasNamed
|
|
150
|
+
} = describeExports(ts, file);
|
|
151
|
+
const fileName = _nodePath.default.basename(file).replace(/\.[cm]?tsx?$/, '');
|
|
152
|
+
return [...(hasDefault ? [`export { default as ${toIdentifier(fileName)} } from '${modulePath}'`] : []), ...(hasNamed ? [`export * from '${modulePath}'`] : [])];
|
|
153
|
+
});
|
|
154
|
+
const description = group.path ? describeFolder(group.path) : '';
|
|
155
|
+
// TypeDoc takes the first comment of an entry file which has the @module tag as the description of the module
|
|
156
|
+
const moduleComment = description ? `/**\n${description.split('\n').map(line => ` * ${line}`.trimEnd()).join('\n')}\n * @module\n */\n\n` : '';
|
|
157
|
+
const entryPath = _nodePath.default.join(entryDir, `${group.name}.ts`);
|
|
158
|
+
_nodeFs.default.writeFileSync(entryPath, moduleComment + lines.join('\n') + '\n');
|
|
159
|
+
return entryPath;
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
exports.writeDocEntries = writeDocEntries;
|
|
163
|
+
const projectName = () => {
|
|
164
|
+
try {
|
|
165
|
+
return JSON.parse(_nodeFs.default.readFileSync(_nodePath.default.join(process.cwd(), 'package.json'), 'utf8')).name;
|
|
166
|
+
} catch (error) {
|
|
167
|
+
return _nodePath.default.basename(process.cwd());
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Generate the HTML documentation of a TypeScript project with TypeDoc, straight from the TypeScript source, so the
|
|
173
|
+
* types (and the comments on them) are documented from where they are defined. The modules mirror the folders of the
|
|
174
|
+
* source, see {@link writeDocEntries}. Configure this with 'docs.from', 'docs.to', 'docs.index', 'docs.title',
|
|
175
|
+
* 'docs.tsconfig' and 'docs.logLevel'.
|
|
176
|
+
* @memberOf module:partials
|
|
177
|
+
* @param {string} [srcPath=gulpConfig.get('docs.from')] - The directory holding the TypeScript source.
|
|
178
|
+
* @param {string} [outPath=gulpConfig.get('docs.to')] - The directory the documentation is generated into (cleared first).
|
|
179
|
+
* @param {function(string): Promise<Object>} [loadDocs] - Resolves the TypeDoc module, tests can inject a stand-in.
|
|
180
|
+
* @returns {Function} A gulp task, it accepts an optional callback and returns a promise.
|
|
181
|
+
*/
|
|
182
|
+
const typeDocsFor = (srcPath = gulpConfig.get('docs.from'), outPath = gulpConfig.get('docs.to'), loadDocs = loadTypeDoc) => {
|
|
183
|
+
if (gulpConfig.get('docs.enabled') === false) {
|
|
184
|
+
return () => {};
|
|
185
|
+
}
|
|
186
|
+
return done => {
|
|
187
|
+
const generate = async () => {
|
|
188
|
+
const ts = (0, _tsFor.loadTypescript)();
|
|
189
|
+
const {
|
|
190
|
+
Application
|
|
191
|
+
} = await loadDocs();
|
|
192
|
+
const workDir = _nodeFs.default.mkdtempSync(_nodePath.default.join(_nodeOs.default.tmpdir(), 'typedocs-'));
|
|
193
|
+
try {
|
|
194
|
+
const entryPoints = writeDocEntries(ts, srcPath, _nodePath.default.join(workDir, 'entries'));
|
|
195
|
+
// The entry files live outside the project, so the tsconfig which is used for the documentation extends the
|
|
196
|
+
// one of the project and adds the entries to the files it includes.
|
|
197
|
+
const projectConfig = gulpConfig.get('docs.tsconfig') || gulpConfig.get('typescript.config');
|
|
198
|
+
const tsconfig = _nodePath.default.join(workDir, 'tsconfig.json');
|
|
199
|
+
_nodeFs.default.writeFileSync(tsconfig, JSON.stringify({
|
|
200
|
+
...(projectConfig ? {
|
|
201
|
+
extends: _nodePath.default.resolve(projectConfig)
|
|
202
|
+
} : {}),
|
|
203
|
+
include: [_nodePath.default.join(workDir, 'entries', '*.ts').split(_nodePath.default.sep).join('/'), _nodePath.default.resolve(srcPath).split(_nodePath.default.sep).join('/') + '/**/*.ts'],
|
|
204
|
+
exclude: [_nodePath.default.resolve(srcPath).split(_nodePath.default.sep).join('/') + '/**/*.test.*']
|
|
205
|
+
}));
|
|
206
|
+
const indexFile = gulpConfig.get('docs.index');
|
|
207
|
+
await (0, _removeDirectory.removeDirectory)(outPath);
|
|
208
|
+
const app = await Application.bootstrap({
|
|
209
|
+
entryPoints,
|
|
210
|
+
tsconfig,
|
|
211
|
+
name: gulpConfig.get('docs.title') || projectName(),
|
|
212
|
+
readme: indexFile && _nodeFs.default.existsSync(indexFile) ? indexFile : 'none',
|
|
213
|
+
logLevel: gulpConfig.get('docs.logLevel') || 'Warn',
|
|
214
|
+
skipErrorChecking: true
|
|
215
|
+
});
|
|
216
|
+
const project = await app.convert();
|
|
217
|
+
if (!project) {
|
|
218
|
+
throw new Error('TypeDoc could not read the TypeScript source, see the errors above.');
|
|
219
|
+
}
|
|
220
|
+
await app.generateDocs(project, outPath);
|
|
221
|
+
} finally {
|
|
222
|
+
await (0, _removeDirectory.removeDirectory)(workDir);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
return typeof done === 'function' ? generate().then(() => done(), done) : generate();
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
exports.typeDocsFor = typeDocsFor;
|
package/dist/partials.js
CHANGED
|
@@ -51,6 +51,18 @@ Object.defineProperty(exports, 'imagesFor', {
|
|
|
51
51
|
return _imagesFor.imagesFor
|
|
52
52
|
}
|
|
53
53
|
})
|
|
54
|
+
Object.defineProperty(exports, 'importModule', {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _loadPeer.importModule
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
Object.defineProperty(exports, 'importPeer', {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _loadPeer.importPeer
|
|
64
|
+
}
|
|
65
|
+
})
|
|
54
66
|
Object.defineProperty(exports, 'minifyFor', {
|
|
55
67
|
enumerable: true,
|
|
56
68
|
get: function () {
|
|
@@ -69,6 +81,12 @@ Object.defineProperty(exports, 'removeDirectory', {
|
|
|
69
81
|
return _removeDirectory.removeDirectory
|
|
70
82
|
}
|
|
71
83
|
})
|
|
84
|
+
Object.defineProperty(exports, 'requirePeer', {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _loadPeer.requirePeer
|
|
88
|
+
}
|
|
89
|
+
})
|
|
72
90
|
Object.defineProperty(exports, 'runOnChange', {
|
|
73
91
|
enumerable: true,
|
|
74
92
|
get: function () {
|
|
@@ -93,6 +111,12 @@ Object.defineProperty(exports, 'tsFor', {
|
|
|
93
111
|
return _tsFor.tsFor
|
|
94
112
|
}
|
|
95
113
|
})
|
|
114
|
+
Object.defineProperty(exports, 'typeDocsFor', {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function () {
|
|
117
|
+
return _typeDocsFor.typeDocsFor
|
|
118
|
+
}
|
|
119
|
+
})
|
|
96
120
|
var _addToReadme = require('./partials/addToReadme.js')
|
|
97
121
|
var _beginWatcher = require('./partials/beginWatcher.js')
|
|
98
122
|
var _clean = require('./partials/clean.js')
|
|
@@ -101,6 +125,7 @@ var _distFor = require('./partials/distFor.js')
|
|
|
101
125
|
var _distForSrc = require('./partials/distForSrc.js')
|
|
102
126
|
var _distSeries = require('./partials/distSeries.js')
|
|
103
127
|
var _imagesFor = require('./partials/imagesFor.js')
|
|
128
|
+
var _loadPeer = require('./partials/loadPeer.js')
|
|
104
129
|
var _minifyFor = require('./partials/minifyFor.js')
|
|
105
130
|
var _readmeTemplate = require('./partials/readmeTemplate.js')
|
|
106
131
|
var _removeDirectory = require('./partials/removeDirectory.js')
|
|
@@ -108,3 +133,4 @@ var _runOnChange = require('./partials/runOnChange.js')
|
|
|
108
133
|
var _sassFor = require('./partials/sassFor.js')
|
|
109
134
|
var _standardLint = require('./partials/standardLint.js')
|
|
110
135
|
var _tsFor = require('./partials/tsFor.js')
|
|
136
|
+
var _typeDocsFor = require('./partials/typeDocsFor.js')
|
package/dist/partials.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"addToReadme",{enumerable:!0,get:function(){return _addToReadme.addToReadme}}),Object.defineProperty(exports,"beginWatcher",{enumerable:!0,get:function(){return _beginWatcher.beginWatcher}}),Object.defineProperty(exports,"clean",{enumerable:!0,get:function(){return _clean.clean}}),Object.defineProperty(exports,"copyFor",{enumerable:!0,get:function(){return _copyFor.copyFor}}),Object.defineProperty(exports,"distFor",{enumerable:!0,get:function(){return _distFor.distFor}}),Object.defineProperty(exports,"distForSrc",{enumerable:!0,get:function(){return _distForSrc.distForSrc}}),Object.defineProperty(exports,"distSeries",{enumerable:!0,get:function(){return _distSeries.distSeries}}),Object.defineProperty(exports,"imagesFor",{enumerable:!0,get:function(){return _imagesFor.imagesFor}}),Object.defineProperty(exports,"minifyFor",{enumerable:!0,get:function(){return _minifyFor.minifyFor}}),Object.defineProperty(exports,"readmeTemplate",{enumerable:!0,get:function(){return _readmeTemplate.readmeTemplate}}),Object.defineProperty(exports,"removeDirectory",{enumerable:!0,get:function(){return _removeDirectory.removeDirectory}}),Object.defineProperty(exports,"runOnChange",{enumerable:!0,get:function(){return _runOnChange.runOnChange}}),Object.defineProperty(exports,"sassFor",{enumerable:!0,get:function(){return _sassFor.sassFor}}),Object.defineProperty(exports,"standardLint",{enumerable:!0,get:function(){return _standardLint.standardLint}}),Object.defineProperty(exports,"tsFor",{enumerable:!0,get:function(){return _tsFor.tsFor}});var _addToReadme=require("./partials/addToReadme.js"),_beginWatcher=require("./partials/beginWatcher.js"),_clean=require("./partials/clean.js"),_copyFor=require("./partials/copyFor.js"),_distFor=require("./partials/distFor.js"),_distForSrc=require("./partials/distForSrc.js"),_distSeries=require("./partials/distSeries.js"),_imagesFor=require("./partials/imagesFor.js"),_minifyFor=require("./partials/minifyFor.js"),_readmeTemplate=require("./partials/readmeTemplate.js"),_removeDirectory=require("./partials/removeDirectory.js"),_runOnChange=require("./partials/runOnChange.js"),_sassFor=require("./partials/sassFor.js"),_standardLint=require("./partials/standardLint.js"),_tsFor=require("./partials/tsFor.js");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"addToReadme",{enumerable:!0,get:function(){return _addToReadme.addToReadme}}),Object.defineProperty(exports,"beginWatcher",{enumerable:!0,get:function(){return _beginWatcher.beginWatcher}}),Object.defineProperty(exports,"clean",{enumerable:!0,get:function(){return _clean.clean}}),Object.defineProperty(exports,"copyFor",{enumerable:!0,get:function(){return _copyFor.copyFor}}),Object.defineProperty(exports,"distFor",{enumerable:!0,get:function(){return _distFor.distFor}}),Object.defineProperty(exports,"distForSrc",{enumerable:!0,get:function(){return _distForSrc.distForSrc}}),Object.defineProperty(exports,"distSeries",{enumerable:!0,get:function(){return _distSeries.distSeries}}),Object.defineProperty(exports,"imagesFor",{enumerable:!0,get:function(){return _imagesFor.imagesFor}}),Object.defineProperty(exports,"importModule",{enumerable:!0,get:function(){return _loadPeer.importModule}}),Object.defineProperty(exports,"importPeer",{enumerable:!0,get:function(){return _loadPeer.importPeer}}),Object.defineProperty(exports,"minifyFor",{enumerable:!0,get:function(){return _minifyFor.minifyFor}}),Object.defineProperty(exports,"readmeTemplate",{enumerable:!0,get:function(){return _readmeTemplate.readmeTemplate}}),Object.defineProperty(exports,"removeDirectory",{enumerable:!0,get:function(){return _removeDirectory.removeDirectory}}),Object.defineProperty(exports,"requirePeer",{enumerable:!0,get:function(){return _loadPeer.requirePeer}}),Object.defineProperty(exports,"runOnChange",{enumerable:!0,get:function(){return _runOnChange.runOnChange}}),Object.defineProperty(exports,"sassFor",{enumerable:!0,get:function(){return _sassFor.sassFor}}),Object.defineProperty(exports,"standardLint",{enumerable:!0,get:function(){return _standardLint.standardLint}}),Object.defineProperty(exports,"tsFor",{enumerable:!0,get:function(){return _tsFor.tsFor}}),Object.defineProperty(exports,"typeDocsFor",{enumerable:!0,get:function(){return _typeDocsFor.typeDocsFor}});var _addToReadme=require("./partials/addToReadme.js"),_beginWatcher=require("./partials/beginWatcher.js"),_clean=require("./partials/clean.js"),_copyFor=require("./partials/copyFor.js"),_distFor=require("./partials/distFor.js"),_distForSrc=require("./partials/distForSrc.js"),_distSeries=require("./partials/distSeries.js"),_imagesFor=require("./partials/imagesFor.js"),_loadPeer=require("./partials/loadPeer.js"),_minifyFor=require("./partials/minifyFor.js"),_readmeTemplate=require("./partials/readmeTemplate.js"),_removeDirectory=require("./partials/removeDirectory.js"),_runOnChange=require("./partials/runOnChange.js"),_sassFor=require("./partials/sassFor.js"),_standardLint=require("./partials/standardLint.js"),_tsFor=require("./partials/tsFor.js"),_typeDocsFor=require("./partials/typeDocsFor.js");
|
package/dist/sass.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.sass = void 0
|
|
7
|
-
const _sassFor = require('./partials/sassFor.js')
|
|
8
|
-
// Compile sass into CSS & auto-inject into browsers
|
|
9
|
-
const sass = () => (0, _sassFor.sassFor)()
|
|
10
|
-
exports.sass = sass
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.sass = void 0
|
|
7
|
+
const _sassFor = require('./partials/sassFor.js')
|
|
8
|
+
// Compile sass into CSS & auto-inject into browsers
|
|
9
|
+
const sass = () => (0, _sassFor.sassFor)()
|
|
10
|
+
exports.sass = sass
|