Convert sign-xpi to be ESM compatible

next v0.8.1
neobooru 2022-08-12 02:20:39 +02:00
parent a0c262c337
commit 44592c7aa9
2 changed files with 13 additions and 10 deletions

View File

@ -12,7 +12,7 @@
"build": "webpack --config webpack.prod.cjs", "build": "webpack --config webpack.prod.cjs",
"build:dev": "webpack --config webpack.dev.cjs", "build:dev": "webpack --config webpack.dev.cjs",
"build-zip": "node scripts/build-zip.cjs", "build-zip": "node scripts/build-zip.cjs",
"sign-xpi": "node scripts/sign-xpi.cjs", "sign-xpi": "node scripts/sign-xpi.js",
"watch": "webpack --watch --config webpack.dev.cjs", "watch": "webpack --watch --config webpack.dev.cjs",
"lint": "eslint src" "lint": "eslint src"
}, },

View File

@ -1,15 +1,18 @@
#!/usr/bin/env node #!/usr/bin/env node
const path = require("path"); import { fileURLToPath } from 'url';
const { existsSync, renameSync } = require("fs"); import { join } from "path";
const { argv, exit } = require("process"); import { existsSync, renameSync } from "fs";
const { signAddon } = require("sign-addon"); import { argv, exit } from "process";
const { version } = require("../package.json"); import { signAddon } from 'sign-addon';
import info from "../package.json" assert { type: "json" };
const RELEASE_DIR = path.join(__dirname, "../release"); const __dirname = fileURLToPath(new URL('.', import.meta.url));
const version = info.version;
const RELEASE_DIR = join(__dirname, "../release");
async function main() { async function main() {
const args = process.argv.slice(2); const args = argv.slice(2);
if (args.length != 3) { if (args.length != 3) {
console.log("USAGE: yarn sign-zip <extension_id> <api_key> <api_secret>"); console.log("USAGE: yarn sign-zip <extension_id> <api_key> <api_secret>");
exit(1); exit(1);
@ -19,8 +22,8 @@ async function main() {
const apiKey = args[1]; const apiKey = args[1];
const apiSecret = args[2]; const apiSecret = args[2];
const zipPath = path.join(RELEASE_DIR, `SzuruChrome-${version}.zip`); const zipPath = join(RELEASE_DIR, `SzuruChrome-${version}.zip`);
const xpiPath = path.join(RELEASE_DIR, `SzuruChrome-${version}.xpi`); const xpiPath = join(RELEASE_DIR, `SzuruChrome-${version}.xpi`);
// Ensure the file exists. // Ensure the file exists.
if (!existsSync(zipPath)) { if (!existsSync(zipPath)) {