Skip to content

Commit ff18f23

Browse files
authored
More monorepo updates (#1207)
1 parent c38ef40 commit ff18f23

24 files changed

Lines changed: 741 additions & 272 deletions

.ado/publish.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ extends:
4242

4343
stages:
4444
- stage: main
45-
displayName:
4645
jobs:
4746
- job: build
48-
displayName: Build and test
47+
displayName: Build, test, pack
4948
cancelTimeoutInMinutes: 45 # to allow more time to collect CodeQL debug info.
5049

5150
pool:
@@ -76,8 +75,6 @@ extends:
7675
version: '${{ variables.nodeVersion }}.x'
7776
checkLatest: false
7877

79-
- script: npm i -g npm@${{ variables.npmVersion }}
80-
8178
# For multiline scripts, we want the whole task to fail if any line of the script fails.
8279
# ADO doesn't have bash configured this way by default. To fix we override the SHELLOPTS built-in variable.
8380
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
@@ -95,11 +92,13 @@ extends:
9592
displayName: Show environment
9693
9794
- script: yarn --frozen-lockfile
95+
displayName: Install dependencies
96+
97+
- script: yarn build --verbose
98+
displayName: Build
9899

99-
- script: yarn build
100-
- script: yarn test:unit
101-
- script: yarn test:func
102-
- script: yarn test:e2e
100+
- script: yarn test --verbose
101+
displayName: Test
103102

104103
# TODO: figure out if this should bump or not (currently does bump)
105104
- script: |

.ado/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ resources:
1515
- main
1616

1717
repositories:
18-
- repository: CustomPipelineTemplates
18+
- repository: OfficePipelineTemplates
1919
type: git
2020
name: 1ESPipelineTemplates/OfficePipelineTemplates
2121
ref: refs/tags/release
2222

2323
extends:
24-
template: v1/Office.Official.PipelineTemplate.yml@CustomPipelineTemplates
24+
template: v1/Office.Official.PipelineTemplate.yml@OfficePipelineTemplates
2525
parameters:
2626
pool:
2727
name: Azure-Pipelines-1ESPT-ExDShared

.github/workflows/pr.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,16 @@ jobs:
6464

6565
- run: yarn --frozen-lockfile
6666

67-
- run: yarn build
67+
- run: yarn build --verbose
6868

6969
- run: yarn checkchange --verbose
7070

7171
- run: yarn format:check
7272
if: matrix.os == 'ubuntu-latest' && matrix.node == 14 && matrix.npm == 8
7373

74-
- run: yarn lint
74+
- run: yarn lint:ci
7575

76-
- run: yarn test:unit
77-
78-
- run: yarn test:func
79-
80-
- run: yarn test:e2e
76+
- run: yarn test --verbose
8177

8278
# The docs have a separate installation using Node 22 due to needing newer dependencies
8379
docs:

.github/workflows/release.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,9 @@ jobs:
4444

4545
- run: yarn --frozen-lockfile
4646

47-
- run: yarn build
47+
- run: yarn build --verbose
4848

49-
- run: yarn test:unit
50-
51-
- run: yarn test:func
52-
53-
- name: yarn test:e2e (npm ${{ env.npmVersion }})
54-
run: yarn test:e2e
49+
- run: yarn test --verbose
5550

5651
- name: Publish package
5752
run: |

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.log
2+
*.patch
23
*.snap
34
*.styl
45
*.svg

CLAUDE.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,49 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Overview
66

7-
Beachball is a CLI tool for automating semantic version bumping, changelog generation, and npm publishing in monorepos and single-package repos. It is a single-package TypeScript project (not a monorepo itself).
7+
Beachball is a CLI tool for automating semantic version bumping, changelog generation, and npm publishing in monorepos and single-package repos.
8+
9+
## Monorepo structure
10+
11+
- `packages/beachball`: `beachball` package
12+
- `scripts`: repo-internal scripts (`@microsoft/beachball-scripts`)
813

914
## Commands
1015

11-
TODO: Beachball has been updated to a monorepo and this needs to be updated
16+
### Top-level
17+
18+
These commands work at the top level of the monorepo.
19+
20+
DO NOT run `jest` or `tsc` directly from the top level!
21+
22+
| Task | Command |
23+
| ------------------ | ----------------------- |
24+
| Build | `yarn build` |
25+
| Test | `yarn test` |
26+
| Lint (code + deps) | `yarn lint` |
27+
| Lint code only | `yarn lint:code` |
28+
| Format | `yarn format` |
29+
| Update snapshots | `yarn update-snapshots` |
30+
31+
### Per-package commands
32+
33+
These commands work in the `beachball` package and potentially other future packages.
1234

1335
| Task | Command |
1436
| ----------------------------- | ------------------------------- |
1537
| Build | `yarn build` |
16-
| Watch mode | `yarn start` |
1738
| All tests in correct order | `yarn test:all` |
1839
| Unit tests only | `yarn test:unit` |
1940
| Functional tests only | `yarn test:func` |
2041
| E2E tests only | `yarn test:e2e` |
2142
| Single test file (wraps jest) | `yarn test <test path or name>` |
22-
| Lint (code + deps) | `yarn lint` |
23-
| Lint code only | `yarn lint:code` |
24-
| Format | `yarn format` |
43+
| Lint | `yarn lint` |
2544
| Update snapshots | `yarn update-snapshots` |
2645

2746
## Architecture
2847

48+
All these paths refer to the `beachball` package under `packages/beachball`.
49+
2950
**Entry point:** `src/cli.ts` dispatches to commands: `check`, `change`, `bump`, `publish`, `canary`, `sync`, `init`, `config`.
3051

3152
**Key modules:**
@@ -79,7 +100,7 @@ TODO: Beachball has been updated to a monorepo and this needs to be updated
79100

80101
### Test structure
81102

82-
Three Jest projects:
103+
`packages/beachball` has three Jest projects:
83104

84105
- **Unit** (`src/__tests__/`): Unit tests for individual functions (no filesystem)
85106
- **Functional** (`src/__functional__/`): Single-function tests with realistic setups, or unit-like tests which must run against the actual filesystem

beachball.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// @ts-check
2-
/** @type {Partial<import('./src/types/BeachballOptions').RepoOptions>}*/
2+
/** @type {Partial<import('./packages/beachball/src/types/BeachballOptions').RepoOptions>}*/
33
const config = {
44
branch: 'main',
55
commit: false,
66
disallowedChangeTypes: ['major'],
7+
groupChanges: true,
78
ignorePatterns: ['.*ignore', '.eslintrc.js', 'jest.*.js', 'src/__*/**'],
89
};
910

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"type": "patch",
5+
"comment": "Update workspace-tools to 0.41.4",
6+
"packageName": "beachball",
7+
"email": "elcraig@microsoft.com",
8+
"dependentChangeType": "patch"
9+
}
10+
]
11+
}

lage.config.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// @ts-check
2+
3+
/** @typedef {import('lage').ConfigOptions} ConfigOptions */
4+
/** @typedef {import('lage').CacheOptions} CacheOptions */
5+
6+
/**
7+
* Lage config (the types are slightly incorrect about what's required/optional)
8+
* @type {Partial<Omit<ConfigOptions, 'cacheOptions'>> & { cacheOptions?: Partial<CacheOptions> }}
9+
*/
10+
const config = {
11+
npmClient: 'yarn',
12+
pipeline: {
13+
build: {
14+
dependsOn: ['^build'],
15+
outputs: ['lib/**/*'],
16+
},
17+
lint: ['build'],
18+
depcheck: [],
19+
test: ['build'],
20+
'update-snapshots': ['build'],
21+
// For the beachball package, run the tests in order during the main test run
22+
'beachball#test': {
23+
type: 'noop',
24+
dependsOn: ['test:unit', 'test:func', 'test:e2e'],
25+
},
26+
// These are not typically run directly, but the dependencies enforce ordering for beachball#test
27+
'test:unit': ['build'],
28+
'test:func': ['build', 'test:unit'],
29+
'test:e2e': ['build', 'test:unit', 'test:func'],
30+
},
31+
32+
cacheOptions: {
33+
// These are relative to the git root, and affects the hash of the cache
34+
// Any of these file changes will invalidate cache
35+
environmentGlob: [
36+
// Folder globs MUST end with **/* to include all files!
37+
'!.yarn/**/*',
38+
'!node_modules/**/*',
39+
'!**/node_modules/**/*',
40+
'.github/workflows/*',
41+
'*.js',
42+
'*.json',
43+
'*.yml',
44+
'yarn.lock',
45+
],
46+
47+
// Subset of files in package directories that will be saved into the cache.
48+
// (set per target instead)
49+
outputGlob: [],
50+
// outputGlob: ['lib/**/*', 'temp/*.api.md'],
51+
},
52+
};
53+
54+
module.exports = config;

package.json

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
"node": ">=14.0.0"
1212
},
1313
"workspaces": [
14-
"packages/*"
14+
"packages/*",
15+
"scripts"
1516
],
1617
"scripts": {
1718
"beachball": "node ./packages/beachball/lib/cli.js",
18-
"build": "yarn workspace beachball build",
19+
"build": "yarn lage build",
1920
"bump": "yarn beachball bump",
2021
"change": "yarn beachball change",
2122
"checkchange": "yarn beachball check",
@@ -24,19 +25,20 @@
2425
"format": "prettier --write .",
2526
"format:check": "prettier --check .",
2627
"prepare": "husky install",
27-
"lint": "yarn lint:deps && yarn lint:marketplace && yarn lint:code",
28-
"lint:code": "yarn workspace beachball lint",
29-
"lint:deps": "yarn workspace beachball run depcheck .",
28+
"lage": "cross-env NODE_OPTIONS=\"--experimental-abortcontroller\" lage",
29+
"lint": "yarn lint:deps && yarn lint:versions && yarn lint:marketplace && yarn lint:code",
30+
"lint:ci": "yarn lint:deps --verbose && yarn lint:versions && yarn lint:marketplace && yarn lint:code --verbose",
31+
"lint:code": "yarn lage lint",
32+
"lint:deps": "yarn lage depcheck",
33+
"lint:versions": "yarn syncpack:check",
3034
"lint:marketplace": "node scripts/lint-marketplace.js",
35+
"postinstall": "patch-package",
3136
"release": "yarn beachball publish -y",
3237
"release:docs": "echo \"Run this from the docs folder instead\" && exit 1",
33-
"test": "yarn workspace beachball test",
34-
"test:all": "yarn test:unit && yarn test:func && yarn test:e2e",
35-
"test:e2e": "yarn workspace beachball test:e2e",
36-
"test:func": "yarn workspace beachball test:func",
37-
"test:unit": "yarn workspace beachball test:unit",
38-
"test:watch": "yarn workspace beachball test:watch",
39-
"update-snapshots": "yarn workspace beachball update-snapshots"
38+
"syncpack:check": "syncpack list-mismatches",
39+
"syncpack:update": "syncpack fix-mismatches",
40+
"test": "yarn lage test",
41+
"update-snapshots": "yarn lage update-snapshots"
4042
},
4143
"lint-staged": {
4244
"*": [
@@ -50,14 +52,18 @@
5052
"@typescript-eslint/eslint-plugin": "^5.0.0",
5153
"@typescript-eslint/parser": "^5.0.0",
5254
"@typescript-eslint/utils": "^5.0.0",
55+
"cross-env": "^7.0.0",
5356
"depcheck": "^1.4.7",
5457
"eslint": "^8.0.0",
5558
"eslint-config-prettier": "^10.1.8",
5659
"eslint-plugin-etc": "^2.0.3",
5760
"husky": "^8.0.0",
5861
"jest": "^29.0.0",
62+
"lage": "2.4.0",
5963
"lint-staged": "^12.0.0",
64+
"patch-package": "^8.0.1",
6065
"prettier": "~2.8.4",
66+
"syncpack": "^9.0.0",
6167
"ts-jest": "29.2.6",
6268
"typescript": "~5.2.0"
6369
},
@@ -68,9 +74,11 @@
6874
"**/body-parser/qs": "^6.14.2",
6975
"**/express/qs": "^6.14.2",
7076
"**/@cypress/request/qs": "^6.14.2",
77+
"**/syncpack/minimatch": "^6.2.3",
78+
"**/syncpack/semver": "^7.7.4",
7179
"**/verdaccio/handlebars": "^4.7.9",
72-
"**/verdaccio/minimatch": "^7.4.9",
7380
"**/verdaccio/js-yaml": "^4.1.0",
81+
"**/verdaccio/minimatch": "^7.4.9",
7482
"**/verdaccio/validator": "^13.15.22",
7583
"**/@verdaccio/config/js-yaml": "^4.1.0",
7684
"**/@verdaccio/config/minimatch": "^7.4.9",
@@ -79,14 +87,16 @@
7987
},
8088
"rationale": {
8189
"devDependencies": {
90+
"lage@2.4.0": "Pin to newest version that supports node 14",
8291
"ts-jest@29.2.6": "29.3.0 introduces type-fest v4 which requires node 16+"
8392
},
8493
"resolutions": {
8594
"**/lodash": "Unpin due to security issue",
8695
"**/*/qs": "Unpin due to security issue",
96+
"**/semver": "Unpin due to security issues",
8797
"**/verdaccio/*": "Unpin due to security issues",
8898
"**/@verdaccio/*/*": "Unpin due to security issues",
89-
"**/minimatch": "Unpin minimatch v7 due to security issues"
99+
"**/minimatch": "Unpin minimatch due to security issues"
90100
}
91101
}
92102
}

0 commit comments

Comments
 (0)