Skip to content

Commit 6ba23bb

Browse files
committed
fix: convert all scripts to ES modules for compatibility
- Convert build-firefox.js to use import statements - Convert package-chrome.js to use import statements - Convert package-chrome-crx.js to use import statements - Convert package-firefox.js to use import statements - Convert package-firefox-xpi.js to use import statements - Update shell scripts to use JSON.parse for version reading - Fix path resolution issues in package scripts - Remove unused variables to fix linting warnings - All build and package scripts now work with ES module project
1 parent 026cf1d commit 6ba23bb

11 files changed

+41
-24
lines changed

β€Žblog-link-analyzer-1.1.1.zipβ€Ž

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
76.6 KB
Binary file not shown.

β€Žscripts/build-firefox.jsβ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs');
4-
const path = require('path');
3+
import fs from 'fs';
4+
import path from 'path';
5+
import { fileURLToPath } from 'url';
6+
7+
const __filename = fileURLToPath(import.meta.url);
58

69
function createFirefoxStructure() {
710
console.log('πŸ”₯ Building Firefox Extension for Submission...');

β€Žscripts/package-chrome-crx.jsβ€Ž

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs');
4-
const path = require('path');
5-
const archiver = require('archiver');
3+
import fs from 'fs';
4+
import path from 'path';
5+
import archiver from 'archiver';
6+
import { fileURLToPath } from 'url';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
610

711
// Get version from package.json
8-
const packageJson = require('../package.json');
12+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'));
913
const VERSION = packageJson.version;
1014

1115
async function createChromeCRX() {

β€Žscripts/package-chrome.jsβ€Ž

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs');
4-
const path = require('path');
5-
const archiver = require('archiver');
3+
import fs from 'fs';
4+
import path from 'path';
5+
import archiver from 'archiver';
6+
import { fileURLToPath } from 'url';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
610

711
// Get version from package.json
8-
const packageJson = require('../package.json');
12+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'));
913
const VERSION = packageJson.version;
1014

1115
async function createChromePackage() {

β€Žscripts/package-firefox-xpi.jsβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs');
4-
const path = require('path');
5-
const archiver = require('archiver');
3+
import fs from 'fs';
4+
import path from 'path';
5+
import { execSync } from 'child_process';
6+
import { fileURLToPath } from 'url';
7+
8+
const __filename = fileURLToPath(import.meta.url);
69

710
async function createFirefoxXPI() {
811
console.log('Starting XPI generation...');
912

1013
// First build Firefox structure
11-
const { execSync } = require('child_process');
1214
execSync('node scripts/build-firefox.js', { stdio: 'inherit' });
1315

1416
// Create XPI with web-ext
15-
const webExt = require('web-ext');
17+
const webExt = (await import('web-ext')).default;
1618

1719
try {
1820
await webExt.cmd.build({

β€Žscripts/package-firefox.jsβ€Ž

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs');
4-
const path = require('path');
5-
const archiver = require('archiver');
3+
import fs from 'fs';
4+
import path from 'path';
5+
import archiver from 'archiver';
6+
import { fileURLToPath } from 'url';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
610

711
// Get version from package.json
8-
const packageJson = require('../package.json');
12+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'));
913
const VERSION = packageJson.version;
1014

1115
async function createFirefoxPackage() {

β€Žscripts/pre-deploy.shβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ npm run package:all-formats
4444

4545
# Validate packages
4646
echo "πŸ“‹ Validating packages..."
47-
VERSION=$(node -p "require('./package.json').version")
47+
VERSION=$(node -p "JSON.parse(require('fs').readFileSync('./package.json', 'utf8')).version")
4848

4949
REQUIRED_PACKAGES=(
5050
"blog-link-analyzer-$VERSION.zip"
@@ -82,7 +82,7 @@ fi
8282
# Version consistency check
8383
echo "πŸ”’ Checking version consistency..."
8484
MANIFEST_VERSION=$(node -p "JSON.parse(require('fs').readFileSync('manifest.json', 'utf8')).version")
85-
PACKAGE_VERSION=$(node -p "require('./package.json').version")
85+
PACKAGE_VERSION=$(node -p "JSON.parse(require('fs').readFileSync('./package.json', 'utf8')).version")
8686

8787
if [ "$MANIFEST_VERSION" != "$PACKAGE_VERSION" ]; then
8888
echo "❌ Version mismatch: manifest.json ($MANIFEST_VERSION) != package.json ($PACKAGE_VERSION)"

β€Žscripts/release.shβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ echo "πŸ”„ Running version bump..."
1616
./scripts/version.sh "$VERSION_TYPE" "$MESSAGE"
1717

1818
# Get new version
19-
NEW_VERSION=$(node -p "require('../package.json').version")
19+
NEW_VERSION=$(node -p "JSON.parse(require('fs').readFileSync('../package.json', 'utf8')).version")
2020
echo "πŸŽ‰ Release version: $NEW_VERSION"
2121

2222
# Create GitHub release (if gh CLI is available)

0 commit comments

Comments
Β (0)