Skip to content

Commit

Permalink
Compile ahk2 project alongside main project (#461)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mark-wiemer authored Aug 18, 2024
1 parent d653813 commit bd03fb4
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "src/ahk2"]
path = src/ahk2
[submodule "ahk2"]
path = ahk2
url = https://github.com/mark-wiemer-org/vscode-autohotkey2-lsp
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
dist
node_modules
out
src/ahk2
ahk2

# Files
.vscode/settings.json
Expand Down
2 changes: 1 addition & 1 deletion Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ahk2
Submodule ahk2 added at c95899
55 changes: 38 additions & 17 deletions package-lock.json

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

22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -36,7 +36,7 @@
"language/autohotkey2.svg",
"language/snippetsV1.json",
"language/snippetsV2.json",
"out/extension.js",
"dist/extension.js",
"icon.png",
"license.txt"
],
Expand All @@ -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..."
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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",
Expand All @@ -553,7 +551,7 @@
"vscode-tmgrammar-test": "^0.1.1"
},
"engines": {
"vscode": "^1.50.0"
"vscode": "^1.90.0"
},
"icon": "icon.png",
"galleryBanner": {
Expand Down
1 change: 0 additions & 1 deletion src/ahk2
Submodule ahk2 deleted from d936c0
13 changes: 7 additions & 6 deletions src/parser/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
13 changes: 7 additions & 6 deletions src/providers/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 7 additions & 6 deletions src/providers/formattingProvider.utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
32 changes: 9 additions & 23 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

0 comments on commit bd03fb4

Please sign in to comment.