diff --git a/package.json b/package.json index d957d9c82..7b68ea935 100644 --- a/package.json +++ b/package.json @@ -57,12 +57,14 @@ "@types/lodash": "^4.17.16", "@types/validator": "^13.12.2", "babel-jest": "^29.7.0", + "child-process-promise": "^2.2.1", "eslint": "^9.18.0", "generate-changelog": "^1.8.0", "jest": "^29.7.0", "json-schema-typed": "^8.0.1", "lodash": "^4.17.21", "randexp": "^0.5.3", + "semver": "^7.7.2", "tsup": "^8.3.5", "typescript": "^5.7.3" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4ac1bed6f..dfd6b76b5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -42,6 +42,9 @@ importers: babel-jest: specifier: ^29.7.0 version: 29.7.0(@babel/core@7.26.0) + child-process-promise: + specifier: ^2.2.1 + version: 2.2.1 eslint: specifier: ^9.18.0 version: 9.18.0 @@ -60,6 +63,9 @@ importers: randexp: specifier: ^0.5.3 version: 0.5.3 + semver: + specifier: ^7.7.2 + version: 7.7.2 tsup: specifier: ^8.3.5 version: 8.3.5(postcss@8.5.1)(typescript@5.7.3)(yaml@2.7.0) @@ -1513,6 +1519,9 @@ packages: character-entities@2.0.2: resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==} + child-process-promise@2.2.1: + resolution: {integrity: sha512-Fi4aNdqBsr0mv+jgWxcZ/7rAIC2mgihrptyVI4foh/rrjY/3BNjfP9+oaiFx/fzim+1ZyCNBae0DlyfQhSugog==} + chokidar@4.0.3: resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} engines: {node: '>= 14.16.0'} @@ -1585,6 +1594,9 @@ packages: create-require@1.1.1: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} + cross-spawn@4.0.2: + resolution: {integrity: sha512-yAXz/pA1tD8Gtg2S98Ekf/sewp3Lcp3YoFKJ4Hkp5h5yLWnKVTDU0kwjKJ8NDCYcfTLfyGkzTikst+jWypT1iA==} + cross-spawn@7.0.6: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} @@ -2404,6 +2416,9 @@ packages: lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} + lru-cache@4.1.5: + resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==} + lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} @@ -2597,6 +2612,10 @@ packages: node-releases@2.0.19: resolution: {integrity: sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==} + node-version@1.2.0: + resolution: {integrity: sha512-ma6oU4Sk0qOoKEAymVoTvk8EdXEobdS7m/mAGhDJ8Rouugho48crHBORAmy5BoOcv8wraPM6xumapQp5hl4iIQ==} + engines: {node: '>=6.0.0'} + normalize-package-data@2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} @@ -2750,10 +2769,16 @@ packages: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + promise-polyfill@6.1.0: + resolution: {integrity: sha512-g0LWaH0gFsxovsU7R5LrrhHhWAWiHRnh1GPrhXnPgYsDkIqjRYUYSZEsej/wtleDrz5xVSIDbeKfidztp2XHFQ==} + prompts@2.4.2: resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} engines: {node: '>= 6'} + pseudomap@1.0.2: + resolution: {integrity: sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==} + punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -2879,8 +2904,8 @@ packages: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true - semver@7.6.3: - resolution: {integrity: sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==} + semver@7.7.2: + resolution: {integrity: sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==} engines: {node: '>=10'} hasBin: true @@ -3195,6 +3220,10 @@ packages: whatwg-url@7.1.0: resolution: {integrity: sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==} + which@1.3.1: + resolution: {integrity: sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==} + hasBin: true + which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} @@ -3227,6 +3256,9 @@ packages: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} + yallist@2.1.2: + resolution: {integrity: sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==} + yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} @@ -4686,7 +4718,7 @@ snapshots: fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.5 - semver: 7.6.3 + semver: 7.7.2 ts-api-utils: 2.0.0(typescript@5.7.3) typescript: 5.7.3 transitivePeerDependencies: @@ -4938,6 +4970,12 @@ snapshots: character-entities@2.0.2: {} + child-process-promise@2.2.1: + dependencies: + cross-spawn: 4.0.2 + node-version: 1.2.0 + promise-polyfill: 6.1.0 + chokidar@4.0.3: dependencies: readdirp: 4.1.1 @@ -5004,6 +5042,11 @@ snapshots: create-require@1.1.1: optional: true + cross-spawn@4.0.2: + dependencies: + lru-cache: 4.1.5 + which: 1.3.1 + cross-spawn@7.0.6: dependencies: path-key: 3.1.1 @@ -5113,12 +5156,12 @@ snapshots: eslint-compat-utils@0.5.1(eslint@9.18.0): dependencies: eslint: 9.18.0 - semver: 7.6.3 + semver: 7.7.2 eslint-compat-utils@0.6.4(eslint@9.18.0): dependencies: eslint: 9.18.0 - semver: 7.6.3 + semver: 7.7.2 eslint-config-flat-gitignore@1.0.0(eslint@9.18.0): dependencies: @@ -5178,7 +5221,7 @@ snapshots: get-tsconfig: 4.9.0 is-glob: 4.0.3 minimatch: 9.0.5 - semver: 7.6.3 + semver: 7.7.2 stable-hash: 0.0.4 tslib: 2.8.1 transitivePeerDependencies: @@ -5196,7 +5239,7 @@ snapshots: espree: 10.3.0 esquery: 1.6.0 parse-imports: 2.2.1 - semver: 7.6.3 + semver: 7.7.2 spdx-expression-parse: 4.0.0 synckit: 0.9.2 transitivePeerDependencies: @@ -5226,7 +5269,7 @@ snapshots: globals: 15.14.0 ignore: 5.3.2 minimatch: 9.0.5 - semver: 7.6.3 + semver: 7.7.2 eslint-plugin-no-only-tests@3.3.0: {} @@ -5278,7 +5321,7 @@ snapshots: read-pkg-up: 7.0.1 regexp-tree: 0.1.27 regjsparser: 0.10.0 - semver: 7.6.3 + semver: 7.7.2 strip-indent: 3.0.0 eslint-plugin-unused-imports@4.1.4(@typescript-eslint/eslint-plugin@8.20.0(@typescript-eslint/parser@8.20.0(eslint@9.18.0)(typescript@5.7.3))(eslint@9.18.0)(typescript@5.7.3))(eslint@9.18.0): @@ -5295,7 +5338,7 @@ snapshots: natural-compare: 1.4.0 nth-check: 2.1.1 postcss-selector-parser: 6.1.2 - semver: 7.6.3 + semver: 7.7.2 vue-eslint-parser: 9.4.3(eslint@9.18.0) xml-name-validator: 4.0.0 transitivePeerDependencies: @@ -5624,7 +5667,7 @@ snapshots: '@babel/parser': 7.26.5 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.2 - semver: 7.6.3 + semver: 7.7.2 transitivePeerDependencies: - supports-color @@ -5910,7 +5953,7 @@ snapshots: jest-util: 29.7.0 natural-compare: 1.4.0 pretty-format: 29.7.0 - semver: 7.6.3 + semver: 7.7.2 transitivePeerDependencies: - supports-color @@ -6002,7 +6045,7 @@ snapshots: acorn: 8.14.0 eslint-visitor-keys: 3.4.3 espree: 9.6.1 - semver: 7.6.3 + semver: 7.7.2 keyv@4.5.4: dependencies: @@ -6048,6 +6091,11 @@ snapshots: lru-cache@10.4.3: {} + lru-cache@4.1.5: + dependencies: + pseudomap: 1.0.2 + yallist: 2.1.2 + lru-cache@5.1.1: dependencies: yallist: 3.1.1 @@ -6058,7 +6106,7 @@ snapshots: make-dir@4.0.0: dependencies: - semver: 7.6.3 + semver: 7.7.2 make-error@1.3.6: optional: true @@ -6410,6 +6458,8 @@ snapshots: node-releases@2.0.19: {} + node-version@1.2.0: {} + normalize-package-data@2.5.0: dependencies: hosted-git-info: 2.8.9 @@ -6547,11 +6597,15 @@ snapshots: ansi-styles: 5.2.0 react-is: 18.3.1 + promise-polyfill@6.1.0: {} + prompts@2.4.2: dependencies: kleur: 3.0.3 sisteransi: 1.0.5 + pseudomap@1.0.2: {} + punycode@2.3.1: {} pure-rand@6.1.0: {} @@ -6685,7 +6739,7 @@ snapshots: semver@6.3.1: {} - semver@7.6.3: {} + semver@7.7.2: {} shebang-command@2.0.0: dependencies: @@ -6985,7 +7039,7 @@ snapshots: espree: 9.6.1 esquery: 1.6.0 lodash: 4.17.21 - semver: 7.6.3 + semver: 7.7.2 transitivePeerDependencies: - supports-color @@ -7001,6 +7055,10 @@ snapshots: tr46: 1.0.1 webidl-conversions: 4.0.2 + which@1.3.1: + dependencies: + isexe: 2.0.0 + which@2.0.2: dependencies: isexe: 2.0.0 @@ -7030,6 +7088,8 @@ snapshots: y18n@5.0.8: {} + yallist@2.1.2: {} + yallist@3.1.1: {} yaml-eslint-parser@1.2.3: diff --git a/scripts/release.helpers.js b/scripts/release.helpers.js index 9019703a1..f9e1dc7a3 100644 --- a/scripts/release.helpers.js +++ b/scripts/release.helpers.js @@ -1,6 +1,5 @@ -const readline = require('node:readline/promises'); - -const { exec } = require('child-process-promise'); +import readline from 'node:readline/promises'; +import { exec } from 'child-process-promise'; async function checkGitStatus() { const result = await runExec('git status --porcelain', { @@ -113,7 +112,7 @@ async function runExec(cmd, { silent } = {}) { } } -module.exports = { +export { checkNpmAuth, checkGitStatus, askForText, diff --git a/scripts/release_v1.js b/scripts/release_v1.js index 0fafbc0c1..24723f6f5 100644 --- a/scripts/release_v1.js +++ b/scripts/release_v1.js @@ -1,8 +1,9 @@ -const path = require('path'); +import path from 'path'; +import semver from 'semver'; +import { fileURLToPath } from 'url'; +import { readFileSync } from 'fs'; -const semver = require('semver'); - -const { +import { askForConfirmation, askForText, checkGitStatus, @@ -11,10 +12,11 @@ const { revertCommit, revertChanges, getDateYYYYMMDDHHMMSS, -} = require('./release.helpers'); +} from './release.helpers.js'; -const packageJsonPath = path.resolve(__dirname, '../next/package.json'); -const packageJson = require(packageJsonPath); +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const packageJsonPath = path.resolve(__dirname, '../package.json'); +const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')); async function checkGitBranchAndStatus() { const releaseType = process.argv[2]; @@ -83,19 +85,19 @@ async function getNewVersion() { } async function bumpVersion({ newVersion }) { - const cmd = `cd next && npm version --no-git-tag-version ${newVersion}`; + const cmd = `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'; + console.log('Building version...'); + const cmd = 'npm run build'; await runExec(cmd); } async function updateChangelog() { console.log('Updating changelog...'); - const cmd = 'cd next && npx generate-changelog'; + const cmd = 'npx generate-changelog'; await runExec(cmd); } @@ -106,7 +108,7 @@ async function gitCommit({ newVersion, releaseType }) { let cmd; if (releaseType === 'beta') { // 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`; + cmd = `git add package.json 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`; @@ -122,12 +124,12 @@ async function publish({ newVersion, releaseType, otp }) { try { // Publish with the dev/beta version - const cmd = `cd next && npm publish --access=public --tag=${npmTag} --otp=${otp}`; + const cmd = `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}`; + const revertCmd = `npm version --no-git-tag-version ${originalVersion}`; await runExec(revertCmd); }