diff --git a/examples/basic/package.json b/examples/basic/package.json index 0f67583da..cec0a3b88 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -1,6 +1,6 @@ { "name": "basic", - "version": "0.10.0", + "version": "0.11.0", "description": "Demonstration of basic usage of UpscalerJS", "main": "index.js", "scripts": { diff --git a/examples/comparisons/package.json b/examples/comparisons/package.json index e96ad5144..ec4e21529 100644 --- a/examples/comparisons/package.json +++ b/examples/comparisons/package.json @@ -1,6 +1,6 @@ { "name": "comparisons", - "version": "0.10.0", + "version": "0.11.0", "description": "Demonstration of the different models of UpscalerJS", "main": "index.js", "scripts": { diff --git a/examples/models/package.json b/examples/models/package.json index 93b4e988b..fe0e2ed67 100644 --- a/examples/models/package.json +++ b/examples/models/package.json @@ -28,5 +28,5 @@ "last 1 safari version" ] }, - "version": "0.10.0" + "version": "0.11.0" } diff --git a/examples/nodejs-custom-model/package.json b/examples/nodejs-custom-model/package.json index e75b32b9b..bbe750960 100644 --- a/examples/nodejs-custom-model/package.json +++ b/examples/nodejs-custom-model/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-custom-model", - "version": "0.10.0", + "version": "0.11.0", "description": "Demonstration of Node.js usage of UpscalerJS with a local custom model", "author": "Kevin Scott", "license": "MIT", diff --git a/examples/nodejs/package.json b/examples/nodejs/package.json index 5e50e269a..6c8c25337 100644 --- a/examples/nodejs/package.json +++ b/examples/nodejs/package.json @@ -1,6 +1,6 @@ { "name": "nodejs", - "version": "0.10.0", + "version": "0.11.0", "description": "Demonstration of Node.js usage of UpscalerJS", "author": "Kevin Scott", "license": "MIT", diff --git a/examples/patch-sizes/package.json b/examples/patch-sizes/package.json index b388124fa..3f6418914 100644 --- a/examples/patch-sizes/package.json +++ b/examples/patch-sizes/package.json @@ -30,5 +30,5 @@ "last 1 safari version" ] }, - "version": "0.10.0" + "version": "0.11.0" } diff --git a/examples/progress/package.json b/examples/progress/package.json index 5fa5944e4..4d018b8b1 100644 --- a/examples/progress/package.json +++ b/examples/progress/package.json @@ -1,6 +1,6 @@ { "name": "progress", - "version": "0.10.0", + "version": "0.11.0", "description": "Demonstration of upscale progress with UpscalerJS", "main": "index.js", "scripts": { diff --git a/examples/react-demo/package.json b/examples/react-demo/package.json index 255215633..919c96f03 100644 --- a/examples/react-demo/package.json +++ b/examples/react-demo/package.json @@ -29,5 +29,5 @@ "last 1 safari version" ] }, - "version": "0.10.0" + "version": "0.11.0" } diff --git a/examples/tensor/package.json b/examples/tensor/package.json index db6a02309..3f03d9ba2 100644 --- a/examples/tensor/package.json +++ b/examples/tensor/package.json @@ -1,6 +1,6 @@ { "name": "tensor", - "version": "0.10.0", + "version": "0.11.0", "description": "Demonstration of basic usage of UpscalerJS", "main": "index.js", "scripts": { diff --git a/examples/upload/package.json b/examples/upload/package.json index a46ec82c0..900cdea01 100644 --- a/examples/upload/package.json +++ b/examples/upload/package.json @@ -1,6 +1,6 @@ { "name": "upload", - "version": "0.10.0", + "version": "0.11.0", "description": "Demonstration of uploading an image to UpscalerJS", "main": "index.js", "scripts": { diff --git a/examples/warmup/package.json b/examples/warmup/package.json index 41779eaab..cb0cb192e 100644 --- a/examples/warmup/package.json +++ b/examples/warmup/package.json @@ -1,6 +1,6 @@ { "name": "warmup", - "version": "0.10.0", + "version": "0.11.0", "description": "Demonstration of warming up UpscalerJS", "main": "index.js", "scripts": { diff --git a/examples/webcam/package.json b/examples/webcam/package.json index 06ecca5f5..080a8913b 100644 --- a/examples/webcam/package.json +++ b/examples/webcam/package.json @@ -1,6 +1,6 @@ { "name": "webcam", - "version": "0.10.0", + "version": "0.11.0", "description": "Demonstration of webcam usage of UpscalerJS", "main": "index.js", "scripts": { diff --git a/examples/webworker/package.json b/examples/webworker/package.json index bacc88705..ddc080abd 100644 --- a/examples/webworker/package.json +++ b/examples/webworker/package.json @@ -1,6 +1,6 @@ { "name": "webworker", - "version": "0.10.0", + "version": "0.11.0", "description": "Demonstration of webworker integration with UpscalerJS", "main": "index.js", "scripts": { diff --git a/package.json b/package.json index e50e9e598..4f813e7d4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.10.0", + "version": "0.11.0", "private": true, "workspaces": [ "packages/*", diff --git a/packages/models/package.json b/packages/models/package.json index 5df12d3a3..5719aa2b6 100755 --- a/packages/models/package.json +++ b/packages/models/package.json @@ -1,6 +1,6 @@ { "name": "@upscalerjs/models", - "version": "0.9.0", + "version": "0.10.0", "description": "Neural Network Models for upscalerjs", "keywords": [ "image super resolution", diff --git a/packages/upscalerjs/CHANGELOG.md b/packages/upscalerjs/CHANGELOG.md index 3b773a9c8..42dc8c860 100644 --- a/packages/upscalerjs/CHANGELOG.md +++ b/packages/upscalerjs/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.11.0](https://github.com/thekevinscott/UpscalerJS/compare/v0.11.0...v0.10.0) (2021-03-2) + +feat: Add support for `progress` callback to receive a second argument, the current slice of procesed image + ## [0.10.0](https://github.com/thekevinscott/UpscalerJS/compare/v0.10.0...v0.9.0) (2021-02-25) feat: Add Node support diff --git a/packages/upscalerjs/package.json b/packages/upscalerjs/package.json index 04856add3..0bc78bec7 100644 --- a/packages/upscalerjs/package.json +++ b/packages/upscalerjs/package.json @@ -1,6 +1,6 @@ { "name": "upscaler", - "version": "0.10.0", + "version": "0.11.0", "description": "Increase Image resolution with Tensorflow.js", "exports": { "./node": "./dist/node/cjs/cjs.js", diff --git a/scripts/package-scripts/update-version.ts b/scripts/package-scripts/update-version.ts index a62df6ae3..1fc107aae 100644 --- a/scripts/package-scripts/update-version.ts +++ b/scripts/package-scripts/update-version.ts @@ -3,9 +3,10 @@ import path from 'path'; import inquirer from 'inquirer'; import findAllPackages from './find-all-packages'; import isValidVersion from './utils/isValidVersion'; +import execute from './utils/execute'; type Package = 'UpscalerJS' | 'Models' | 'Examples' | 'Root'; -type Answers = { packages: Array, version: string} +type Answers = { packages: Array, version: string, commit: boolean } const ROOT_DIR = path.resolve(__dirname, '../..'); const PACKAGES_DIR = path.resolve(ROOT_DIR, 'packages'); @@ -17,37 +18,44 @@ const getFormattedName = (file: string) => { return file.split(`${ROOT_DIR}/`).pop(); }; -const updateMultiplePackages = (dir: string, version: string) => { +const updateMultiplePackages = async (dir: string, version: string, commit: boolean) => { const packages = findAllPackages(dir); for (let i = 0; i < packages.length; i++) { const pkg = packages[i]; - updateSinglePackage(pkg, version); + await updateSinglePackage(pkg, version, commit); } }; -const updateSinglePackage = (dir: string, version: string) => { +const updateSinglePackage = async (dir: string, version: string, commit: boolean) => { const packageJSON = getPackageJSON(dir); packageJSON.version = version; writePackageJSON(dir, packageJSON); + if (commit) { + await commitPackageJSON(dir); + } console.log(`- Updated ${getFormattedName(dir)}`); }; -const writePackageJSON = (file: string, contents: Record>) => { - const stringifiedContents = `${JSON.stringify(contents, null, 2)}\n`; +const getPackageJSONPath = (file: string) => { if (file.endsWith('package.json')) { - fs.writeFileSync(file, stringifiedContents); - } else { - fs.writeFileSync(path.resolve(file, 'package.json'), stringifiedContents); + return file; } -}; + return path.resolve(file, 'package.json'); +} -const getPackageJSON = (file: string) => { - if (file.endsWith('package.json')) { - return JSON.parse(fs.readFileSync(file, 'utf-8')); - } - return JSON.parse(fs.readFileSync(path.resolve(file, 'package.json'), 'utf-8')); +const commitPackageJSON = async (dir: string) => { + const file = getPackageJSONPath(dir); + const cmd = `git add "${file}"` + await execute(cmd); } +const writePackageJSON = (file: string, contents: Record>) => { + const stringifiedContents = `${JSON.stringify(contents, null, 2)}\n`; + fs.writeFileSync(getPackageJSONPath(file), stringifiedContents); +}; + +const getPackageJSON = (file: string) => JSON.parse(fs.readFileSync(getPackageJSONPath(file), 'utf-8')); + const getVersion = (dir: string) => { return getPackageJSON(dir).version; }; @@ -79,7 +87,13 @@ const updateVersion = () => new Promise(resolve => { 'UpscalerJS', 'Models', 'Examples', 'Root', ], }, - ]).then(({ version, packages }) => { + { + name: 'commit', + message: `Do you wish to commit changes`, + type: 'confirm', + default: true, + }, + ]).then(async ({ version, packages, commit }) => { if (!isValidVersion(version)) { throw new Error(`Version is not in the format x.x.x. You specified: ${version}`); } @@ -88,17 +102,21 @@ const updateVersion = () => new Promise(resolve => { return; } - packages.forEach(packageKey => { + await Promise.all(packages.map(packageKey => { if (packageKey === 'Examples') { - updateMultiplePackages(EXAMPLES_DIR, version) + return updateMultiplePackages(EXAMPLES_DIR, version, commit); } else if (packageKey === 'Models') { - updateSinglePackage(MODELS_DIR, version) + return updateSinglePackage(MODELS_DIR, version, commit); } else if (packageKey === 'UpscalerJS') { - updateSinglePackage(UPSCALERJS_DIR, version) + return updateSinglePackage(UPSCALERJS_DIR, version, commit); } else if (packageKey === 'Root') { - updateSinglePackage(ROOT_DIR, version) + return updateSinglePackage(ROOT_DIR, version, commit); } - }); + })); + if (commit) { + const cmd = `git commit -m "Updated version to ${version} for ${formatArray(packages)}"`; + await execute(cmd); + } resolve(); }); }); @@ -108,3 +126,16 @@ export default updateVersion; if (require.main === module) { updateVersion(); } + +const formatArray = (packages: Array) => { + if (packages.length === 1) { + return packages[0]; + } + if (packages.length === 2) { + return packages.join(' and '); + } + return [ + packages.slice(0, -1).join(', '), + packages.pop(), + ].join(' and '); +} diff --git a/scripts/package-scripts/utils/execute.ts b/scripts/package-scripts/utils/execute.ts new file mode 100644 index 000000000..039f525f4 --- /dev/null +++ b/scripts/package-scripts/utils/execute.ts @@ -0,0 +1,14 @@ +import { exec } from 'child_process'; +const execute = (cmd: string) => new Promise((resolve, reject) => { + const spawnedProcess = exec(cmd, {}, (error: Error | null) => { + if (error) { + reject(error.message); + } else { + resolve(); + } + }); + spawnedProcess.stderr?.pipe(process.stderr); + spawnedProcess.stdout?.pipe(process.stdout); +}) +export default execute; +