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

Extension can be activated and opened when no workspace folder is open #194

Merged
merged 3 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@
},
"views": {
"hubspot-explorer": [
{
"id": "hubspot.viewsWelcome.noFolderOpened",
"name": "No Folder Opened",
"when": "workbench.explorer.emptyView.active"
},
{
"id": "hubspot.treedata.accounts",
"name": "Accounts",
Expand All @@ -401,13 +406,13 @@
{
"id": "hubspot.viewsWelcome.tools",
"name": "Tools",
"when": "!workbench.explorer.emptyView.active && hubspot.versionChecksComplete && hubspot.terminal.versions.installed.npm && !hubspot.terminal.versions.installed.hs || hubspot.updateAvailableForCLI"
"when": "hubspot.versionChecksComplete && hubspot.terminal.versions.installed.npm && !hubspot.terminal.versions.installed.hs || hubspot.updateAvailableForCLI"
},
{
"id": "hubspot.treedata.helpAndFeedback",
"name": "Help & Feedback",
"when": "!workbench.explorer.emptyView.active"
"name": "Help & Feedback"
}

]
},
"viewsWelcome": [
Expand All @@ -430,6 +435,11 @@
"view": "hubspot.viewsWelcome.tools",
"contents": "An update is available for the [HubSpot CLI](https://developers.hubspot.com/docs/cms/developer-reference/local-development-cli). \n[Update CLI](command:hubspot.hs.update)",
"when": "hubspot.updateAvailableForCLI"
},
{
"view": "hubspot.viewsWelcome.noFolderOpened",
"contents": "You have not yet opened a folder.\n[Open Folder](command:workbench.action.files.openFileFolder)\nYou can clone a repository locally.\n[Clone Repository](command:git.clone)\nTo learn more about how to use git and source control in VS Code [read our docs](https://code.visualstudio.com/docs/sourcecontrol/overview).",
"when": "workbench.explorer.emptyView.active"
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import { initializeTracking, trackEvent } from './lib/tracking';
import { initializeGlobalState } from './lib/globalState';

export const activate = async (context: ExtensionContext) => {
if (!workspace.workspaceFolders) return;

initializeTracking(context);
await trackEvent(TRACKED_EVENTS.ACTIVATE);
console.log(
Expand All @@ -36,5 +34,7 @@ export const activate = async (context: ExtensionContext) => {
initializeTerminal();
initializeStatusBar(context);

initializeConfig(rootPath);
if (rootPath) {
initializeConfig(rootPath);
}
};
6 changes: 4 additions & 2 deletions src/lib/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import { registerCommands as registerTerminalCommands } from './commands/termina

export const registerCommands = (
context: ExtensionContext,
rootPath: string
rootPath: string | undefined
) => {
if (rootPath) {
registerAuthCommands(context, rootPath);
}
registerAccountCommands(context);
registerAuthCommands(context, rootPath);
registerConfigCommands(context);
registerGlobalStateCommands(context);
registerModuleCommands(context);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const getRootPath = () => {
const workspaceFolders = workspace.workspaceFolders;

if (!workspaceFolders || workspaceFolders.length < 1) {
throw new Error('No workspace folder found.');
return;
}
return workspaceFolders[0].uri.path;
};
Expand Down