You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/10/04 13:33:49 UTC
[camel] 03/06: Use ECMAScript modules
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit f06d2014834e074a974797295bc68cec848e222a
Author: Zoran Regvart <zo...@regvart.com>
AuthorDate: Tue Oct 4 14:59:27 2022 +0200
Use ECMAScript modules
---
docs/{.eslintrc.js => .eslintrc.cjs} | 0
docs/gulpfile.js | 61 ++++++++++++++++++------------------
docs/package.json | 1 +
3 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/docs/.eslintrc.js b/docs/.eslintrc.cjs
similarity index 100%
rename from docs/.eslintrc.js
rename to docs/.eslintrc.cjs
diff --git a/docs/gulpfile.js b/docs/gulpfile.js
index c2999071931..03c6ef9163e 100644
--- a/docs/gulpfile.js
+++ b/docs/gulpfile.js
@@ -15,19 +15,18 @@
* limitations under the License.
*/
-/* eslint-disable-next-line no-unused-vars */
-const { dest, series, parallel, src, symlink } = require('gulp')
-const del = require('del')
-const inject = require('gulp-inject')
-const map = require('map-stream')
-const path = require('path')
-const rename = require('gulp-rename')
-const sort = require('gulp-sort')
-const through2 = require('through2')
-const File = require('vinyl')
+import File from 'vinyl'
+import gulp from 'gulp'
+import inject from 'gulp-inject'
+import map from 'map-stream'
+import path from 'path'
+import rename from 'gulp-rename'
+import sort from 'gulp-sort'
+import through2 from 'through2'
+import { deleteAsync } from 'del'
function titleFrom (file) {
- var maybeName = /(?::doctitle: )(.*)/.exec(file.contents.toString())
+ let maybeName = /(?::doctitle: )(.*)/.exec(file.contents.toString())
if (maybeName === null) {
//TODO investigate these... why dont they have them?
// console.warn(`${file.path} doesn't contain Asciidoc doctitle attribute (':doctitle: <Title>'`);
@@ -43,7 +42,7 @@ function titleFrom (file) {
}
function groupFrom (file) {
- var groupName = /(?::group: )(.*)/.exec(file.contents.toString())
+ const groupName = /(?::group: )(.*)/.exec(file.contents.toString())
if (groupName !== null) return groupName[1]
return null
}
@@ -71,7 +70,7 @@ function compare (file1, file2) {
}
function insertGeneratedNotice () {
- return inject(src('./generated.txt'), {
+ return inject(gulp.src('./generated.txt'), {
name: 'generated',
removeTags: true,
transform: (filename, file) => {
@@ -222,12 +221,12 @@ const sources = {
// }
// },
//
-// parallel( // root containing multiple groupings (say, components, dataformats, eips...)
-// parallel( // tasks for the given taskName
-// series(clean:asciidoc:taskName, symlink:asciidoc:taskName, nav:asciidoc:taskName),
-// series(clean:json:taskName, symlink:json:taskName),
+// gulp.parallel( // root containing multiple groupings (say, components, dataformats, eips...)
+// gulp.parallel( // tasks for the given taskName
+// gulp.series(clean:asciidoc:taskName, symlink:asciidoc:taskName, nav:asciidoc:taskName),
+// gulp.series(clean:json:taskName, symlink:json:taskName),
// ),
-// parallel( // tasks configured for a different group
+// gulp.parallel( // tasks configured for a different group
// ...
// )
// )
@@ -271,7 +270,7 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
const deleteAry = [`${destination}/*`] // files in destination needs to be deleted
// append any exceptions, i.e. files to keep at the destination
deleteAry.push(...(keep || ['index.adoc']).map((file) => `!${destination}/${file}`))
- return del(deleteAry, {
+ return deleteAsync(deleteAry, {
force: true,
})
}
@@ -288,7 +287,7 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
}
})
- return src(source)
+ return gulp.src(source)
.pipe(filterFn)
.pipe(
map((file, done) => {
@@ -298,7 +297,7 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
done(null, file)
})
)
- .pipe(symlink(destination, {
+ .pipe(gulp.symlink(destination, {
relativeSymlinks: true,
}))
}
@@ -306,11 +305,11 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
// generates sorted & grouped nav.adoc file from a set of .adoc
// files at the destination
const createNav = (destination) => {
- return src(`${type}-nav.adoc.template`)
+ return gulp.src(`${type}-nav.adoc.template`)
.pipe(insertGeneratedNotice())
.pipe(
inject(
- src([
+ gulp.src([
`${destination}/**/*.adoc`,
`!${destination}/index.adoc`,
]).pipe(sort(compare)),
@@ -328,7 +327,7 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
)
)
.pipe(rename('nav.adoc'))
- .pipe(dest(`${destination}/../`))
+ .pipe(gulp.dest(`${destination}/../`))
}
// creates symlinks from source to destination for every example
@@ -359,7 +358,7 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
return done()
}
- return src(source) // asciidoc files
+ return gulp.src(source) // asciidoc files
.pipe(through2.obj(extractExamples)) // extracted example files
// symlink links from a fixed directory, i.e. we could link to
// the example files from `destination`, that would not work for
@@ -372,7 +371,7 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
// - file.dirname='/path/to/git/repository/components/example-component/src/test/resources/example-route.xml'
// we want the resulting destination to be:
// components/modules/ROOT/examples/components/example-component/src/test/resources/example-route.xml
- .pipe(symlink((file) => path.join(destination, file.dirname.replace(path.resolve('..'), '')), {
+ .pipe(gulp.symlink((file) => path.join(destination, file.dirname.replace(path.resolve('..'), '')), {
relativeSymlinks: true,
}))
}
@@ -403,7 +402,7 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
if (asciidoc) {
allTasks.push(
- series(
+ gulp.series(
named(`clean:asciidoc:${type}`, clean, asciidoc.destination, asciidoc.keep),
named(`symlink:asciidoc:${type}`, createSymlinks, asciidoc.source, asciidoc.destination),
named(`nav:asciidoc:${type}`, createNav, asciidoc.destination)
@@ -413,7 +412,7 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
if (image) {
allTasks.push(
- series(
+ gulp.series(
named(`clean:image:${type}`, clean, image.destination, image.keep),
named(`symlink:image:${type}`, createSymlinks, image.source, image.destination)
)
@@ -422,7 +421,7 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
if (example) {
allTasks.push(
- series(
+ gulp.series(
named(`clean:example:${type}`, clean, example.destination, ['json', 'js']),
named(`symlink:example:${type}`, createExampleSymlinks, example.source, example.destination)
)
@@ -431,7 +430,7 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
if (json) {
allTasks.push(
- series(
+ gulp.series(
named(`clean:json:${type}`, clean, json.destination, json.keep),
named(`symlink:json:${type}`, createSymlinks, json.source, json.destination, json.filter)
)
@@ -445,4 +444,4 @@ const tasks = Array.from(sourcesMap).flatMap(([type, definition]) => {
return []
}, [])
-exports.default = parallel(tasks)
+export default gulp.parallel(tasks)
diff --git a/docs/package.json b/docs/package.json
index 3b870d8d32e..99d49210560 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -4,6 +4,7 @@
"lint": "eslint gulpfile.js",
"lint-fix": "eslint gulpfile.js --fix"
},
+ "type": "module",
"license": "Apache-2.0",
"devDependencies": {
"del": "^7.0.0",