Add version to build and the archived asar app (#854)

This commit is contained in:
Lipis 2020-02-28 22:51:36 +01:00 committed by GitHub
parent 759df14143
commit d2827aa40b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 91 additions and 3 deletions

49
package-lock.json generated
View File

@ -2408,6 +2408,22 @@
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
},
"asar": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/asar/-/asar-2.1.0.tgz",
"integrity": "sha512-d2Ovma+bfqNpvBzY/KU8oPY67ZworixTpkjSx0PCXnQi67c2cXmssaTxpFDUM0ttopXoGx/KRxNg/GDThYbXQA==",
"dev": true,
"requires": {
"@types/glob": "^7.1.1",
"chromium-pickle-js": "^0.2.0",
"commander": "^2.20.0",
"cuint": "^0.2.2",
"glob": "^7.1.3",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"tmp-promise": "^1.0.5"
}
},
"asn1": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
@ -3383,6 +3399,12 @@
"tslib": "^1.9.0"
}
},
"chromium-pickle-js": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
"integrity": "sha1-BKEGZywYsIWrd02YPfo+oTjyIgU=",
"dev": true
},
"ci-info": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz",
@ -4183,6 +4205,12 @@
"integrity": "sha512-xz39Sb4+OaTsULgUERcCk+TJj8ylkL4aSVDQiX/ksxbELSqwkgt4d4RD7fovIdgJGSuNYqwZEiVjYY5l0ask+Q==",
"dev": true
},
"cuint": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/cuint/-/cuint-0.2.2.tgz",
"integrity": "sha1-QICG1AlVDCYxFVYZ6fp7ytw7mRs=",
"dev": true
},
"currently-unhandled": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz",
@ -14810,6 +14838,27 @@
"os-tmpdir": "~1.0.2"
}
},
"tmp-promise": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/tmp-promise/-/tmp-promise-1.1.0.tgz",
"integrity": "sha512-8+Ah9aB1IRXCnIOxXZ0uFozV1nMU5xiu7hhFVUSxZ3bYu+psD4TzagCzVbexUCgNNGJnsmNDQlS4nG3mTyoNkw==",
"dev": true,
"requires": {
"bluebird": "^3.5.0",
"tmp": "0.1.0"
},
"dependencies": {
"tmp": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.1.0.tgz",
"integrity": "sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==",
"dev": true,
"requires": {
"rimraf": "^2.6.3"
}
}
}
},
"tmpl": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz",

View File

@ -15,8 +15,8 @@
"roughjs": "4.0.4",
"stacktrace-js": "2.0.2"
},
"description": "",
"devDependencies": {
"asar": "2.1.0",
"@testing-library/jest-dom": "5.1.1",
"@testing-library/react": "9.4.1",
"@types/jest": "25.1.3",
@ -80,8 +80,10 @@
"main": "src/index.js",
"name": "excalidraw",
"scripts": {
"build": "react-scripts build",
"build-node": "./scripts/build-node.js",
"build:app": "react-scripts build",
"build:zip": "node ./scripts/build-version.js",
"build": "npm run build:app && npm run build:zip",
"build-node": "node ./scripts/build-node.js",
"eject": "react-scripts eject",
"fix": "npm run fix:other && npm run fix:code",
"fix:code": "npm run test:code -- --fix",

37
scripts/build-version.js Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const asar = require("asar");
const zero = digit => `0${digit}`.slice(-2);
const versionDate = date => {
const date_ = `${date.getFullYear()}-${zero(date.getMonth() + 1)}-${zero(
date.getDate(),
)}`;
const time = `${zero(date.getHours())}-${zero(date.getMinutes())}-${zero(
date.getSeconds(),
)}`;
return `${date_}-${time}`;
};
const now = new Date();
const data = JSON.stringify(
{
app: `excalidraw-${versionDate(now)}.asar`,
version: versionDate(now),
},
undefined,
2,
);
fs.writeFileSync(path.join("build", "version.json"), data);
(async () => {
const src = "build/";
const dest = path.join("build", `excalidraw-${versionDate(now)}.asar`);
await asar.createPackage(src, dest);
})();