Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: More upgrades to monorepo tooling #9753

Merged
merged 6 commits into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions internal-tooling/.gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions internal-tooling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 3 additions & 0 deletions internal-tooling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
24 changes: 23 additions & 1 deletion internal-tooling/src/-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ 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();
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;
Expand Down Expand Up @@ -91,6 +102,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<void>;
}
Expand Down Expand Up @@ -138,13 +154,14 @@ export async function walkPackages(
const dir = await getMonorepoRoot();
const packages = await collectAllPackages(dir);
const projects = new Map<string, ProjectPackageWithTsConfig>();
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');
Expand All @@ -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.startsWith(TestDir),
pkg,
tsconfig,
save: async ({ pkgEdited, configEdited }: { pkgEdited: boolean; configEdited: Boolean }) => {
Expand Down
29 changes: 26 additions & 3 deletions internal-tooling/src/sync-references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -195,8 +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 anyFileEdited = false;

walkPackages(async (project: ProjectPackage, projects: Map<string, ProjectPackage>) => {
await walkPackages(async (project: ProjectPackage, projects: Map<string, ProjectPackage>) => {
log(`\t📦 Syncing ${project.pkg.name}`);
let pkgEdited = false;
let tsconfigEdited = false;
Expand Down Expand Up @@ -231,6 +238,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) {
Expand Down Expand Up @@ -262,8 +280,13 @@ async function main() {
}
}

await project.save({ pkgEdited, configEdited: tsconfigEdited });
if (pkgEdited || tsconfigEdited) {
anyFileEdited = true;
await project.save({ pkgEdited, configEdited: tsconfigEdited });
}
});

if (anyFileEdited) await runPrettier();
}

main();
3 changes: 2 additions & 1 deletion packages/codemods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"utils",
"codemods",
"logos",
"LICENSE.md"
"LICENSE.md",
"unstable-preview-types"
],
"author": "",
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
},
"files": [
"README.md",
"LICENSE.md"
"LICENSE.md",
"unstable-preview-types"
],
"bin": {
"parse": "./parse",
Expand Down
16 changes: 0 additions & 16 deletions warp-drive-packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,6 @@ rich application &mdash; letting you ship better experiences more quickly withou

<br>

## 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)

<br>

## Installation

```sh
Expand Down
Loading