Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions loaders/jsyamlLoader.js

This file was deleted.

16 changes: 2 additions & 14 deletions package-lock.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be good to update the repo to use yarn since everything else we own does

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I'll do that in a separate pr since I already have too many changes bundled into this one

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

36 changes: 1 addition & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,6 @@
"command": "hubspot.config.renameAccount",
"title": "Rename account"
},
{
"command": "hubspot.notifications.showFeedbackRequest",
"title": "Show feedback request"
},
{
"command": "hubspot.modals.openFeedbackPanel",
"title": "Open feedback panel"
Expand All @@ -296,21 +292,9 @@
"title": "Show personal access key info",
"icon": "$(link-external)"
},
{
"command": "hubspot.remoteFs.refresh",
"title": "Cached Refresh"
},
{
"command": "hubspot.remoteFs.hardRefresh",
"title": "Refresh"
},
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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).

"command": "hubspot.remoteFs.invalidateCache",
"title": "Invalidate Cache"
},
{
"command": "hubspot.remoteFs.startWatch",
"title": "Start Watch"
"title": "test: Refresh"
},
{
"command": "hubspot.remoteFs.endWatch",
Expand Down Expand Up @@ -485,10 +469,6 @@
"command": "hubspot.config.deleteAccount",
"when": "false"
},
{
"command": "hubspot.notifications.showFeedbackRequest",
"when": "false"
},
{
"command": "hubspot.modals.openFeedbackPanel",
"when": "false"
Expand All @@ -500,18 +480,6 @@
{
"command": "hubspot.account.viewPersonalAccessKey",
"when": "false"
},
{
"command": "hubspot.remoteFs.refresh",
"when": "false"
},
{
"command": "hubspot.remoteFs.invalidateCache",
"when": "false"
},
{
"command": "hubspot.remoteFs.startWatch",
"when": "false"
}
]
},
Expand Down Expand Up @@ -603,7 +571,6 @@
"devDependencies": {
"@types/debounce": "^1.2.1",
"@types/findup-sync": "^4.0.2",
"@types/js-yaml": "^4.0.5",
"@types/node": "^15.12.4",
"@types/node-fetch": "^2.6.3",
"@types/semver": "^7.3.8",
Expand All @@ -617,7 +584,6 @@
"ts-loader": "^9.2.3",
"ts-node": "^10.9.1",
"typescript": "^4.3.4",
"un-eval": "^1.2.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.7.2",
"webpack-node-externals": "^3.0.0"
Expand Down
3 changes: 2 additions & 1 deletion src/lib/commands/account.ts → src/commands/account.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { commands, ExtensionContext, Uri } from 'vscode';
import { CLIAccount_DEPRECATED } from '@hubspot/local-dev-lib/types/Accounts';
import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
import { COMMANDS } from '../constants';

import { COMMANDS } from '../lib/constants';

export const registerCommands = (context: ExtensionContext) => {
context.subscriptions.push(
Expand Down
5 changes: 3 additions & 2 deletions src/lib/commands/auth.ts → src/commands/auth.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { commands, env, ExtensionContext, Uri } from 'vscode';
import { COMMANDS, IDE_NAMES } from '../constants';

import { COMMANDS, IDE_NAMES } from '../lib/constants';

export const registerCommands = (
context: ExtensionContext,
rootPath: string
) => {
context.subscriptions.push(
commands.registerCommand(COMMANDS.AUTHORIZE_ACCOUNT, async () => {
commands.registerCommand(COMMANDS.ACCOUNT.AUTHORIZE, async () => {
// Detect the IDE type based on env.appName
const ideParam =
env.appName.toLowerCase() === IDE_NAMES.CURSOR
Expand Down
27 changes: 14 additions & 13 deletions src/lib/commands/config.ts → src/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import {
CLIAccount_DEPRECATED,
} from '@hubspot/local-dev-lib/types/Accounts';
import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
import { updateStatusBarItems } from '../statusBar';
import { COMMANDS, TRACKED_EVENTS } from '../constants';
import { getDisplayedHubspotPortalInfo } from '../helpers';
import { portalNameInvalid } from '../validation';
import { trackEvent } from '../tracking';
import { showAutoDismissedStatusBarMessage } from '../messaging';

import { updateStatusBarItems } from '../features/statusBar';
import { COMMANDS, EVENTS, TRACKED_EVENTS } from '../lib/constants';
import { getDisplayedHubspotPortalInfo } from '../lib/config';
import { portalNameInvalid } from '../lib/config';
import { trackEvent } from '../lib/tracking';
import { showAutoDismissedStatusBarMessage } from '../lib/statusBar';

const showRenameAccountPrompt = (accountToRename: CLIAccount_DEPRECATED) => {
window
Expand All @@ -44,14 +45,14 @@ const showRenameAccountPrompt = (accountToRename: CLIAccount_DEPRECATED) => {
return;
}
renameAccount(String(oldName), newName);
commands.executeCommand(COMMANDS.ACCOUNTS_REFRESH);
commands.executeCommand(EVENTS.ACCOUNT.REFRESH);
showAutoDismissedStatusBarMessage(
`Successfully renamed default account from ${oldName} to ${newName}.`
);
await trackEvent(TRACKED_EVENTS.RENAME_ACCOUNT);
trackEvent(TRACKED_EVENTS.RENAME_ACCOUNT);
} else {
window.showErrorMessage(invalidReason);
await trackEvent(TRACKED_EVENTS.RENAME_ACCOUNT_ERROR, {
trackEvent(TRACKED_EVENTS.RENAME_ACCOUNT_ERROR, {
oldName,
newName,
invalidReason,
Expand All @@ -75,7 +76,7 @@ export const registerCommands = (context: ExtensionContext) => {
: defaultAccount.name || getAccountIdentifier(defaultAccount);
console.log('Setting default account to: ', newDefaultAccount);
updateDefaultAccount(newDefaultAccount);
await trackEvent(TRACKED_EVENTS.UPDATE_DEFAULT_ACCOUNT);
trackEvent(TRACKED_EVENTS.UPDATE_DEFAULT_ACCOUNT);
commands.executeCommand(COMMANDS.REMOTE_FS.HARD_REFRESH);
if (!silenceNotification) {
showAutoDismissedStatusBarMessage(
Expand Down Expand Up @@ -122,7 +123,7 @@ export const registerCommands = (context: ExtensionContext) => {
);
return;
}
await trackEvent(TRACKED_EVENTS.SELECT_DEFAULT_ACCOUNT);
trackEvent(TRACKED_EVENTS.SELECT_DEFAULT_ACCOUNT);
updateDefaultAccount(newDefaultAccount);
showAutoDismissedStatusBarMessage(
`Successfully set default account to ${newDefaultAccount}.`
Expand Down Expand Up @@ -171,9 +172,9 @@ export const registerCommands = (context: ExtensionContext) => {
`Successfully deleted account ${accountIdentifier}.`
);
}
await trackEvent(TRACKED_EVENTS.DELETE_ACCOUNT);
trackEvent(TRACKED_EVENTS.DELETE_ACCOUNT);
commands.executeCommand(COMMANDS.REMOTE_FS.HARD_REFRESH);
commands.executeCommand(COMMANDS.ACCOUNTS_REFRESH);
commands.executeCommand(EVENTS.ACCOUNT.REFRESH);
updateStatusBarItems();
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { commands, ExtensionContext } from 'vscode';
import * as dayjs from 'dayjs';
import { COMMANDS } from '../constants';

import { EVENTS } from '../lib/constants';

export const registerCommands = (context: ExtensionContext) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

context.subscriptions.push(
commands.registerCommand(
COMMANDS.GLOBAL_STATE.UPDATE_DELAY,
EVENTS.GLOBAL_STATE.UPDATE_DELAY,
async (variableToUpdate, delayNumber, delayUnitName) => {
const newDelayDate = dayjs()
.add(delayNumber, delayUnitName)
Expand Down
22 changes: 11 additions & 11 deletions src/lib/commands.ts → src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { ExtensionContext } from 'vscode';
import { registerCommands as registerAccountCommands } from './commands/account';
import { registerCommands as registerAuthCommands } from './commands/auth';
import { registerCommands as registerConfigCommands } from './commands/config';
import { registerCommands as registerGlobalStateCommands } from './commands/globalState';
import { registerCommands as registerModuleCommands } from './commands/modules';
import { registerCommands as registerNotificationCommands } from './commands/notifications';
import { registerCommands as registerServerlessCommands } from './commands/serverless';
import { registerCommands as registerTemplateCommands } from './commands/templates';
import { registerCommands as registerTerminalCommands } from './commands/terminal';
import { registerCommands as registerRemoteFsCommands } from './commands/remoteFs';

import { registerCommands as registerAccountCommands } from './account';
import { registerCommands as registerAuthCommands } from './auth';
import { registerCommands as registerConfigCommands } from './config';
import { registerCommands as registerGlobalStateCommands } from './globalState';
import { registerCommands as registerModuleCommands } from './modules';
import { registerCommands as registerServerlessCommands } from './serverless';
import { registerCommands as registerTemplateCommands } from './templates';
import { registerCommands as registerTerminalCommands } from './terminal';
import { registerCommands as registerRemoteFsCommands } from './remoteFs';

export const registerCommands = (
context: ExtensionContext,
rootPath: string | undefined
Expand All @@ -20,7 +21,6 @@ export const registerCommands = (
registerConfigCommands(context);
registerGlobalStateCommands(context);
registerModuleCommands(context);
registerNotificationCommands(context);
registerServerlessCommands(context);
registerTemplateCommands(context);
registerTerminalCommands(context);
Expand Down
7 changes: 4 additions & 3 deletions src/lib/commands/modules.ts → src/commands/modules.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ExtensionContext, commands } from 'vscode';
import { COMMANDS, TRACKED_EVENTS } from '../constants';
import { onClickCreateFolder } from '../fileHelpers';
import { trackEvent } from '../tracking';
const path = require('path');

import { COMMANDS, TRACKED_EVENTS } from '../lib/constants';
import { onClickCreateFolder } from '../lib/fileHelpers';
import { trackEvent } from '../lib/tracking';

const { createModule } = require('@hubspot/local-dev-lib/cms/modules');

export const registerCommands = (context: ExtensionContext) => {
Expand Down
24 changes: 11 additions & 13 deletions src/lib/commands/remoteFs.ts → src/commands/remoteFs.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { ExtensionContext, window, commands, Uri } from 'vscode';
import { existsSync, statSync } from 'fs';
import { join } from 'path';
import { ExtensionContext, window, commands, Uri } from 'vscode';
import { COMMANDS, TRACKED_EVENTS } from '../constants';
import {
buildStatusBarItem,
getRootPath,
invalidateParentDirectoryCache,
requireAccountId,
} from '../helpers';
import { trackEvent } from '../tracking';

const { deleteFile, upload } = require('@hubspot/local-dev-lib/api/fileMapper');
const { downloadFileOrFolder } = require('@hubspot/local-dev-lib/fileMapper');
const { getAccountId } = require('@hubspot/local-dev-lib/config');
Expand All @@ -25,6 +16,13 @@ const {
} = require('@hubspot/local-dev-lib/cms/uploadFolder');
const { walk } = require('@hubspot/local-dev-lib/fs');

import { COMMANDS, EVENTS, TRACKED_EVENTS } from '../lib/constants';
import { getRootPath } from '../lib/helpers';
import { invalidateParentDirectoryCache } from '../lib/remoteDesignManagerFs';
import { buildStatusBarItem } from '../lib/statusBar';
import { requireAccountId } from '../lib/config';
import { trackEvent } from '../lib/tracking';

export const registerCommands = (context: ExtensionContext) => {
context.subscriptions.push(
commands.registerCommand(
Expand Down Expand Up @@ -115,7 +113,7 @@ export const registerCommands = (context: ExtensionContext) => {
.then(() => {
window.showInformationMessage(`Successfully deleted "${filePath}"`);
invalidateParentDirectoryCache(filePath);
commands.executeCommand(COMMANDS.REMOTE_FS.REFRESH);
commands.executeCommand(EVENTS.REMOTE_FS.REFRESH);
})
.catch((err: any) => {
window.showErrorMessage(
Expand Down Expand Up @@ -222,7 +220,7 @@ export const registerCommands = (context: ExtensionContext) => {
}
const filesToUpload = await getUploadableFileList(srcPath);
commands.executeCommand(
COMMANDS.REMOTE_FS.START_WATCH,
EVENTS.REMOTE_FS.START_WATCH,
srcPath,
destPath,
filesToUpload
Expand Down Expand Up @@ -305,6 +303,6 @@ const handleFolderUpload = async (srcPath: string, destPath: string) => {
})
.finally(() => {
uploadingStatus.dispose();
commands.executeCommand(COMMANDS.REMOTE_FS.REFRESH);
commands.executeCommand(EVENTS.REMOTE_FS.REFRESH);
});
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ExtensionContext, commands, window } from 'vscode';
import { COMMANDS, TRACKED_EVENTS } from '../constants';
import { onClickCreateFile, onClickCreateFolder } from '../fileHelpers';
import { basename, dirname, join, parse } from 'path';
import { trackEvent } from '../tracking';

const findup = require('findup-sync');
const { createFunction } = require('@hubspot/local-dev-lib/cms/functions');

import { COMMANDS, TRACKED_EVENTS } from '../lib/constants';
import { onClickCreateFile, onClickCreateFolder } from '../lib/fileHelpers';
import { trackEvent } from '../lib/tracking';

export const registerCommands = (context: ExtensionContext) => {
context.subscriptions.push(
commands.registerCommand(
Expand Down
15 changes: 11 additions & 4 deletions src/lib/commands/templates.ts → src/commands/templates.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { ExtensionContext, commands } from 'vscode';
import { COMMANDS, TRACKED_EVENTS, TEMPLATE_NAMES } from '../constants';
import { onClickCreateFile } from '../fileHelpers';
import { basename, dirname } from 'path';
import { trackEvent } from '../tracking';

const { createTemplate } = require('@hubspot/local-dev-lib/cms/templates');

import { COMMANDS, TRACKED_EVENTS } from '../lib/constants';
import { onClickCreateFile } from '../lib/fileHelpers';
import { trackEvent } from '../lib/tracking';

const TEMPLATE_NAMES = {
SECTION: 'section',
TEMPLATE: 'page-template',
PARTIAL: 'partial',
GLOBAL_PARTIAL: 'global-partial',
} as const;

export const registerCommands = (context: ExtensionContext) => {
context.subscriptions.push(
commands.registerCommand(
Expand Down
Loading