Skip to content
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

Download syntax file on build #22

Merged
merged 4 commits into from
Mar 21, 2022
Merged

Download syntax file on build #22

merged 4 commits into from
Mar 21, 2022

Conversation

jpogran
Copy link
Contributor

@jpogran jpogran commented Mar 14, 2022

Downloads syntax file on build or package.

@jpogran jpogran self-assigned this Mar 14, 2022
@jpogran jpogran added the ci Continuous integration/delivery related label Mar 14, 2022
@jpogran jpogran added this to the 0.1.0 milestone Mar 14, 2022
@jpogran jpogran linked an issue Mar 14, 2022 that may be closed by this pull request
@jpogran jpogran requested a review from a team March 16, 2022 14:56
@jpogran jpogran marked this pull request as ready for review March 16, 2022 14:56
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

Aside from my in-line comments - I think the docs may need updating too?
https://github.com/hashicorp/vscode-terraform/blob/main/DEVELOPMENT.md

build/download-syntax.ts Outdated Show resolved Hide resolved
extensionVersion: string;
syntaxVersion: string;
preview: false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we only end up using syntaxVersion here - shall we drop the other two fields then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used this same inteface across vscode-terraform, vscode-chl and vscode-sentinel.

It doesn't hurt to have it in there and we plan on moving to a framework when we know better what we need to build each of these extensions.

@@ -64,6 +67,8 @@
]
},
"scripts": {
"download:syntax": "ts-node ./build/download-syntax.ts",
"preesbuild-base": "npm run download:syntax",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need to plumb this into the release process too anywhere in GHA, or is that basically what preesbuild-base does here through the magic name? i.e. do we end up with downloaded grammar in /syntax as part of npm ci or npm run package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Npm script magic takes care of this

npm run package runs vsce. vsce looks for a script called vscode:prepublish, which calls npm run esbuild-base. NPM will run anything with pre before the thing without the pre, so preesbuild-base runs before esbuild-base. That finally downloads the file, and the rest of the chain can run.

If all this sounds complicated and obtuse, welcome to npm 😁 .

More seriously, this was the minimal code to get the job done. To make this better, we can use a build framework instead

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run package runs vsce. vsce looks for a script called vscode:prepublish, which calls npm run esbuild-base. NPM will run anything with pre before the thing without the pre, so preesbuild-base runs before esbuild-base. That finally downloads the file, and the rest of the chain can run.

rocket-science-complicated

@jpogran jpogran force-pushed the download_syntaxes branch 2 times, most recently from 1f08899 to 0e36d0e Compare March 16, 2022 15:31
@jpogran jpogran requested a review from a team March 16, 2022 16:44
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, merge at will.

:shipit:

build/download-syntax.ts Outdated Show resolved Hide resolved
build/download-syntax.ts Outdated Show resolved Hide resolved
build/download-syntax.ts Outdated Show resolved Hide resolved
Copy link
Member

@dbanck dbanck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Thank you for integrating got!

package.json Outdated
@@ -89,13 +94,16 @@
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"@vscode/test-electron": "^2.0.3",
"axios": "^0.26.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

axios can be removed

@jpogran jpogran merged commit 5dcb78e into main Mar 21, 2022
@jpogran jpogran deleted the download_syntaxes branch March 21, 2022 13:09
@jpogran jpogran modified the milestones: 0.1.0, 0.2.0 Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Continuous integration/delivery related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resolve HCL grammar from hashicorp/syntax
3 participants