Skip to content

Commit dc0f4a0

Browse files
authored
Merge branch 'main' into tab-format-19-aug-24
2 parents 3504d34 + 312b590 commit dc0f4a0

File tree

13 files changed

+236
-67
lines changed

13 files changed

+236
-67
lines changed

.github/workflows/release-ui-bundle.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Configure Git Credentials
1717
uses: de-vri-es/setup-git-credentials@v2
1818
with:
19-
credentials: ${{ secrets.GIT_CREDENTIALS }}
19+
credentials: https://${{ secrets.DOCS_GITHUB_PAT }}@github.com
2020

2121
- name: Checkout Repository
2222
uses: actions/checkout@v4
@@ -25,8 +25,6 @@ jobs:
2525

2626
- name: Check Last Commit Message
2727
id: skip_release
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3028
run: |
3129
last_commit_message=$(git log -1 --pretty=%B)
3230
if [[ $last_commit_message == *"[no-release]"* ]]; then

gulp.d/tasks/build-preview-pages.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const { Transform } = require('stream')
1111
const map = (transform = () => {}, flush = undefined) => new Transform({ objectMode: true, transform, flush })
1212
const vfs = require('vinyl-fs')
1313
const yaml = require('js-yaml')
14-
const { execSync } = require('child_process')
1514

1615
const ASCIIDOC_ATTRIBUTES = { experimental: '', icons: 'font', sectanchors: '', 'source-highlighter': 'highlight.js' }
1716

@@ -100,7 +99,8 @@ function registerPartials (src) {
10099
function registerHelpers (src, previewDest) {
101100
handlebars.registerHelper('resolvePage', resolvePage)
102101
handlebars.registerHelper('resolvePageURL', resolvePageURL)
103-
handlebars.registerHelper('assets-manifest', (assetPath) => assetsManifest(assetPath, previewDest))
102+
// Since we are not creating an assets-manifest.json file in the preview build, we need to mock the helper.
103+
handlebars.registerHelper('assets-manifest', (assetPath) => assetPath)
104104
return vfs.src('helpers/*.js', { base: src, cwd: src }).pipe(
105105
map((file, enc, next) => {
106106
if (!(file.stem === 'assets-manifest')) {
@@ -128,12 +128,6 @@ function compileLayouts (src) {
128128
)
129129
}
130130

131-
function assetsManifest (assetPath, previewDest) {
132-
const manifestPath = execSync(`find ${previewDest} -name assets-manifest.json`).toString().trim()
133-
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'))
134-
return manifest[assetPath]
135-
}
136-
137131
function copyImages (src, dest) {
138132
return vfs
139133
.src('**/*.{png,svg}', { base: src, cwd: src })

gulp.d/tasks/build.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const ospath = require('path')
1111
const path = ospath.posix
1212
const postcss = require('gulp-postcss')
1313
const postcssCalc = require('postcss-calc')
14+
const gulpif = require('gulp-if')
1415
const postcssAdvancedVars = require('postcss-advanced-variables')
1516
const postcssImport = require('postcss-import')
1617
const tailwindcss = require('tailwindcss')
@@ -74,34 +75,34 @@ module.exports = (src, dest, preview) => () => {
7475
.pipe(uglify({ output: { comments: /^! / } }))
7576
// NOTE concat already uses stat from newest combined file
7677
.pipe(concat('js/site.js'))
77-
.pipe(hash({ template: '<%= name %>-<%= hash %><%= ext %>' }))
78+
.pipe(gulpif(!preview, hash({ template: '<%= name %>-<%= hash %><%= ext %>' })))
7879
.pipe(vfs.dest(dest))
79-
.pipe(hash.manifest('assets-manifest.json', { append: true }))
80+
.pipe(gulpif(!preview, hash.manifest('assets-manifest.json', { append: true })))
8081
.pipe(vfs.dest(dest)),
8182
vfs
8283
.src('js/vendor/*([^.])?(.bundle).js', { ...opts, read: false })
8384
.pipe(bundle(opts))
8485
.pipe(uglify({ output: { comments: /^! / } }))
85-
.pipe(hash({ template: '<%= name %>-<%= hash %><%= ext %>' }))
86+
.pipe(gulpif(!preview, hash({ template: '<%= name %>-<%= hash %><%= ext %>' })))
8687
.pipe(vfs.dest(dest))
87-
.pipe(hash.manifest('assets-manifest.json', { append: true }))
88+
.pipe(gulpif(!preview, hash.manifest('assets-manifest.json', { append: true })))
8889
.pipe(vfs.dest(dest)),
8990
vfs
9091
.src('js/vendor/*.min.js', opts)
9192
.pipe(map((file, enc, next) => next(null, Object.assign(file, { extname: '' }, { extname: '.js' }))))
92-
.pipe(hash({ template: '<%= name %>-<%= hash %><%= ext %>' }))
93+
.pipe(gulpif(!preview, hash({ template: '<%= name %>-<%= hash %><%= ext %>' })))
9394
.pipe(vfs.dest(dest))
94-
.pipe(hash.manifest('assets-manifest.json', { append: true }))
95+
.pipe(gulpif(!preview, hash.manifest('assets-manifest.json', { append: true })))
9596
.pipe(vfs.dest(dest)),
9697
// NOTE use the next line to bundle a JavaScript library that cannot be browserified, like jQuery
9798
//vfs.src(require.resolve('<package-name-or-require-path>'), opts).pipe(concat('js/vendor/<library-name>.js')),
9899
vfs.src('./tailwind.config.js').pipe(concat('js/tailwind.config.js')),
99100
vfs
100101
.src(['css/site.css', 'css/vendor/*.css'], { ...opts, sourcemaps })
101102
.pipe(postcss((file) => ({ plugins: postcssPlugins, options: { file } })))
102-
.pipe(hash({ template: '<%= name %>-<%= hash %><%= ext %>' }))
103+
.pipe(gulpif(!preview, hash({ template: '<%= name %>-<%= hash %><%= ext %>' })))
103104
.pipe(vfs.dest(dest))
104-
.pipe(hash.manifest('assets-manifest.json', { append: true }))
105+
.pipe(gulpif(!preview, hash.manifest('assets-manifest.json', { append: true })))
105106
.pipe(vfs.dest(dest)),
106107
vfs.src('font/*.{ttf,woff*(2)}', opts),
107108
vfs.src('img/**/*.{gif,ico,jpg,png,svg}', opts).pipe(

package-lock.json

Lines changed: 176 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"gulp-connect": "~5.7",
4040
"gulp-eslint": "~6.0",
4141
"gulp-hash": "^4.2.2",
42+
"gulp-if": "^3.0.0",
4243
"gulp-imagemin": "~6.2",
4344
"gulp-postcss": "~9.0",
4445
"gulp-uglify": "~3.0",

src/helpers/assets-manifest.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
'use strict'
22

3-
const { execSync } = require('child_process')
4-
const fs = require('fs')
53
const logger = require('@antora/logger')('assets-manifest-helper')
64

75
module.exports = (assetPath) => {
8-
let manifestPath
9-
let manifest
10-
try {
11-
manifestPath = execSync('find ./build/site -name assets-manifest.json').toString().trim()
12-
manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'))
13-
} catch (err) {
14-
logger.error(err)
6+
const manifest = global.assetsManifest
7+
if (!manifest) {
8+
logger.error(
9+
`
10+
Assets manifest not found in global context.
11+
The .js and .css files from the UI bundle will not be linked properly in the HTML.
12+
Ensure assets-manifest.json from the UI bundle is parsed and added
13+
to global.assetsManifest after uiLoader is complete.
14+
`
15+
)
16+
return assetPath
1517
}
16-
if (manifest) return manifest[assetPath]
17-
return assetPath
18+
return manifest[assetPath]
1819
}

0 commit comments

Comments
 (0)