From bd03fb495d01171d44f76bb207a373e41095a9ad Mon Sep 17 00:00:00 2001 From: Mark Wiemer <7833360+mark-wiemer@users.noreply.github.com> Date: Sun, 18 Aug 2024 08:47:16 -0700 Subject: [PATCH] Compile ahk2 project alongside main project (#461) * Use composite build command * Remove submodule * Move submodule to top level * Update tsconfig for submodule * Make @types/vscode match submodule version * Use correct libraries for submodule compatibility * Use Node 20 * Use Node 20 to build * Ignore new submodule location * Fixup new submodule location * Validate project with new build strat * Fix entrypoint * Fixup npm prepare * Cleanup tsconfig.json * Remove unused TS libs --- .github/workflows/node.js.yml | 2 +- .gitmodules | 4 +- .prettierignore | 2 +- Contributing.md | 2 +- ahk2 | 1 + package-lock.json | 55 +++++++++++++------ package.json | 22 ++++---- src/ahk2 | 1 - src/parser/parser.test.ts | 13 +++-- src/providers/format.test.ts | 13 +++-- .../formattingProvider.utils.test.ts | 13 +++-- tsconfig.json | 32 +++-------- 12 files changed, 84 insertions(+), 76 deletions(-) create mode 160000 ahk2 delete mode 160000 src/ahk2 diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index eaf9e7cd..05750265 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -18,7 +18,7 @@ jobs: # AHK is built for Windows only, so we only build on Windows # As always, if community asks, community shall receive ;) os: [windows-latest] - node-version: [22.x] + node-version: [20.x] runs-on: ${{ matrix.os }} steps: - name: Checkout diff --git a/.gitmodules b/.gitmodules index d53e4eda..df7e084f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "src/ahk2"] - path = src/ahk2 +[submodule "ahk2"] + path = ahk2 url = https://github.com/mark-wiemer-org/vscode-autohotkey2-lsp diff --git a/.prettierignore b/.prettierignore index a7a4aeb9..35779b5e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,7 +5,7 @@ dist node_modules out -src/ahk2 +ahk2 # Files .vscode/settings.json diff --git a/Contributing.md b/Contributing.md index c83af161..03fb8847 100644 --- a/Contributing.md +++ b/Contributing.md @@ -9,7 +9,7 @@ I welcome any issues or PRs :) 1. Clone the repo 1. Install the relevant dependencies - VS Code Insiders (needed to run the tests from CLI, see [using Insiders version for extension development](https://code.visualstudio.com/api/working-with-extensions/testing-extension#using-insiders-version-for-extension-development)) - - [Node 22](https://nodejs.org/en/), which comes automatically bundled with npm 10, another dependency. + - [Node 20](https://nodejs.org/en/), which comes automatically bundled with npm 8, another dependency. 1. `npm i` 1. Use `bash` to run the npm scripts. They use commands that are not compatible with PowerShell. Use this setting: `"terminal.integrated.defaultProfile.windows": "Git Bash"` > If you use Command Prompt or PowerShell, you may see errors like diff --git a/ahk2 b/ahk2 new file mode 160000 index 00000000..c9589948 --- /dev/null +++ b/ahk2 @@ -0,0 +1 @@ +Subproject commit c9589948db2b7136722e6d425e186696f1a52c92 diff --git a/package-lock.json b/package-lock.json index 25b6b44a..7959679c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,8 +21,8 @@ "@types/fs-extra": "^9.0.7", "@types/glob": "^7.1.3", "@types/mocha": "^9.1.1", - "@types/node": "^17.0.23", - "@types/vscode": "^1.50.0", + "@types/node": "^20.16.0", + "@types/vscode": "1.90.0", "@types/xml2js": "^0.4.11", "@vscode/test-electron": "^2.3.10", "@vscode/vsce": "^3.0.0", @@ -1187,10 +1187,14 @@ "dev": true }, "node_modules/@types/node": { - "version": "17.0.45", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", - "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==", - "dev": true + "version": "20.16.0", + "resolved": "https://registry.npmmirror.com/@types/node/-/node-20.16.0.tgz", + "integrity": "sha512-vDxceJcoZhIVh67S568bm1UGZO0DX0hpplJZxzeXMKwIPLn190ec5RRxQ69BKhX44SUGIxxgMdDY557lGLKprQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.2" + } }, "node_modules/@types/normalize-package-data": { "version": "2.4.4", @@ -1200,10 +1204,11 @@ "license": "MIT" }, "node_modules/@types/vscode": { - "version": "1.68.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.68.0.tgz", - "integrity": "sha512-duBwEK5ta/eBBMJMQ7ECMEsMvlE3XJdRGh3xoS1uOO4jl2Z4LPBl5vx8WvBP10ERAgDRmIt/FaSD4RHyBGbChw==", - "dev": true + "version": "1.90.0", + "resolved": "https://registry.npmmirror.com/@types/vscode/-/vscode-1.90.0.tgz", + "integrity": "sha512-oT+ZJL7qHS9Z8bs0+WKf/kQ27qWYR3trsXpq46YDjFqBsMLG4ygGGjPaJ2tyrH0wJzjOEmDyg9PDJBBhWg9pkQ==", + "dev": true, + "license": "MIT" }, "node_modules/@types/xml2js": { "version": "0.4.11", @@ -6569,6 +6574,13 @@ "dev": true, "license": "MIT" }, + "node_modules/undici-types": { + "version": "6.19.6", + "resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-6.19.6.tgz", + "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", + "dev": true, + "license": "MIT" + }, "node_modules/universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", @@ -7623,10 +7635,13 @@ "dev": true }, "@types/node": { - "version": "17.0.45", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", - "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==", - "dev": true + "version": "20.16.0", + "resolved": "https://registry.npmmirror.com/@types/node/-/node-20.16.0.tgz", + "integrity": "sha512-vDxceJcoZhIVh67S568bm1UGZO0DX0hpplJZxzeXMKwIPLn190ec5RRxQ69BKhX44SUGIxxgMdDY557lGLKprQ==", + "dev": true, + "requires": { + "undici-types": "~6.19.2" + } }, "@types/normalize-package-data": { "version": "2.4.4", @@ -7635,9 +7650,9 @@ "dev": true }, "@types/vscode": { - "version": "1.68.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.68.0.tgz", - "integrity": "sha512-duBwEK5ta/eBBMJMQ7ECMEsMvlE3XJdRGh3xoS1uOO4jl2Z4LPBl5vx8WvBP10ERAgDRmIt/FaSD4RHyBGbChw==", + "version": "1.90.0", + "resolved": "https://registry.npmmirror.com/@types/vscode/-/vscode-1.90.0.tgz", + "integrity": "sha512-oT+ZJL7qHS9Z8bs0+WKf/kQ27qWYR3trsXpq46YDjFqBsMLG4ygGGjPaJ2tyrH0wJzjOEmDyg9PDJBBhWg9pkQ==", "dev": true }, "@types/xml2js": { @@ -11352,6 +11367,12 @@ "integrity": "sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g==", "dev": true }, + "undici-types": { + "version": "6.19.6", + "resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-6.19.6.tgz", + "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", + "dev": true + }, "universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", diff --git a/package.json b/package.json index 639e726f..306a429f 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "license": "See license.txt", "publisher": "mark-wiemer", - "main": "./out/extension", + "main": "./dist/extension", "files": [ "language/ahk.configuration.json", "language/ahk.tmLanguage.json", @@ -36,7 +36,7 @@ "language/autohotkey2.svg", "language/snippetsV1.json", "language/snippetsV2.json", - "out/extension.js", + "dist/extension.js", "icon.png", "license.txt" ], @@ -47,23 +47,22 @@ "clean:language": "del-cli language/*.tmLanguage.json", "clean:out": "del-cli out", "compile-grammar": "js-yaml language/ahk.tmLanguage.yaml > language/ahk.tmLanguage.json && js-yaml language/ahk2.tmLanguage.yaml > language/ahk2.tmLanguage.json", - "compile-ts": "tsc -p ./", + "compile-ts": "tsc -b", "eslint": "npm run eslint:files -- src && echo No ESLint problems", "eslint:files": "eslint --max-warnings=0", "eslint:fix": "npm run eslint:files -- src --fix", "format": "prettier --check .", "format:fix": "prettier --write .", - "lint": "npm run tsc && npm run eslint && npm run format && npm run sort-package-json", + "lint": "npm run eslint && npm run format && npm run sort-package-json", "package": "vsce package", - "prepare": "husky install", + "prepare": "husky install && git submodule update --init --recursive && cd ahk2 && npm install", "sort-package-json": "sort-package-json --check", "sort-package-json:fix": "sort-package-json", "test": "npm run test-grammar && npm run test-unit", "pretest-grammar": "npm run compile-grammar", "test-grammar": "vscode-tmgrammar-snap language/samples/*.{ahk1,ahk2}", "pretest-unit": "npm run clean:out && npm run compile-ts", - "test-unit": "node ./out/test/runTest.js", - "tsc": "tsc --noEmit --skipLibCheck && echo No TSC problems", + "test-unit": "node ./out/src/test/runTest.js", "validate": "npm run lint && npm run test && npm run package", "vscode:prepublish": "npm run build && echo Packaging..." }, @@ -495,8 +494,7 @@ "lint-staged": { "*": "prettier --check", "src/**/*.ts": [ - "npm run eslint:files", - "npm run tsc" + "npm run eslint:files" ], "package.json": "npm run sort-package-json" }, @@ -530,8 +528,8 @@ "@types/fs-extra": "^9.0.7", "@types/glob": "^7.1.3", "@types/mocha": "^9.1.1", - "@types/node": "^17.0.23", - "@types/vscode": "^1.50.0", + "@types/node": "^20.16.0", + "@types/vscode": "1.90.0", "@types/xml2js": "^0.4.11", "@vscode/test-electron": "^2.3.10", "@vscode/vsce": "^3.0.0", @@ -553,7 +551,7 @@ "vscode-tmgrammar-test": "^0.1.1" }, "engines": { - "vscode": "^1.50.0" + "vscode": "^1.90.0" }, "icon": "icon.png", "galleryBanner": { diff --git a/src/ahk2 b/src/ahk2 deleted file mode 160000 index d936c0a0..00000000 --- a/src/ahk2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d936c0a0798557cbc8bb87d399532c66c89b6e05 diff --git a/src/parser/parser.test.ts b/src/parser/parser.test.ts index 6ed3db9a..1435762c 100644 --- a/src/parser/parser.test.ts +++ b/src/parser/parser.test.ts @@ -111,12 +111,13 @@ suite('Parser', () => { suite('buildScript', () => { // Currently in `out` folder, need to get back to main `src` folder const filesParentPath = path.join( - __dirname, - '..', - '..', - 'src', - 'parser', - 'samples', + __dirname, // ./out/src/parser + '..', // ./out/src + '..', // ./out + '..', // . + 'src', // ./src + 'parser', // ./src/parser + 'samples', // ./src/parser/samples ); const myTests: { diff --git a/src/providers/format.test.ts b/src/providers/format.test.ts index 081e5ed0..2f1e3e93 100644 --- a/src/providers/format.test.ts +++ b/src/providers/format.test.ts @@ -108,12 +108,13 @@ const formatTests: FormatTest[] = [ // Currently in `out` folder, need to get back to main `src` folder const filesParentPath = path.join( - __dirname, - '..', - '..', - 'src', - 'providers', - 'samples', + __dirname, // ./out/src/providers + '..', // ./out/src + '..', // ./out + '..', // . + 'src', // ./src + 'providers', // ./src/providers + 'samples', // ./src/providers/samples ); const fileToString = (path: string): string => fs.readFileSync(path).toString(); diff --git a/src/providers/formattingProvider.utils.test.ts b/src/providers/formattingProvider.utils.test.ts index d0fa9573..f3df8524 100644 --- a/src/providers/formattingProvider.utils.test.ts +++ b/src/providers/formattingProvider.utils.test.ts @@ -1060,12 +1060,13 @@ suite('FormattingProvider utils', () => { suite(externalDocumentToString, () => { // Currently in `out` folder, need to get back to main `src` folder const filesParentPath = path.join( - __dirname, - '..', - '..', - 'src', - 'providers', - 'samples', + __dirname, // ./out/src/providers + '..', // ./out/src + '..', // ./out + '..', // . + 'src', // ./src + 'providers', // ./src/providers + 'samples', // ./src/providers/samples ); const myTests = [ diff --git a/tsconfig.json b/tsconfig.json index 90938f09..c4175036 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,32 +1,18 @@ { "compilerOptions": { "module": "commonjs", - "target": "es2019", + "target": "ES2022", + "lib": ["ES2022", "WebWorker"], "outDir": "out", "experimentalDecorators": true, - "lib": ["es6", "es2017", "es2019"], "sourceMap": true, - "rootDir": "src", - - // Type checking - "alwaysStrict": true, - // "exactOptionalPropertyTypes": true, // TODO - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitOverride": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - // "strict": true // TODO - "strictBindCallApply": true, - "strictFunctionTypes": true, - // "strictNullChecks": true // TODO - // "strictPropertyInitialization": true // TODO - "useUnknownInCatchVariables": true, - - // ESM + "rootDirs": ["src", "ahk2/client"], "esModuleInterop": true }, - "exclude": ["node_modules", "src/ahk2"] + "exclude": ["node_modules", "./ahk2/node_modules"], + "references": [ + { + "path": "./ahk2/client" + } + ] }