Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,30 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Build distribution
- name: Build full distribution
run: npm run build

- name: Build simple distribution
run: SIMPLE_MODE=true BUILD_OUTPUT_DIR=dist-simple npm run build

- name: Extract version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=${VERSION}" >> $GITHUB_OUTPUT

- name: Package distribution
- name: Package full distribution
run: npm run package

- name: Package simple distribution
run: BUILD_OUTPUT_DIR=dist-simple npm run package
Comment on lines +47 to +48
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Set SIMPLE_MODE=true during simple packaging, or the “simple” zip can contain default-mode output.

npm run package triggers a build again, so at Line 48 the rebuild runs without simple mode and can overwrite dist-simple with default-mode assets before zipping.

✅ Minimal fix
-      - name: Package simple distribution
-        run: BUILD_OUTPUT_DIR=dist-simple npm run package
+      - name: Package simple distribution
+        run: SIMPLE_MODE=true BUILD_OUTPUT_DIR=dist-simple npm run package
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Package simple distribution
run: BUILD_OUTPUT_DIR=dist-simple npm run package
- name: Package simple distribution
run: SIMPLE_MODE=true BUILD_OUTPUT_DIR=dist-simple npm run package
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build-and-publish.yml around lines 47 - 48, The "Package
simple distribution" step re-runs the build without simple mode and can
overwrite dist-simple; set SIMPLE_MODE=true when invoking the package/build step
so the rebuild produces simple-mode assets (e.g. run the package step with
SIMPLE_MODE=true and BUILD_OUTPUT_DIR=dist-simple) to ensure the zip contains
simple-mode output and not default-mode files.


- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist-${{ steps.version.outputs.version }}.zip
files: |
dist-${{ steps.version.outputs.version }}.zip
dist-simple-${{ steps.version.outputs.version }}.zip
generate_release_notes: true
draft: false
prerelease: false
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ lerna-debug.log*

node_modules
dist
dist-simple
dist-ssr
*.local
.npm-cache
Expand Down Expand Up @@ -41,4 +42,4 @@ libreoffice-wasm-package
bentopdf-*.tgz

# test
dist-test
dist-test
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import eslintConfigPrettier from "eslint-config-prettier";

export default [
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ ignores: ["dist/**", "coverage/**", "node_modules/**", "**/.vitepress/cache/**", "public/**/*.min.js"] },
{ ignores: ["dist/**", "dist-simple/**", "coverage/**", "node_modules/**", "**/.vitepress/cache/**", "public/**/*.min.js"] },
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
Expand Down
13 changes: 7 additions & 6 deletions scripts/package-dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { execSync } from 'child_process';
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const version = packageJson.version;

console.log(`📦 Building dist folder for version ${version}...`);
const buildOutputDirName = process.env.BUILD_OUTPUT_DIR || 'dist';
console.log(`📦 Building ${buildOutputDirName} folder for version ${version}...`);

// Run the build command
try {
Expand All @@ -25,12 +26,12 @@ import { pipeline } from 'stream';
import { promisify } from 'util';
import archiver from 'archiver';

const distDir = path.resolve('./dist');
const zipPath = path.resolve(`./dist-${version}.zip`);
const buildOutputDir = path.resolve('./${buildOutputDirName}');
Comment thread
oleole39 marked this conversation as resolved.
Outdated
const zipPath = path.resolve(`./${buildOutputDirName}-${version}.zip`);

// Check if dist directory exists
if (!existsSync(distDir)) {
console.error('❌ dist directory does not exist. Please run build first.');
if (!existsSync(buildOutputDir)) {
console.error('❌ ${buildOutputDirName} directory does not exist. Please run build first.');
Comment thread
oleole39 marked this conversation as resolved.
Outdated
process.exit(1);
}

Expand All @@ -55,7 +56,7 @@ archive.on('error', (err) => {
archive.pipe(output);

// Append the dist directory to the archive
archive.directory(distDir, false);
archive.directory(buildOutputDir, false);

// Finalize the archive
archive.finalize();
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@
}
},
"include": ["src", "src/**/*.ts", "public/workers", "vite.config.ts"], // Updated to include all TS files
"exclude": ["node_modules", "dist"]
"exclude": ["node_modules", "dist", "dist-simple"]
}
9 changes: 6 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function createLanguageMiddleware(isDev: boolean): Connect.NextHandleFunction {

const basePath = getBasePath();
const [fullPathname, queryString] = req.url.split('?');
const outputDir = process.env.BUILD_OUTPUT_DIR || 'dist';

let pathname = fullPathname;
if (basePath && basePath !== '/' && pathname.startsWith(basePath)) {
Expand Down Expand Up @@ -114,7 +115,7 @@ function createLanguageMiddleware(isDev: boolean): Connect.NextHandleFunction {
if (isDev) {
req.url = '/index.html' + (queryString ? `?${queryString}` : '');
} else {
const langIndexPath = resolve(__dirname, 'dist', lang, 'index.html');
const langIndexPath = resolve(__dirname, outputDir, lang, 'index.html');
if (fs.existsSync(langIndexPath)) {
req.url =
`/${lang}/index.html` + (queryString ? `?${queryString}` : '');
Expand Down Expand Up @@ -142,7 +143,7 @@ function createLanguageMiddleware(isDev: boolean): Connect.NextHandleFunction {
} else {
const langPagePath = resolve(
__dirname,
'dist',
outputDir,
lang,
`${pageName}.html`
);
Expand All @@ -162,7 +163,7 @@ function createLanguageMiddleware(isDev: boolean): Connect.NextHandleFunction {
} else {
const langPagePath = resolve(
__dirname,
'dist',
outputDir,
lang,
`${cleanPath}.html`
);
Expand Down Expand Up @@ -367,6 +368,7 @@ export default defineConfig(() => {
},
},
build: {
outDir: process.env.BUILD_OUTPUT_DIR || 'dist',
rollupOptions: {
input: {
main:
Expand Down Expand Up @@ -582,6 +584,7 @@ export default defineConfig(() => {
'*.config.ts',
'**/*.d.ts',
'dist/',
'dist-simple/',
],
},
},
Expand Down
1 change: 1 addition & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default defineConfig({
'node_modules/',
'src/tests/',
'dist/',
'dist-simple/',
'*.config.ts',
'*.config.js',
'**/*.d.ts',
Expand Down