diff --git a/.changeset/little-humans-relate.md b/.changeset/little-humans-relate.md new file mode 100644 index 000000000..69dffbd25 --- /dev/null +++ b/.changeset/little-humans-relate.md @@ -0,0 +1,18 @@ +--- +'@baseplate-dev/project-builder-server': patch +'@baseplate-dev/project-builder-cli': patch +'@baseplate-dev/project-builder-lib': patch +'@baseplate-dev/project-builder-web': patch +'@baseplate-dev/fastify-generators': patch +'@baseplate-dev/react-generators': patch +'@baseplate-dev/core-generators': patch +'@baseplate-dev/create-project': patch +'@baseplate-dev/ui-components': patch +'@baseplate-dev/plugin-storage': patch +'@baseplate-dev/plugin-queue': patch +'@baseplate-dev/plugin-auth': patch +'@baseplate-dev/utils': patch +'@baseplate-dev/sync': patch +--- + +Ignore \*.map files from built output in package.json diff --git a/.workspace-meta/config.ts b/.workspace-meta/config.ts index 56f646066..29265319b 100644 --- a/.workspace-meta/config.ts +++ b/.workspace-meta/config.ts @@ -77,7 +77,7 @@ export default defineWorkspaceMetaConfig({ 'LICENSE', 'CHANGELOG', 'dist/**/*', - '!dist/**/*.d.ts.map', + '!dist/**/*.map', '!dist/**/*.tsbuildinfo', ]; diff --git a/packages/core-generators/package.json b/packages/core-generators/package.json index aeb51a653..feb4703a2 100644 --- a/packages/core-generators/package.json +++ b/packages/core-generators/package.json @@ -55,7 +55,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/packages/create-project/package.json b/packages/create-project/package.json index c757917e7..c03757c5c 100644 --- a/packages/create-project/package.json +++ b/packages/create-project/package.json @@ -29,7 +29,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo", "templates/**/*", "bin/**/*" diff --git a/packages/fastify-generators/package.json b/packages/fastify-generators/package.json index abdc349ea..8fbc30597 100644 --- a/packages/fastify-generators/package.json +++ b/packages/fastify-generators/package.json @@ -29,7 +29,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/packages/project-builder-cli/package.json b/packages/project-builder-cli/package.json index 4866df11c..5628267ef 100644 --- a/packages/project-builder-cli/package.json +++ b/packages/project-builder-cli/package.json @@ -35,7 +35,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo", "bin/**/*" ], diff --git a/packages/project-builder-lib/package.json b/packages/project-builder-lib/package.json index 3efeed336..3bd2f24bb 100644 --- a/packages/project-builder-lib/package.json +++ b/packages/project-builder-lib/package.json @@ -34,7 +34,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/packages/project-builder-server/package.json b/packages/project-builder-server/package.json index 9ec774a61..b309ff333 100644 --- a/packages/project-builder-server/package.json +++ b/packages/project-builder-server/package.json @@ -36,7 +36,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/packages/project-builder-web/package.json b/packages/project-builder-web/package.json index a9afa275c..628175a8c 100644 --- a/packages/project-builder-web/package.json +++ b/packages/project-builder-web/package.json @@ -24,7 +24,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/packages/react-generators/package.json b/packages/react-generators/package.json index 1155f4c06..2cc68a333 100644 --- a/packages/react-generators/package.json +++ b/packages/react-generators/package.json @@ -29,7 +29,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/packages/sync/package.json b/packages/sync/package.json index 383fe497a..cc8d01409 100644 --- a/packages/sync/package.json +++ b/packages/sync/package.json @@ -37,7 +37,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/packages/ui-components/package.json b/packages/ui-components/package.json index 0100c5d85..f9035bc38 100644 --- a/packages/ui-components/package.json +++ b/packages/ui-components/package.json @@ -32,7 +32,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/packages/utils/package.json b/packages/utils/package.json index b4de91dd0..30718c206 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -34,7 +34,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/plugins/plugin-auth/package.json b/plugins/plugin-auth/package.json index e4456ff25..2ad4330a6 100644 --- a/plugins/plugin-auth/package.json +++ b/plugins/plugin-auth/package.json @@ -24,7 +24,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/plugins/plugin-queue/package.json b/plugins/plugin-queue/package.json index af160506d..5c123bc3a 100644 --- a/plugins/plugin-queue/package.json +++ b/plugins/plugin-queue/package.json @@ -27,7 +27,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/plugins/plugin-storage/package.json b/plugins/plugin-storage/package.json index 36b680744..2f07a5d49 100644 --- a/plugins/plugin-storage/package.json +++ b/plugins/plugin-storage/package.json @@ -27,7 +27,7 @@ "LICENSE", "CHANGELOG", "dist/**/*", - "!dist/**/*.d.ts.map", + "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "scripts": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 723da4245..26c0f1847 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5263,8 +5263,8 @@ packages: resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==} engines: {node: '>= 0.4'} - foreground-child@3.3.0: - resolution: {integrity: sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==} + foreground-child@3.3.1: + resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==} engines: {node: '>=14'} form-data@4.0.4: @@ -5384,12 +5384,12 @@ packages: resolution: {integrity: sha512-ZyqlgowMbfj2NPjxaZZ/EtsXlOch28FRXgMd64vqZWk1bT9+wvSRLYD1om9M7QfQru51zJPAT17qXm4/zd+9QA==} engines: {node: '>= 0.10'} - glob@10.4.5: - resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==} + glob@10.5.0: + resolution: {integrity: sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==} hasBin: true - glob@11.0.0: - resolution: {integrity: sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==} + glob@11.1.0: + resolution: {integrity: sha512-vuNwKSaKiqm7g0THUBu2x7ckSs3XJLXE+2ssL7/MfTGPLLcrJQ/4Uq1CjPTtO5cCIiRxqvN6Twy1qOwhL0Xjcw==} engines: {node: 20 || >=22} hasBin: true @@ -5773,8 +5773,8 @@ packages: jackspeak@3.4.3: resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} - jackspeak@4.0.2: - resolution: {integrity: sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==} + jackspeak@4.1.1: + resolution: {integrity: sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==} engines: {node: 20 || >=22} jiti@2.6.1: @@ -5791,8 +5791,8 @@ packages: js-tokens@9.0.1: resolution: {integrity: sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==} - js-yaml@3.14.1: - resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} + js-yaml@3.14.2: + resolution: {integrity: sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==} hasBin: true js-yaml@4.1.1: @@ -6103,8 +6103,8 @@ packages: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} - minimatch@10.0.3: - resolution: {integrity: sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==} + minimatch@10.1.1: + resolution: {integrity: sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==} engines: {node: 20 || >=22} minimatch@3.1.2: @@ -8184,7 +8184,7 @@ snapshots: '@changesets/parse@0.4.1': dependencies: '@changesets/types': 6.1.0 - js-yaml: 3.14.1 + js-yaml: 3.14.2 '@changesets/pre@2.0.2': dependencies: @@ -8460,7 +8460,7 @@ snapshots: content-disposition: 0.5.4 fastify-plugin: 5.0.1 fastq: 1.19.1 - glob: 11.0.0 + glob: 11.1.0 '@fastify/websocket@11.0.1': dependencies: @@ -8671,7 +8671,7 @@ snapshots: '@joshwooding/vite-plugin-react-docgen-typescript@0.6.1(typescript@5.8.3)(vite@7.1.12(@types/node@22.17.2)(jiti@2.6.1)(lightningcss@1.30.1)(tsx@4.20.6)(yaml@2.8.1))': dependencies: - glob: 10.4.5 + glob: 10.5.0 magic-string: 0.30.19 react-docgen-typescript: 2.2.2(typescript@5.8.3) vite: 7.1.12(@types/node@22.17.2)(jiti@2.6.1)(lightningcss@1.30.1)(tsx@4.20.6)(yaml@2.8.1) @@ -10171,7 +10171,7 @@ snapshots: '@ts-morph/common@0.27.0': dependencies: fast-glob: 3.3.3 - minimatch: 10.0.3 + minimatch: 10.1.1 path-browserify: 1.0.1 '@tsconfig/node22@22.0.2': {} @@ -10580,7 +10580,7 @@ snapshots: archiver-utils@5.0.2: dependencies: - glob: 10.4.5 + glob: 10.5.0 graceful-fs: 4.2.11 is-stream: 2.0.1 lazystream: 1.0.1 @@ -11080,10 +11080,10 @@ snapshots: debug: 4.4.1 duplexer: 0.1.2 fs-extra: 11.3.0 - glob: 11.0.0 + glob: 11.1.0 glob2base: 0.0.12 ignore: 6.0.2 - minimatch: 10.0.3 + minimatch: 10.1.1 p-map: 7.0.3 resolve: 1.22.11 safe-buffer: 5.2.1 @@ -11523,7 +11523,7 @@ snapshots: eslint: 9.32.0(jiti@2.6.1) eslint-import-context: 0.1.9(unrs-resolver@1.11.1) is-glob: 4.0.3 - minimatch: 10.0.3 + minimatch: 10.1.1 semver: 7.7.2 stable-hash-x: 0.2.0 unrs-resolver: 1.11.1 @@ -11929,7 +11929,7 @@ snapshots: dependencies: is-callable: 1.2.7 - foreground-child@3.3.0: + foreground-child@3.3.1: dependencies: cross-spawn: 7.0.6 signal-exit: 4.1.0 @@ -12059,20 +12059,20 @@ snapshots: dependencies: find-index: 0.1.1 - glob@10.4.5: + glob@10.5.0: dependencies: - foreground-child: 3.3.0 + foreground-child: 3.3.1 jackspeak: 3.4.3 minimatch: 9.0.5 minipass: 7.1.2 package-json-from-dist: 1.0.1 path-scurry: 1.11.1 - glob@11.0.0: + glob@11.1.0: dependencies: - foreground-child: 3.3.0 - jackspeak: 4.0.2 - minimatch: 10.0.3 + foreground-child: 3.3.1 + jackspeak: 4.1.1 + minimatch: 10.1.1 minipass: 7.1.2 package-json-from-dist: 1.0.1 path-scurry: 2.0.0 @@ -12417,7 +12417,7 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 - jackspeak@4.0.2: + jackspeak@4.1.1: dependencies: '@isaacs/cliui': 8.0.2 @@ -12429,7 +12429,7 @@ snapshots: js-tokens@9.0.1: {} - js-yaml@3.14.1: + js-yaml@3.14.2: dependencies: argparse: 1.0.10 esprima: 4.0.1 @@ -12729,7 +12729,7 @@ snapshots: min-indent@1.0.1: {} - minimatch@10.0.3: + minimatch@10.1.1: dependencies: '@isaacs/brace-expansion': 5.0.0 @@ -13408,7 +13408,7 @@ snapshots: read-yaml-file@1.1.0: dependencies: graceful-fs: 4.2.11 - js-yaml: 3.14.1 + js-yaml: 3.14.2 pify: 4.0.1 strip-bom: 3.0.0 diff --git a/scripts/check-changesets.ts b/scripts/check-changesets.ts index 190a3addc..4ecb97192 100644 --- a/scripts/check-changesets.ts +++ b/scripts/check-changesets.ts @@ -8,11 +8,11 @@ * - Uses the last git tag with prefix "@baseplate-dev/project-builder-cli@" as the comparison point */ +import { exec } from 'node:child_process'; import { promises as fs, globSync } from 'node:fs'; -import * as path from 'node:path'; import * as os from 'node:os'; +import path from 'node:path'; import { promisify } from 'node:util'; -import { exec } from 'node:child_process'; const execAsync = promisify(exec); @@ -21,7 +21,7 @@ interface PackageJson { name: string; private?: boolean; files?: string[]; - [key: string]: any; + [key: string]: unknown; } interface PackageInfo { @@ -39,11 +39,11 @@ interface ChangesetRelease { } interface ChangesetStatus { - changesets: Array<{ - releases: Array<{ name: string; type: string }>; + changesets: { + releases: { name: string; type: string }[]; summary: string; id: string; - }>; + }[]; releases: ChangesetRelease[]; } @@ -51,10 +51,10 @@ interface TurboOutput { packageManager: string; packages: { count: number; - items: Array<{ + items: { name: string; path: string; - }>; + }[]; }; } @@ -69,13 +69,13 @@ async function extractAndValidatePackage( try { // Pack the package to the temp directory - console.log(`Packing ${pkg.name} to temporary directory...`); + console.info(`Packing ${pkg.name} to temporary directory...`); const { stdout: packOutput } = await execAsync( `npm pack ${pkg.name}@latest --pack-destination="${packageTempDir}"`, ); // Extract the tarball name from the output - const tarballName = packOutput.trim().split('\n').pop() as string; + const tarballName = packOutput.trim().split('\n').pop() ?? ''; const tarballPath = path.join(packageTempDir, tarballName); // Extract the tarball @@ -84,7 +84,7 @@ async function extractAndValidatePackage( // Now check the package contents const extractedPackageDir = path.join(packageTempDir, 'package'); const filesInPackage = new Set(); - for await (const file of await globSync('**/*', { + for (const file of globSync('**/*', { withFileTypes: true, cwd: extractedPackageDir, })) { @@ -109,23 +109,26 @@ async function extractAndValidatePackage( const expectedFiles = new Set(); // Add files from the "files" array - for (const pattern of declaredFiles) { - const matchedFiles = await fs.glob(pattern, { - cwd: pkg.dir, - withFileTypes: true, - }); - - for await (const file of matchedFiles) { - if (!file.isDirectory() && file.name !== 'package.json') { - expectedFiles.add( - path.relative(pkg.dir, path.join(file.parentPath, file.name)), - ); - } + const globPatterns = declaredFiles.filter((f) => !f.startsWith('!')); + const excludePatterns = declaredFiles + .filter((f) => f.startsWith('!')) + .map((f) => f.slice(1)); + const matchedFiles = fs.glob(globPatterns, { + cwd: pkg.dir, + withFileTypes: true, + exclude: excludePatterns, + }); + + for await (const file of matchedFiles) { + if (!file.isDirectory() && file.name !== 'package.json') { + expectedFiles.add( + path.relative(pkg.dir, path.join(file.parentPath, file.name)), + ); } } // Convert expectedFiles set to array for comparison - const expectedFilesArray = Array.from(expectedFiles); + const expectedFilesArray = [...expectedFiles]; // Check if all expected files exist in the package const missingFiles = expectedFilesArray.filter( @@ -153,7 +156,7 @@ async function extractAndValidatePackage( const mismatchedFiles = fileMatches.filter(({ isMatch }) => !isMatch); // Check if there are files in the package that aren't in the expected files - const extraFiles = Array.from(filesInPackage).filter( + const extraFiles = [...filesInPackage].filter( (file) => !expectedFiles.has(file), ); @@ -200,7 +203,7 @@ async function getLastPackageTag(): Promise { const tags = stdout.trim().split('\n').filter(Boolean); if (tags.length === 0) { - console.log( + console.info( 'No previous tags found for @baseplate-dev/project-builder-cli', ); return null; @@ -208,7 +211,7 @@ async function getLastPackageTag(): Promise { // Return the most recent tag (first in the list due to sorting) const lastTag = tags[0]; - console.log(`Last tag for project-builder-cli: ${lastTag}`); + console.info(`Last tag for project-builder-cli: ${lastTag}`); return lastTag; } catch (error) { console.warn('Error getting last tag:', error); @@ -230,7 +233,7 @@ async function getPackagesToPublish(): Promise { // If no changeset files, return empty array (no packages to publish) if (changesetFiles.length === 0) { - console.log('No changeset files found, assuming no packages to publish'); + console.info('No changeset files found, assuming no packages to publish'); return []; } @@ -243,13 +246,13 @@ async function getPackagesToPublish(): Promise { ? `pnpm changeset status --since ${lastTag} --output=${CHANGESET_OUTPUT_FILE}` : `pnpm changeset status --output=${CHANGESET_OUTPUT_FILE}`; - console.log(`Running: ${changesetCommand}`); + console.info(`Running: ${changesetCommand}`); await execAsync(changesetCommand); // Parse the output file - const changesetData: ChangesetStatus = JSON.parse( + const changesetData = JSON.parse( await fs.readFile(CHANGESET_OUTPUT_FILE, 'utf8'), - ); + ) as ChangesetStatus; // Extract packages that will be published (from the releases array) const packagesToPublish = changesetData.releases.map( @@ -269,37 +272,37 @@ async function getPackagesToPublish(): Promise { // Main function to run the validation async function checkChangesets(): Promise { - let tempDir: string = await fs.mkdtemp( + const tempDir: string = await fs.mkdtemp( path.join(os.tmpdir(), 'npm-packages-'), ); let exitCode = 0; try { // Step 1: Create a temporary directory - console.log(`Created temporary directory: ${tempDir}`); + console.info(`Created temporary directory: ${tempDir}`); // Step 2: Get the list of affected packages from turbo - console.log('Getting affected packages from turbo...'); + console.info('Getting affected packages from turbo...'); const { stdout: turboOutput } = await execAsync( `pnpm turbo ls --affected --output json`, ); - const turboData: TurboOutput = JSON.parse(turboOutput); + const turboData = JSON.parse(turboOutput) as TurboOutput; const affectedPackageNames = turboData.packages.items.map( (item) => item.name, ); - console.log( + console.info( `Found ${affectedPackageNames.length} affected packages from turbo:`, ); - console.log(affectedPackageNames.join(', ')); + console.info(affectedPackageNames.join(', ')); // Step 3: Get packages to be published from changeset - console.log('Getting packages from changeset...'); + console.info('Getting packages from changeset...'); // Extract packages that will be published (from the releases array) const packagesToPublish = await getPackagesToPublish(); - console.log( + console.info( `Packages to be published according to changeset:`, packagesToPublish.join(', ') || 'None', ); @@ -310,16 +313,16 @@ async function checkChangesets(): Promise { ); if (packagesToCheck.length === 0) { - console.log( + console.info( 'No affected packages need checking. All affected packages are already in changeset or there are no affected packages.', ); return; } - console.log( + console.info( `Checking ${packagesToCheck.length} affected packages not in changeset:`, ); - console.log(packagesToCheck.join(', ')); + console.info(packagesToCheck.join(', ')); // Step 5: Find all package.json files for the packages to check const packagesInfo: PackageInfo[] = []; @@ -339,17 +342,17 @@ async function checkChangesets(): Promise { try { const packageJsonContent = await fs.readFile(packageJsonPath, 'utf8'); - const packageJson: PackageJson = JSON.parse(packageJsonContent); + const packageJson = JSON.parse(packageJsonContent) as PackageJson; // Skip private packages if (packageJson.private === true) { - console.log(`Skipping private package: ${packageJson.name}`); + console.info(`Skipping private package: ${packageJson.name}`); continue; } // Check if "files" array exists if (!Array.isArray(packageJson.files)) { - throw new Error( + throw new TypeError( `Package ${packageJson.name} is missing the "files" array in package.json`, ); } @@ -360,15 +363,14 @@ async function checkChangesets(): Promise { packageJson, }); } catch (error) { - console.error( - `Error processing package.json for ${packageName}:`, - error, + throw new Error( + `Error processing package.json for ${packageName}: ${String(error)}`, + { cause: error }, ); - exitCode = 1; } } - console.log( + console.info( `Found ${packagesInfo.length} non-private packages to validate`, ); @@ -403,7 +405,7 @@ async function checkChangesets(): Promise { throw new Error('Some packages have issues and need changesets'); } - console.log('Package changeset validation completed successfully!'); + console.info('Package changeset validation completed successfully!'); } catch (error) { console.error('Package changeset validation failed:', error); exitCode = 1; @@ -412,7 +414,7 @@ async function checkChangesets(): Promise { if (tempDir) { try { await fs.rm(tempDir, { recursive: true, force: true }); - console.log(`Cleaned up temporary directory: ${tempDir}`); + console.info(`Cleaned up temporary directory: ${tempDir}`); } catch (cleanupError) { console.error('Error during cleanup:', cleanupError); } @@ -422,4 +424,7 @@ async function checkChangesets(): Promise { } // Run the validation -checkChangesets(); +await checkChangesets().catch((error: unknown) => { + console.error('Package changeset validation failed:', error); + process.exit(1); +});