Converted leftover CommonJS scripts to ESModule.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
"test": "vitest",
|
||||
"server": "node server.js --dev",
|
||||
"dev": "concurrently \"npm start\" \"node --watch server.js --dev\"",
|
||||
"build-image": "vite build && node scripts/build-image.js"
|
||||
"build-image": "vite build && node scripts/build-image.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=24.0.0"
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { pathToFileURL } = require('url');
|
||||
const { parseArgs } = require('util');
|
||||
import { execSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
import { parseArgs } from 'node:util';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
function execCommand(command, description) {
|
||||
try {
|
||||
@@ -71,7 +74,7 @@ function showHelp() {
|
||||
console.log(`Build multi-architecture container images for JMESPath Playground
|
||||
|
||||
Usage:
|
||||
build-image.js [OPTIONS]
|
||||
build-image.mjs [OPTIONS]
|
||||
|
||||
Options:
|
||||
--all-arch Build for both arm64 and amd64 (default: build for host architecture only)
|
||||
@@ -79,11 +82,11 @@ Options:
|
||||
--help, -h Show this help message and exit
|
||||
|
||||
Examples:
|
||||
build-image.js # Builds for ${hostArch} only (host architecture)
|
||||
build-image.js --all-arch # Builds for both arm64 and amd64
|
||||
build-image.js --arch arm64 # Builds for arm64 only
|
||||
build-image.js --arch arm64 --arch amd64 # Explicitly specify both
|
||||
build-image.js -h # Show help`);
|
||||
build-image.mjs # Builds for ${hostArch} only (host architecture)
|
||||
build-image.mjs --all-arch # Builds for both arm64 and amd64
|
||||
build-image.mjs --arch arm64 # Builds for arm64 only
|
||||
build-image.mjs --arch arm64 --arch amd64 # Explicitly specify both
|
||||
build-image.mjs -h # Show help`);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
@@ -150,10 +153,10 @@ async function main() {
|
||||
|
||||
// Show usage instructions
|
||||
console.log(`\nUsage examples:`);
|
||||
console.log(` build-image.js # Builds for host architecture only`);
|
||||
console.log(` build-image.js --all-arch # Builds for both arm64 and amd64`);
|
||||
console.log(` build-image.js --arch arm64 # Builds for arm64 only`);
|
||||
console.log(` build-image.js --arch arm64 --arch amd64 # Explicitly specify both`);
|
||||
console.log(` build-image.mjs # Builds for host architecture only`);
|
||||
console.log(` build-image.mjs --all-arch # Builds for both arm64 and amd64`);
|
||||
console.log(` build-image.mjs --arch arm64 # Builds for arm64 only`);
|
||||
console.log(` build-image.mjs --arch arm64 --arch amd64 # Explicitly specify both`);
|
||||
|
||||
if (isRelease) {
|
||||
console.log(`\nTo run the container:`);
|
||||
@@ -169,7 +172,10 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
const isDirectRun = process.argv[1]
|
||||
&& fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
|
||||
|
||||
if (isDirectRun) {
|
||||
main().catch((error) => {
|
||||
console.error(`Error: ${error.message}`);
|
||||
process.exit(1);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const { execSync } = require('child_process');
|
||||
import { execSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
function showUsage() {
|
||||
console.log('Usage: node scripts/new-version.js <version> [--force] [-m|--message "commit message"]');
|
||||
console.log(' node scripts/new-version.js --check <version>');
|
||||
console.log('Usage: node scripts/new-version.mjs <version> [--force] [-m|--message "commit message"]');
|
||||
console.log(' node scripts/new-version.mjs --check <version>');
|
||||
console.log('');
|
||||
console.log('Creates a new version by tagging the current commit.');
|
||||
console.log('');
|
||||
@@ -15,10 +17,10 @@ function showUsage() {
|
||||
console.log(' -m, --message TEXT Custom commit message (only used when commit is needed)');
|
||||
console.log('');
|
||||
console.log('Example:');
|
||||
console.log(' node scripts/new-version.js 1.2.0');
|
||||
console.log(' node scripts/new-version.js 1.2.0 --force');
|
||||
console.log(' node scripts/new-version.js 1.2.0 -m "Add new feature XYZ"');
|
||||
console.log(' node scripts/new-version.js --check 1.3.0');
|
||||
console.log(' node scripts/new-version.mjs 1.2.0');
|
||||
console.log(' node scripts/new-version.mjs 1.2.0 --force');
|
||||
console.log(' node scripts/new-version.mjs 1.2.0 -m "Add new feature XYZ"');
|
||||
console.log(' node scripts/new-version.mjs --check 1.3.0');
|
||||
}
|
||||
|
||||
function performCheck(targetVersion) {
|
||||
@@ -129,18 +131,18 @@ function performCheck(targetVersion) {
|
||||
console.log('');
|
||||
console.log('📋 Commands that would work:');
|
||||
if (isRepoDirty || needsPackageUpdate) {
|
||||
console.log(` node scripts/new-version.js ${targetVersion} --force`);
|
||||
console.log(` node scripts/new-version.mjs ${targetVersion} --force`);
|
||||
} else {
|
||||
console.log(` node scripts/new-version.js ${targetVersion}`);
|
||||
console.log(` node scripts/new-version.js ${targetVersion} --force`);
|
||||
console.log(` node scripts/new-version.mjs ${targetVersion}`);
|
||||
console.log(` node scripts/new-version.mjs ${targetVersion} --force`);
|
||||
}
|
||||
} else {
|
||||
console.log('⚡ Actions needed:');
|
||||
console.log(` • Create tag ${tagName} (no commit needed)`);
|
||||
console.log('');
|
||||
console.log('📋 Commands that would work:');
|
||||
console.log(` node scripts/new-version.js ${targetVersion}`);
|
||||
console.log(` node scripts/new-version.js ${targetVersion} --force`);
|
||||
console.log(` node scripts/new-version.mjs ${targetVersion}`);
|
||||
console.log(` node scripts/new-version.mjs ${targetVersion} --force`);
|
||||
}
|
||||
|
||||
console.log('');
|
||||
@@ -297,4 +299,9 @@ function main() {
|
||||
}
|
||||
}
|
||||
|
||||
const isDirectRun = process.argv[1]
|
||||
&& fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
|
||||
|
||||
if (isDirectRun) {
|
||||
main();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user