diff --git a/package.json b/package.json index 03d6576a27f6..e1f231c13a54 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "lint": "npx nx run-many --target=lint --parallel", "postinstall": "npx nx run repo-tools:postinstall-script", "pre-commit": "yarn lint-staged", - "release": "tsx tools/release/release.ts", + "release": "tsx tools/release/release.mts", "start": "npx nx run website:start", "test": "npx nx run-many --target=test --parallel --exclude integration-tests --exclude website --exclude website-eslint", "test-integration": "npx nx run integration-tests:test", diff --git a/tools/release/release.mts b/tools/release/release.mts new file mode 100644 index 000000000000..d8306324325c --- /dev/null +++ b/tools/release/release.mts @@ -0,0 +1,67 @@ +import { execaSync } from 'execa'; +import { + releaseChangelog, + releasePublish, + releaseVersion, +} from 'nx/src/command-line/release'; +import yargs from 'yargs'; + +const options = await yargs + .version(false) + .option('version', { + description: + 'Explicit version specifier to use, if overriding conventional commits', + type: 'string', + }) + .option('dryRun', { + alias: 'd', + description: + 'Whether to perform a dry-run of the release process, defaults to true', + type: 'boolean', + default: true, + }) + .option('verbose', { + description: 'Whether or not to enable verbose logging, defaults to false', + type: 'boolean', + default: false, + }) + .parseAsync(); + +const { workspaceVersion, projectsVersionData } = await releaseVersion({ + specifier: options.version, + // stage package.json updates to be committed later by the changelog command + stageChanges: true, + dryRun: options.dryRun, + verbose: options.verbose, +}); + +// Update the lock file after the version bumps and stage it ready to be committed by the changelog step +if (!options.dryRun) { + console.log('⏳ Updating yarn.lock...'); + execaSync(`yarn`, [`install`], { + env: { ...process.env, SKIP_POSTINSTALL: 'true' }, + }); + execaSync(`git`, [`add`, `yarn.lock`]); + console.log('✅ Updated and staged yarn.lock\n'); +} + +// This will create a release on GitHub +await releaseChangelog({ + versionData: projectsVersionData, + version: workspaceVersion, + dryRun: options.dryRun, + verbose: options.verbose, +}); + +// An explicit null value here means that no changes were detected across any package +// eslint-disable-next-line eqeqeq +if (workspaceVersion === null) { + console.log( + '⏭️ No changes detected across any package, skipping publish step altogether', + ); +} else { + await releasePublish({ + dryRun: options.dryRun, + verbose: options.verbose, + }); +} diff --git a/tools/release/release.ts b/tools/release/release.ts deleted file mode 100644 index 74341bb2dfe3..000000000000 --- a/tools/release/release.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { execaSync } from 'execa'; -import { - releaseChangelog, - releasePublish, - releaseVersion, -} from 'nx/src/command-line/release'; -import yargs from 'yargs'; - -void (async () => { - try { - const options = await yargs - .version(false) - .option('version', { - description: - 'Explicit version specifier to use, if overriding conventional commits', - type: 'string', - }) - .option('dryRun', { - alias: 'd', - description: - 'Whether to perform a dry-run of the release process, defaults to true', - type: 'boolean', - default: true, - }) - .option('verbose', { - description: - 'Whether or not to enable verbose logging, defaults to false', - type: 'boolean', - default: false, - }) - .parseAsync(); - - const { workspaceVersion, projectsVersionData } = await releaseVersion({ - specifier: options.version, - // stage package.json updates to be committed later by the changelog command - stageChanges: true, - dryRun: options.dryRun, - verbose: options.verbose, - }); - - // Update the lock file after the version bumps and stage it ready to be committed by the changelog step - if (!options.dryRun) { - console.log('⏳ Updating yarn.lock...'); - execaSync(`yarn`, [`install`], { - env: { ...process.env, SKIP_POSTINSTALL: 'true' }, - }); - execaSync(`git`, [`add`, `yarn.lock`]); - console.log('✅ Updated and staged yarn.lock\n'); - } - - // This will create a release on GitHub - await releaseChangelog({ - versionData: projectsVersionData, - version: workspaceVersion, - dryRun: options.dryRun, - verbose: options.verbose, - }); - - // An explicit null value here means that no changes were detected across any package - // eslint-disable-next-line eqeqeq - if (workspaceVersion === null) { - console.log( - '⏭️ No changes detected across any package, skipping publish step altogether', - ); - } else { - await releasePublish({ - dryRun: options.dryRun, - verbose: options.verbose, - }); - } - - // eslint-disable-next-line no-process-exit - process.exit(0); - } catch (err) { - console.error(err); - // eslint-disable-next-line no-process-exit - process.exit(1); - } -})(); diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 36b912142b9a..7e9f118ed405 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -7,6 +7,7 @@ "extends": "./tsconfig.base.json", "include": [ "tools/**/*.ts", + "tools/**/*.mts", ".eslintrc.js", "jest.config.base.js", "jest.config.js",