Skip to content

Commit 1ee8171

Browse files
committed
build: Added pack, publish & release script
1 parent f862265 commit 1ee8171

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
release

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Redmine Time Tracking (Chrome Extensions)
22

3+
> Start-stop timer for [Redmine](https://www.redmine.org/).
4+
35
![license](https://img.shields.io/badge/license-MIT-green)
46

5-
Start-stop timer for Redmine
7+
View all your assigned Redmine issue.
8+
Start and stop the timer for your current tasks, then transfer the time to the Redmine issue.
69

710
![issues](screenshots/issues.png)
811

pack.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import AdmZip from "adm-zip";
2+
import { existsSync, mkdirSync, readFileSync } from "fs";
3+
import { dirname, parse, resolve } from "path";
4+
5+
try {
6+
const __dirname = resolve(dirname(""));
7+
const { base } = parse(__dirname);
8+
const { version } = JSON.parse(readFileSync(resolve(__dirname, "dist", "manifest.json"), "utf8"));
9+
10+
const outdir = "release";
11+
const filename = `${base}-v${version}.zip`;
12+
const zip = new AdmZip();
13+
zip.addLocalFolder("dist");
14+
if (!existsSync(outdir)) {
15+
mkdirSync(outdir);
16+
}
17+
zip.writeZip(`${outdir}/${filename}`);
18+
19+
console.log(`Success! Created a ${filename} file under ${outdir} directory. You can upload this file to web store.`);
20+
} catch (e) {
21+
console.log(e);
22+
console.error("Error! Failed to generate a zip file.");
23+
}

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
{
22
"name": "redmine-time-tracking",
33
"description": "Redmine Time Tracking",
4-
"version": "0.0.1",
4+
"version": "1.0.0",
55
"type": "module",
66
"scripts": {
77
"dev": "tsc && vite build --watch",
88
"build": "tsc && vite build",
9+
"pack": "node pack.js",
10+
"release": "gh release create v%npm_package_version% release/redmine-time-tracking-v%npm_package_version%.zip --generate-notes",
11+
"publish": "pnpm run build && pnpm run pack && pnpm run release",
912
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
1013
},
1114
"dependencies": {
@@ -29,6 +32,7 @@
2932
"@typescript-eslint/parser": "^5.57.1",
3033
"@vitejs/plugin-react": "^4.0.0",
3134
"autoprefixer": "^10.4.14",
35+
"adm-zip": "^0.5.10",
3236
"eslint": "^8.38.0",
3337
"eslint-plugin-react-hooks": "^4.6.0",
3438
"eslint-plugin-react-refresh": "^0.3.4",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)