From e2c52389e621fd3f660826eefb11bbe778cc1e61 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Sat, 8 Mar 2025 12:41:02 -0800 Subject: [PATCH 1/6] chore: update files array for types when needed --- internal-tooling/.gitignore | 34 ------------------------- internal-tooling/package.json | 3 +++ internal-tooling/src/-utils.ts | 22 ++++++++++++++++ internal-tooling/src/sync-references.ts | 21 ++++++++++++++- warp-drive-packages/core/README.md | 16 ------------ 5 files changed, 45 insertions(+), 51 deletions(-) delete mode 100644 internal-tooling/.gitignore diff --git a/internal-tooling/.gitignore b/internal-tooling/.gitignore deleted file mode 100644 index a14702c409..0000000000 --- a/internal-tooling/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# dependencies (bun install) -node_modules - -# output -out -dist -*.tgz - -# code coverage -coverage -*.lcov - -# logs -logs -_.log -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# caches -.eslintcache -.cache -*.tsbuildinfo - -# IntelliJ based IDEs -.idea - -# Finder (MacOS) folder config -.DS_Store diff --git a/internal-tooling/package.json b/internal-tooling/package.json index fb8cb48ca6..e4e0d85ab7 100644 --- a/internal-tooling/package.json +++ b/internal-tooling/package.json @@ -23,6 +23,9 @@ "@pnpm/find-workspace-packages": "6.0.9", "@pnpm/logger": "1000.0.0" }, + "engines": { + "node": ">= 18.20.7" + }, "volta": { "extends": "../package.json" } diff --git a/internal-tooling/src/-utils.ts b/internal-tooling/src/-utils.ts index f6929e3165..21f6937974 100644 --- a/internal-tooling/src/-utils.ts +++ b/internal-tooling/src/-utils.ts @@ -34,6 +34,18 @@ export async function getPackageJson({ packageDir, packagesDir }: { packageDir: return { file: packageJsonFile, pkg, path: packageJsonPath, nicePath: path.join(packageDir, 'package.json') }; } +export async function runPrettier() { + const root = await getMonorepoRoot(); + console.log(`Running prettier on ${root}`); + const childProcess = Bun.spawn(['bun', 'lint:prettier:fix'], { + env: process.env, + cwd: root, + stdout: 'inherit', + stderr: 'inherit', + }); + await childProcess.exited; +} + type PkgJsonFile = { name: string; version: string; @@ -91,6 +103,11 @@ interface BaseProjectPackage { tsconfigFile: BunFile; pkgPath: string; tsconfigPath: string; + isRoot: boolean; + isPrivate: boolean; + isTooling: boolean; + isConfig: boolean; + isTest: boolean; pkg: PkgJsonFile; save: (editStatus: { pkgEdited: boolean; configEdited: Boolean }) => Promise; } @@ -162,6 +179,11 @@ export async function walkPackages( pkgPath, hasTsConfig, tsconfigPath, + isRoot: name === 'root', + isPrivate: project.manifest.private ?? false, + isTooling: name === '@warp-drive/internal-tooling', + isConfig: name === '@warp-drive/config', + isTest: project.dir === 'tests', pkg, tsconfig, save: async ({ pkgEdited, configEdited }: { pkgEdited: boolean; configEdited: Boolean }) => { diff --git a/internal-tooling/src/sync-references.ts b/internal-tooling/src/sync-references.ts index 2426ed5a41..86e7502ab8 100755 --- a/internal-tooling/src/sync-references.ts +++ b/internal-tooling/src/sync-references.ts @@ -3,7 +3,13 @@ import debug from 'debug'; import path from 'path'; import chalk from 'chalk'; -import { walkPackages, type ProjectPackage, type ProjectPackageWithTsConfig, type TsConfigFile } from './-utils'; +import { + runPrettier, + walkPackages, + type ProjectPackage, + type ProjectPackageWithTsConfig, + type TsConfigFile, +} from './-utils'; const log = debug('wd:sync-references'); @@ -231,6 +237,17 @@ async function main() { log(`\t\t🔧 Added paths hash to tsconfig.json`); } + if (!project.isTest) { + if (!project.pkg.files?.includes(tsconfig.compilerOptions!.declarationDir!)) { + project.pkg.files ??= []; + project.pkg.files.push(tsconfig.compilerOptions!.declarationDir!); + pkgEdited = true; + log( + `\t\t🔧 Added types output directory "${tsconfig.compilerOptions.declarationDir}" to files in package.json` + ); + } + } + for (const name of referenced) { const relProject = projects.get(name); if (!relProject) { @@ -264,6 +281,8 @@ async function main() { await project.save({ pkgEdited, configEdited: tsconfigEdited }); }); + + await runPrettier(); } main(); diff --git a/warp-drive-packages/core/README.md b/warp-drive-packages/core/README.md index 64de63adcb..f1dffc7736 100644 --- a/warp-drive-packages/core/README.md +++ b/warp-drive-packages/core/README.md @@ -50,22 +50,6 @@ rich application — letting you ship better experiences more quickly withou
-## Quick Links - -- [Installation](#installation) -- [API Docs](https://api.emberjs.com/ember-data/release) -- [Guides](./guides/index.md) -- [Build Config](./packages/build-config/README.md) -- [Ember Compatibility](#compatibility) -- [The Big List of Versions](#the-big-list-of-versions) -- [Contributing](./CONTRIBUTING.md) -- [Community & Help](https://emberjs.com/community) -- [RFCs](https://github.com/emberjs/rfcs/labels/T-ember-data) -- [Team](https://emberjs.com/team) -- [Blog](https://emberjs.com/blog) - -
- ## Installation ```sh From 31d213fe353d4833a792150651505e4d80bcc91e Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Sat, 8 Mar 2025 12:45:24 -0800 Subject: [PATCH 2/6] chore: improve detection of test apps --- internal-tooling/src/-utils.ts | 4 ++-- internal-tooling/src/sync-references.ts | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal-tooling/src/-utils.ts b/internal-tooling/src/-utils.ts index 21f6937974..f129a3aa38 100644 --- a/internal-tooling/src/-utils.ts +++ b/internal-tooling/src/-utils.ts @@ -36,7 +36,6 @@ export async function getPackageJson({ packageDir, packagesDir }: { packageDir: export async function runPrettier() { const root = await getMonorepoRoot(); - console.log(`Running prettier on ${root}`); const childProcess = Bun.spawn(['bun', 'lint:prettier:fix'], { env: process.env, cwd: root, @@ -155,13 +154,14 @@ export async function walkPackages( const dir = await getMonorepoRoot(); const packages = await collectAllPackages(dir); const projects = new Map(); + const TestDir = path.join(dir, 'tests'); for (const [name, project] of packages) { if (config.excludeRoot && name === 'root') continue; if (config.excludePrivate && project.manifest.private) continue; if (config.excludeTooling && name === '@warp-drive/internal-tooling') continue; if (config.excludeConfig && name === '@warp-drive/config') continue; - if (config.excludeTests && project.dir === 'tests') continue; + if (config.excludeTests && project.dir.startsWith(TestDir)) continue; const pkgPath = path.join(project.dir, 'package.json'); const tsconfigPath = path.join(project.dir, 'tsconfig.json'); diff --git a/internal-tooling/src/sync-references.ts b/internal-tooling/src/sync-references.ts index 86e7502ab8..dcf21622e4 100755 --- a/internal-tooling/src/sync-references.ts +++ b/internal-tooling/src/sync-references.ts @@ -201,6 +201,7 @@ async function main() { log( `\n\t${chalk.gray('=').repeat(60)}\n\t\t${chalk.magentaBright('@warp-drive/')}${chalk.greenBright('internal-tooling')} Sync TypeScript References\n\t${chalk.gray('=').repeat(60)}\n\n\t\t${chalk.gray(`Syncing Project References`)}\n\n` ); + let anyEdited = false; walkPackages(async (project: ProjectPackage, projects: Map) => { log(`\t📦 Syncing ${project.pkg.name}`); @@ -279,10 +280,13 @@ async function main() { } } + if (pkgEdited || tsconfigEdited) { + anyEdited = true; + } await project.save({ pkgEdited, configEdited: tsconfigEdited }); }); - await runPrettier(); + if (anyEdited) await runPrettier(); } main(); From 59ea055b12fadaf3502f3ddc0e67a820022a226c Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Sat, 8 Mar 2025 12:49:20 -0800 Subject: [PATCH 3/6] better guard --- internal-tooling/README.md | 3 +++ internal-tooling/src/sync-references.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal-tooling/README.md b/internal-tooling/README.md index 22be2684fc..3b44d78ea8 100644 --- a/internal-tooling/README.md +++ b/internal-tooling/README.md @@ -23,3 +23,6 @@ in tsconfig.json for any other workspace package specified by package.json as a dependency, peer-dependency, or dev-dependency. Will also ensure the proper settings for composite etc. are in use. + +For packages that should emit types (any non-test app package) it will +ensure that the declarationDir is added to the files array in package.json. diff --git a/internal-tooling/src/sync-references.ts b/internal-tooling/src/sync-references.ts index dcf21622e4..738381edaf 100755 --- a/internal-tooling/src/sync-references.ts +++ b/internal-tooling/src/sync-references.ts @@ -282,8 +282,8 @@ async function main() { if (pkgEdited || tsconfigEdited) { anyEdited = true; + await project.save({ pkgEdited, configEdited: tsconfigEdited }); } - await project.save({ pkgEdited, configEdited: tsconfigEdited }); }); if (anyEdited) await runPrettier(); From 53022bdbd002f4fb3d2923c6c1e0e0ecca0995c1 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Sat, 8 Mar 2025 12:51:23 -0800 Subject: [PATCH 4/6] better guard --- internal-tooling/src/sync-references.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal-tooling/src/sync-references.ts b/internal-tooling/src/sync-references.ts index 738381edaf..53a01ac205 100755 --- a/internal-tooling/src/sync-references.ts +++ b/internal-tooling/src/sync-references.ts @@ -201,9 +201,9 @@ async function main() { log( `\n\t${chalk.gray('=').repeat(60)}\n\t\t${chalk.magentaBright('@warp-drive/')}${chalk.greenBright('internal-tooling')} Sync TypeScript References\n\t${chalk.gray('=').repeat(60)}\n\n\t\t${chalk.gray(`Syncing Project References`)}\n\n` ); - let anyEdited = false; + let anyFileEdited = false; - walkPackages(async (project: ProjectPackage, projects: Map) => { + await walkPackages(async (project: ProjectPackage, projects: Map) => { log(`\t📦 Syncing ${project.pkg.name}`); let pkgEdited = false; let tsconfigEdited = false; @@ -281,12 +281,12 @@ async function main() { } if (pkgEdited || tsconfigEdited) { - anyEdited = true; + anyFileEdited = true; await project.save({ pkgEdited, configEdited: tsconfigEdited }); } }); - if (anyEdited) await runPrettier(); + if (anyFileEdited) await runPrettier(); } main(); From 698c3b14907b12dc1ec2b3a198c92541ddc708b9 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Sat, 8 Mar 2025 12:53:16 -0800 Subject: [PATCH 5/6] better guard --- internal-tooling/src/-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal-tooling/src/-utils.ts b/internal-tooling/src/-utils.ts index f129a3aa38..26d851966c 100644 --- a/internal-tooling/src/-utils.ts +++ b/internal-tooling/src/-utils.ts @@ -183,7 +183,7 @@ export async function walkPackages( isPrivate: project.manifest.private ?? false, isTooling: name === '@warp-drive/internal-tooling', isConfig: name === '@warp-drive/config', - isTest: project.dir === 'tests', + isTest: project.dir.startsWith(TestDir), pkg, tsconfig, save: async ({ pkgEdited, configEdited }: { pkgEdited: boolean; configEdited: Boolean }) => { From dcf727268eb49ad88b0e0539fa0dfcc81680194b Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Sat, 8 Mar 2025 12:53:42 -0800 Subject: [PATCH 6/6] fix --- packages/codemods/package.json | 3 ++- packages/schema/package.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/codemods/package.json b/packages/codemods/package.json index 20f6ca31d8..d0b8e731ad 100644 --- a/packages/codemods/package.json +++ b/packages/codemods/package.json @@ -28,7 +28,8 @@ "utils", "codemods", "logos", - "LICENSE.md" + "LICENSE.md", + "unstable-preview-types" ], "author": "", "license": "MIT", diff --git a/packages/schema/package.json b/packages/schema/package.json index 2fbe54b86c..f84cf7c71a 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -27,7 +27,8 @@ }, "files": [ "README.md", - "LICENSE.md" + "LICENSE.md", + "unstable-preview-types" ], "bin": { "parse": "./parse",