js-build-tools 6.2.2 → 6.3.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.
Files changed (52) hide show
  1. package/README.md +180 -9
  2. package/dist/build.js +66 -66
  3. package/dist/bundle.js +1 -1
  4. package/dist/docs.js +11 -11
  5. package/dist/partials/jsdocDocsFor.js +31 -13
  6. package/dist/partials/loadPlaywright.js +34 -0
  7. package/dist/partials/neostandardLint.js +5 -3
  8. package/dist/partials/resolveDocsMethod.js +12 -12
  9. package/dist/partials/serveStatic.js +57 -0
  10. package/dist/partials/tsFor.js +2 -2
  11. package/dist/partials/typeDocsFor.js +28 -22
  12. package/dist/partials.js +169 -149
  13. package/dist/partials.min.js +1 -1
  14. package/dist/test-helpers/setUp.js +6 -0
  15. package/dist/utilities/convertMjsFilesForDocs.js +1 -0
  16. package/dist/utilities/dotGet.js +1 -0
  17. package/dist/utilities/dotNotate.js +5 -0
  18. package/dist/utilities/dotSet.js +1 -0
  19. package/dist/utilities/esmNamedExportsToCjs.js +1 -0
  20. package/dist/utilities/getBundleConfigs.js +1 -0
  21. package/dist/utilities/isObject.js +1 -0
  22. package/dist/utilities/strAfter.js +1 -0
  23. package/dist/utilities/strBefore.js +1 -0
  24. package/functions/bundle.mjs +1 -1
  25. package/functions/jsdocEsmExports.test.mjs +24 -0
  26. package/functions/partials/jsdocDocsFor.mjs +25 -13
  27. package/functions/partials/jsdocDocsFor.test.mjs +48 -0
  28. package/functions/partials/loadPlaywright.mjs +23 -0
  29. package/functions/partials/loadPlaywright.test.mjs +71 -0
  30. package/functions/partials/neostandardLint.mjs +5 -3
  31. package/functions/partials/serveStatic.mjs +47 -0
  32. package/functions/partials/serveStatic.test.mjs +71 -0
  33. package/functions/partials/tsFor.mjs +2 -2
  34. package/functions/partials/typeDocsFor.mjs +24 -20
  35. package/functions/partials/typeDocsFor.test.mjs +23 -0
  36. package/functions/partials.mjs +2 -0
  37. package/functions/partials.test.mjs +1 -1
  38. package/functions/test-helpers/setUp.mjs +6 -0
  39. package/functions/utilities/convertMjsFilesForDocs.mjs +1 -0
  40. package/functions/utilities/dotGet.mjs +1 -0
  41. package/functions/utilities/dotNotate.mjs +5 -0
  42. package/functions/utilities/dotSet.mjs +1 -0
  43. package/functions/utilities/esmNamedExportsToCjs.mjs +1 -0
  44. package/functions/utilities/getBundleConfigs.mjs +1 -0
  45. package/functions/utilities/isObject.mjs +1 -0
  46. package/functions/utilities/strAfter.mjs +1 -0
  47. package/functions/utilities/strBefore.mjs +1 -0
  48. package/gulp.config.mjs +2 -2
  49. package/gulpfile.base.mjs +1 -3
  50. package/jsdoc.base.js +9 -3
  51. package/jsdoc.esmExports.js +17 -0
  52. package/package.json +16 -10
@@ -23,6 +23,12 @@ export const setDefaults = (testDir = 'test-temp') => {
23
23
  gulpConfig.set('dist.from', `${srcPath}/**/!(*.test).js`)
24
24
  gulpConfig.set('dist.main', `${distPath}/main`)
25
25
  gulpConfig.set('dist.to', distPath)
26
+ // Reset explicitly, for the same reason as readme.fromEsm below: this project's own build-tools.config.json turns
27
+ // docs on and points them at the website checkout, which would leak into every test that never sets these itself.
28
+ gulpConfig.set('docs.enabled', false)
29
+ gulpConfig.set('docs.from', srcPath)
30
+ gulpConfig.set('docs.to', `${tempDir}docs`)
31
+ gulpConfig.set('docs.title', '')
26
32
  gulpConfig.set('fonts.from', `${srcPath}/fonts/**/*`)
27
33
  gulpConfig.set('fonts.to', `${browserPath}/fonts`)
28
34
  gulpConfig.set('images.from', `${srcPath}/img/**/*.+(png|jpg|jpeg|gif|svg)`)
@@ -14,6 +14,7 @@ import { esmNamedExportsToCjs } from './esmNamedExportsToCjs.mjs'
14
14
  * @param {Array<string>} mjsFilePaths - Real `.mjs` files to convert. An empty array is a safe, cheap no-op.
15
15
  * @returns {{filePaths: Array<string>, cleanUp: function(): void}} The temp `.js` file paths to pass to
16
16
  * jsdoc-to-markdown instead of the real `.mjs` ones, and a function to remove the temp directory afterward.
17
+ * @private
17
18
  */
18
19
  export const convertMjsFilesForDocs = (mjsFilePaths = []) => {
19
20
  if (mjsFilePaths.length === 0) {
@@ -9,6 +9,7 @@ import { strBefore } from './strBefore.mjs'
9
9
  * @param {string} [dotNotation=''] - The path to the property
10
10
  * @param {string|null} [defaultValue=null] - The default value to return if the property is not found
11
11
  * @returns {*} The value of the property
12
+ * @private
12
13
  */
13
14
  export const dotGet = (arrayObject = {}, dotNotation= '', defaultValue = null) => {
14
15
  if (!dotNotation) {
@@ -4,12 +4,14 @@ import { isObject } from './isObject.mjs'
4
4
  * Convert an array of keys into a regex, return a function to test if incoming keys match.
5
5
  * @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
6
6
  * @returns {Function} The dot-notated array
7
+ * @private
7
8
  */
8
9
  const handleRetainObjects = (retainObjects = []) => {
9
10
  if (!retainObjects.length) {
10
11
  /**
11
12
  * Bypass the test function if there are no retainObjects.
12
13
  * @returns {false}
14
+ * @private
13
15
  */
14
16
  return (currentKey, value, results) => false
15
17
  }
@@ -21,6 +23,7 @@ const handleRetainObjects = (retainObjects = []) => {
21
23
  * @param {*} value - The value of the key
22
24
  * @param {Object} results - The result object to add to
23
25
  * @returns {boolean}
26
+ * @private
24
27
  */
25
28
  return (currentKey, value, results) => {
26
29
  if (!currentKey.match(retainRegex)) {
@@ -38,6 +41,7 @@ const handleRetainObjects = (retainObjects = []) => {
38
41
  * @param {string} [prepend=''] - The path for the property being processed
39
42
  * @param {Object<string, *>} [results={}] - The final notated object to return
40
43
  * @returns {Object<string, *>} The dot-notated object
44
+ * @private
41
45
  */
42
46
  const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) => {
43
47
  for (let key in arrayObject) {
@@ -64,5 +68,6 @@ const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) =>
64
68
  * @param {Object} arrayObject - The array or object to dot-notate
65
69
  * @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
66
70
  * @returns {Object<string, *>} The dot-notated object
71
+ * @private
67
72
  */
68
73
  export const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects))
@@ -9,6 +9,7 @@ import { strBefore } from './strBefore.mjs'
9
9
  * @param {string} dotNotation - The path for the property
10
10
  * @param {*} value - The default value to return if the property is not found
11
11
  * @returns {Object} The modified object
12
+ * @private
12
13
  */
13
14
  export const dotSet = (arrayObject, dotNotation, value = null) => {
14
15
  let key = strBefore(dotNotation, '.')
@@ -12,6 +12,7 @@
12
12
  * @memberOf module:utilities
13
13
  * @param {string} source - The raw ESM source text (never executed, just rewritten as text).
14
14
  * @returns {string} The rewritten text, safe to write out with a `.js` extension for jsdoc-to-markdown to read.
15
+ * @private
15
16
  */
16
17
  export const esmNamedExportsToCjs = (source) => {
17
18
  const exportedNames = []
@@ -8,6 +8,7 @@ import * as gulpConfig from '../../gulp.config.mjs'
8
8
  * specify what's actually different about it.
9
9
  * @memberOf module:utilities
10
10
  * @returns {Array<{name: string, main: string, ignore: Array, exclude: Array}>}
11
+ * @private
11
12
  */
12
13
  export const getBundleConfigs = () => {
13
14
  const primary = {
@@ -3,5 +3,6 @@
3
3
  * Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/isObject.ts Sí, funciona}
4
4
  * @param {*} object
5
5
  * @returns {boolean}
6
+ * @private
6
7
  */
7
8
  export const isObject = (object) => typeof object === 'object' && object !== null
@@ -4,6 +4,7 @@
4
4
  * @param {string} str
5
5
  * @param {string} search
6
6
  * @returns {string}
7
+ * @private
7
8
  */
8
9
  export const strAfter = (str, search) => {
9
10
  const index = str.indexOf(search)
@@ -4,6 +4,7 @@
4
4
  * @param {string} str
5
5
  * @param {string} search
6
6
  * @returns {string}
7
+ * @private
7
8
  */
8
9
  export const strBefore = (str, search) => {
9
10
  const index = str.indexOf(search)
package/gulp.config.mjs CHANGED
@@ -133,8 +133,8 @@ import { fileExists } from 'test-filesystem'
133
133
  * @typedef {Object<string, Setting>} module:gulpConfig~DocsConfig
134
134
  * @property {BooleanSetting} enabled - Toggle generating the documentation from the source. When it is on the
135
135
  * build does this instead of generating the readme from the jsdoc comments of the compiled files.
136
- * @property {StringSetting} from - The directory holding the source, each folder in it becomes a module (TypeDoc) or
137
- * is scanned recursively (jsdoc).
136
+ * @property {ArrayableSetting} from - The directory holding the source, each folder in it becomes a module (TypeDoc) or
137
+ * is scanned recursively (jsdoc). jsdoc also takes a list of directories and files.
138
138
  * @property {StringSetting} index - The markdown file used as the front page of the documentation.
139
139
  * @property {StringSetting} logLevel - How much TypeDoc reports: Verbose, Info, Warn, Error or None. Not used by jsdoc.
140
140
  * @property {FlagStringSetting} method - 'typedoc' or 'jsdoc'. False (the default) infers it from typescript.enabled -
package/gulpfile.base.mjs CHANGED
@@ -1,8 +1,6 @@
1
1
  /**
2
- * import these functions to your own project to customize your build pipeline.
3
- * @file
2
+ * Import these functions to your own project to customize your build pipeline.
4
3
  * @author Joshua Heagle <joshuaheagle@gmail.com>
5
- * @version 3.0.0
6
4
  * @module js-build-tools
7
5
  */
8
6
  export { build } from './functions/build.mjs'
package/jsdoc.base.js CHANGED
@@ -1,10 +1,16 @@
1
+ const path = require('path')
1
2
  const gulpConfig = require('./gulp.config.js')
2
3
 
3
4
  module.exports = {
4
- plugins: ['plugins/markdown'],
5
+ plugins: ['plugins/markdown', path.join(__dirname, 'jsdoc.esmExports.js')],
6
+ // Give markdown headings ids (the README / docs.index front page), so they can be linked to and a theme's
7
+ // table of contents can follow them
8
+ markdown: { idInHeadings: true },
5
9
  source: {
6
10
  include: [gulpConfig.get('dist.to')],
7
- includePattern: '.+\\.js(doc|x)?$',
8
- excludePattern: '((^|\\/|\\\\)_|.+\\.test\\..*)'
11
+ // .mjs / .cjs too, so ES module source can be documented as it is, not only its compiled CommonJS
12
+ includePattern: '.+\\.[cm]?js(doc|x)?$',
13
+ // Files starting with _, tests, and minified copies (which only repeat what their unminified file documents)
14
+ excludePattern: '((^|\\/|\\\\)_|.+\\.test\\..*|.+\\.min\\.[cm]?js$)'
9
15
  },
10
16
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A jsdoc plugin for ES module source. When a file has no @module tag of its own, jsdoc names each
3
+ * `export const x` it documents `exports.x`, so with `@memberOf module:name` it becomes `module:name.exports.x`
4
+ * (shown as "exports.x"). This drops that `exports.` so it is `module:name.x`, the name it is used by.
5
+ */
6
+ const prefix = 'exports.'
7
+
8
+ exports.handlers = {
9
+ newDoclet ({ doclet }) {
10
+ if (doclet.name && doclet.name.startsWith(prefix)) {
11
+ doclet.name = doclet.name.slice(prefix.length)
12
+ }
13
+ if (doclet.longname && doclet.longname.includes(`.${prefix}`)) {
14
+ doclet.longname = doclet.longname.replace(`.${prefix}`, '.')
15
+ }
16
+ }
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-build-tools",
3
- "version": "6.2.2",
3
+ "version": "6.3.0",
4
4
  "description": "Standardised build process with gulp.",
5
5
  "main": "gulpfile.base.js",
6
6
  "exports": {
@@ -20,7 +20,7 @@
20
20
  "scripts": {
21
21
  "build": "gulp build",
22
22
  "dev": "gulp",
23
- "htmldocs": "jsdoc -R MAIN.md -c ./.jsdoc.conf.js -d docs",
23
+ "docs": "gulp docs",
24
24
  "readme": "gulp readme",
25
25
  "release": "release-it",
26
26
  "release:dry-run": "release-it --dry-run",
@@ -56,9 +56,9 @@
56
56
  "autoprefixer": "^10.6.1",
57
57
  "babel-jest": "^30.5.2",
58
58
  "browserify": "^17.0.1",
59
- "core-js": "^3.50.0",
59
+ "core-js": "^3.51.0",
60
60
  "cssnano": "^6.1.2",
61
- "eslint": "^10.12.0",
61
+ "eslint": "^10.13.0",
62
62
  "glob": "^13.0.6",
63
63
  "gulp": "^5.0.1",
64
64
  "gulp-babel": "^8.1.0",
@@ -66,17 +66,17 @@
66
66
  "gulp-postcss": "^10.0.0",
67
67
  "gulp-rename": "^2.1.0",
68
68
  "gulp-sass": "^6.0.1",
69
- "gulp-ts-compile": "^1.0.1",
69
+ "gulp-ts-compile": "^1.0.2",
70
70
  "gulp-uglify-es": "^3.0.0",
71
71
  "jest": "^30.5.2",
72
72
  "jest-environment-jsdom": "^30.5.2",
73
73
  "jsdoc-to-markdown": "^9.1.3",
74
74
  "merge-stream": "^2.0.0",
75
75
  "neostandard": "^0.14.1",
76
- "postcss": "^8.5.30",
76
+ "postcss": "^8.5.31",
77
77
  "regenerator-runtime": "^0.14.1",
78
- "sass": "^1.105.1",
79
- "test-filesystem": "^2.0.0",
78
+ "sass": "^1.105.2",
79
+ "test-filesystem": "^2.0.2",
80
80
  "through2": "^4.0.2",
81
81
  "vinyl-source-stream": "^2.0.0"
82
82
  },
@@ -84,6 +84,7 @@
84
84
  "clean-jsdoc-theme": ">=4.0.0",
85
85
  "gulp-imagemin": ">=9.0.0",
86
86
  "jsdoc": ">=4.0.0",
87
+ "playwright": ">=1.40.0",
87
88
  "typedoc": ">=0.28.0",
88
89
  "typescript": ">=5.0.0 <7.0.0"
89
90
  },
@@ -97,6 +98,9 @@
97
98
  "jsdoc": {
98
99
  "optional": true
99
100
  },
101
+ "playwright": {
102
+ "optional": true
103
+ },
100
104
  "typedoc": {
101
105
  "optional": true
102
106
  },
@@ -112,13 +116,15 @@
112
116
  "gulpfile.base.mjs",
113
117
  "gulp.config.js",
114
118
  "gulp.config.mjs",
115
- "jsdoc.base.js"
119
+ "jsdoc.base.js",
120
+ "jsdoc.esmExports.js"
116
121
  ],
117
122
  "funding": "https://www.paypal.com/donate/?business=LRYR6SZRWKXVY&no_recurring=0&item_name=Let%27s+build+together+today+to+simplify+our+jobs+tomorrow.&currency_code=CAD",
118
123
  "devDependencies": {
119
- "clean-jsdoc-theme": "^5.2.0",
124
+ "clean-jsdoc-theme": "^4.3.3",
120
125
  "gulp-imagemin": "github:jheagle/gulp-imagemin#common-js-compatibility",
121
126
  "jsdoc": "^4.0.5",
127
+ "playwright": "~1.62.1",
122
128
  "release-it": "^21.1.1",
123
129
  "typedoc": "^0.28.20",
124
130
  "typescript": "^6.0.3"