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