diff --git a/package.json b/package.json index adb41cfbc..53245c465 100644 --- a/package.json +++ b/package.json @@ -143,7 +143,6 @@ "@types/minimist": "^1.2.5", "@types/node": "^25.9.4", "@types/picomatch": "^4.0.3", - "@types/prompts": "^2.4.9", "@types/semver": "^7.7.1", "chokidar": "^5.0.0", "conventional-changelog": "^7.2.1", @@ -178,7 +177,6 @@ "postcss": "^8.5.6", "postcss-selector-parser": "^7.1.4", "prettier": "^3.9.0", - "prompts": "^2.4.2", "punycode": "^2.3.1", "rollup": "^4.62.2", "rollup-plugin-dts": "6.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3ccff2765..1cb266da6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -161,9 +161,6 @@ importers: '@types/picomatch': specifier: ^4.0.3 version: 4.0.3 - '@types/prompts': - specifier: ^2.4.9 - version: 2.4.9 '@types/semver': specifier: ^7.7.1 version: 7.7.1 @@ -266,9 +263,6 @@ importers: prettier: specifier: ^3.9.0 version: 3.9.0 - prompts: - specifier: ^2.4.2 - version: 2.4.2 punycode: specifier: ^2.3.1 version: 2.3.1 @@ -1098,9 +1092,6 @@ packages: '@types/picomatch@4.0.3': resolution: {integrity: sha512-iG0T6+nYJ9FAPmx9SsUlnwcq1ZVRuCXcVEvWnntoPlrOpwtSTKNDC9uVAxTsC3PUvJ+99n4RpAcNgBbHX3JSnQ==} - '@types/prompts@2.4.9': - resolution: {integrity: sha512-qTxFi6Buiu8+50/+3DGIWLHM6QuWsEKugJnnP6iv2Mc4ncxE4A/OJkjuVOA+5X0X1S/nq5VJRa8Lu+nwcvbrKA==} - '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -1921,10 +1912,6 @@ packages: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} - kleur@3.0.3: - resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} - engines: {node: '>=6'} - lightningcss-android-arm64@1.32.0: resolution: {integrity: sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==} engines: {node: '>= 12.0.0'} @@ -2403,10 +2390,6 @@ packages: resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} engines: {node: '>= 0.6.0'} - prompts@2.4.2: - resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} - engines: {node: '>= 6'} - property-information@7.2.0: resolution: {integrity: sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==} @@ -3596,11 +3579,6 @@ snapshots: '@types/picomatch@4.0.3': {} - '@types/prompts@2.4.9': - dependencies: - '@types/node': 25.9.4 - kleur: 3.0.3 - '@types/resolve@1.20.2': {} '@types/sax@1.2.7': @@ -4415,8 +4393,6 @@ snapshots: kind-of@6.0.3: {} - kleur@3.0.3: {} - lightningcss-android-arm64@1.32.0: optional: true @@ -4959,11 +4935,6 @@ snapshots: process@0.11.10: {} - prompts@2.4.2: - dependencies: - kleur: 3.0.3 - sisteransi: 1.0.5 - property-information@7.2.0: {} proxy-from-env@2.1.0: {} diff --git a/scripts/release.ts b/scripts/release.ts index 2d4d15055..8e5745545 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -4,8 +4,7 @@ import fs from 'node:fs' import { createRequire } from 'node:module' import { resolve } from 'node:path' import { fileURLToPath } from 'node:url' -import c from 'picocolors' -import prompts from 'prompts' +import * as prompts from '@clack/prompts' import semver from 'semver' const { version: currentVersion } = createRequire(import.meta.url)( @@ -37,7 +36,7 @@ const run = (bin: string, args: string[], opts: SpawnOptions = {}) => } }) }) -const step = (msg: string) => console.log(c.cyan(msg)) +const cancel = () => prompts.cancel('Operation cancelled') async function main() { let targetVersion: string @@ -46,22 +45,19 @@ async function main() { .map((i) => `${i} (${inc(i)})`) .concat(['custom']) - const { release } = await prompts({ - type: 'select', - name: 'release', + const release = await prompts.select({ message: 'Select release type', - choices: versions.map((title, value) => ({ title, value })) + options: versions.map((label, value) => ({ label, value })) }) + if (prompts.isCancel(release)) return cancel() if (release === 3) { - targetVersion = ( - await prompts({ - type: 'text', - name: 'version', - message: 'Input custom version', - initial: currentVersion - }) - ).version + const customVersion = await prompts.text({ + message: 'Input custom version', + initialValue: currentVersion + }) + if (prompts.isCancel(customVersion)) return cancel() + targetVersion = customVersion } else { targetVersion = versions[release].match(/\((.*)\)/)![1] } @@ -70,39 +66,35 @@ async function main() { throw new Error(`Invalid target version: ${targetVersion}`) } - const { tag } = await prompts({ - type: 'select', - name: 'tag', + const tag = await prompts.select({ message: 'Select tag type', - choices: tags.map((title, value) => ({ title, value })) + options: tags.map((label, value) => ({ label, value })) }) + if (prompts.isCancel(tag)) return cancel() - const { yes: tagOk } = await prompts({ - type: 'confirm', - name: 'yes', + const tagOk = await prompts.confirm({ message: `Releasing v${targetVersion} on ${tags[tag]}. Confirm?` }) + if (prompts.isCancel(tagOk)) return cancel() if (!tagOk) { return } // Update the package version. - step('\nUpdating the package version...') + prompts.log.step('Updating the package version...') updatePackage(targetVersion) // Build the package. - step('\nBuilding the package...') + prompts.log.step('Building the package...') await run('pnpm', ['build']) // Generate the changelog. - step('\nGenerating the changelog...') + prompts.log.step('Generating the changelog...') await run('pnpm', ['changelog']) await run('pnpm', ['prettier', '--write', 'CHANGELOG.md']) - const { yes: changelogOk } = await prompts({ - type: 'confirm', - name: 'yes', + const changelogOk = await prompts.confirm({ message: `Changelog generated. Does it look good?` }) @@ -111,13 +103,13 @@ async function main() { } // Commit changes to the Git and create a tag. - step('\nCommitting changes...') + prompts.log.step('Committing changes...') await run('git', ['add', 'CHANGELOG.md', 'package.json']) await run('git', ['commit', '-m', `release: v${targetVersion}`]) await run('git', ['tag', `v${targetVersion}`]) // Publish the package. - step('\nPublishing the package...') + prompts.log.step('Publishing the package...') await run('pnpm', [ 'publish', '--tag', @@ -127,7 +119,7 @@ async function main() { ]) // Push to GitHub. - step('\nPushing to GitHub...') + prompts.log.step('Pushing to GitHub...') await run('git', ['push', 'origin', `refs/tags/v${targetVersion}`]) await run('git', ['push']) }