Skip to content

Restructure directories in preparation for move to pnpm workspace #1275

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

Merged
merged 43 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
df06942
Restructure before nx
pokey Feb 15, 2023
5f3c467
More moves
pokey Feb 15, 2023
65b70bc
Happy tsc; still unhappy lint
pokey Feb 15, 2023
45c607b
More fixes / cleanup
pokey Feb 15, 2023
8989ac3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 15, 2023
44c3297
Merge apps and libs directories into packages
pokey Feb 16, 2023
0625bdf
add more packages
pokey Feb 16, 2023
f55acc7
Revert packages move
pokey Feb 16, 2023
496e6e3
Properly move `libs` and `apps` to `packages`
pokey Feb 16, 2023
4d8340a
move app
pokey Feb 16, 2023
8f0b507
more moves
pokey Feb 16, 2023
f0dddaa
Remove Debug dependence on vscode
pokey Feb 16, 2023
e6e32ee
Move tests and scripts into packages dir
pokey Feb 16, 2023
e5d6ab3
pre-commit
pokey Feb 16, 2023
9a6f45b
`mv src/packages packages`
pokey Feb 20, 2023
d3426e3
Update paths for `src/packages` => `packages`
pokey Feb 20, 2023
d32de19
Remove the old vsc-extension-quickstart.md file
pokey Feb 20, 2023
09c6d7c
tweaks
pokey Feb 20, 2023
4189b24
move command types into common
pokey Feb 20, 2023
0ee4a10
Rename `Position` to avoid conflict
pokey Feb 20, 2023
0d84979
do export of partial target descriptor types
pokey Feb 20, 2023
5a4ce5b
Bunch more fixes
pokey Feb 20, 2023
f8c03de
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 20, 2023
bd0d6d7
Allow type imports for now
pokey Feb 21, 2023
3b4f6ef
`../vscode-common` => `@cursorless/vscode-common`
pokey Feb 21, 2023
481c801
`../common` => `@cursorless/common`
pokey Feb 21, 2023
96bdd70
more fixes and lint
pokey Feb 21, 2023
9f01437
Clean lint and compile
pokey Feb 21, 2023
fb79491
pre-commit run --all
pokey Feb 21, 2023
8ffed5e
fix bug
pokey Feb 21, 2023
2f8e991
Fix directories
pokey Feb 21, 2023
7162def
more fix
pokey Feb 21, 2023
c7fb4fe
more fix
pokey Feb 21, 2023
2b59664
fix CI imports
pokey Feb 21, 2023
ab813f8
fix typedoc
pokey Feb 21, 2023
d8b2c0d
More cleanup
pokey Feb 21, 2023
6fc087b
tweak
pokey Feb 21, 2023
9b45322
fix links
pokey Feb 21, 2023
c777060
another link fix
pokey Feb 21, 2023
c9e7dba
revert prettier on vendor
pokey Feb 21, 2023
6a47a1f
test => testHarness
pokey Feb 21, 2023
9bfa34a
testHarness => test-harness
pokey Feb 21, 2023
dbca26b
fix path
pokey Feb 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ insert_final_newline = false
# with a line that has trailing white space. Many of our recorded
# tests use strings with trailing white space to represent the final
# document contents. For example
# src/test/suite/fixtures/recorded/languages/ruby/changeCondition.yml
# packages/cursorless-vscode-e2e/suite/fixtures/recorded/languages/ruby/changeCondition.yml
trim_trailing_whitespace = false

[Makefile]
indent_style = tab

[src/vendor/**]
[**/vendor/**]
charset = unset
end_of_line = unset
indent_size = unset
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
minimum_pre_commit_version: "2.9.0"
exclude: ^src/vendor/
exclude: /vendor/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand All @@ -21,8 +21,8 @@ repos:
# with a line that has trailing white space. Many of our recorded
# tests use strings with trailing white space to represent the final
# document contents. For example
# src/test/suite/fixtures/recorded/languages/ruby/changeCondition.yml
exclude: ^src/test/suite/fixtures/recorded/.*/[^/]*\.yml$
# packages/cursorless-vscode-e2e/suite/fixtures/recorded/languages/ruby/changeCondition.yml
exclude: ^packages/cursorless-vscode-e2e/suite/fixtures/recorded/.*/[^/]*\.yml$
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
hooks:
Expand Down
5 changes: 2 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/src/vendor
**/vendor

# We use our own format for our recorded yaml tests to keep them compact
/src/test/suite/fixtures/recorded/**/*.yml

/packages/cursorless-vscode-e2e/suite/fixtures/recorded/**/*.yml

# This was swizzled from a Docusaurus core class
docs-site/src/theme/SearchBar/index.js
10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"args": [
"--profile=cursorlessDevelopment",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/runners/all"
"--extensionTestsPath=${workspaceFolder}/out/test-harness/runners/all"
],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
Expand All @@ -43,7 +43,7 @@
"type": "node",
"request": "launch",
"name": "Unit tests only",
"program": "${workspaceFolder}/out/test/scripts/runUnitTestsOnly",
"program": "${workspaceFolder}/out/test-harness/scripts/runUnitTestsOnly",
"env": {
"CURSORLESS_TEST": "true"
},
Expand All @@ -65,7 +65,7 @@
"args": [
"--profile=cursorlessDevelopment",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/runners/all"
"--extensionTestsPath=${workspaceFolder}/out/test-harness/runners/all"
],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
Expand All @@ -85,7 +85,7 @@
"args": [
"--profile=cursorlessDevelopment",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/runners/all"
"--extensionTestsPath=${workspaceFolder}/out/test-harness/runners/all"
],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
Expand All @@ -106,7 +106,7 @@
"args": [
"--profile=cursorlessDevelopment",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/runners/all"
"--extensionTestsPath=${workspaceFolder}/out/test-harness/runners/all"
],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
Expand Down
2 changes: 1 addition & 1 deletion docs-site/typedoc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
tsconfig: "../tsconfig.json",
entryPoints: ["../src/"],
entryPoints: ["../packages/"],
entryPointStrategy: "expand",

readme: "../docs/contributing/_api-index.md",
Expand Down
12 changes: 6 additions & 6 deletions docs/contributing/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Extension" or "Extension Tests".

### Running a subset of tests

The entire test suite takes a little while to run (1-2 mins), so if you'd like to run just a subset of the tests, you can edit the constant in [`runTestSubset`](../../src/test/suite/runTestSubset.ts) to a string supported by [mocha grep](https://mochajs.org/#-grep-regexp-g-regexp) and use the "Run Test Subset" launch config instead of the usual "Extension Tests".
The entire test suite takes a little while to run (1-2 mins), so if you'd like to run just a subset of the tests, you can edit the constant in [`runTestSubset`](../../packages/common/testUtil/runTestSubset.ts) to a string supported by [mocha grep](https://mochajs.org/#-grep-regexp-g-regexp) and use the "Run Test Subset" launch config instead of the usual "Extension Tests".

## Code formatting

Expand Down Expand Up @@ -95,7 +95,7 @@ code --profile=cursorlessDevelopment --install-extension bundle.vsix
You'll probably want to run the following to make sure the SVGs have everything they need:

```sh
yarn run compile && node ./out/scripts/preprocessSvgHats.js
yarn run compile && node out/cursorless-vscode-core/scripts/preprocessSvgHats.js
```

This script will add dummy width, height and fill attributes as necessary to appease the regex in `Decorations.ts`
Expand All @@ -105,15 +105,15 @@ This script will add dummy width, height and fill attributes as necessary to app
While tweaking, the easiest approach is probably to use the
`cursorless.individualHatAdjustments` setting in your settings.json to change
size / alignment so you don't need to refresh every time. Once you're done, you
can paste the settings into `scripts/hatAdjustments/add.ts` and run the following to get
can paste the settings into `packages/cursorless-vscode-core/scripts/hatAdjustments/add.ts` and run the following to get
your updates:

```sh
yarn run compile && node ./out/scripts/hatAdjustments/add.js
yarn run compile && node ./out/cursorless-vscode-core/scripts/hatAdjustments/add.js
```

If instead, you want to average your adjustments with those in main and see the differences to get to yours and main, you can paste the settings into `scripts/hatAdjustments/average.ts` and run:
If instead, you want to average your adjustments with those in main and see the differences to get to yours and main, you can paste the settings into `packages/cursorless-vscode-core/scripts/hatAdjustments/average.ts` and run:

```sh
yarn run compile && node ./out/scripts/hatAdjustments/average.js
yarn run compile && node ./out/cursorless-vscode-core/scripts/hatAdjustments/average.js
```
2 changes: 1 addition & 1 deletion docs/contributing/_api-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ contributors get up to speed.
For the time being, we recommend watching the [internals walk-through
videos](https://youtube.com/playlist?list=PLkafpFOBVedScHi0dy_80DsHwnZIOSOTy)
and having a look through the API docs, starting from the [`runCommand`
function](classes/core_commandRunner_CommandRunner.CommandRunner#runcommand).
function](classes/cursorless_engine_core_commandRunner_CommandRunner.CommandRunner#runcommand).
10 changes: 5 additions & 5 deletions docs/contributing/adding-a-new-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ First a few notes / tips:

Minimum changes that each language needs:

- new file in `/src/languages/<yourlanguage>.ts`. Take a look at [existing languages](../../src/languages) as a base. At its core you're implementing your language's version of the `nodeMatchers` const, mapping scope types found in [`Types.ts:ScopeType`](../../src/typings/Types.ts) with matching expressions that align with the parse tree output.
- new entry in [`getNodeMatcher.ts:languageMatchers`](../../src/languages/getNodeMatcher.ts), importing your new file above
- new entry in [`constants.ts`](../../src/languages/constants.ts)
- new text fragment extractor (default is likely fine) in [`getTextFragmentExtractor.ts:textFragmentExtractors`](../../src/languages/getTextFragmentExtractor.ts)
- new file in `/packages/cursorless-engine/languages/<yourlanguage>.ts`. Take a look at [existing languages](../../packages/cursorless-engine/languages) as a base. At its core you're implementing your language's version of the `nodeMatchers` const, mapping scope types found in [`Types.ts:ScopeType`](../../packages/cursorless-engine/typings/Types.ts) with matching expressions that align with the parse tree output.
- new entry in [`getNodeMatcher.ts:languageMatchers`](../../packages/cursorless-engine/languages/getNodeMatcher.ts), importing your new file above
- new entry in [`constants.ts`](../../packages/cursorless-engine/languages/constants.ts)
- new text fragment extractor (default is likely fine) in [`getTextFragmentExtractor.ts:textFragmentExtractors`](../../packages/cursorless-engine/languages/getTextFragmentExtractor.ts)

The parse trees exposed by tree-sitter are often pretty close to what we're
looking for, but we often need to look for specific patterns within the parse
Expand All @@ -39,6 +39,6 @@ domain-specific language that makes these definitions fairly compact.
Test cases can be automatically recorded, which should speed things up a lot.
See the [docs](test-case-recorder.md) for the test case recorder. It will also
likely be helpful to look at the existing recorded test cases (eg
[java](../../src/test/suite/fixtures/recorded/languages/java)) to see how
[java](../../packages/cursorless-vscode-e2e/suite/fixtures/recorded/languages/java)) to see how
they
should end up looking when they're recorded.
16 changes: 8 additions & 8 deletions docs/contributing/test-case-recorder.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ like `hello world`), positioning your cursor where you want, tell cursorless to
start recording, and then issue one or more cursorless commands. It works by
recording the initial state of the file including cursor position(s), the
command run, and the final state, all in the form of a yaml document. See
[existing test cases](../../src/test/suite/fixtures/recorded) for example outputs.
[existing test cases](../../packages/cursorless-vscode-e2e/suite/fixtures/recorded) for example outputs.

## Recording new tests

1. Start debugging (F5)
1. Create a minimal file to use for recording tests. And position your cursor
where you'd like. Check out the `initialState.documentContents` field of
[existing test cases](../../src/test/suite/fixtures/recorded) for examples.
[existing test cases](../../packages/cursorless-vscode-e2e/suite/fixtures/recorded) for examples.
1. Issue the `"cursorless record"` command. Alternately, issue one of the special recording commands listed in
- List of target directories is shown. All test cases will be put into the
given subdirectory of `src/test/suite/fixtures/recorded`
given subdirectory of `packages/cursorless-vscode-e2e/suite/fixtures/recorded`
1. Select existing directory or create new one
- Select `Create new folder`
- If the new directory name contains any `/`, it will create nested
Expand All @@ -35,7 +35,7 @@ command run, and the final state, all in the form of a yaml document. See

## Test case recorder options

The test case recorder has several additional configuration options. The default configuration works for most tests, but you may find the following useful. For a full list of supported configuration options, see [the api docs](../api/interfaces/testutil_testcaserecorder.internal.recordtestcasecommandarg/).
The test case recorder has several additional configuration options. The default configuration works for most tests, but you may find the following useful. For a full list of supported configuration options, see [the api docs](../api/interfaces/cursorless_engine_testCaseRecorder_TestCaseRecorder.internal.RecordTestCaseCommandArg/).

### The options

Expand All @@ -55,15 +55,15 @@ By default, we don't capture the `that` mark returned by a command, unless the t

#### Testing the hat map

We have a way to test that the hats in the hat map update correctly during the course of a single phrase. These tests are also how we usually test our [range updating code](../api/modules/core_updateSelections_updateSelections).
We have a way to test that the hats in the hat map update correctly during the course of a single phrase. These tests are also how we usually test our [range updating code](../api/modules/cursorless_engine_core_updateSelections_updateSelections).

Any tests recorded in the `hatTokenMap` directory will automatically be treated as hat token map tests. To initiate a series of hat token map tests in another directory, say `"cursorless record navigation"`.

Then each time you record a test, you need to issue two commands. The second command should be of the form `"take air"` (or another decorated mark), and will tell the test case recorder which decorated mark you're checking.

### Default config per test case directory

Any test case directory that contains a `config.json` will set default configuration for all tests recorded in any descendant directory. For example, the file [`actions/config.json`](../../src/test/suite/fixtures/recorded/actions/config.json) makes it so that all our action tests will capture the final `that` mark. For a full list of keys supported in this json, see [the api docs](../api/interfaces/testutil_testcaserecorder.internal.recordtestcasecommandarg/).
Any test case directory that contains a `config.json` will set default configuration for all tests recorded in any descendant directory. For example, the file [`actions/config.json`](../../packages/cursorless-vscode-e2e/suite/fixtures/recorded/actions/config.json) makes it so that all our action tests will capture the final `that` mark. For a full list of keys supported in this json, see [the api docs](../api/interfaces/cursorless_engine_testCaseRecorder_TestCaseRecorder.internal.RecordTestCaseCommandArg/).

### Navigation map tests

Expand All @@ -86,9 +86,9 @@ To upgrade all the test fixtures to the latest command version, run the command

### Custom transformation

1. Add a new transformation to the `src/scripts/transformRecordedTests/transformations` directory. Look at the existing transformations in that directory for inspiration.
1. Add a new transformation to the [`transformRecordedTests` directory](../../packages/cursorless-engine/scripts/transformRecordedTests). Look at the existing transformations in that directory for inspiration.
1. Change the value at the `custom` key in `AVAILABLE_TRANSFORMATIONS` at the top of
[`transformRecordedTests/index.ts`](../../src/scripts/transformRecordedTests/index.ts) to
[`transformRecordedTests/index.ts`](../../packages/cursorless-engine/scripts/transformRecordedTests/index.ts) to
point to your new transformation
1. Run `yarn compile && yarn transform-recorded-tests custom`

Expand Down
2 changes: 1 addition & 1 deletion docs/user/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Note that if the mark is `"this"`, and you have multiple cursors, the modifiers

##### Syntactic scopes

For programming languages where Cursorless has rich parse tree support, we support modifiers that expand to the nearest containing function, class, etc. See [the source code](../../src/libs/cursorless-engine/languages/constants.ts) for a list of supported languages. Below is a list of supported scope types, keeping in mind that this table can sometimes lag behind the actual list. Your cheatsheet (say "cursorless help") will have the most up-to-date list.
For programming languages where Cursorless has rich parse tree support, we support modifiers that expand to the nearest containing function, class, etc. See [the source code](../../packages/cursorless-engine/languages/constants.ts) for a list of supported languages. Below is a list of supported scope types, keeping in mind that this table can sometimes lag behind the actual list. Your cheatsheet (say "cursorless help") will have the most up-to-date list.

| Term | Syntactic element |
| -------------- | --------------------------------------------------- |
Expand Down
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -743,25 +743,27 @@
},
"funding": "https://github.com/sponsors/pokey",
"_moduleAliases": {
"@cursorless/common": "./out/libs/common/index.js",
"@cursorless/vscode-common": "./out/libs/vscode-common/index.js"
"@cursorless/common": "./out/common/index.js",
"@cursorless/vscode-common": "./out/vscode-common/index.js",
"@cursorless/cursorless-vscode-core": "./out/cursorless-vscode-core/index.js",
"@cursorless/cursorless-engine": "./out/cursorless-engine/index.js"
},
"scripts": {
"vscode:prepublish": "npm run -S esbuild-base -- --minify",
"update-licenses": "npx npm-license-crawler --onlyDirectDependencies --csv third-party-licenses.csv",
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node",
"esbuild-base": "esbuild ./packages/cursorless-vscode/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node",
"esbuild": "npm run -S esbuild-base -- --sourcemap",
"esbuild-watch": "npm run -S esbuild-base -- --sourcemap --watch",
"test-compile": "tsc -p ./",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "yarn run compile && yarn run lint && yarn run esbuild",
"lint": "eslint src --ext ts",
"test": "env CURSORLESS_TEST=true node ./out/test/scripts/runTestsCI.js",
"lint": "eslint packages --ext ts",
"test": "env CURSORLESS_TEST=true node ./out/test-harness/scripts/runTestsCI.js",
"unused-exports": "ts-unused-exports tsconfig.json --showLineNumber",
"init-launch-sandbox": "node ./out/scripts/initLaunchSandbox.js",
"prepare-for-extension-publish": "node ./out/scripts/prepareForExtensionPublish.js",
"transform-recorded-tests": "node ./out/scripts/transformRecordedTests/index.js"
"init-launch-sandbox": "node ./out/cursorless-vscode-core/scripts/initLaunchSandbox.js",
"prepare-for-extension-publish": "node ./out/cursorless-vscode-core/scripts/prepareForExtensionPublish.js",
"transform-recorded-tests": "node ./out/cursorless-engine/scripts/transformRecordedTests/index.js"
},
"devDependencies": {
"@types/chai": "^4.3.3",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EditableTextEditor, TextEditor } from "@cursorless/common";
import type { EditableTextEditor, TextEditor } from "../..";
import { pull } from "lodash";
import { GeneralizedRange } from "../../types/GeneralizedRange";
import { TextDocument } from "../../types/TextDocument";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PassthroughIDEBase from "../PassthroughIDEBase";
import { FlashDescriptor } from "../types/FlashDescriptor";
import type { IDE } from "../types/ide.types";

export default class NormalizedIDE extends PassthroughIDEBase {
export class NormalizedIDE extends PassthroughIDEBase {
configuration: FakeConfiguration;
globalState: FakeGlobalState;
clipboard: FakeClipboard;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Listener } from "@cursorless/common";
import { Listener } from "../..";
import { HatStability } from "./HatStability";
import { Disposable } from "./ide.types";
import { GetFieldType, Paths } from "./Paths";
Expand All @@ -8,6 +8,7 @@ export type CursorlessConfiguration = {
wordSeparators: string[];
experimental: { snippetsDir: string | undefined; hatStability: HatStability };
decorationDebounceDelayMs: number;
debug: boolean;
};

export type CursorlessConfigKey = keyof CursorlessConfiguration;
Expand All @@ -25,6 +26,7 @@ export const CONFIGURATION_DEFAULTS: CursorlessConfiguration = {
snippetsDir: undefined,
hatStability: HatStability.balanced,
},
debug: false,
};

export interface Configuration {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TextDocument, Range } from "@cursorless/common";
import type { TextDocument, Range } from "../..";

/**
* An event describing a transactional {@link TextDocument document} change.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TextEditor } from "@cursorless/common";
import { TextEditor } from "../..";
import { GeneralizedRange } from "../../types/GeneralizedRange";

export enum FlashStyle {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
InputBoxOptions,
TextDocument,
TextEditor,
} from "@cursorless/common";
} from "../..";
import { URI } from "vscode-uri";
import { GeneralizedRange } from "../../types/GeneralizedRange";
import { Capabilities } from "./Capabilities";
Expand Down
Loading