From 382378faed2ce0183e4977060a0944fced78337c Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 10 Jan 2025 18:52:41 -0500 Subject: [PATCH] looks like the type declarations are always wrong? --- scripts/test-package-manager.mjs | 38 ++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/scripts/test-package-manager.mjs b/scripts/test-package-manager.mjs index 7e460cbd37..9513e711b4 100644 --- a/scripts/test-package-manager.mjs +++ b/scripts/test-package-manager.mjs @@ -1,7 +1,8 @@ import assert from 'node:assert'; import { readFileSync, writeFileSync } from 'node:fs'; +import { rimraf } from 'rimraf'; import { tmpdir } from 'node:os'; -import { mkdtemp, copyFile, cp, rm } from 'node:fs/promises'; +import { mkdtemp, copyFile, cp, rm, readFile } from 'node:fs/promises'; import { join, basename } from 'node:path'; import { $ } from 'execa'; import { globby } from 'globby'; @@ -100,6 +101,16 @@ async function buildAll(tag) { await generatePackageTarballs(config, packages, strategy); } +async function debugTypes() { + let entries = await globby('**/unstable-preview-types/index.d.ts', { ignore: ['**/node_modules', '**/dist'] }); + + for (let entry of entries) { + banner(entry); + let contents = await readFile(entry); + console.debug(contents.toString()); + } +} + async function deleteTars() { let tars = await globby('{tmp,packages}/**/*.tgz', { ignore: ['**/node_modules', '**/dist'] }); @@ -110,6 +121,25 @@ async function deleteTars() { ); } +/** + * Mostly only matters for local testing + */ +async function deletePriorBuildArtifacts() { + // let outputs = await globby('**/{dist/(unstable-)?(preview-)?types', { ignore: ['**/node_modules'] }); + let outputs = await globby('**/{dist,unstable-preview-types}/', { + ignore: ['**/node_modules'], + onlyDirectories: true, + }); + + outputs = outputs.map((x) => x.trim()); + + await Promise.all( + outputs.map((output) => { + return rimraf(output); + }) + ); +} + async function copyTars(toDir) { let tars = await globby('{tmp/tarballs/,packages}/**/*.tgz', { ignore: ['**/node_modules', '**/dist'] }); @@ -285,14 +315,18 @@ async function main() { const reuseTars = options.includes('--reuse-tars'); if (!reuseTars) { + await deletePriorBuildArtifacts(); await deleteTars(); + await $`pnpm prepare`; await buildAll(tag); } + await debugTypes(); + let tmpDir = await createTempFolder(); let projectDir = await copyProject(tmpDir); - console.debug(`To debug this test run, the project is located at ${projectDir}`); + banner(`To debug this test run, the project is located at ${projectDir}`); await copyTars(projectDir); await fixManifest(projectDir);