Skip to content

Commit 675a722

Browse files
chore: Reorganizing + fixing hubl auto detection (#295)
* Reorganizing this project * Remove commands from package.json, cleanup constants, remove awaits on tracking * global state does not need to be an event * fix key
1 parent 52df8b8 commit 675a722

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+839
-855
lines changed

loaders/jsyamlLoader.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

package-lock.json

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,6 @@
279279
"command": "hubspot.config.renameAccount",
280280
"title": "Rename account"
281281
},
282-
{
283-
"command": "hubspot.notifications.showFeedbackRequest",
284-
"title": "Show feedback request"
285-
},
286282
{
287283
"command": "hubspot.modals.openFeedbackPanel",
288284
"title": "Open feedback panel"
@@ -296,21 +292,9 @@
296292
"title": "Show personal access key info",
297293
"icon": "$(link-external)"
298294
},
299-
{
300-
"command": "hubspot.remoteFs.refresh",
301-
"title": "Cached Refresh"
302-
},
303295
{
304296
"command": "hubspot.remoteFs.hardRefresh",
305-
"title": "Refresh"
306-
},
307-
{
308-
"command": "hubspot.remoteFs.invalidateCache",
309-
"title": "Invalidate Cache"
310-
},
311-
{
312-
"command": "hubspot.remoteFs.startWatch",
313-
"title": "Start Watch"
297+
"title": "test: Refresh"
314298
},
315299
{
316300
"command": "hubspot.remoteFs.endWatch",
@@ -485,10 +469,6 @@
485469
"command": "hubspot.config.deleteAccount",
486470
"when": "false"
487471
},
488-
{
489-
"command": "hubspot.notifications.showFeedbackRequest",
490-
"when": "false"
491-
},
492472
{
493473
"command": "hubspot.modals.openFeedbackPanel",
494474
"when": "false"
@@ -500,18 +480,6 @@
500480
{
501481
"command": "hubspot.account.viewPersonalAccessKey",
502482
"when": "false"
503-
},
504-
{
505-
"command": "hubspot.remoteFs.refresh",
506-
"when": "false"
507-
},
508-
{
509-
"command": "hubspot.remoteFs.invalidateCache",
510-
"when": "false"
511-
},
512-
{
513-
"command": "hubspot.remoteFs.startWatch",
514-
"when": "false"
515483
}
516484
]
517485
},
@@ -559,12 +527,12 @@
559527
"viewsWelcome": [
560528
{
561529
"view": "hubspot.viewsWelcome.accountAuth",
562-
"contents": "No authenticated accounts were found.\nIn order to use HubSpot VSCode features, you need to authenticate your account(s). \n[Authenticate HubSpot Account](command:hubspot.auth.onClickAuthorize)\nTo learn more about authentication using personal access keys, [read our docs](https://developers.hubspot.com/docs/cms/personal-access-key).",
530+
"contents": "No authenticated accounts were found.\nIn order to use HubSpot VSCode features, you need to authenticate your account(s). \n[Authenticate HubSpot Account](command:hubspot.account.onClickAuthorize)\nTo learn more about authentication using personal access keys, [read our docs](https://developers.hubspot.com/docs/cms/personal-access-key).",
563531
"when": "!hubspot.configPath"
564532
},
565533
{
566534
"view": "hubspot.viewsWelcome.accountAuth",
567-
"contents": "To work with other HubSpot accounts within VSCode, authenticate each additional account by clicking the button below. \n[Authenticate Additional HubSpot Account](command:hubspot.auth.onClickAuthorize)\nTo learn more about authentication using personal access keys, [read our docs](https://developers.hubspot.com/docs/cms/personal-access-key).",
535+
"contents": "To work with other HubSpot accounts within VSCode, authenticate each additional account by clicking the button below. \n[Authenticate Additional HubSpot Account](command:hubspot.account.onClickAuthorize)\nTo learn more about authentication using personal access keys, [read our docs](https://developers.hubspot.com/docs/cms/personal-access-key).",
568536
"when": "hubspot.configPath"
569537
},
570538
{
@@ -603,7 +571,6 @@
603571
"devDependencies": {
604572
"@types/debounce": "^1.2.1",
605573
"@types/findup-sync": "^4.0.2",
606-
"@types/js-yaml": "^4.0.5",
607574
"@types/node": "^15.12.4",
608575
"@types/node-fetch": "^2.6.3",
609576
"@types/semver": "^7.3.8",
@@ -617,7 +584,6 @@
617584
"ts-loader": "^9.2.3",
618585
"ts-node": "^10.9.1",
619586
"typescript": "^4.3.4",
620-
"un-eval": "^1.2.0",
621587
"webpack": "^5.102.1",
622588
"webpack-cli": "^4.7.2",
623589
"webpack-node-externals": "^3.0.0"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { commands, ExtensionContext, Uri } from 'vscode';
22
import { CLIAccount_DEPRECATED } from '@hubspot/local-dev-lib/types/Accounts';
33
import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
4-
import { COMMANDS } from '../constants';
4+
5+
import { COMMANDS } from '../lib/constants';
56

67
export const registerCommands = (context: ExtensionContext) => {
78
context.subscriptions.push(
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { commands, env, ExtensionContext, Uri } from 'vscode';
2-
import { COMMANDS, IDE_NAMES } from '../constants';
2+
3+
import { COMMANDS, IDE_NAMES } from '../lib/constants';
34

45
export const registerCommands = (
56
context: ExtensionContext,
67
rootPath: string
78
) => {
89
context.subscriptions.push(
9-
commands.registerCommand(COMMANDS.AUTHORIZE_ACCOUNT, async () => {
10+
commands.registerCommand(COMMANDS.ACCOUNT.AUTHORIZE, async () => {
1011
// Detect the IDE type based on env.appName
1112
const ideParam =
1213
env.appName.toLowerCase() === IDE_NAMES.CURSOR
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ import {
1414
CLIAccount_DEPRECATED,
1515
} from '@hubspot/local-dev-lib/types/Accounts';
1616
import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
17-
import { updateStatusBarItems } from '../statusBar';
18-
import { COMMANDS, TRACKED_EVENTS } from '../constants';
19-
import { getDisplayedHubspotPortalInfo } from '../helpers';
20-
import { portalNameInvalid } from '../validation';
21-
import { trackEvent } from '../tracking';
22-
import { showAutoDismissedStatusBarMessage } from '../messaging';
17+
18+
import { updateStatusBarItems } from '../features/statusBar';
19+
import { COMMANDS, EVENTS, TRACKED_EVENTS } from '../lib/constants';
20+
import { getDisplayedHubspotPortalInfo } from '../lib/config';
21+
import { portalNameInvalid } from '../lib/config';
22+
import { trackEvent } from '../lib/tracking';
23+
import { showAutoDismissedStatusBarMessage } from '../lib/statusBar';
2324

2425
const showRenameAccountPrompt = (accountToRename: CLIAccount_DEPRECATED) => {
2526
window
@@ -44,14 +45,14 @@ const showRenameAccountPrompt = (accountToRename: CLIAccount_DEPRECATED) => {
4445
return;
4546
}
4647
renameAccount(String(oldName), newName);
47-
commands.executeCommand(COMMANDS.ACCOUNTS_REFRESH);
48+
commands.executeCommand(EVENTS.ACCOUNT.REFRESH);
4849
showAutoDismissedStatusBarMessage(
4950
`Successfully renamed default account from ${oldName} to ${newName}.`
5051
);
51-
await trackEvent(TRACKED_EVENTS.RENAME_ACCOUNT);
52+
trackEvent(TRACKED_EVENTS.RENAME_ACCOUNT);
5253
} else {
5354
window.showErrorMessage(invalidReason);
54-
await trackEvent(TRACKED_EVENTS.RENAME_ACCOUNT_ERROR, {
55+
trackEvent(TRACKED_EVENTS.RENAME_ACCOUNT_ERROR, {
5556
oldName,
5657
newName,
5758
invalidReason,
@@ -75,7 +76,7 @@ export const registerCommands = (context: ExtensionContext) => {
7576
: defaultAccount.name || getAccountIdentifier(defaultAccount);
7677
console.log('Setting default account to: ', newDefaultAccount);
7778
updateDefaultAccount(newDefaultAccount);
78-
await trackEvent(TRACKED_EVENTS.UPDATE_DEFAULT_ACCOUNT);
79+
trackEvent(TRACKED_EVENTS.UPDATE_DEFAULT_ACCOUNT);
7980
commands.executeCommand(COMMANDS.REMOTE_FS.HARD_REFRESH);
8081
if (!silenceNotification) {
8182
showAutoDismissedStatusBarMessage(
@@ -122,7 +123,7 @@ export const registerCommands = (context: ExtensionContext) => {
122123
);
123124
return;
124125
}
125-
await trackEvent(TRACKED_EVENTS.SELECT_DEFAULT_ACCOUNT);
126+
trackEvent(TRACKED_EVENTS.SELECT_DEFAULT_ACCOUNT);
126127
updateDefaultAccount(newDefaultAccount);
127128
showAutoDismissedStatusBarMessage(
128129
`Successfully set default account to ${newDefaultAccount}.`
@@ -171,9 +172,9 @@ export const registerCommands = (context: ExtensionContext) => {
171172
`Successfully deleted account ${accountIdentifier}.`
172173
);
173174
}
174-
await trackEvent(TRACKED_EVENTS.DELETE_ACCOUNT);
175+
trackEvent(TRACKED_EVENTS.DELETE_ACCOUNT);
175176
commands.executeCommand(COMMANDS.REMOTE_FS.HARD_REFRESH);
176-
commands.executeCommand(COMMANDS.ACCOUNTS_REFRESH);
177+
commands.executeCommand(EVENTS.ACCOUNT.REFRESH);
177178
updateStatusBarItems();
178179
}
179180
});
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { ExtensionContext } from 'vscode';
2-
import { registerCommands as registerAccountCommands } from './commands/account';
3-
import { registerCommands as registerAuthCommands } from './commands/auth';
4-
import { registerCommands as registerConfigCommands } from './commands/config';
5-
import { registerCommands as registerGlobalStateCommands } from './commands/globalState';
6-
import { registerCommands as registerModuleCommands } from './commands/modules';
7-
import { registerCommands as registerNotificationCommands } from './commands/notifications';
8-
import { registerCommands as registerServerlessCommands } from './commands/serverless';
9-
import { registerCommands as registerTemplateCommands } from './commands/templates';
10-
import { registerCommands as registerTerminalCommands } from './commands/terminal';
11-
import { registerCommands as registerRemoteFsCommands } from './commands/remoteFs';
2+
3+
import { registerCommands as registerAccountCommands } from './account';
4+
import { registerCommands as registerAuthCommands } from './auth';
5+
import { registerCommands as registerConfigCommands } from './config';
6+
import { registerCommands as registerModuleCommands } from './modules';
7+
import { registerCommands as registerServerlessCommands } from './serverless';
8+
import { registerCommands as registerTemplateCommands } from './templates';
9+
import { registerCommands as registerTerminalCommands } from './terminal';
10+
import { registerCommands as registerRemoteFsCommands } from './remoteFs';
11+
1212
export const registerCommands = (
1313
context: ExtensionContext,
1414
rootPath: string | undefined
@@ -18,9 +18,7 @@ export const registerCommands = (
1818
}
1919
registerAccountCommands(context);
2020
registerConfigCommands(context);
21-
registerGlobalStateCommands(context);
2221
registerModuleCommands(context);
23-
registerNotificationCommands(context);
2422
registerServerlessCommands(context);
2523
registerTemplateCommands(context);
2624
registerTerminalCommands(context);
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { ExtensionContext, commands } from 'vscode';
2-
import { COMMANDS, TRACKED_EVENTS } from '../constants';
3-
import { onClickCreateFolder } from '../fileHelpers';
4-
import { trackEvent } from '../tracking';
52
const path = require('path');
63

4+
import { COMMANDS, TRACKED_EVENTS } from '../lib/constants';
5+
import { onClickCreateFolder } from '../lib/fileHelpers';
6+
import { trackEvent } from '../lib/tracking';
7+
78
const { createModule } = require('@hubspot/local-dev-lib/cms/modules');
89

910
export const registerCommands = (context: ExtensionContext) => {
Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1+
import { ExtensionContext, window, commands, Uri } from 'vscode';
12
import { existsSync, statSync } from 'fs';
23
import { join } from 'path';
3-
import { ExtensionContext, window, commands, Uri } from 'vscode';
4-
import { COMMANDS, TRACKED_EVENTS } from '../constants';
5-
import {
6-
buildStatusBarItem,
7-
getRootPath,
8-
invalidateParentDirectoryCache,
9-
requireAccountId,
10-
} from '../helpers';
11-
import { trackEvent } from '../tracking';
12-
134
const { deleteFile, upload } = require('@hubspot/local-dev-lib/api/fileMapper');
145
const { downloadFileOrFolder } = require('@hubspot/local-dev-lib/fileMapper');
156
const { getAccountId } = require('@hubspot/local-dev-lib/config');
@@ -25,6 +16,13 @@ const {
2516
} = require('@hubspot/local-dev-lib/cms/uploadFolder');
2617
const { walk } = require('@hubspot/local-dev-lib/fs');
2718

19+
import { COMMANDS, EVENTS, TRACKED_EVENTS } from '../lib/constants';
20+
import { getRootPath } from '../lib/helpers';
21+
import { invalidateParentDirectoryCache } from '../lib/remoteDesignManagerFs';
22+
import { buildStatusBarItem } from '../lib/statusBar';
23+
import { requireAccountId } from '../lib/config';
24+
import { trackEvent } from '../lib/tracking';
25+
2826
export const registerCommands = (context: ExtensionContext) => {
2927
context.subscriptions.push(
3028
commands.registerCommand(
@@ -115,7 +113,7 @@ export const registerCommands = (context: ExtensionContext) => {
115113
.then(() => {
116114
window.showInformationMessage(`Successfully deleted "${filePath}"`);
117115
invalidateParentDirectoryCache(filePath);
118-
commands.executeCommand(COMMANDS.REMOTE_FS.REFRESH);
116+
commands.executeCommand(EVENTS.REMOTE_FS.REFRESH);
119117
})
120118
.catch((err: any) => {
121119
window.showErrorMessage(
@@ -222,7 +220,7 @@ export const registerCommands = (context: ExtensionContext) => {
222220
}
223221
const filesToUpload = await getUploadableFileList(srcPath);
224222
commands.executeCommand(
225-
COMMANDS.REMOTE_FS.START_WATCH,
223+
EVENTS.REMOTE_FS.START_WATCH,
226224
srcPath,
227225
destPath,
228226
filesToUpload
@@ -305,6 +303,6 @@ const handleFolderUpload = async (srcPath: string, destPath: string) => {
305303
})
306304
.finally(() => {
307305
uploadingStatus.dispose();
308-
commands.executeCommand(COMMANDS.REMOTE_FS.REFRESH);
306+
commands.executeCommand(EVENTS.REMOTE_FS.REFRESH);
309307
});
310308
};
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { ExtensionContext, commands, window } from 'vscode';
2-
import { COMMANDS, TRACKED_EVENTS } from '../constants';
3-
import { onClickCreateFile, onClickCreateFolder } from '../fileHelpers';
42
import { basename, dirname, join, parse } from 'path';
5-
import { trackEvent } from '../tracking';
6-
73
const findup = require('findup-sync');
84
const { createFunction } = require('@hubspot/local-dev-lib/cms/functions');
95

6+
import { COMMANDS, TRACKED_EVENTS } from '../lib/constants';
7+
import { onClickCreateFile, onClickCreateFolder } from '../lib/fileHelpers';
8+
import { trackEvent } from '../lib/tracking';
9+
1010
export const registerCommands = (context: ExtensionContext) => {
1111
context.subscriptions.push(
1212
commands.registerCommand(

0 commit comments

Comments
 (0)