Skip to content

Commit f90f496

Browse files
authored
Migrate to a pnpm monorepo (#1281)
- closes #945 - closes #1044 - depends on #1322 - depends on #1327 ## Checklist - [x] Split into smaller PRs for ease of review - [x] Try DX tests again #1289 - [x] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [x] File issue for speeding up cheatsheet / making it not optional locally #1307 - [x] Set package manager in package.json https://nodejs.org/api/packages.html#packagemanager - [x] Re-add lint rule to prevent api types from importing anything - [x] Try local install - [x] Make sure cheatsheet works - [x] Make sure local extension build depends on building cheatsheet, or allows no cheatsheet - [x] Figure out why we're getting so many extra `internal` modules - [x] Update #931 to indicate we're now patching instead of swizzling - [x] Make sure lint rules are actually running in CI - [x] Check that we've addressed everything in #945 - [x] Incorporate changes from #1166 - [x] ~~Make sure this PR doesn't break doc links; see #942 (comment) There's no way to avoid these links getting broken if we upgrade typedoc; filed #1304 to track - [x] Revert #1284 - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [x] I have not broken the cheatsheet - [x] Generate cursorless-vscode package.json automatically, and change the name we use to `@cursorless/cursorless-vscode` in the `package.json` checked into source control - [x] Be sure to update meta-updater to check for that instead of name `cursorless` (see fixme in its `index.ts`) ## Desiderata - From #1289 ### Correctly flagging errors - [x] `D1`: It is a compile error to import external packages that are not listed in `package.json` - [x] `D1.1`: `vscode` (for some reason this one behaves strangely) - [x] `D1.2`: Other packages - [x] `D2`: It is **not** a compile error to import from local packages that you depend on, using our preferred syntax (eg `@cursorless/foo`) - [x] `D3`: It is a compile error to import from local packages that you depend on, **not** using our preferred syntax (eg `../foo`) - [x] `D4`: It is a compile error to import from local packages that you do **not** depend on, either - [x] `D4.1`: using our non-preferred syntax (eg `../packages/foo`), or - [x] `D4.2`: using preferred syntax (eg `@cursorless/foo`) - [ ] `D5`: It is a compile error to import from anything other than `index.ts` in another module - [x] `D5.1`: **no** `@cursorless/foo/bar` - [x] `D5.2`: **no** `../foo/bar` - [x] `a`: Even if you depend on the module - [ ] `b`: Even if `bar` was re-exported in `foo/index.ts`. In that case it should be required to import `@cursorless/foo`. Untested, but probably works, and I ran out of steam 😅 - [x] `D6`: It is **not** a compile error to import external packages listed in `package.json` - [x] `D6.1`: `vscode` (for some reason this one behaves strangely) - [x] `D6.2`: Other packages ### Auto-import - [x] `D7`: Auto-import doesn't import from external packages not listed in `package.json` - [x] `D7.1`: `vscode` (for some reason this one behaves strangely) - [x] `D7.2`: Other packages - [x] `D8`: Auto-import imports from external packages listed in `package.json` - [x] `D8.1`: `vscode` (for some reason this one behaves strangely) - [x] `D8.2`: Other packages - [x] `D9`: Auto-import imports from local packages that you depend on, using our preferred syntax (eg `@cursorless/foo`) - [x] `D10`: Auto-import doesn't import from local packages that you don't depend on - [x] `D11`: Auto-import doesn't import from anything other than `index.ts` in another package (eg **no** `@cursorless/foo/bar`) - [x] `D11.1`: When you depend on the package - [x] `D11.2`: When you don't depend on the package ### Other DX - [x] `D12`: Find references across projects when no file from the referencing project is open - [x] `D13`: Rename across projects when no file from the referencing project is open - [x] `D14`: Jump to definition across projects - [ ] `D15`: It is easy to move a file from one package to another - [ ] `D16`: It is easy to create a new package - [ ] `D17`: Breakpoints work in Cursorless extension - [x] `D18`: Breakpoints work on Cursorless root website - [ ] `D19`: Breakpoints work on Cursorless docs website
1 parent 3f2f2dc commit f90f496

File tree

3,114 files changed

+20829
-44455
lines changed

Some content is hidden

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

3,114 files changed

+20829
-44455
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ insert_final_newline = false
2222
# with a line that has trailing white space. Many of our recorded
2323
# tests use strings with trailing white space to represent the final
2424
# document contents. For example
25-
# packages/cursorless-vscode-e2e/suite/fixtures/recorded/languages/ruby/changeCondition.yml
25+
# packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/ruby/changeCondition.yml
2626
trim_trailing_whitespace = false
2727

2828
[Makefile]

.eslintrc.json

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
"ecmaVersion": 6,
1111
"sourceType": "module"
1212
},
13-
"plugins": ["@typescript-eslint", "unused-imports"],
13+
"plugins": ["@typescript-eslint", "unused-imports", "import"],
1414
"rules": {
15-
// Note: you must disable the base rule as it can report incorrect errors
16-
"no-restricted-imports": "off",
17-
"@typescript-eslint/no-restricted-imports": "error",
15+
"import/no-relative-packages": "error",
1816
"@typescript-eslint/consistent-type-assertions": [
1917
"error",
2018
{
@@ -51,5 +49,31 @@
5149
"no-throw-literal": "warn",
5250
"semi": "off"
5351
},
54-
"ignorePatterns": ["**/vendor/**/*.ts", "**/vendor/**/*.js"]
52+
"overrides": [
53+
{
54+
"files": ["*.tsx"],
55+
"rules": {
56+
"@typescript-eslint/naming-convention": [
57+
"warn",
58+
{
59+
"selector": ["function"],
60+
"format": ["PascalCase", "camelCase"]
61+
}
62+
]
63+
}
64+
}
65+
],
66+
"settings": {
67+
"import/parsers": {
68+
"@typescript-eslint/parser": [".ts", ".tsx"]
69+
},
70+
"import/resolver": {
71+
"typescript": {
72+
"alwaysTryTypes": true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
73+
74+
"project": ["tsconfig.json", "packages/*/tsconfig.json"]
75+
}
76+
}
77+
},
78+
"ignorePatterns": ["**/vendor/**/*.ts", "**/vendor/**/*.js", "**/out/**"]
5579
}

.github/workflows/deploy.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ jobs:
1515
- uses: actions/checkout@v3
1616
with:
1717
fetch-depth: 0
18+
- uses: pnpm/action-setup@v2
19+
with:
20+
version: 7
1821
- uses: actions/setup-node@v3
1922
with:
2023
node-version: 16
21-
cache: yarn
22-
- run: yarn install --frozen-lockfile
23-
- run: yarn run compile
24-
- run: yarn run prepare-for-extension-publish
25-
- name: Initialize cursorless-nx subdir
26-
run: npm ci
27-
working-directory: cursorless-nx
28-
- name: Build cheatsheet html
29-
run: npx nx build cheatsheet-local
30-
working-directory: cursorless-nx
24+
cache: pnpm
25+
- run: pnpm install
26+
- run: pnpm compile
27+
- run: pnpm build
28+
env:
29+
CURSORLESS_DEPLOY: true
3130
- name: Publish to Open VSX Registry
32-
uses: HaaLeo/publish-vscode-extension@v1
3331
id: publishToOpenVSX
32+
uses: HaaLeo/publish-vscode-extension@v1
3433
with:
3534
pat: ${{ secrets.OPEN_VSX_TOKEN }}
35+
packagePath: packages/cursorless-vscode/dist
3636
- name: Publish to Visual Studio Marketplace
3737
uses: HaaLeo/publish-vscode-extension@v1
3838
with:

.github/workflows/test-docs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v3
12+
- uses: pnpm/action-setup@v2
13+
with:
14+
version: 7
1215
- uses: actions/setup-node@v3
1316
with:
1417
node-version: 16
15-
cache: yarn
16-
- run: bash -x scripts/docs-build.sh
18+
cache: pnpm
19+
- run: bash -x scripts/build-and-assemble-website.sh

.github/workflows/test.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,40 @@ jobs:
2525
VSCODE_LOGS_DIR: ${{ github.workspace }}/artifacts/logs
2626
steps:
2727
- uses: actions/checkout@v3
28+
- uses: pnpm/action-setup@v2
29+
with:
30+
version: 7
2831
- uses: actions/setup-node@v3
2932
with:
3033
node-version: 16
31-
cache: yarn
34+
cache: pnpm
3235
- run: mkdir -p "${{ env.VSCODE_CRASH_DIR }}" "${{ env.VSCODE_LOGS_DIR }}"
3336
shell: bash
34-
- run: yarn install --frozen-lockfile
35-
- run: xvfb-run -a yarn test
37+
- run: pnpm --color install
38+
- run: pnpm --color compile
39+
- run: pnpm --color --filter '!cursorless-org' --filter '!cursorless-org-*' build
40+
- run: xvfb-run -a pnpm --color test
3641
if: runner.os == 'Linux'
37-
- run: yarn test
42+
- run: pnpm --color test
3843
if: runner.os != 'Linux'
44+
- name: Create vscode dist that can be installed locally
45+
run: pnpm -F @cursorless/cursorless-vscode populate-dist --local-install
46+
if: runner.os == 'Linux' && matrix.vscode_version == 'stable'
47+
- name: Test create vsix
48+
id: createVsix
49+
uses: HaaLeo/publish-vscode-extension@v1
50+
with:
51+
pat: none
52+
packagePath: packages/cursorless-vscode/dist
53+
dryRun: true
54+
- run: mv ${{ steps.createVsix.outputs.vsixPath }} cursorless-development.vsix
55+
if: runner.os == 'Linux' && matrix.vscode_version == 'stable'
56+
- name: Upload vsix
57+
uses: actions/upload-artifact@v3
58+
if: runner.os == 'Linux' && matrix.vscode_version == 'stable'
59+
with:
60+
name: vsix
61+
path: cursorless-development.vsix
3962
- name: Archive logs
4063
uses: actions/upload-artifact@v3
4164
with:

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,37 @@ node_modules
88

99
# TypeDoc output
1010
docs/contributing/api/
11+
12+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
13+
14+
# dependencies
15+
.pnp
16+
.pnp.js
17+
18+
# testing
19+
coverage
20+
21+
# next.js
22+
.next/
23+
24+
# production
25+
build
26+
27+
# misc
28+
*.pem
29+
30+
# debug
31+
npm-debug.log*
32+
yarn-debug.log*
33+
yarn-error.log*
34+
.pnpm-debug.log*
35+
36+
# local env files
37+
.env*.local
38+
39+
# vercel
40+
.vercel
41+
42+
# typescript
43+
*.tsbuildinfo
44+
next-env.d.ts

.meta-updater/main.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { updater } from "../packages/meta-updater/dist/index.cjs";
2+
3+
export default updater;

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
save-workspace-protocol=rolling
2+
save-prefix=""

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@ repos:
2424
- id: detect-private-key
2525
- id: end-of-file-fixer
2626
exclude_types: [svg]
27+
exclude: patches/.*\.patch
2728
- id: fix-byte-order-marker
2829
- id: mixed-line-ending
2930
- id: trailing-whitespace
3031
# Trailing whitespace breaks yaml files if you use a multiline string
3132
# with a line that has trailing white space. Many of our recorded
3233
# tests use strings with trailing white space to represent the final
3334
# document contents. For example
34-
# packages/cursorless-vscode-e2e/suite/fixtures/recorded/languages/ruby/changeCondition.yml
35-
exclude: ^packages/cursorless-vscode-e2e/suite/fixtures/recorded/.*/[^/]*\.yml$
35+
# packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/ruby/changeCondition.yml
36+
exclude: ^packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/.*/[^/]*\.yml$
3637
- repo: https://github.com/pre-commit/mirrors-prettier
3738
rev: "v2.7.1"
3839
hooks:

.prettierignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
**/vendor
22

33
# We use our own format for our recorded yaml tests to keep them compact
4-
/packages/cursorless-vscode-e2e/suite/fixtures/recorded/**/*.yml
4+
/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/**/*.yml
55

6-
# This was swizzled from a Docusaurus core class
7-
docs-site/src/theme/SearchBar/index.js
6+
pnpm-lock.yaml

0 commit comments

Comments
 (0)