Skip to content

Commit

Permalink
Aligned package versions, added script to bump versions on snapshot r…
Browse files Browse the repository at this point in the history
…eleases
  • Loading branch information
s1hofmann committed Feb 15, 2024
1 parent 508b857 commit 323139f
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 39 deletions.
43 changes: 43 additions & 0 deletions .build/bump_version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { exec } = require("child_process");
const { readFile, writeFile } = require("fs");
const { join } = require("path");

const args = process.argv.slice(2);
const version = args[0];

if (version == null || version === "") {
throw new Error("Version is required");
}

exec("pnpm m ls --json --depth=-1", (_, stdout) => {
const modules = JSON.parse(stdout).filter(
(module) => module.private !== true,
);

for (const module of modules) {
const filePath = join(module.path, "package.json");

readFile(filePath, "utf8", (err, data) => {
if (err) {
throw new Error(err);
}
// Parse JSON
const obj = JSON.parse(data);

// Change a property
obj.version = version;

// Convert object back to JSON
const json = JSON.stringify(obj, null, 2);

// Write JSON file
writeFile(filePath, json, "utf8", (err) => {
if (err) {
throw new Error(err);
} else {
console.log("File successfully updated.");
}
});
});
}
});
2 changes: 1 addition & 1 deletion .build/pre-release.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ patchVersion=$(npm --no-git-tag version patch)
nextVersion=${patchVersion}-next."$(date +%Y%m%d%H%M%S)"
echo "${nextVersion:1}"

npm version --no-git-tag -f "${nextVersion:1}"
node ./bump_version.js "${nextVersion:1}"
24 changes: 9 additions & 15 deletions .github/workflows/snapshot_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,16 @@ jobs:
- name: Setup pnpm
uses: pnpm/[email protected]
- name: Install
run: npm ci
run: pnpm i
- name: Install @nut-tree/libnut@next
run: npm i @nut-tree/libnut@next
run: |
pnpm --filter @nut-tree/libnut i @nut-tree/libnut-darwin@next @nut-tree/libnut-linux@next @nut-tree/libnut-win32@next
- name: Compile
run: npm run compile
- name: Init window e2e test subpackage
run: npm --prefix e2e/window-test ci
run: pnpm run compile
- name: Run tests
uses: GabrielBB/xvfb-action@v1
with:
run: |
npx playwright install --with-deps
npm test
- name: Run Electron e2e test subpackage
uses: GabrielBB/xvfb-action@v1
with:
run: npm --prefix e2e/electron-test cit
run: pnpm run coverage

deploy:
needs:
Expand All @@ -63,13 +56,14 @@ jobs:
- name: Setup pnpm
uses: pnpm/[email protected]
- name: Install
run: npm ci
run: pnpm i
- name: Install @nut-tree/libnut@next
run: npm i @nut-tree/libnut@next
run: |
pnpm --filter @nut-tree/libnut i @nut-tree/libnut-darwin@next @nut-tree/libnut-linux@next @nut-tree/libnut-win32@next
- name: Create snapshot release
run: bash ./.build/pre-release.sh
- name: Publish snapshot release to npm
run: npm run publish-next
run: pnpm run publish:next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion core/configs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nut-tree/configs",
"private": true,
"version": "1.0.0",
"version": "4.0.0",
"description": "Shared configs for nut.js",
"author": {
"name": "dry Software UG (haftungsbeschränkt)",
Expand Down
4 changes: 2 additions & 2 deletions core/nut.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"test": "jest --runInBand",
"coverage": "jest --coverage --runInBand --logHeapUsage",
"coverage:clean": "rimraf coverage",
"publish-next": "pnpm publish --tag next",
"publish:next": "pnpm publish --tag next",
"prepublishOnly": "pnpm run compile",
"versionBump": "bump --tag --push --all",
"typedoc": "typedoc --options ./typedoc.js --entryPointStrategy expand ./lib"
Expand All @@ -73,4 +73,4 @@
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
}
}
}
12 changes: 6 additions & 6 deletions core/provider-interfaces/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@nut-tree/provider-interfaces",
"version": "1.0.0",
"version": "4.0.0",
"description": "Public provider interfaces for @nut-tree/nut-js",
"main": "dist/index",
"typings": "dist/index",
"scripts": {
"clean": "rimraf dist",
"compile": "pnpm run clean && tsc -p .",
"publish-next": "pnpm publish --tag next",
"publish:next": "pnpm publish --tag next",
"prepublishOnly": "pnpm run compile"
},
"keywords": [
Expand All @@ -23,7 +23,7 @@
"dependencies": {
"@nut-tree/shared": "workspace:*"
},
"devDependencies": {
"@nut-tree/configs": "workspace:*"
}
}
"devDependencies": {
"@nut-tree/configs": "workspace:*"
}
}
4 changes: 2 additions & 2 deletions core/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nut-tree/shared",
"version": "1.0.0",
"version": "4.0.0",
"description": "Shared objects, data types and functions for @nut-tree/nut-js",
"main": "dist/index",
"typings": "dist/index",
Expand All @@ -10,7 +10,7 @@
"coverage:clean": "rimraf coverage",
"clean": "rimraf dist",
"compile": "pnpm run clean && tsc -p .",
"publish-next": "pnpm publish --tag next",
"publish:next": "pnpm publish --tag next",
"prepublishOnly": "pnpm run compile"
},
"dependencies": {
Expand Down
4 changes: 4 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# nut.js examples

The projects contained in this folder are meant to be used as examples for how to use nut.js.
Especially the image matching samples will probably not run out of the box on you machine, nonetheless they should give you a good starting point for your own projects.
2 changes: 1 addition & 1 deletion examples/jest-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sample-jest",
"version": "2.0.0",
"version": "4.0.0",
"private": true,
"description": "A simple nut.js test example which demos Jest integration",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/keyboard-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sample-keyboard",
"version": "2.0.0",
"version": "4.0.0",
"private": true,
"description": "A simple nut.js test example which tests keyboard control",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/mouse-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sample-mouse",
"version": "2.0.0",
"version": "4.0.0",
"private": true,
"description": "A simple nut.js test example which tests mouse control",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion examples/screen-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sample-screen",
"version": "2.0.0",
"version": "4.0.0",
"private": true,
"description": "A simple nut.js test example which tests screen control",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sample-typescript",
"version": "2.0.0",
"version": "4.0.0",
"private": true,
"description": "A simple nut.js test example which demos usage with TypeScript",
"main": "index.ts",
Expand Down
3 changes: 2 additions & 1 deletion examples/window-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "sample-window",
"version": "2.0.0",
"version": "4.0.0",
"private": true,
"description": "Integration tests to verify window handling",
"main": "main.js",
"author": {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"compile": "pnpm -r run compile",
"coverage": "pnpm -r run coverage",
"coverage:clean": "pnpm -r run coverage:clean",
"prepare": "husky install"
"prepare": "husky install",
"publish:next": "pnpm -r run publish:next",
"publish": "pnpm -r run publish"
},
"packageManager": "[email protected]",
"workspaces": [
Expand Down
4 changes: 2 additions & 2 deletions providers/clipboardy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nut-tree/default-clipboard-provider",
"version": "1.0.0",
"version": "4.0.0",
"description": "The @nut-tree/nut-js default clipboard provider based on clipboardy",
"main": "dist/index",
"typings": "dist/index",
Expand All @@ -10,7 +10,7 @@
"test": "jest --runInBand",
"clean": "rimraf dist",
"compile": "pnpm run clean && tsc -p .",
"publish-next": "pnpm publish --tag next",
"publish:next": "pnpm publish --tag next",
"prepublishOnly": "pnpm run compile"
},
"keywords": [
Expand Down
7 changes: 4 additions & 3 deletions providers/libnut/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nut-tree/libnut",
"version": "3.0.0",
"version": "4.0.0",
"description": "libnut is an N-API module for desktop automation with node",
"main": "dist/index",
"typings": "dist/index",
Expand Down Expand Up @@ -34,7 +34,8 @@
"coverage": "jest --coverage --runInBand",
"coverage:clean": "rimraf coverage",
"publish:next": "pnpm publish --tag next",
"prepublishOnly": "pnpm run compile"
"prepublishOnly": "pnpm run compile",
"version": "npm version --no-git-tag -f"
},
"engines": {
"node": ">=10.15.3"
Expand All @@ -52,4 +53,4 @@
"peerDependencies": {
"@nut-tree/nut-js": "^3"
}
}
}

0 comments on commit 323139f

Please sign in to comment.