Reorganizing + fixing hubl auto detection#295
Conversation
| fileAssoc[`*.html`] = HUBL_HTML_ID; | ||
| fileAssoc[`*.css`] = HUBL_CSS_ID; | ||
| filesConfig.update('associations', fileAssoc); | ||
| filesConfig.update('associations', fileAssoc, ConfigurationTarget.Workspace); |
There was a problem hiding this comment.
We should be explicit here and save the "this project uses hubl" setting at the workspace level.
| @@ -4,47 +4,67 @@ import { | |||
| window, | |||
There was a problem hiding this comment.
There were two issues in this. The loop for the hubl detection wasn't reading the first character, and the hubl check logic wasn't running for documents that were already opened in the editor.
| "command": "hubspot.remoteFs.hardRefresh", | ||
| "title": "Refresh" | ||
| }, | ||
| { |
There was a problem hiding this comment.
These commands can be deleted from here. This project uses a pattern where we have "events" and "commands".
- commands - user-facing commands that can be executed via some form of ui interaction
- events - internal-only "commands" that cannot be directly triggered by a user through the ui
Anything that is purely an event, does not need to be configured here in the package.json file. I cleaned up everything in here that was defined as a command, has a "when: false" clause, and is not referenced anywhere else in the package.json file (i.e. menu options or something else).
| loader: 'node-loader', | ||
| }, | ||
| { | ||
| test: /\.lyaml$/, |
There was a problem hiding this comment.
We removed the lyaml file as part of the migration from cli-lib to local-dev-lib, so we don't need this anymore.
| import * as dayjs from 'dayjs'; | ||
| import { COMMANDS } from '../constants'; | ||
|
|
||
| export const registerCommands = (context: ExtensionContext) => { |
There was a problem hiding this comment.
Per the patterns of this project, this is actually an "event" instead of a command. But it also isn't leveraged anywhere in the package.json file, so we can remove this completely. It's just a thin wrapper around the context.globalState.update() function. I added two utils to the helpers.ts file, updated the panels/feedback.ts file, and then updated all the code that previously called executeCommand(COMMANDS.GLOBAL_STATE.UPDATE_DELAY) to directly call the global state update function instead.
| @@ -0,0 +1,11 @@ | |||
| import { ExtensionContext } from 'vscode'; | |||
There was a problem hiding this comment.
I'm still ramping up here, but from what I can tell so far this "Events" pattern is adding unnecessary complexity. In most (all?) cases there isn't a need to leverage VSCode's event bus to execute logic like this. AFAIK the primary reason to register events is to expose them as user-facing functionality in the contributes section of the package.json.
I undid some of it (all the terminal logic that checks the installation status for npm and the cli, and also the global state events), but not all of it because some events are pretty deeply rooted.
| import { COMMANDS, POLLING_INTERVALS } from '../constants'; | ||
|
|
||
| export const registerCommands = (context: ExtensionContext) => { | ||
| context.subscriptions.push( |
There was a problem hiding this comment.
This is an example of "events" that don't need to be events. These aren't referenced anywhere in the package.json file, so there's no reason for them to leverage the register/execute event bus pattern. I ported all of these into the terminal.ts file and now they're called directly as standard js functions
| @@ -1,13 +1,3 @@ | |||
| export const TEMPLATE_ERRORS_TYPES = { | |||
There was a problem hiding this comment.
I removed some constants from here that are only used in a single place
| @@ -1,11 +1,5 @@ | |||
| import { dirname } from 'path'; | |||
There was a problem hiding this comment.
This file was operating as a catch-all so I moved some of the utils to dedicated lib files
| @@ -0,0 +1,11 @@ | |||
| import { ExtensionContext } from 'vscode'; | |||
There was a problem hiding this comment.
Mostly just moving files around for all these providers so they follow the same registration pattern that we're using for panels, commands, and events
camden11
left a comment
There was a problem hiding this comment.
Still ramping up with the VScode extension so not entirely sure whats going on 100% of the time here, but nothing stood out to me. Still need to test things out
There was a problem hiding this comment.
Might be good to update the repo to use yarn since everything else we own does
There was a problem hiding this comment.
Good call. I'll do that in a separate pr since I already have too many changes bundled into this one
8c5be8b to
3b8c81e
Compare
camden11
left a comment
There was a problem hiding this comment.
Still looking through the code, but when testing I noticed that the "Authenticate Additional HubSpot Account" button doesn't seem to be working. Not sure if that's just an issue with my local setup, but it works as expected in my installed version of the extension
camden11
left a comment
There was a problem hiding this comment.
Once again, not really a VSCode expert but code here LGTM. Only issue I can find is the auth button not working
camden11
left a comment
There was a problem hiding this comment.
Nice, auth button is working again! LGTM
Some mostly structural updates to the project to make it easier to build on. This makes some fixes to the hubl auto detection functionality that seems to have not been working. The major changes: