From 393ad861d84547800dab64cfead23810b2140d9e Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Tue, 21 Jan 2025 17:20:31 +0000 Subject: [PATCH 01/23] tests(next): reuse existing tests but with different imports --- next/jest.config.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 next/jest.config.js diff --git a/next/jest.config.js b/next/jest.config.js new file mode 100644 index 000000000..3898f316f --- /dev/null +++ b/next/jest.config.js @@ -0,0 +1,30 @@ +const path = require('node:path'); + +/** @type {import('jest').Config} */ +module.exports = { + testEnvironment: 'jsdom', + // Point to the original test files + roots: [path.resolve(__dirname, '../src/tests')], + moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'], + transform: { + '^.+\\.(js|jsx)$': [ + 'babel-jest', + { + presets: [ + [ + '@babel/preset-env', + { + targets: { + node: 'current', + }, + }, + ], + ], + }, + ], + '^.+\\.(ts|tsx)$': 'ts-jest', + }, + moduleNameMapper: { + '^@/(.*)$': '/src/$1', + }, +}; From 3a27a10fb98bdce7f290873159dbb13ea0fbaa55 Mon Sep 17 00:00:00 2001 From: thien-remote <159022487+thien-remote@users.noreply.github.com> Date: Wed, 22 Jan 2025 17:34:53 +0700 Subject: [PATCH 02/23] build(next): Simplify test setup (#112) * Fix * Update jest.config.js * Update babel.config.js * chore: add default node version --------- Co-authored-by: David Dragovacz --- next/jest.config.js | 30 ------------------------------ package.json | 3 ++- 2 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 next/jest.config.js diff --git a/next/jest.config.js b/next/jest.config.js deleted file mode 100644 index 3898f316f..000000000 --- a/next/jest.config.js +++ /dev/null @@ -1,30 +0,0 @@ -const path = require('node:path'); - -/** @type {import('jest').Config} */ -module.exports = { - testEnvironment: 'jsdom', - // Point to the original test files - roots: [path.resolve(__dirname, '../src/tests')], - moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'], - transform: { - '^.+\\.(js|jsx)$': [ - 'babel-jest', - { - presets: [ - [ - '@babel/preset-env', - { - targets: { - node: 'current', - }, - }, - ], - ], - }, - ], - '^.+\\.(ts|tsx)$': 'ts-jest', - }, - moduleNameMapper: { - '^@/(.*)$': '/src/$1', - }, -}; diff --git a/package.json b/package.json index 1a12ceb00..f1585367a 100644 --- a/package.json +++ b/package.json @@ -81,5 +81,6 @@ ], "engines": { "node": ">=18.14.0" - } + }, + "packageManager": "pnpm@9.15.2+sha512.93e57b0126f0df74ce6bff29680394c0ba54ec47246b9cf321f0121d8d9bb03f750a705f24edc3c1180853afd7c2c3b94196d0a3d53d3e069d9e2793ef11f321" } From 3e2dfe864ebb70ada752905eefd7520c70e20039 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Wed, 22 Jan 2025 14:49:12 +0000 Subject: [PATCH 03/23] chore: apply changes based on review --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index f1585367a..1a12ceb00 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,5 @@ ], "engines": { "node": ">=18.14.0" - }, - "packageManager": "pnpm@9.15.2+sha512.93e57b0126f0df74ce6bff29680394c0ba54ec47246b9cf321f0121d8d9bb03f750a705f24edc3c1180853afd7c2c3b94196d0a3d53d3e069d9e2793ef11f321" + } } From da31ee763478d724fb9f6629524390b7b89a7b49 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Wed, 22 Jan 2025 21:09:24 +0000 Subject: [PATCH 04/23] build(next): add release script based on existing ones --- scripts/release_next.js | 98 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 scripts/release_next.js diff --git a/scripts/release_next.js b/scripts/release_next.js new file mode 100644 index 000000000..456207278 --- /dev/null +++ b/scripts/release_next.js @@ -0,0 +1,98 @@ +const path = require('path'); + +const semver = require('semver'); + +const { + askForConfirmation, + askForText, + checkGitStatus, + checkNpmAuth, + runExec, + revertCommit, +} = require('./release.helpers'); + +const packageJsonPath = path.resolve(__dirname, '../next/package.json'); +const packageJson = require(packageJsonPath); + +async function checkGitBranchAndStatus() { + console.log('Checking your branch...'); + const resultBranch = await runExec('git branch --show-current', { + silent: true, + }); + const branchName = resultBranch.stdout.toString().trim(); + if (branchName === 'main') { + console.error(`🟠 You are at "main". Are you sure you wanna release a next version here?`); + process.exit(1); + } + + await checkGitStatus(); +} + +async function getNewVersion() { + const currentVersion = packageJson.version; + const versionType = process.argv.slice(2)[0]; + + if (!versionType) { + console.log('🟠 version type is missing. Make sure to run the script from package.json'); + process.exit(1); + } + + // Keep alpha tag for next versions + const versionBase = semver.coerce(currentVersion); + return semver.inc(versionBase, versionType) + '-alpha.0'; +} + +async function bumpVersion({ newVersion }) { + const cmd = `cd next && npm version --no-git-tag-version ${newVersion}`; + await runExec(cmd); +} + +async function build() { + console.log('Building next version...'); + const cmd = 'cd next && npm run build'; + await runExec(cmd); +} + +async function gitCommit({ newVersion }) { + console.log('Committing published version...'); + const cmd = `git add next/package.json && git commit -m "Release next ${newVersion}" && git tag next-v${newVersion} && git push && git push origin --tags`; + await runExec(cmd); +} + +async function publish({ newVersion, otp }) { + console.log('Publishing new version...'); + + // Use --tag=next to mark this as the "next" version + const cmd = `cd next && npm publish --access=public --tag=next --otp=${otp}`; + try { + await runExec(cmd); + console.log(`🎉 Next version ${newVersion} published!`); + } catch { + console.log('🚨 Publish failed! Perhaps the OTP is wrong.'); + await revertCommit({ newVersion }); + } +} + +async function init() { + await checkGitBranchAndStatus(); + const newVersion = await getNewVersion(); + + console.log(':: Current version:', packageJson.version); + console.log(':::::: New version:', newVersion); + + const answer = await askForConfirmation('Ready to commit and publish it?'); + + if (answer === 'no') { + process.exit(1); + } + + await checkNpmAuth(); + const otp = await askForText('🔐 What is the NPM Auth OTP? (Check 1PW) '); + + await bumpVersion({ newVersion }); + await build(); + await gitCommit({ newVersion }); + await publish({ newVersion, otp }); +} + +init(); From 5cc66de66154c2ca68254135a00804a491c2631b Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Wed, 22 Jan 2025 21:10:13 +0000 Subject: [PATCH 05/23] build(next): add release:next scripts --- next/package.json | 4 +++- package.json | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/next/package.json b/next/package.json index 7bc2acacf..bb5514cba 100644 --- a/next/package.json +++ b/next/package.json @@ -21,11 +21,13 @@ "node": "22.13.1" }, "scripts": { + "build": "tsup", "test": "jest", "test:watch": "jest --watchAll", "test:file": "jest --runTestsByPath", "lint": "eslint --max-warnings 0 .", - "build": "tsup" + "release:patch": "cd .. && npm run release:next:patch", + "release:minor": "cd .. && npm run release:next:minor" }, "devDependencies": { "@antfu/eslint-config": "^3.14.0", diff --git a/package.json b/package.json index 1a12ceb00..08508f4dc 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,8 @@ "release:dev:minor": "node scripts/release_dev minor", "release:main:patch": "node scripts/release_main patch", "release:main:minor": "node scripts/release_main minor", + "release:next:patch": "node scripts/release_next patch", + "release:next:minor": "node scripts/release_next minor", "version_as_main": "node scripts/version_as_main.js", "psrepublishOnly": "if [[ ! $PWD =~ scripts$ ]]; then npm run publish:nopublish; fi", "psublish:nopublish": "echo 'Use `npm release:*` script instead && exit 1" From 17e6257d44b13e1e06e777a2b4d30cb8c281c93c Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Thu, 23 Jan 2025 09:38:50 +0000 Subject: [PATCH 06/23] chore: make changes based on review --- scripts/release_next.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_next.js b/scripts/release_next.js index 456207278..f9052612e 100644 --- a/scripts/release_next.js +++ b/scripts/release_next.js @@ -39,7 +39,7 @@ async function getNewVersion() { // Keep alpha tag for next versions const versionBase = semver.coerce(currentVersion); - return semver.inc(versionBase, versionType) + '-alpha.0'; + return semver.inc(versionBase, versionType, 'alpha'); } async function bumpVersion({ newVersion }) { From b33dcd7d7ab02ba97ec029e6c362a51cc1198a23 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Thu, 23 Jan 2025 12:21:07 +0000 Subject: [PATCH 07/23] build(next): adjust release script --- next/package.json | 5 ++--- package.json | 3 +-- scripts/release_next.js | 12 +++--------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/next/package.json b/next/package.json index bb5514cba..4b6f55fff 100644 --- a/next/package.json +++ b/next/package.json @@ -1,6 +1,6 @@ { "name": "@remoteoss/json-schema-form", - "version": "1.0.0-alpha.1", + "version": "1.0.0-alpha.0", "packageManager": "pnpm@9.15.2", "description": "WIP V2 – Headless UI form powered by JSON Schemas", "author": "Remote.com (https://remote.com/)", @@ -26,8 +26,7 @@ "test:watch": "jest --watchAll", "test:file": "jest --runTestsByPath", "lint": "eslint --max-warnings 0 .", - "release:patch": "cd .. && npm run release:next:patch", - "release:minor": "cd .. && npm run release:next:minor" + "release": "cd .. && npm run release:next" }, "devDependencies": { "@antfu/eslint-config": "^3.14.0", diff --git a/package.json b/package.json index 08508f4dc..b66375302 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,7 @@ "release:dev:minor": "node scripts/release_dev minor", "release:main:patch": "node scripts/release_main patch", "release:main:minor": "node scripts/release_main minor", - "release:next:patch": "node scripts/release_next patch", - "release:next:minor": "node scripts/release_next minor", + "release:next": "node scripts/release_next", "version_as_main": "node scripts/version_as_main.js", "psrepublishOnly": "if [[ ! $PWD =~ scripts$ ]]; then npm run publish:nopublish; fi", "psublish:nopublish": "echo 'Use `npm release:*` script instead && exit 1" diff --git a/scripts/release_next.js b/scripts/release_next.js index f9052612e..736c990cd 100644 --- a/scripts/release_next.js +++ b/scripts/release_next.js @@ -30,16 +30,10 @@ async function checkGitBranchAndStatus() { async function getNewVersion() { const currentVersion = packageJson.version; - const versionType = process.argv.slice(2)[0]; - if (!versionType) { - console.log('🟠 version type is missing. Make sure to run the script from package.json'); - process.exit(1); - } - - // Keep alpha tag for next versions - const versionBase = semver.coerce(currentVersion); - return semver.inc(versionBase, versionType, 'alpha'); + // Instead of coercing and losing the prerelease info, + // we'll just increment the prerelease number + return semver.inc(currentVersion, 'prerelease', 'alpha'); } async function bumpVersion({ newVersion }) { From d14f2f0a672773b4973a55cef56555093f2f5367 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Thu, 23 Jan 2025 12:24:38 +0000 Subject: [PATCH 08/23] Release next 1.0.0-alpha.1 --- next/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next/package.json b/next/package.json index 4b6f55fff..8375ba419 100644 --- a/next/package.json +++ b/next/package.json @@ -1,6 +1,6 @@ { "name": "@remoteoss/json-schema-form", - "version": "1.0.0-alpha.0", + "version": "1.0.0-alpha.1", "packageManager": "pnpm@9.15.2", "description": "WIP V2 – Headless UI form powered by JSON Schemas", "author": "Remote.com (https://remote.com/)", From 5b659cbc688ec81b5a8d71cb980ca4cba15cb3ef Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 24 Jan 2025 12:53:07 +0000 Subject: [PATCH 09/23] build(next): change release script - includes separate `dev` and `beta` versions - `dev` will work the same way as the main `dev` script that we have where we append the version with the timestamp - `beta` will increment the version in the `/next/package.json` file --- scripts/{release_next.js => release_v1.js} | 56 +++++++++++++++------- 1 file changed, 39 insertions(+), 17 deletions(-) rename scripts/{release_next.js => release_v1.js} (51%) diff --git a/scripts/release_next.js b/scripts/release_v1.js similarity index 51% rename from scripts/release_next.js rename to scripts/release_v1.js index 736c990cd..b36a7dff9 100644 --- a/scripts/release_next.js +++ b/scripts/release_v1.js @@ -9,6 +9,7 @@ const { checkNpmAuth, runExec, revertCommit, + getDateYYYYMMDDHHMMSS, } = require('./release.helpers'); const packageJsonPath = path.resolve(__dirname, '../next/package.json'); @@ -21,7 +22,7 @@ async function checkGitBranchAndStatus() { }); const branchName = resultBranch.stdout.toString().trim(); if (branchName === 'main') { - console.error(`🟠 You are at "main". Are you sure you wanna release a next version here?`); + console.error(`🟠 You are at "main". Are you sure you wanna release a v1 version here?`); process.exit(1); } @@ -29,16 +30,34 @@ async function checkGitBranchAndStatus() { } async function getNewVersion() { + const releaseType = process.argv[2]; + if (!['dev', 'beta'].includes(releaseType)) { + console.error('🟠 Invalid release type. Use dev or beta'); + process.exit(1); + } + const currentVersion = packageJson.version; - // Instead of coercing and losing the prerelease info, - // we'll just increment the prerelease number - return semver.inc(currentVersion, 'prerelease', 'alpha'); + if (releaseType === 'dev') { + const timestamp = getDateYYYYMMDDHHMMSS(); + console.log('Creating new dev version...'); + return `1.0.0-dev.${timestamp}`; + } + + // For beta releases + console.log('Creating new beta version...'); + if (currentVersion.includes('-beta.')) { + return semver.inc(currentVersion, 'prerelease', 'beta'); + } + return '1.0.0-beta.0'; } -async function bumpVersion({ newVersion }) { - const cmd = `cd next && npm version --no-git-tag-version ${newVersion}`; - await runExec(cmd); +async function bumpVersion({ newVersion, releaseType }) { + // Only update package.json for beta releases + if (releaseType === 'beta') { + const cmd = `cd next && npm version --no-git-tag-version ${newVersion}`; + await runExec(cmd); + } } async function build() { @@ -47,20 +66,22 @@ async function build() { await runExec(cmd); } -async function gitCommit({ newVersion }) { +async function gitCommit({ newVersion, releaseType }) { console.log('Committing published version...'); - const cmd = `git add next/package.json && git commit -m "Release next ${newVersion}" && git tag next-v${newVersion} && git push && git push origin --tags`; + const prefix = `v1-${releaseType}`; + const cmd = `git add next/package.json && git commit -m "Release ${prefix} ${newVersion}" && git tag ${prefix}-${newVersion} && git push && git push origin --tags`; await runExec(cmd); } -async function publish({ newVersion, otp }) { +async function publish({ newVersion, releaseType, otp }) { console.log('Publishing new version...'); + const npmTag = `v1-${releaseType}`; - // Use --tag=next to mark this as the "next" version - const cmd = `cd next && npm publish --access=public --tag=next --otp=${otp}`; + const cmd = `cd next && npm publish --access=public --tag=${npmTag} --otp=${otp}`; try { await runExec(cmd); - console.log(`🎉 Next version ${newVersion} published!`); + console.log(`🎉 ${npmTag} version ${newVersion} published!`); + console.log(`Install with: npm i @remoteoss/json-schema-form@${npmTag}`); } catch { console.log('🚨 Publish failed! Perhaps the OTP is wrong.'); await revertCommit({ newVersion }); @@ -68,11 +89,12 @@ async function publish({ newVersion, otp }) { } async function init() { + const releaseType = process.argv[2]; await checkGitBranchAndStatus(); const newVersion = await getNewVersion(); console.log(':: Current version:', packageJson.version); - console.log(':::::: New version:', newVersion); + console.log(`:::::: New version (${releaseType}):`, newVersion); const answer = await askForConfirmation('Ready to commit and publish it?'); @@ -83,10 +105,10 @@ async function init() { await checkNpmAuth(); const otp = await askForText('🔐 What is the NPM Auth OTP? (Check 1PW) '); - await bumpVersion({ newVersion }); + await bumpVersion({ newVersion, releaseType }); await build(); - await gitCommit({ newVersion }); - await publish({ newVersion, otp }); + await gitCommit({ newVersion, releaseType }); + await publish({ newVersion, releaseType, otp }); } init(); From d8968ffa6d61485b5a3ae03160b16dc256b092ef Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 24 Jan 2025 12:53:22 +0000 Subject: [PATCH 10/23] build(next): add new scripts --- next/package.json | 7 ++++--- package.json | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/next/package.json b/next/package.json index 8375ba419..4a25d64cd 100644 --- a/next/package.json +++ b/next/package.json @@ -1,6 +1,6 @@ { "name": "@remoteoss/json-schema-form", - "version": "1.0.0-alpha.1", + "version": "1.0.0-beta.0", "packageManager": "pnpm@9.15.2", "description": "WIP V2 – Headless UI form powered by JSON Schemas", "author": "Remote.com (https://remote.com/)", @@ -18,7 +18,7 @@ ], "main": "index.js", "engines": { - "node": "22.13.1" + "node": ">=18.14.0" }, "scripts": { "build": "tsup", @@ -26,7 +26,8 @@ "test:watch": "jest --watchAll", "test:file": "jest --runTestsByPath", "lint": "eslint --max-warnings 0 .", - "release": "cd .. && npm run release:next" + "release:dev": "cd .. && npm run release:v1:dev", + "release:beta": "cd .. && npm run release:v1:beta" }, "devDependencies": { "@antfu/eslint-config": "^3.14.0", diff --git a/package.json b/package.json index b66375302..6a989bcba 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "release:dev:minor": "node scripts/release_dev minor", "release:main:patch": "node scripts/release_main patch", "release:main:minor": "node scripts/release_main minor", - "release:next": "node scripts/release_next", + "release:v1:dev": "node scripts/release_v1 dev", + "release:v1:beta": "node scripts/release_v1 beta", "version_as_main": "node scripts/version_as_main.js", "psrepublishOnly": "if [[ ! $PWD =~ scripts$ ]]; then npm run publish:nopublish; fi", "psublish:nopublish": "echo 'Use `npm release:*` script instead && exit 1" From 932c4003f5ace9ce14ad0d8fbf4ebf52a4bd543c Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 24 Jan 2025 13:05:00 +0000 Subject: [PATCH 11/23] build(next): do not update package.json with dev versions --- scripts/release_v1.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/release_v1.js b/scripts/release_v1.js index b36a7dff9..315005ea4 100644 --- a/scripts/release_v1.js +++ b/scripts/release_v1.js @@ -69,7 +69,16 @@ async function build() { async function gitCommit({ newVersion, releaseType }) { console.log('Committing published version...'); const prefix = `v1-${releaseType}`; - const cmd = `git add next/package.json && git commit -m "Release ${prefix} ${newVersion}" && git tag ${prefix}-${newVersion} && git push && git push origin --tags`; + + let cmd; + if (releaseType === 'beta') { + // For beta, we commit package.json changes + cmd = `git add next/package.json && git commit -m "Release ${prefix} ${newVersion}" && git tag ${prefix}-${newVersion} && git push && git push origin --tags`; + } else { + // For dev, we only create a tag + cmd = `git tag ${prefix}-${newVersion} && git push origin --tags`; + } + await runExec(cmd); } From 00ad987cff1a72ac6ed570345af5909232cf730f Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 24 Jan 2025 13:31:08 +0000 Subject: [PATCH 12/23] build(next): adjust script to always use the current version --- scripts/release_v1.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/release_v1.js b/scripts/release_v1.js index 315005ea4..ea99a4109 100644 --- a/scripts/release_v1.js +++ b/scripts/release_v1.js @@ -53,11 +53,16 @@ async function getNewVersion() { } async function bumpVersion({ newVersion, releaseType }) { - // Only update package.json for beta releases + // For beta, update package.json if (releaseType === 'beta') { const cmd = `cd next && npm version --no-git-tag-version ${newVersion}`; await runExec(cmd); } + // For dev, temporarily update version for publishing only + else { + const cmd = `cd next && npm --no-git-tag-version version ${newVersion} --no-workspaces-update --workspace-update=false`; + await runExec(cmd); + } } async function build() { @@ -85,10 +90,19 @@ async function gitCommit({ newVersion, releaseType }) { async function publish({ newVersion, releaseType, otp }) { console.log('Publishing new version...'); const npmTag = `v1-${releaseType}`; + const originalVersion = packageJson.version; - const cmd = `cd next && npm publish --access=public --tag=${npmTag} --otp=${otp}`; try { + // Publish with the dev/beta version + const cmd = `cd next && npm publish --access=public --tag=${npmTag} --otp=${otp}`; await runExec(cmd); + + // For dev releases, revert package.json back to original version + if (releaseType === 'dev') { + const revertCmd = `cd next && npm version --no-git-tag-version ${originalVersion}`; + await runExec(revertCmd); + } + console.log(`🎉 ${npmTag} version ${newVersion} published!`); console.log(`Install with: npm i @remoteoss/json-schema-form@${npmTag}`); } catch { From e3bf095ebdba6a2ea4c21231f1b2cef643e090e7 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 24 Jan 2025 13:33:45 +0000 Subject: [PATCH 13/23] Release v1-beta 1.0.0-beta.1 --- next/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next/package.json b/next/package.json index 4a25d64cd..4aefe9652 100644 --- a/next/package.json +++ b/next/package.json @@ -1,6 +1,6 @@ { "name": "@remoteoss/json-schema-form", - "version": "1.0.0-beta.0", + "version": "1.0.0-beta.1", "packageManager": "pnpm@9.15.2", "description": "WIP V2 – Headless UI form powered by JSON Schemas", "author": "Remote.com (https://remote.com/)", From f90466cff2fad5452aa47bb4848caf07645e0624 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 24 Jan 2025 15:15:44 +0000 Subject: [PATCH 14/23] build(next): add `files` to package.json --- next/package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/next/package.json b/next/package.json index 4aefe9652..9ce2a1792 100644 --- a/next/package.json +++ b/next/package.json @@ -16,7 +16,11 @@ "json-schema", "form" ], - "main": "index.js", + "main": "index.mjs", + "files": [ + "README.md", + "dist" + ], "engines": { "node": ">=18.14.0" }, From f90b799f604bd52a7ec383957a1d5049c5012624 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 24 Jan 2025 15:25:53 +0000 Subject: [PATCH 15/23] build(next): correct main entry --- next/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/next/package.json b/next/package.json index 9ce2a1792..b419ab175 100644 --- a/next/package.json +++ b/next/package.json @@ -16,7 +16,8 @@ "json-schema", "form" ], - "main": "index.mjs", + "main": "dist/index.mjs", + "module": "dist/index.mjs", "files": [ "README.md", "dist" From 65a62c3e8713db6d36d6e2f792caa984164c6533 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 24 Jan 2025 15:37:17 +0000 Subject: [PATCH 16/23] Release v1-beta 1.0.0-beta.2 --- next/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next/package.json b/next/package.json index b419ab175..99251e6b0 100644 --- a/next/package.json +++ b/next/package.json @@ -1,6 +1,6 @@ { "name": "@remoteoss/json-schema-form", - "version": "1.0.0-beta.1", + "version": "1.0.0-beta.2", "packageManager": "pnpm@9.15.2", "description": "WIP V2 – Headless UI form powered by JSON Schemas", "author": "Remote.com (https://remote.com/)", From 4e653d1832c8b202d97ed9bfc4740bf4f2fce2a3 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 31 Jan 2025 14:59:38 +0000 Subject: [PATCH 17/23] build(next): release rules prevents the `dev` release when on `main` branch only allows a `beta` release when on `main` branch and local branch up to date --- scripts/release_v1.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/scripts/release_v1.js b/scripts/release_v1.js index ea99a4109..d974863f9 100644 --- a/scripts/release_v1.js +++ b/scripts/release_v1.js @@ -16,14 +16,38 @@ const packageJsonPath = path.resolve(__dirname, '../next/package.json'); const packageJson = require(packageJsonPath); async function checkGitBranchAndStatus() { - console.log('Checking your branch...'); + const releaseType = process.argv[2]; + console.log(`Checking your branch for ${releaseType} release...`); + const resultBranch = await runExec('git branch --show-current', { silent: true, }); const branchName = resultBranch.stdout.toString().trim(); - if (branchName === 'main') { - console.error(`🟠 You are at "main". Are you sure you wanna release a v1 version here?`); - process.exit(1); + + if (releaseType === 'dev') { + // For dev releases, cannot be on main branch + if (branchName === 'main') { + console.error(`🟠 You are at "main". Dev versions cannot be released from main branch.`); + process.exit(1); + } + } else if (releaseType === 'beta') { + // For beta releases, must be on main branch and up to date + if (branchName !== 'main') { + console.error( + `🟠 You are at "${branchName}" instead of "main" branch. Beta versions must be released from main.` + ); + process.exit(1); + } + + // Check if local main is up to date + await runExec('git remote update', { silent: true }); + const resultStatus = await runExec('git status -uno', { silent: true }); + const mainStatus = resultStatus.stdout.toString().trim(); + + if (!mainStatus.includes("Your branch is up to date with 'origin/main'.")) { + console.error(`🟠 Please make sure your branch is up to date with the git repo.`); + process.exit(1); + } } await checkGitStatus(); From a0bdf45f0aed30e7a218c9b7d16132f5a56f1a0e Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 31 Jan 2025 15:04:21 +0000 Subject: [PATCH 18/23] build(next): simplify `bumpVersion` --- scripts/release_v1.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/scripts/release_v1.js b/scripts/release_v1.js index d974863f9..0f5bad262 100644 --- a/scripts/release_v1.js +++ b/scripts/release_v1.js @@ -76,17 +76,9 @@ async function getNewVersion() { return '1.0.0-beta.0'; } -async function bumpVersion({ newVersion, releaseType }) { - // For beta, update package.json - if (releaseType === 'beta') { - const cmd = `cd next && npm version --no-git-tag-version ${newVersion}`; - await runExec(cmd); - } - // For dev, temporarily update version for publishing only - else { - const cmd = `cd next && npm --no-git-tag-version version ${newVersion} --no-workspaces-update --workspace-update=false`; - await runExec(cmd); - } +async function bumpVersion({ newVersion }) { + const cmd = `cd next && npm version --no-git-tag-version ${newVersion}`; + await runExec(cmd); } async function build() { @@ -152,7 +144,7 @@ async function init() { await checkNpmAuth(); const otp = await askForText('🔐 What is the NPM Auth OTP? (Check 1PW) '); - await bumpVersion({ newVersion, releaseType }); + await bumpVersion({ newVersion }); await build(); await gitCommit({ newVersion, releaseType }); await publish({ newVersion, releaseType, otp }); From 00e467a7fc38e6f38b08bfcd36d97c2d3f36b8d6 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 31 Jan 2025 15:18:56 +0000 Subject: [PATCH 19/23] build(next): generate changelog for beta releases --- next/package.json | 1 + next/pnpm-lock.yaml | 28 ++++++++++++++++++++++++++++ scripts/release_v1.js | 26 +++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/next/package.json b/next/package.json index 99251e6b0..35c77c628 100644 --- a/next/package.json +++ b/next/package.json @@ -42,6 +42,7 @@ "@jest/globals": "^29.7.0", "babel-jest": "^29.7.0", "eslint": "^9.18.0", + "generate-changelog": "^1.8.0", "jest": "^29.7.0", "json-schema-typed": "^8.0.1", "tsup": "^8.3.5", diff --git a/next/pnpm-lock.yaml b/next/pnpm-lock.yaml index a995f495a..bbd18b1cb 100644 --- a/next/pnpm-lock.yaml +++ b/next/pnpm-lock.yaml @@ -29,6 +29,9 @@ importers: eslint: specifier: ^9.18.0 version: 9.18.0 + generate-changelog: + specifier: ^1.8.0 + version: 1.8.0 jest: specifier: ^29.7.0 version: 29.7.0(@types/node@22.10.7)(ts-node@10.9.2(@types/node@22.10.7)(typescript@5.7.3)) @@ -1409,6 +1412,9 @@ packages: balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + bluebird@3.7.2: + resolution: {integrity: sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==} + boolbase@1.0.0: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} @@ -1513,6 +1519,9 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + commander@2.20.3: + resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} + commander@4.1.1: resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} engines: {node: '>= 6'} @@ -1940,6 +1949,10 @@ packages: function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + generate-changelog@1.8.0: + resolution: {integrity: sha512-msgpxeB75Ziyg3wGsZuPNl7c5RxChMKmYcAX5obnhUow90dBZW3nLic6nxGtst7Bpx453oS6zAIHcX7F3QVasw==} + hasBin: true + gensync@1.0.0-beta.2: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} @@ -1959,6 +1972,9 @@ packages: get-tsconfig@4.9.0: resolution: {integrity: sha512-52n24W52sIueosRe0XZ8Ex5Yle+WbhfCKnV/gWXpbVR8FXNTfqdKEKUSypKso66VRHTvvcQxL44UTZbJRlCTnw==} + github-url-from-git@1.5.0: + resolution: {integrity: sha512-WWOec4aRI7YAykQ9+BHmzjyNlkfJFG8QLXnDTsLz/kZefq7qkzdfo4p6fkYYMIq1aj+gZcQs/1HQhQh3DPPxlQ==} + glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -4812,6 +4828,8 @@ snapshots: balanced-match@1.0.2: {} + bluebird@3.7.2: {} + boolbase@1.0.0: {} brace-expansion@1.1.11: @@ -4898,6 +4916,8 @@ snapshots: color-name@1.1.4: {} + commander@2.20.3: {} + commander@4.1.1: {} comment-parser@1.4.1: {} @@ -5411,6 +5431,12 @@ snapshots: function-bind@1.1.2: {} + generate-changelog@1.8.0: + dependencies: + bluebird: 3.7.2 + commander: 2.20.3 + github-url-from-git: 1.5.0 + gensync@1.0.0-beta.2: {} get-caller-file@2.0.5: {} @@ -5423,6 +5449,8 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 + github-url-from-git@1.5.0: {} + glob-parent@5.1.2: dependencies: is-glob: 4.0.3 diff --git a/scripts/release_v1.js b/scripts/release_v1.js index 0f5bad262..61f359533 100644 --- a/scripts/release_v1.js +++ b/scripts/release_v1.js @@ -9,6 +9,7 @@ const { checkNpmAuth, runExec, revertCommit, + revertChanges, getDateYYYYMMDDHHMMSS, } = require('./release.helpers'); @@ -87,14 +88,20 @@ async function build() { await runExec(cmd); } +async function updateChangelog() { + console.log('Updating changelog...'); + const cmd = 'cd next && npx generate-changelog'; + await runExec(cmd); +} + async function gitCommit({ newVersion, releaseType }) { console.log('Committing published version...'); const prefix = `v1-${releaseType}`; let cmd; if (releaseType === 'beta') { - // For beta, we commit package.json changes - cmd = `git add next/package.json && git commit -m "Release ${prefix} ${newVersion}" && git tag ${prefix}-${newVersion} && git push && git push origin --tags`; + // For beta, we commit package.json changes and changelog + cmd = `git add next/package.json next/CHANGELOG.md && git commit -m "Release ${prefix} ${newVersion}" && git tag ${prefix}-${newVersion} && git push && git push origin --tags`; } else { // For dev, we only create a tag cmd = `git tag ${prefix}-${newVersion} && git push origin --tags`; @@ -142,10 +149,23 @@ async function init() { } await checkNpmAuth(); - const otp = await askForText('🔐 What is the NPM Auth OTP? (Check 1PW) '); await bumpVersion({ newVersion }); + + // Only update changelog for beta releases + if (releaseType === 'beta') { + await updateChangelog(); + const answerChangelog = await askForConfirmation( + 'Changelog is updated. You may tweak it as needed. Once ready, press Y to continue.' + ); + if (answerChangelog === 'no') { + await revertChanges(); + } + } + await build(); + const otp = await askForText('🔐 What is the NPM Auth OTP? (Check 1PW) '); + await gitCommit({ newVersion, releaseType }); await publish({ newVersion, releaseType, otp }); } From 40a045f2e20098264d78a593b85b22c669d09279 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 31 Jan 2025 15:30:56 +0000 Subject: [PATCH 20/23] fix: versioning bug --- scripts/release_v1.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/release_v1.js b/scripts/release_v1.js index 61f359533..c63052a4c 100644 --- a/scripts/release_v1.js +++ b/scripts/release_v1.js @@ -74,7 +74,12 @@ async function getNewVersion() { if (currentVersion.includes('-beta.')) { return semver.inc(currentVersion, 'prerelease', 'beta'); } - return '1.0.0-beta.0'; + + console.error( + `🟠 Cannot create beta version: Current version "${currentVersion}" is not a beta version.\n` + + ' The package.json version should be in the format "1.0.0-beta.X"' + ); + process.exit(1); } async function bumpVersion({ newVersion }) { From 9259d8d63779f3e5ac3170217f167e5d86afa015 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 31 Jan 2025 15:46:43 +0000 Subject: [PATCH 21/23] build(next): check dev version restriction - this checks the version in the `next` package before merging and fails if it is anything other than `beta` - this commit should make the build fail since I'm checking if it is `beta` (for testing purposes) --- .github/workflows/build.yml | 1 + package.json | 1 + scripts/pr_next_dev_version.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 scripts/pr_next_dev_version.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0afa7173e..68e78d2fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,3 +60,4 @@ jobs: run: npm run lint - run: npm run prettier:check - run: npm run check:pr-version + - run: npm run check:pr-next-version diff --git a/package.json b/package.json index 6a989bcba..1b98b1035 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "format:prettier": "prettier --write \"src/**/*.{js,ts}\"", "prettier:check": "prettier --check \"src/**/*.{js,ts}\"", "check:pr-version": "node scripts/pr_dev_version", + "check:pr-next-version": "node scripts/pr_next_dev_version", "release:local": "node scripts/release_local", "release:dev:patch": "node scripts/release_dev patch", "release:dev:minor": "node scripts/release_dev minor", diff --git a/scripts/pr_next_dev_version.js b/scripts/pr_next_dev_version.js new file mode 100644 index 000000000..8e8bd6cc9 --- /dev/null +++ b/scripts/pr_next_dev_version.js @@ -0,0 +1,30 @@ +const fs = require('fs'); +const path = require('path'); + +function init() { + const packageJson = fs.readFileSync(path.resolve(__dirname, '../next/package.json'), 'utf8'); + const { version } = JSON.parse(packageJson); + + if (!version.includes('-dev')) { + console.log( + `🟠 This PR cannot be merged because the next/package.json version ${version} contains "-dev".` + + '\n The version in next/package.json should be a beta version (e.g., 1.0.0-beta.0).' + ); + process.exit(1); + } + + // Making this fail on purpose to test the CI + if (version.includes('-beta.')) { + console.log( + `🟠 This PR cannot be merged because the next/package.json version ${version} is not a beta version.` + + '\n The version in next/package.json should be in format X.X.X-beta.Y (e.g., 1.0.0-beta.0).' + ); + process.exit(1); + } + + console.log( + `The package version in next/package.json is ${version} and seems valid. Continuing...` + ); +} + +init(); From d11dc6793b74ab57d2c112d212a6ce3e7ec011a4 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 31 Jan 2025 15:48:16 +0000 Subject: [PATCH 22/23] build(next): correcting version check --- scripts/pr_next_dev_version.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/pr_next_dev_version.js b/scripts/pr_next_dev_version.js index 8e8bd6cc9..239ead02a 100644 --- a/scripts/pr_next_dev_version.js +++ b/scripts/pr_next_dev_version.js @@ -5,7 +5,7 @@ function init() { const packageJson = fs.readFileSync(path.resolve(__dirname, '../next/package.json'), 'utf8'); const { version } = JSON.parse(packageJson); - if (!version.includes('-dev')) { + if (version.includes('-dev')) { console.log( `🟠 This PR cannot be merged because the next/package.json version ${version} contains "-dev".` + '\n The version in next/package.json should be a beta version (e.g., 1.0.0-beta.0).' @@ -13,8 +13,7 @@ function init() { process.exit(1); } - // Making this fail on purpose to test the CI - if (version.includes('-beta.')) { + if (!version.includes('-beta.')) { console.log( `🟠 This PR cannot be merged because the next/package.json version ${version} is not a beta version.` + '\n The version in next/package.json should be in format X.X.X-beta.Y (e.g., 1.0.0-beta.0).' From cad063dcc01a1850515675c54da1660b7cbf1c34 Mon Sep 17 00:00:00 2001 From: David Dragovacz Date: Fri, 31 Jan 2025 16:35:17 +0000 Subject: [PATCH 23/23] chore: reset version --- next/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next/package.json b/next/package.json index 35c77c628..7c3426d57 100644 --- a/next/package.json +++ b/next/package.json @@ -1,6 +1,6 @@ { "name": "@remoteoss/json-schema-form", - "version": "1.0.0-beta.2", + "version": "1.0.0-beta.0", "packageManager": "pnpm@9.15.2", "description": "WIP V2 – Headless UI form powered by JSON Schemas", "author": "Remote.com (https://remote.com/)",