From ae79bae1d698f3de195f5671b9a481961e1e18a9 Mon Sep 17 00:00:00 2001 From: Sebastian Dine Date: Mon, 27 Mar 2023 09:36:20 +0000 Subject: [PATCH] precommit version adjustments --- README.md | 2 +- card-collection-manager-2/package.json | 56 ++++---- .../src-tauri/Cargo.toml | 84 +++++------ .../src-tauri/tauri.conf.json | 134 +++++++++--------- card-collection-manager-2/version | 1 - hooks/activate_hooks.sh | 2 +- hooks/pre-commit | 17 ++- version | 2 +- 8 files changed, 150 insertions(+), 148 deletions(-) mode change 100644 => 100755 card-collection-manager-2/package.json mode change 100644 => 100755 card-collection-manager-2/src-tauri/Cargo.toml mode change 100644 => 100755 card-collection-manager-2/src-tauri/tauri.conf.json delete mode 100644 card-collection-manager-2/version mode change 100644 => 100755 version diff --git a/README.md b/README.md index eb07dbe..2801a18 100755 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ After performing these steps, the next time you open CCM2, you will see your col ### Contribute The project includes configuration for [VSCode development containers](https://code.visualstudio.com/docs/remote/containers) which should be the preffered environment to develop new features of the app. The container automatically sets up a whole Tauri development environment including Typescript & Rust plugins for VSCode. -Also, in directory `hooks/` you find some helpful git hooks that automate/standardize some work. You can activate these hooks by executing the script `activate_hooks.sh` from within the `hooks/` directory. If you are receiving errors like `fatal: cannot run .git/hooks/pre-commit: No such file or directory`, check the line-end sequence of the hook scripts, adjust them according to your system and run `activate_hooks.sh` again. +Also, in directory `hooks/` you find some helpful git hooks that automate/standardize some work. You can activate these hooks by executing the script `activate_hooks.sh` from within the `hooks/` directory. If you are receiving errors like `fatal: cannot run .git/hooks/pre-commit: No such file or directory`, check the line-end sequence of the hook scripts, adjust them according to your system and run `activate_hooks.sh` again. The hooks are especially useful for versioning. They ensure that the version number in each of the 3 manifest files are the same and create a `version` file with the current version at the project's root level, which can be picked up easily by automated CI/CD tasks. Additionally, if you want to run the GUI out of the container, you need to use a X11 tool. I will briefly explain how to run them in order to display the GUI from the container: diff --git a/card-collection-manager-2/package.json b/card-collection-manager-2/package.json old mode 100644 new mode 100755 index d674fe4..59968ee --- a/card-collection-manager-2/package.json +++ b/card-collection-manager-2/package.json @@ -1,28 +1,28 @@ -{ - "name": "card-collection-manager-2", - "private": true, - "version": "1.0.1", - "scripts": { - "dev": "next dev -p 1420", - "build": "next build && next export -o dist", - "tauri": "tauri" - }, - "dependencies": { - "@tauri-apps/api": "^1.1.0", - "next": "^12.2.5", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-icons": "^4.6.0", - "react-loader-spinner": "^5.3.4" - }, - "devDependencies": { - "@tauri-apps/cli": "^1.1.0", - "@types/node": "^18.7.11", - "@types/react": "^18.0.17", - "@types/react-dom": "^18.0.6", - "autoprefixer": "^10.4.13", - "postcss": "^8.4.18", - "tailwindcss": "^3.2.2", - "typescript": "^4.7.4" - } -} +{ + "name": "card-collection-manager-2", + "private": true, + "version": "1.0.2", + "scripts": { + "dev": "next dev -p 1420", + "build": "next build && next export -o dist", + "tauri": "tauri" + }, + "dependencies": { + "@tauri-apps/api": "^1.1.0", + "next": "^12.2.5", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-icons": "^4.6.0", + "react-loader-spinner": "^5.3.4" + }, + "devDependencies": { + "@tauri-apps/cli": "^1.1.0", + "@types/node": "^18.7.11", + "@types/react": "^18.0.17", + "@types/react-dom": "^18.0.6", + "autoprefixer": "^10.4.13", + "postcss": "^8.4.18", + "tailwindcss": "^3.2.2", + "typescript": "^4.7.4" + } +} diff --git a/card-collection-manager-2/src-tauri/Cargo.toml b/card-collection-manager-2/src-tauri/Cargo.toml old mode 100644 new mode 100755 index bb6f7df..3f7b039 --- a/card-collection-manager-2/src-tauri/Cargo.toml +++ b/card-collection-manager-2/src-tauri/Cargo.toml @@ -1,42 +1,42 @@ -[package] -name = "card-collection-manager-2" -version = "1.0.1" -description = "A Tauri App" -authors = ["you"] -license = "" -repository = "" -edition = "2021" -rust-version = "1.57" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[build-dependencies] -tauri-build = { version = "1.1", features = [] } - -[dependencies] -serde_json = "1.0" -serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.1", features = ["api-all"] } - -# b64 image encoding -base64 = "0.13" -image = "0.24" - -# rest calls -reqwest = { version = "0.11", features = ["blocking", "json"] } - -# iterator for enums -strum = "0.24" -strum_macros = "0.24" - -# data type checker, e.g. is_digit -nom = "7.1.1" - - -[features] -# by default Tauri runs in production mode -# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL -default = [ "custom-protocol" ] -# this feature is used used for production builds where `devPath` points to the filesystem -# DO NOT remove this -custom-protocol = [ "tauri/custom-protocol" ] +[package] +name = "card-collection-manager-2" +version = "1.0.2" +description = "A Tauri App" +authors = ["you"] +license = "" +repository = "" +edition = "2021" +rust-version = "1.57" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +tauri-build = { version = "1.1", features = [] } + +[dependencies] +serde_json = "1.0" +serde = { version = "1.0", features = ["derive"] } +tauri = { version = "1.1", features = ["api-all"] } + +# b64 image encoding +base64 = "0.13" +image = "0.24" + +# rest calls +reqwest = { version = "0.11", features = ["blocking", "json"] } + +# iterator for enums +strum = "0.24" +strum_macros = "0.24" + +# data type checker, e.g. is_digit +nom = "7.1.1" + + +[features] +# by default Tauri runs in production mode +# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL +default = [ "custom-protocol" ] +# this feature is used used for production builds where `devPath` points to the filesystem +# DO NOT remove this +custom-protocol = [ "tauri/custom-protocol" ] diff --git a/card-collection-manager-2/src-tauri/tauri.conf.json b/card-collection-manager-2/src-tauri/tauri.conf.json old mode 100644 new mode 100755 index bca662f..235b7b1 --- a/card-collection-manager-2/src-tauri/tauri.conf.json +++ b/card-collection-manager-2/src-tauri/tauri.conf.json @@ -1,67 +1,67 @@ -{ - "build": { - "beforeDevCommand": "yarn dev", - "beforeBuildCommand": "yarn build", - "devPath": "http://localhost:1420", - "distDir": "../dist", - "withGlobalTauri": false - }, - "package": { - "productName": "card-collection-manager-2", - "version": "1.0.1" - }, - "tauri": { - "allowlist": { - "all": true - }, - "bundle": { - "active": true, - "category": "DeveloperTool", - "copyright": "", - "deb": { - "depends": [] - }, - "externalBin": [], - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/icon.icns", - "icons/icon.ico" - ], - "identifier": "com.sdine.dev", - "longDescription": "", - "macOS": { - "entitlements": null, - "exceptionDomain": "", - "frameworks": [], - "providerShortName": null, - "signingIdentity": null - }, - "resources": [], - "shortDescription": "", - "targets": "all", - "windows": { - "certificateThumbprint": null, - "digestAlgorithm": "sha256", - "timestampUrl": "" - } - }, - "security": { - "csp": null - }, - "updater": { - "active": false - }, - "windows": [ - { - "fullscreen": false, - "resizable": true, - "title": "Card Collection Manager 2", - "minWidth": 1300, - "minHeight": 900, - "width": 1300, - "height": 900 - } - ] - } -} +{ + "build": { + "beforeDevCommand": "yarn dev", + "beforeBuildCommand": "yarn build", + "devPath": "http://localhost:1420", + "distDir": "../dist", + "withGlobalTauri": false + }, + "package": { + "productName": "card-collection-manager-2", + "version": "1.0.2" + }, + "tauri": { + "allowlist": { + "all": true + }, + "bundle": { + "active": true, + "category": "DeveloperTool", + "copyright": "", + "deb": { + "depends": [] + }, + "externalBin": [], + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/icon.icns", + "icons/icon.ico" + ], + "identifier": "com.sdine.dev", + "longDescription": "", + "macOS": { + "entitlements": null, + "exceptionDomain": "", + "frameworks": [], + "providerShortName": null, + "signingIdentity": null + }, + "resources": [], + "shortDescription": "", + "targets": "all", + "windows": { + "certificateThumbprint": null, + "digestAlgorithm": "sha256", + "timestampUrl": "" + } + }, + "security": { + "csp": null + }, + "updater": { + "active": false + }, + "windows": [ + { + "fullscreen": false, + "resizable": true, + "title": "Card Collection Manager 2", + "minWidth": 1300, + "minHeight": 900, + "width": 1300, + "height": 900 + } + ] + } +} diff --git a/card-collection-manager-2/version b/card-collection-manager-2/version deleted file mode 100644 index 7dea76e..0000000 --- a/card-collection-manager-2/version +++ /dev/null @@ -1 +0,0 @@ -1.0.1 diff --git a/hooks/activate_hooks.sh b/hooks/activate_hooks.sh index f662a80..039f455 100755 --- a/hooks/activate_hooks.sh +++ b/hooks/activate_hooks.sh @@ -1,2 +1,2 @@ -#!/bin/sh +#!/bin/sh cp ./pre-commit ../.git/hooks \ No newline at end of file diff --git a/hooks/pre-commit b/hooks/pre-commit index 1506529..47c7410 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,26 +1,29 @@ #!/bin/sh PROJECT_ROOT=$(pwd) -# check if version and project name are the same in frontend and backend manifest +# Check if version and project name are the same in all manifest files. +# TAURI_VERSION is the version that is actually used by the tauri build command, +# but to avoid any misconception, versions in all manifests should be the same. cd $PROJECT_ROOT && cd card-collection-manager-2/src-tauri CARGO_VERSION=$(cargo read-manifest | jq -r .version) CARGO_NAME=$(cargo read-manifest | jq -r .name) +TAURI_VERSION=$(cat tauri.conf.json | jq -r .package.version) +TAURI_NAME=$(cat tauri.conf.json | jq -r .package.productName) cd $PROJECT_ROOT && cd card-collection-manager-2 YARN_VERSION=$(cat package.json | jq -r .version) YARN_NAME=$(cat package.json | jq -r .name) -if [ $CARGO_VERSION != $YARN_VERSION ]; then - echo "[PRE-COMMIT] Project version in 'package.json' and 'Cargo.toml' does not match." +if [ $CARGO_VERSION != $YARN_VERSION ] || [ $CARGO_VERSION != $TAURI_VERSION ] || [ $YARN_VERSION != $TAURI_VERSION ]; then + echo "[PRE-COMMIT] Project version in manifests does not match." exit 1 fi -if [ $CARGO_NAME != $YARN_NAME ]; then - echo "[PRE-COMMIT] Project name in 'package.json' and 'Cargo.toml' does not match." +if [ $CARGO_NAME != $YARN_NAME ] || [ $CARGO_NAME != $TAURI_NAME ] || [ $YARN_NAME != $TAURI_NAME ]; then + echo "[PRE-COMMIT] Project name in manifests does not match." exit 1 fi - cd $PROJECT_ROOT -echo $CARGO_VERSION > version +echo $TAURI_VERSION > version git add version exit 0 \ No newline at end of file diff --git a/version b/version old mode 100644 new mode 100755 index 7dea76e..6d7de6e --- a/version +++ b/version @@ -1 +1 @@ -1.0.1 +1.0.2