Skip to content
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
6 changes: 4 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
branches: [main]

jobs:
publish-extension:
publish-vscode-extension:
name: Publish VSCode extension
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment: production
Expand Down Expand Up @@ -47,6 +48,7 @@ jobs:
extensionFile: ${{ steps.publishToOpenVSX.outputs.vsixPath }}

publish-neovim-extension:
name: Publish Neovim extension
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment: production
Expand Down Expand Up @@ -97,7 +99,7 @@ jobs:
push-cursorless-talon:
name: Push cursorless-talon subrepo
runs-on: ubuntu-latest
needs: publish-extension
needs: publish-vscode-extension
environment: production
env:
DEPLOY_SHA: ${{ github.event.workflow_run.head_sha }}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"license": "MIT",
"packageManager": "pnpm@10.30.3",
"type": "module",
"main": "index.js",
"engines": {
"node": ">=24.14.0"
},
Expand Down
5 changes: 0 additions & 5 deletions packages/cheatsheet-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"license": "MIT",
"private": true,
"type": "module",
"main": "./out/index.js",
"types": "./out/index.d.ts",
"exports": {
".": "./out/index.js"
},
"scripts": {
"typecheck": "tsc",
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build",
Expand Down
1 change: 0 additions & 1 deletion packages/cursorless-everywhere-talon-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"license": "MIT",
"private": true,
"type": "module",
"main": "./out/index.js",
"scripts": {
"typecheck": "tsc",
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build",
Expand Down
1 change: 0 additions & 1 deletion packages/cursorless-everywhere-talon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"license": "MIT",
"private": true,
"type": "module",
"main": "./out/index.js",
"scripts": {
"typecheck": "tsc",
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build",
Expand Down
5 changes: 0 additions & 5 deletions packages/cursorless-neovim-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"license": "MIT",
"private": true,
"type": "module",
"main": "./out/index.js",
"types": "./out/index.d.ts",
"exports": {
".": "./out/index.js"
},
"scripts": {
"typecheck": "tsc",
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build"
Expand Down
4 changes: 0 additions & 4 deletions packages/cursorless-neovim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"license": "MIT",
"private": true,
"main": "./out/index.cjs",
"types": "./out/index.d.ts",
"exports": {
".": "./out/index.cjs"
},
"scripts": {
"typecheck": "tsc",
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build",
Expand Down
5 changes: 0 additions & 5 deletions packages/cursorless-org-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
"description": "Cursorless documentation website",
"license": "MIT",
"private": true,
"main": "./out/index.js",
"types": "./out/index.d.ts",
"exports": {
".": "./out/index.js"
},
"browserslist": {
"production": [
">0.5%",
Expand Down
5 changes: 0 additions & 5 deletions packages/cursorless-org/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"license": "MIT",
"private": true,
"type": "module",
"main": "./out/index.js",
"types": "./out/index.d.ts",
"exports": {
".": "./out/index.js"
},
"scripts": {
"typecheck": "tsc",
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build",
Expand Down
5 changes: 0 additions & 5 deletions packages/cursorless-vscode-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"license": "MIT",
"private": true,
"type": "module",
"main": "./out/index.js",
"types": "./out/index.d.ts",
"exports": {
".": "./out/index.js"
},
"scripts": {
"typecheck": "tsc",
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build"
Expand Down
1 change: 0 additions & 1 deletion packages/cursorless-vscode-tutorial-webview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"license": "MIT",
"private": true,
"type": "module",
"main": "./out/index.js",
"scripts": {
"typecheck": "tsc",
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build",
Expand Down
1 change: 0 additions & 1 deletion packages/meta-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@types/js-yaml": "^4.0.9",
"@types/lodash-es": "^4.17.12",
"@types/normalize-path": "^3.0.2",
"esbuild": "^0.27.4",
"js-yaml": "^4.1.1",
"lodash-es": "^4.17.23",
"normalize-path": "^3.0.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/meta-updater/src/metaUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { textFormat } from "./textFormat";
import { updateLanguageMdx } from "./updateLanguageMdx";
import { updatePackageJson } from "./updatePackageJson";
import { getScopeTypeTypes, updateScopeMdx } from "./updateScopeMdx";
import { updateTSConfig } from "./updateTSConfig";
import { updatesScopeSupportFacetInfos } from "./updatesScopeSupportFacetInfos";
import { updateTSConfig } from "./updateTSConfig";
import { updateTSConfigBase } from "./updateTSConfigBase";

export const updater = async (workspaceDir: string) => {
const pnpmLockfile = await readWantedLockfile(workspaceDir, {
Expand All @@ -31,6 +32,7 @@ export const updater = async (workspaceDir: string) => {
files: {
["package.json"]: updatePackageJson.bind(null, context),
["tsconfig.json"]: updateTSConfig.bind(null, context),
["tsconfig.base.json"]: updateTSConfigBase.bind(null, context),
["data/scopeSupportFacetInfos.md"]: updatesScopeSupportFacetInfos,
...Object.fromEntries(
Object.keys(languageScopeSupport).map((languageId) => [
Expand Down
44 changes: 25 additions & 19 deletions packages/meta-updater/src/updatePackageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { PackageJson } from "type-fest";
import type { Context } from "./Context";
import { getCursorlessVscodeFields } from "./getCursorlessVscodeFields";

const LIB_ENTRY_POINT = "./src/index.ts";
export const LIB_ENTRY_POINT = "src/index.ts";

/**
* Given a package.json, update it to match our conventions. This function is
Expand All @@ -26,10 +26,15 @@ export async function updatePackageJson(
const input: PackageJson = (rawInput ?? {}) as PackageJson;
/** Directory of the package whose package.json we are updating */
const packageDir = options.dir;

/** Whether we are updating the top-level package.json */
const isRoot = packageDir === workspaceDir;

const isLib = !isRoot && !input.private;
const isCursorlessVscode = input.name === "@cursorless/cursorless-vscode";
const isCursorlessNeovim = input.name === "@cursorless/cursorless-neovim";
const isCursorlessOrgDocs = input.name === "@cursorless/cursorless-org-docs";
const isCursorlessTestHarness = input.name === "@cursorless/test-harness";

if (input.description == null || input.description === "") {
throw new Error(`No description found in ${packageDir}/package.json`);
}
Expand All @@ -39,23 +44,29 @@ export async function updatePackageJson(
? input.name
: `@cursorless/${input.name}`;

const isLib = !isRoot && !input.private;

const exportFields: Partial<PackageJson> = (() => {
if (!isLib) {
return {};
}
if (isLib) {
const exports =
input.exports != null &&
typeof input.exports === "object" &&
!Array.isArray(input.exports)
? input.exports
: {};
exports["."] = LIB_ENTRY_POINT;
return { exports };
})();

const isCursorlessVscode = input.name === "@cursorless/cursorless-vscode";
exports["."] = `./${LIB_ENTRY_POINT}`;
input.exports = exports;
} else {
delete input.types;
delete input.exports;
// Extensions need a main field, but other non-lib packages shouldn't have
// one. The test harness is a special case since it's technically not a
// library but still requires main for the neovim tests.
if (
!isCursorlessVscode &&
!isCursorlessNeovim &&
!isCursorlessTestHarness
) {
delete input.main;
}
}

const extraFields = isCursorlessVscode
? getCursorlessVscodeFields(input)
Expand All @@ -65,13 +76,8 @@ export async function updatePackageJson(
...input,
name,
license: "MIT",
type:
name === "@cursorless/cursorless-org-docs" ||
name === "@cursorless/cursorless-neovim"
? undefined
: "module",
type: isCursorlessOrgDocs || isCursorlessNeovim ? undefined : "module",
scripts: await getScripts(input.scripts, name, packageDir, isRoot, isLib),
...exportFields,
...extraFields,
};

Expand Down
47 changes: 47 additions & 0 deletions packages/meta-updater/src/updateTSConfigBase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { FormatPluginFnOptions } from "@pnpm/meta-updater";
import * as fs from "fs/promises";
import type { PackageJson, TsConfigJson } from "type-fest";
import type { Context } from "./Context";
import { LIB_ENTRY_POINT } from "./updatePackageJson";

export async function updateTSConfigBase(
{ workspaceDir, pnpmLockfile }: Context,
rawInput: object | null,
options: FormatPluginFnOptions,
): Promise<TsConfigJson | undefined> {
/** Directory of the package whose tsconfig.json we are updating */
const packageDir = options.dir;

if (packageDir !== workspaceDir) {
return undefined;
}

/** The input tsconfig.json that should be checked / updated */
const input: TsConfigJson = (rawInput ?? {}) as TsConfigJson;

const packages = Object.keys(pnpmLockfile.importers).filter(
(importer) => importer !== ".",
);

const paths: Record<string, string[]> = {};

for (const packagePath of packages) {
const packageName = packagePath.replace("packages/", "@cursorless/");
const packageJsonPath = `${packageDir}/${packagePath}/package.json`;
const packageJson = JSON.parse(
await fs.readFile(packageJsonPath, "utf-8"),
) as PackageJson;

if (!packageJson.private) {
paths[packageName] = [`./${packagePath}/${LIB_ENTRY_POINT}`];
}
}

return {
...rawInput,
compilerOptions: {
...input.compilerOptions,
paths,
},
};
}
2 changes: 1 addition & 1 deletion packages/test-harness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This package contains the machinery used to test Cursorless, both in CI and loca

This package bundles tests into `.mjs` files and includes scripts used to run tests.

Note that we currently have a hack where the `package.json` here appears as if it is only used for Neovim. That is because none of our other test runners require a `package.json`, so they are happy to ignore fields such as `main` and `types` that are required for Neovim to be able to import the test harness. See [#2564](https://github.com/cursorless-dev/cursorless/issues/2564) to track progress on a more elegant solution.
Note that we currently have a hack where the `package.json` here appears as if it is only used for Neovim. That is because none of our other test runners require a `package.json`, so they are happy to ignore fields such as `main` that are required for Neovim to be able to import the test harness. See [#2564](https://github.com/cursorless-dev/cursorless/issues/2564) to track progress on a more elegant solution.
6 changes: 0 additions & 6 deletions packages/test-harness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
"private": true,
"type": "module",
"main": "./out/extensionTestsNeovim.cjs",
"types": "./out/extensionTestsNeovim.d.ts",
"exports": {
".": {
"default": "./out/extensionTestsNeovim.cjs"
}
},
"scripts": {
"typecheck": "tsc",
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build",
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading