From 16c473cf3f0782116a8a3412c79d17a2fd627274 Mon Sep 17 00:00:00 2001 From: dcode Date: Thu, 14 Nov 2019 22:27:17 +0100 Subject: [PATCH 1/3] Test pika-ci From 3014563db943ac601289949ecc61289070809491 Mon Sep 17 00:00:00 2001 From: dcode Date: Thu, 14 Nov 2019 23:46:53 +0100 Subject: [PATCH 2/3] try prepublish hook --- .github/workflows/publish.yml | 2 -- package.json | 2 +- scripts/{release.js => prepublish.js} | 7 ++++++- 3 files changed, 7 insertions(+), 4 deletions(-) rename scripts/{release.js => prepublish.js} (91%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b26d4ad989..d37fc1ffc9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -30,8 +30,6 @@ jobs: npm run build - name: Test distribution files run: npm test - - name: Reconfigure for release - run: npm run release - name: Set up version run: | VERSION=$(node -e "console.log(require('./package.json').version)") diff --git a/package.json b/package.json index d519f6ad2f..42990c1b44 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "make": "npm run clean && npm test && npm run build && npm test", "all": "npm run check && npm run make", "docs": "typedoc --tsconfig tsconfig-docs.json --mode modules --name \"AssemblyScript Compiler API\" --out ./docs/api --ignoreCompilerErrors --excludeNotExported --excludePrivate --excludeExternals --exclude **/std/** --includeDeclarations --readme src/README.md", - "release": "node scripts/release" + "prepublishOnly": "node scripts/prepublish" }, "releaseFiles": [ "lib/rtrace/index.d.ts", diff --git a/scripts/release.js b/scripts/prepublish.js similarity index 91% rename from scripts/release.js rename to scripts/prepublish.js index d265a81eed..37a6d8346a 100644 --- a/scripts/release.js +++ b/scripts/prepublish.js @@ -1,9 +1,14 @@ -// Reconfigures the repository before publishing a release +// Reconfigures the repository before publishing const fs = require("fs"); const path = require("path"); const pkg = require("../package.json"); +if (!pkg.releaseFiles) { + console.log("Package has already been updated"); + return; +} + console.log("Updating package.json ..."); // Stuff we don't need in release From e602da6d9f8ef024cc1dcfe87e4a3690a0535458 Mon Sep 17 00:00:00 2001 From: dcode Date: Fri, 15 Nov 2019 01:10:39 +0100 Subject: [PATCH 3/3] proper pre/postpublish scripts --- .gitignore | 1 + package.json | 3 ++- scripts/postpublish-files.json | 5 +++++ scripts/postpublish.js | 22 ++++++++++++++++++++++ scripts/prepublish.js | 12 ++++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 scripts/postpublish-files.json create mode 100644 scripts/postpublish.js diff --git a/.gitignore b/.gitignore index dc54075dfb..cb7d0b9ef8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules/ out/ raw/ .history +*.backup diff --git a/package.json b/package.json index 42990c1b44..1df7251f47 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,8 @@ "make": "npm run clean && npm test && npm run build && npm test", "all": "npm run check && npm run make", "docs": "typedoc --tsconfig tsconfig-docs.json --mode modules --name \"AssemblyScript Compiler API\" --out ./docs/api --ignoreCompilerErrors --excludeNotExported --excludePrivate --excludeExternals --exclude **/std/** --includeDeclarations --readme src/README.md", - "prepublishOnly": "node scripts/prepublish" + "prepublishOnly": "node scripts/prepublish", + "postpublish": "node scripts/postpublish" }, "releaseFiles": [ "lib/rtrace/index.d.ts", diff --git a/scripts/postpublish-files.json b/scripts/postpublish-files.json new file mode 100644 index 0000000000..c2a9b27bf0 --- /dev/null +++ b/scripts/postpublish-files.json @@ -0,0 +1,5 @@ +[ + "package.json", + "index.js", + "index.d.ts" +] diff --git a/scripts/postpublish.js b/scripts/postpublish.js new file mode 100644 index 0000000000..4c0ddb5fe9 --- /dev/null +++ b/scripts/postpublish.js @@ -0,0 +1,22 @@ +// Reconfigures the repository after publishing + +const fs = require("fs"); +const path = require("path"); +const devFiles = require("./postpublish-files.json"); + +console.log("Restoring development files ..."); + +devFiles.forEach(originalName => { + const backupName = originalName + ".backup"; + const backupPath = path.join(__dirname, "..", backupName); + if (!fs.existsSync(backupPath)) { + console.log("- " + backupName + " does not exist"); + } else { + console.log("- " + backupName + " -> " + originalName); + fs.copyFileSync( + backupPath, + path.join(__dirname, "..", originalName) + ); + fs.unlinkSync(backupPath); + } +}); diff --git a/scripts/prepublish.js b/scripts/prepublish.js index 37a6d8346a..d18b7c373f 100644 --- a/scripts/prepublish.js +++ b/scripts/prepublish.js @@ -3,12 +3,24 @@ const fs = require("fs"); const path = require("path"); const pkg = require("../package.json"); +const devFiles = require("./postpublish-files.json"); if (!pkg.releaseFiles) { console.log("Package has already been updated"); return; } +console.log("Backing up development files ..."); + +devFiles.forEach(originalName => { + const backupName = originalName + ".backup"; + console.log("- " + originalName + " -> " + backupName); + fs.copyFileSync( + path.join(__dirname, "..", originalName), + path.join(__dirname, "..", backupName) + ); +}); + console.log("Updating package.json ..."); // Stuff we don't need in release