Skip to content

Commit 0adddcb

Browse files
runspiredgitKrystan
authored andcommitted
chore: Improve contributing experience (#9759)
* chore: improve developing experience on local * more * temporarily deactivate some scenarios * deactivate more lints * deactivate more prod tests * another
1 parent 3f3ad29 commit 0adddcb

File tree

43 files changed

+800
-449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+800
-449
lines changed

.npmrc

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ link-workspace-packages=false # deep
130130
## script to handle this.
131131
##
132132
sync-injected-deps-after-scripts[]=build:pkg
133-
sync-injected-deps-after-scripts[]=build:infra
134133
sync-injected-deps-after-scripts[]=build:glint
135134
sync-injected-deps-after-scripts[]=sync
136135

contributing/setting-up-the-project.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,30 @@ pnpm dlx @warp-drive/holodeck ensure-cert
7373

7474
## Building the project
7575

76-
The project's packages will build whenever `pnpm install` is run.
76+
The project's packages will build whenever `pnpm install` is run. They can be rebuilt by running `pnpm prepare`.
77+
78+
Both `install` and `prepare` will ensure turbo cache is ignored so that pnpm will automatically update "hardlinks" for
79+
the build output files in the node_modules directory of the various other packages and test apps that depend upon the package.
80+
81+
However, this is pretty slow for development, so a fast albeit slightly manual approach is available for development
82+
by running the below commands in order:
83+
84+
From the project root:
85+
86+
- install: `pnpm install` - installs all dependencies and sets up initial hardlinks
87+
- start: `pnpm start` - starts the build for every public package in watch mode
88+
89+
Then, from an individual test app:
90+
91+
- `pnpm start` - starts the build for test assets in watch mode
92+
- `pnpm test:start` - launches a test server (and by opens a browser window for debugging them)
93+
94+
Because the project uses hardlinks, even though the packages are rebuilding, the test apps won't be able
95+
to see the results of the change in many scenarios unless the hardlinks are regenerated.
96+
97+
At anypoint, run `pnpm sync` from the root to regenerate the hardlinks. The test app server may
98+
pick up this change automatically, but if it does not saving any file (even without changing it)
99+
in the test app will trigger a rebuild.
77100

78101
## Run some commands
79102

internal-tooling/README.md

+32-3
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,38 @@ for use with the monorepo.
55

66
These scripts can be run as bin-scripts from root.
77

8-
## bun sync-logos
8+
### sync-all
9+
10+
```sh
11+
bun sync-all
12+
```
13+
14+
Will run all of the other available scripts.
15+
16+
### sync-logos
17+
18+
```sh
19+
bun sync-logos
20+
```
921

1022
Will sync the logo directory from root to each public package and
1123
ensure that the logos directory is included in published files.
1224

13-
## bun sync-license
25+
### sync-license
26+
27+
```sh
28+
bun sync-license
29+
```
1430

1531
Will sync the LICENSE.md file from root to each public package and
1632
ensure that the license is both set to `MIT` in the package.json and
1733
included in the published files for each package.
1834

19-
## bun sync-references
35+
### sync-references
36+
37+
```sh
38+
bun sync-references
39+
```
2040

2141
Will ensure that `paths` and `references` are both correctly specified
2242
in tsconfig.json for any other workspace package specified by package.json
@@ -26,3 +46,12 @@ Will also ensure the proper settings for composite etc. are in use.
2646

2747
For packages that should emit types (any non-test app package) it will
2848
ensure that the declarationDir is added to the files array in package.json.
49+
50+
### sync-scripts
51+
52+
```sh
53+
bun sync-scripts
54+
```
55+
56+
Will ensure that scripts enumerated in package.json which should be the same
57+
throughout the monorepo match expected configuration.

internal-tooling/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"bin": {
1111
"sync-logos": "src/sync-logos.ts",
1212
"sync-license": "src/sync-license.ts",
13-
"sync-references": "src/sync-references.ts"
13+
"sync-references": "src/sync-references.ts",
14+
"sync-scripts": "src/sync-scripts.ts",
15+
"sync-all": "src/sync-all.ts"
1416
},
1517
"dependencies": {
1618
"@types/bun": "^1.2.4",

internal-tooling/src/sync-all.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /usr/bin/env bun
2+
import { main } from './tasks/sync-all';
3+
4+
main();

internal-tooling/src/sync-licence.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /usr/bin/env bun
2+
import { main } from './tasks/sync-license';
3+
4+
main();

internal-tooling/src/sync-logos.ts

+1-84
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,4 @@
11
#! /usr/bin/env bun
2-
3-
import path from 'path';
4-
import fs from 'fs';
5-
import debug from 'debug';
6-
import chalk from 'chalk';
7-
import type { BunFile } from 'bun';
8-
import { getMonorepoRoot, getPackageJson } from './-utils';
9-
10-
const log = debug('wd:sync-logos');
11-
12-
async function copyFiles({
13-
packageDir,
14-
packageLogosDir,
15-
logosDir,
16-
isCopied,
17-
}: {
18-
packageDir: string;
19-
packageLogosDir: string;
20-
logosDir: string;
21-
isCopied: boolean;
22-
}) {
23-
// if we are in copy mode, remove any existing symlink and copy the files
24-
if (isCopied) {
25-
fs.rmSync(packageLogosDir, { recursive: true, force: true });
26-
log(`\t\t\t🗑️ Deleted existing copy of ${packageDir}/logos`);
27-
}
28-
fs.mkdirSync(packageLogosDir, { recursive: true });
29-
log(`\t\t\t📁 Created ${packageDir}/logos`);
30-
31-
for (const logo of fs.readdirSync(logosDir, { recursive: true, encoding: 'utf-8' })) {
32-
const logoPath = path.join(logosDir, logo);
33-
const destPath = path.join(packageLogosDir, logo);
34-
fs.copyFileSync(logoPath, destPath);
35-
log(`\t\t\t📁 Copied ${logo} to ${packageDir}/logos`);
36-
}
37-
}
38-
39-
async function updatePackageJson({ pkg, file, nicePath }: { pkg: any; file: BunFile; path: string; nicePath: string }) {
40-
// ensure "files" field in package.json includes "logos"
41-
if (!pkg.files) {
42-
pkg.files = ['logos'];
43-
await file.write(JSON.stringify(pkg, null, 2));
44-
log(`\t\t📝 Added "logos" to "files" in ${nicePath}`);
45-
} else if (!pkg.files.includes('logos')) {
46-
pkg.files.push('logos');
47-
await file.write(JSON.stringify(pkg, null, 2));
48-
log(`\t\t📝 Added "logos" to "files" in ${nicePath}`);
49-
}
50-
}
51-
52-
async function main() {
53-
log(
54-
`\n\t${chalk.gray('=').repeat(60)}\n\t\t${chalk.magentaBright('@warp-drive/')}${chalk.greenBright('internal-tooling')} Sync Logos\n\t${chalk.gray('=').repeat(60)}\n\n\t\t${chalk.gray(`Syncing logo files from monorepo root to each public package`)}\n\n`
55-
);
56-
const monorepoRoot = await getMonorepoRoot();
57-
58-
// sync the logos from the monorepo root to each
59-
// package directory that has a logos directory
60-
61-
const logosDir = path.join(monorepoRoot, 'logos');
62-
const packagesDir = path.join(monorepoRoot, 'packages');
63-
64-
for (const packageDir of fs.readdirSync(packagesDir)) {
65-
const packageLogosDir = path.join(packagesDir, packageDir, 'logos');
66-
const isCopied = fs.existsSync(packageLogosDir);
67-
const details = await getPackageJson({ packageDir, packagesDir });
68-
69-
if (details.pkg.private) {
70-
log(`\t\t🔒 Skipping private package ${details.nicePath}`);
71-
continue;
72-
}
73-
74-
log(`\t\t🔁 Syncing logos to ${packageDir}`);
75-
76-
await copyFiles({
77-
packageDir,
78-
packageLogosDir,
79-
logosDir,
80-
isCopied,
81-
});
82-
83-
await updatePackageJson(details);
84-
}
85-
}
2+
import { main } from './tasks/sync-logos';
863

874
main();

0 commit comments

Comments
 (0)