Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Robot-Inventor committed Nov 7, 2024
2 parents 4f225b4 + 719f109 commit 494c191
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"watch": "cross-env NODE_OPTIONS=--experimental-transform-types NODE_ENV=development rspack build --watch",
"format": "prettier --write ./src/**/*",
"format:check": "prettier --check ./src/**/*",
"lint": "eslint ./src/**/*.ts ./rspack.config.ts",
"lint": "eslint ./src/**/*.ts ./rspack.config.ts ./script/**/*.ts",
"package": "tsx ./script/package.ts",
"version": "npm run build && git add ."
},
Expand Down
4 changes: 2 additions & 2 deletions script/addUserScriptComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs";
import packageJson from "../package.json";

const userScript = fs.readFileSync("./index.user.js", "utf8");
const user_script_metadata = `// ==UserScript==
const userScriptMetadata = `// ==UserScript==
// @name Hide View Count
// @namespace https://github.com/Robot-Inventor/hide-view-count
// @version ${packageJson.version}
Expand All @@ -20,5 +20,5 @@ const user_script_metadata = `// ==UserScript==
// @grant none
// ==/UserScript==
`;
const userScriptEdited = user_script_metadata + userScript;
const userScriptEdited = userScriptMetadata + userScript;
fs.writeFileSync("./index.user.js", userScriptEdited);
8 changes: 5 additions & 3 deletions script/copyManifest.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import fs from "fs";
import manifestV2 from "../src/manifest/v2.json";
import manifestV3 from "../src/manifest/v3.json";
import packageJson from "../package.json";
import fs from "fs";

const JSON_INDENT = 4;

manifestV2.version = packageJson.version;
manifestV3.version = packageJson.version;

const manifestV2Text = JSON.stringify(manifestV2, null, 4);
const manifestV3Text = JSON.stringify(manifestV3, null, 4);
const manifestV2Text = JSON.stringify(manifestV2, null, JSON_INDENT);
const manifestV3Text = JSON.stringify(manifestV3, null, JSON_INDENT);

fs.writeFileSync("./dist/firefox/manifest.json", manifestV2Text);
fs.writeFileSync("./dist/chrome/manifest.json", manifestV3Text);
4 changes: 4 additions & 0 deletions script/package.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { execSync } from "child_process";

// eslint-disable-next-line no-console
console.log("Building...");
execSync("npm run build");

// eslint-disable-next-line no-console
console.log("Packaging for Chrome...");
execSync(
`npx web-ext build --source-dir "./dist/chrome/" --artifacts-dir "./web-ext-artifacts/manifestV3" --filename "{name}-{version}-manifestV3.zip"`
);

// eslint-disable-next-line no-console
console.log("Packaging for Firefox...");
execSync(
`npx web-ext build --source-dir "./dist/firefox/" --artifacts-dir "./web-ext-artifacts/manifestV2" --filename "{name}-{version}-manifestV2.zip"`
);
// eslint-disable-next-line no-console
console.log("Done.");
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"include": [
"./src/**/*.ts",
"./rspack.config.ts"
"./rspack.config.ts",
"./script/**/*.ts"
]
}

0 comments on commit 494c191

Please sign in to comment.