Skip to content

Try moving build to just gulp#503

Merged
jcreedcmu merged 21 commits intogithub:mainfrom
jcreedcmu:jcreed/untangle2
Jul 21, 2020
Merged

Try moving build to just gulp#503
jcreedcmu merged 21 commits intogithub:mainfrom
jcreedcmu:jcreed/untangle2

Conversation

@jcreedcmu
Copy link
Copy Markdown
Contributor

@jcreedcmu jcreedcmu commented Jul 16, 2020

This PR is a proposal for how to fulfill #498. All build configuration is moved into extensions/ql-vscode and now only one buildable module exists, so we don't use rush anymore. The Actions workflow files call gulp directly. Building the package with vsce seems to remove devDependencies just fine by itself, so we no longer have to do any traversal of our dependencies, just copy node_modules to the dist directory and let vsce do its thing.

In fact, the only reason we have to create a distribution directory and copy anything at all is because we fiddle with the version number in package.json. But this seems fine --- it lets us have exact control over which files go in the package. But maybe vsce pays attention to the "files" section in package.json, I haven't checked that.

@jcreedcmu jcreedcmu requested a review from aeisenberg July 16, 2020 13:34
@jcreedcmu
Copy link
Copy Markdown
Contributor Author

(for a sense of scale, this diff is +196 loc, -3116 loc excluding the shrinkwrap/lock files)

Copy link
Copy Markdown
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

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

At some point, we should move the extension out of the extensions/ql folder to the top level. Is there any reason not to do this?

We can wait for a different PR since this one is so large.

@jcreedcmu
Copy link
Copy Markdown
Contributor Author

absolutely; that seems like the immediate next step. I only postponed it because this is plenty big and it seemed less deeply consequential (although it requires changing some relative paths in a few files iirc)

@jcreedcmu jcreedcmu marked this pull request as ready for review July 21, 2020 14:10
Comment thread .vscode/tasks.json
"isDefault": true
},
"command": "node common/scripts/install-run-rush.js build --verbose",
"command": "npx gulp buildWithoutPackage --verbose",
Copy link
Copy Markdown
Contributor

@aeisenberg aeisenberg Jul 21, 2020

Choose a reason for hiding this comment

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

I dont think we need npx here. We can assume users have already run npm run build -- buildWithoutPackage --verbose before running in vs code. So, just do the same, but remove npx. You may need to add a full path here, so ${workspaceRoot}/extensions/ql-vscode/node_modules/.bin/gulp.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I sort of like npx as a terse idiom here, but I don't mind being more explicit if you think it's better to avoid the magic of npx auto-downloading packages. I'm pretty sure we already need to be in the correct cwd to have gulp work, so a path relative to extensions/ql-vscode should work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My concern with npx is with versioning. I've had situations before where people ran into different behaviour because npx had installed different versions. If we are running from the node_modules directory, this won't happen.

Comment thread .github/workflows/main.yml Outdated
run: node common/scripts/install-run-rush.js build
run: |
cd extensions/ql-vscode
gulp
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we change this to npm run build? This will ensure $PATH is correct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, and I agree with similar comments below that confining any call to gulp into the package.json scripts is generally a better approach.

Comment thread .github/workflows/main.yml Outdated
run: node common/scripts/install-run-rush.js build
run: |
cd extensions/ql-vscode
gulp
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here, too.

Comment thread .github/workflows/release.yml Outdated
run: node common/scripts/install-run-rush.js build --release
run: |
cd extensions/ql-vscode
gulp --release
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add a npm run release:build script?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or, npm run build -- --release should work.

'--out', path.resolve(deployedPackage.distPath, '..', `${deployedPackage.name}-${deployedPackage.version}.vsix`)
];
const proc = child_process.spawn('vsce', args, {
const proc = childProcess.spawn('npx', ['vsce'].concat(args), {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd like to avoid npx and use the package-installed version of vsce.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree as above.

Comment thread extensions/ql-vscode/package.json Outdated
"format-staged": "lint-staged"
},
"dependencies": {
"@types/semver": "~7.2.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you move this to devDependencies?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, good catch.

@@ -1,3 +1,32 @@
{
"extends": "./node_modules/typescript-config/extension.tsconfig.json"
"$schema": "http://json.schemastore.org/tsconfig",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this line important?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't presently know of anything that requires it but it occurred in other tsconfig files in the previous state of this repo, and it seemed like fine documentation. I have no overwhelmingly strong opinion about including or eliminating it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm fine with keeping it. I've just never seen it explicitly before. I think vscode adds it automatically, but other tools may not.

@aeisenberg
Copy link
Copy Markdown
Contributor

NIce.

@jcreedcmu jcreedcmu merged commit b3dc7d7 into github:main Jul 21, 2020
@jcreedcmu
Copy link
Copy Markdown
Contributor Author

Still need to fix CONTRIBUTING.md now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants