diff --git a/.gitignore b/.gitignore index 1e040552378bb322e771bb9931f7179e0d005db5..7f0cf1e9e3c69df7474d385ee4f67c9132a05ed0 100644 --- a/.gitignore +++ b/.gitignore @@ -480,7 +480,7 @@ tags # End of https://www.toptal.com/developers/gitignore/api/go,git,vim,node,yarn,dbeaver,netbeans,phpstorm,intellij+all,intellij+iml,visualstudiocode - +.npmrc .attach* .devenv* devenv.local.nix diff --git a/CHANGELOG.md b/CHANGELOG.md index dbb8d586fee1aeabbc41043e766a1c63b609bc1f..f451b300b5b3c96bd5e136a6909e05b3b61b6547 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ -## [9.9.9] - 2023-06-19 +## [3.51.5] - 2023-11-01 +### Bug Fixes + +- test release process +- test release process +- test release process +- test release process +### Changes + +- update release process +- add buils-and-publish +- conversion of the repos to nix packagemanger [#125](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/125) ## [v3.51.4] - 2023-06-19 diff --git a/Taskfile.yml b/Taskfile.yml index 1d80647aa7a788ebae02b1e12381ed35479bcdec..97395f8f1b15121b95d659d04c52ca301cfed92f 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,9 +1,3 @@ - -# THIS FILE IS AUTOGENERATED BY THE DEVENVSHELL -# DO NOT EDIT THIS FILE MANUALLY -# INSTEAD EDIT THE DEVENVSHELL CONFIGURATION FILE devenv.nix -# AND OPEN A SHELL WITH THE COMMAND devenv shell -# # Information about the task runner can be found here: # https://taskfile.dev @@ -16,6 +10,7 @@ tasks: silent: true commit: + silent: true desc: Commit changes to the repository. aliases: - c @@ -23,6 +18,7 @@ tasks: - do-commit build-doc: + silent: true desc: Build the documentation to dist/doc aliases: - bd @@ -30,6 +26,7 @@ tasks: - build-doc run-tests: + silent: true desc: Run the tests aliases: - rt @@ -37,8 +34,17 @@ tasks: - run-tests run-web-tests: + silent: true desc: Run the tests aliases: - rt cmds: - run-web-tests + + build-and-publish: + silent: true + desc: Build the app and publish it to the npm registry + aliases: + - bp + cmds: + - build-and-publish \ No newline at end of file diff --git a/devenv.nix b/devenv.nix index ef24380727347c4eca40c8c01988d2438f015a0d..aa005834dea55b05d2f477e54f046a8641f81481 100644 --- a/devenv.nix +++ b/devenv.nix @@ -72,64 +72,15 @@ fi ${pkgs.nodejs_20}/bin/node ${config.devenv.root}/node_modules/jsdoc-plantuml/fixBrokenNodeJS.js - +''; - -cat <<'EOF' > Taskfile.yml - -# THIS FILE IS AUTOGENERATED BY THE DEVENVSHELL -# DO NOT EDIT THIS FILE MANUALLY -# INSTEAD EDIT THE DEVENVSHELL CONFIGURATION FILE devenv.nix -# AND OPEN A SHELL WITH THE COMMAND devenv shell -# -# Information about the task runner can be found here: -# https://taskfile.dev - -version: '3' - -tasks: - default: - cmds: - - task --list - silent: true - - commit: - desc: Commit changes to the repository. - aliases: - - c - cmds: - - do-commit - - build-doc: - desc: Build the documentation to dist/doc - aliases: - - bd - cmds: - - build-doc - - run-tests: - desc: Run the tests - aliases: - - rt - cmds: - - run-tests - - run-web-tests: - desc: Run the tests - aliases: - - rt - cmds: - - run-web-tests -EOF - ''; - scripts.build-changelog.exec = '' ${pkgs.git-chglog}/bin/git-chglog --config ${config.devenv.root}/.chglog/config.yml -o ${config.devenv.root}/CHANGELOG.md ''; scripts.build-and-publish.exec = '' - +set -x if [ -t 1 ]; then RED='\033[0;31m' GREEN='\033[0;32m' @@ -141,7 +92,15 @@ else RESET="" fi -NEXTVERSION="$(${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/version predict --git -0)" + +if [[ -n "$(git status --porcelain)" ]]; then + echo -e "''${RED}✖ Git is not clean. Exiting.''${RESET}" + echo -e " You must commit all changes before you can publish a new version." + exit 1 +fi + + +NEXTVERSION="$(${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/version predict --git)" if [[ "$NEXTVERSION" =~ "No notable changes found." ]]; then echo -e "''${RED}✖ No notable changes found. Exiting.''${RESET}" @@ -150,8 +109,13 @@ if [[ "$NEXTVERSION" =~ "No notable changes found." ]]; then exit 1 fi +echo -e "''${GREEN}✔''${RESET} New version: $NEXTVERSION" +LASTVERSION=$(cat "${config.devenv.root}/package.json" | jq -r '.version') + +jq ".version = \"$NEXTVERSION\"" "${config.devenv.root}/package.json" | ${pkgs.moreutils}/bin/sponge "${config.devenv.root}/package.json" update-versions + PROJECT_ROOT="${config.devenv.root}/" TEST_PATH="${config.devenv.root}/test/" BUILD_PATH="${config.devenv.root}/dist/" @@ -165,7 +129,6 @@ mkdir -p "''${BUILD_PATH}" ${pkgs.git-chglog}/bin/git-chglog --next-tag ''$NEXTVERSION --config "${config.devenv.root}/.chglog/config.yml" \ -o "${config.devenv.root}/CHANGELOG.md" - ${pkgs.rsync}/bin/rsync -a --exclude-from="${config.devenv.root}/.gitignore" "${config.devenv.root}/source" "''${BUILD_PATH}" ${pkgs.rsync}/bin/rsync -a --exclude-from="${config.devenv.root}/.gitignore" "${config.devenv.root}/test" "''${BUILD_PATH}" ${pkgs.rsync}/bin/rsync -a --exclude-from="${config.devenv.root}/.gitignore" "${config.devenv.root}/example" "''${BUILD_PATH}" @@ -174,24 +137,23 @@ cp ${config.devenv.root}/README.md "''${BUILD_PATH}" cp ${config.devenv.root}/LICENSE "''${BUILD_PATH}" cp ${config.devenv.root}/CHANGELOG.md "''${BUILD_PATH}" - jq 'del(.devDependencies)' ${config.devenv.root}/package.json > "''${BUILD_PATH}/package.json" -#git add ''${APPLICATION_PATH}package.json -#git add ''${DEVELOPMENT_PATH}package.json -#git add ''${APPLICATION_PATH}source/types/version.mjs -#git add ''${TEST_PATH}cases/monster.mjs -#git add ''${PROJECT_ROOT}release.json -#git commit -m "release and publish to npm" - -#rm $BUILD_PATH/pnpm-lock.yaml +git add ${config.devenv.root}/package.json +git add ${config.devenv.root}/source/types/version.mjs +git add ${config.devenv.root}/CHANGELOG.md +git add ${config.devenv.root}/test/cases/monster.mjs +if ! git commit -m "chore: release and publish to npm new version $NEXTVERSION" ; then + echo -e "''${RED}✖ Commit failed. Exiting.''${RESET}" + exit 1 +fi cd ''${BUILD_PATH} OPTIONS="" if [ ! -f "${config.devenv.root}/.npmrc" ]; then - echo -e "''${RED}✖ No npmrc file found. Exiting.''${RESET}" - echo -e " Create a file named .npmrc in the root of this repository with the following content:" + echo -e "''${RED}✖ No .npmrc file found.''${RESET}" + echo -e " If you want to publish to npm, you need to create a .npmrc file in the root of the project." echo -e " //registry.npmjs.org/:_authToken=$NPM_TOKEN" echo -e " You can find the token in the npm account settings." echo -e "\n We run in dry-run mode now." @@ -199,17 +161,38 @@ if [ ! -f "${config.devenv.root}/.npmrc" ]; then fi pnpm publish $OPTIONS --dry-run --access public +exitcode=$? cd - + +set -x +if [ -n "$OPTIONS" ] || [ $exitcode -ne 0 ]; then + + ## reset to last version + jq ".version = \"$LASTVERSION\"" "${config.devenv.root}/package.json" | ${pkgs.moreutils}/bin/sponge "${config.devenv.root}/package.json" + update-versions + + echo -e "''${RED}✖ Publishing failed. Exiting.''${RESET}" + git reset --hard HEAD~1 + + exit 1 +fi + +git tag -a ''$NEXTVERSION -m "chore tag new version $NEXTVERSION" + +echo -e "''${GREEN}✔''${RESET} Publishing successful." ''; scripts.update-versions.exec = '' -VERSION=$(cat "${config.devenv.root}/release.json" | jq -r '.version') +VERSION=$(${pkgs.coreutils}/bin/cat "${config.devenv.root}/package.json" | jq -r '.version') -sed -i -E "s_(\"[0-9]+\.[0-9]+\.[0-9]+\")_\"''${VERSION}\"_g" "${config.devenv.root}/source/types/version.mjs" -sed -i -E "s_(\"[0-9]+\.[0-9]+\.[0-9]+\")_\"''${VERSION}\"_g" "${config.devenv.root}/test/cases/monster.mjs" +${pkgs.jq}/bin/jq ".version = \"$VERSION\"" "${config.devenv.root}/package.json" | ${pkgs.moreutils}/bin/sponge "${config.devenv.root}/package.json" + +${pkgs.gnused}/bin/sed -i -E "s_(\"[0-9]+\.[0-9]+\.[0-9]+\")_\"''${VERSION}\"_g" "${config.devenv.root}/source/types/version.mjs" +${pkgs.gnused}/bin/sed -i -E "s_(\"[0-9]+\.[0-9]+\.[0-9]+\")_\"''${VERSION}\"_g" "${config.devenv.root}/test/cases/monster.mjs" + ''; scripts.create-polifill.exec = '' @@ -246,7 +229,7 @@ PROJECT_ROOT="${config.devenv.root}" TEST_PATH="${config.devenv.root}/test/" TEST_CASES_PATH="${config.devenv.root}/test/cases/" -VERSION=$(cat "${config.devenv.root}/release.json" | jq -r '.version') +VERSION=$(cat "${config.devenv.root}/package.json" | jq -r '.version') update-versions build-monster-mjs diff --git a/release.json b/release.json deleted file mode 100644 index 1232d2236ca765f06d010f3d76d8d3ba5696aad9..0000000000000000000000000000000000000000 --- a/release.json +++ /dev/null @@ -1 +0,0 @@ -{"version":"3.51.4"} diff --git a/source/monster.mjs b/source/monster.mjs index f150069521f0ce4f56a60509ddbfedaa27f06cde..12e5ec8e30f2aafdaa93db30cede9910d73240fd 100644 --- a/source/monster.mjs +++ b/source/monster.mjs @@ -129,3 +129,5 @@ export { Monster }; * @memberOf Monster */ class Monster {} + +