diff --git a/Cargo.lock b/Cargo.lock index 7cea91a9..9948707b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -342,7 +342,7 @@ dependencies = [ [[package]] name = "quic" -version = "0.0.1" +version = "0.0.4-alpha.0" dependencies = [ "boring", "napi", diff --git a/Cargo.toml b/Cargo.toml index bc60ddf6..61fa3406 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "quic" -version = "0.0.1" +version = "0.0.4-alpha.0" authors = ["Roger Qiu "] license-file = "LICENSE" edition = "2021" diff --git a/benches/index.ts b/benches/index.ts index eb31ea19..a563b12c 100644 --- a/benches/index.ts +++ b/benches/index.ts @@ -4,13 +4,13 @@ import fs from 'fs'; import path from 'path'; import si from 'systeminformation'; import Stream1KB from './stream_1KB'; -// import Dummy from './dummy'; +// Import Dummy from './dummy'; async function main(): Promise { await fs.promises.mkdir(path.join(__dirname, 'results'), { recursive: true }); // Running benches await Stream1KB(); - // await Dummy(); + // Await Dummy(); const resultFilenames = await fs.promises.readdir( path.join(__dirname, 'results'), ); diff --git a/package-lock.json b/package-lock.json index 5f6be486..811536c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,22 @@ { "name": "@matrixai/quic", - "version": "0.0.2-alpha.0", + "version": "0.0.4-alpha.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@matrixai/quic", - "version": "0.0.2-alpha.0", + "version": "0.0.4-alpha.0", "license": "Apache-2.0", "dependencies": { "@matrixai/async-init": "^1.8.1", "@matrixai/async-locks": "^3.1.1", "@matrixai/errors": "^1.1.2", "@matrixai/logger": "^3.1.0", + "@matrixai/quic-darwin-arm64": "0.0.4-alpha.0", + "@matrixai/quic-darwin-x64": "0.0.4-alpha.0", + "@matrixai/quic-linux-x64": "0.0.4-alpha.0", + "@matrixai/quic-win32-x64": "0.0.4-alpha.0", "@matrixai/resources": "^1.1.3", "@matrixai/workers": "^1.3.5", "ip-num": "^1.5.0" @@ -54,10 +58,10 @@ "typescript": "^4.5.2" }, "optionalDependencies": { - "@matrixai/quic-darwin-arm64": "0.0.1", - "@matrixai/quic-darwin-x64": "0.0.1", - "@matrixai/quic-linux-x64": "0.0.1", - "@matrixai/quic-win32-x64": "0.0.1" + "@matrixai/quic-darwin-arm64": "0.0.4-alpha.0", + "@matrixai/quic-darwin-x64": "0.0.4-alpha.0", + "@matrixai/quic-linux-x64": "0.0.4-alpha.0", + "@matrixai/quic-win32-x64": "0.0.4-alpha.0" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index a2200837..7d061ecf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matrixai/quic", - "version": "0.0.2-alpha.0", + "version": "0.0.4-alpha.0", "bin": { "server": "dist/bin/server.js" }, @@ -20,7 +20,7 @@ "prepare": "tsc -p ./tsconfig.build.json", "prebuild": "node ./scripts/prebuild.js", "build": "rimraf ./dist && tsc -p ./tsconfig.build.json", - "postversion": "node ./scripts/postversion.js", + "version": "node ./scripts/version.js", "prepublishOnly": "node ./scripts/prepublishOnly.js", "ts-node": "ts-node", "test": "jest", @@ -40,10 +40,10 @@ "ip-num": "^1.5.0" }, "optionalDependencies": { - "@matrixai/quic-linux-x64": "0.0.1", - "@matrixai/quic-win32-x64": "0.0.1", - "@matrixai/quic-darwin-x64": "0.0.1", - "@matrixai/quic-darwin-arm64": "0.0.1" + "@matrixai/quic-darwin-arm64": "0.0.4-alpha.0", + "@matrixai/quic-darwin-x64": "0.0.4-alpha.0", + "@matrixai/quic-linux-x64": "0.0.4-alpha.0", + "@matrixai/quic-win32-x64": "0.0.4-alpha.0" }, "devDependencies": { "@fast-check/jest": "^1.1.0", diff --git a/scripts/postversion.js b/scripts/version.js similarity index 52% rename from scripts/postversion.js rename to scripts/version.js index 22da72f1..a05ff59e 100755 --- a/scripts/postversion.js +++ b/scripts/version.js @@ -1,8 +1,9 @@ #!/usr/bin/env node /** - * This runs after `npm version` command. - * This will update the `package.json` optional native dependencies + * This runs after `npm version` command updates the version but before changes are commited. + * This will update the `cargo.toml` version to match the new `package.json` verson. + * This will also update the `package.json` optional native dependencies * to match the same version as the version of this package. * This maintains the same version between this master package * and the optional native dependencies. @@ -12,6 +13,8 @@ * to prevent `npm` from attempting to download unpublished packages. */ +const path = require('path'); +const fs = require('fs'); const os = require('os'); const childProcess = require('child_process'); const packageJSON = require('../package.json'); @@ -20,6 +23,37 @@ const platform = os.platform(); /* eslint-disable no-console */ async function main() { + console.error('Updating the cargo.toml version to match new version'); + const projectRoot = path.join(__dirname, '..'); + const cargoTOMLPath = path.join(projectRoot, 'Cargo.toml'); + const cargoTOML = await fs.promises.readFile(cargoTOMLPath, 'utf-8'); + const cargoTOMLMatch = cargoTOML.match(/version\s*=\s*"(.*)"/); + const cargoTOMLUpdated = cargoTOML.replace( + cargoTOMLMatch[0], + `version = "${packageJSON.version}"`, + ); + await fs.promises.writeFile(cargoTOMLPath, cargoTOMLUpdated, 'utf-8'); + + console.error('updating cargo lock file with change'); + childProcess.execFileSync('cargo', ['update', '--package', 'quic'], { + stdio: ['inherit', 'inherit', 'inherit'], + windowsHide: true, + encoding: 'utf-8', + shell: platform === 'win32' ? true : false, + }); + + console.error('Staging changes in git'); + childProcess.execFileSync( + 'git', + ['add', cargoTOMLPath, path.join(projectRoot, 'Cargo.lock')], + { + stdio: ['inherit', 'inherit', 'inherit'], + windowsHide: true, + encoding: 'utf-8', + shell: platform === 'win32' ? true : false, + }, + ); + console.error( 'Updating the package.json with optional native dependencies and package-lock.json', );