Skip to content

Commit

Permalink
Merge branch 'main' of github.com:HubSpot/hubspot-cli into jy/add-hs-…
Browse files Browse the repository at this point in the history
…doctor-command
  • Loading branch information
joe-yeager committed Sep 11, 2024
2 parents 9267f1b + 62d7c91 commit 795ec89
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
es6: true,
},
parserOptions: {
ecmaVersion: 2021,
ecmaVersion: 2022,
},
rules: {
'no-console': 'off',
Expand Down
2 changes: 1 addition & 1 deletion acceptance-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "acceptance-tests",
"version": "5.4.0",
"version": "6.0.0",
"description": "Acceptance tests for cli",
"private": true,
"homepage": "https://github.com/HubSpot/hubspot-cli#readme",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"npmClient": "yarn",
"useWorkspaces": true,
"packages": ["packages/*", "acceptance-tests"],
"version": "5.4.1-beta.0"
"version": "6.0.0"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"devDependencies": {
"depcheck": "1.3.1",
"eslint": "7.32.0",
"eslint": "^8.56.0",
"husky": "^1.3.1",
"lerna": "^6.6.1",
"lint-staged": "^10.5.4",
Expand Down
22 changes: 3 additions & 19 deletions packages/cli/commands/project/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ const {
validateProjectConfig,
} = require('../../lib/projects');
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
const {
uiAccountDescription,
uiBetaTag,
uiCommandReference,
uiLink,
} = require('../../lib/ui');
const { uiBetaTag, uiCommandReference, uiLink } = require('../../lib/ui');
const SpinniesManager = require('../../lib/ui/SpinniesManager');
const LocalDevManager = require('../../lib/LocalDevManager');
const {
Expand All @@ -52,6 +47,7 @@ const {
createInitialBuildForNewProject,
useExistingDevTestAccount,
validateAccountOption,
checkIfParentAccountIsAuthed,
} = require('../../lib/localDev');

const i18nKey = 'commands.project.subcommands.dev';
Expand Down Expand Up @@ -130,19 +126,7 @@ exports.handler = async options => {
await confirmDefaultAccountIsTarget(accountConfig, hasPublicApps);

if (hasPublicApps) {
// Exit if the user has not authed the parent account in the config
if (!getAccountConfig(accountConfig.parentAccountId)) {
logger.error(
i18n(`${i18nKey}.errors.parentAccountNotConfigured`, {
accountId: accountConfig.parentAccountId,
accountIdentifier: uiAccountDescription(targetTestingAccountId),
authCommand: uiCommandReference(
`hs auth --account=${accountConfig.parentAccountId}`
),
})
);
process.exit(EXIT_CODES.ERROR);
}
checkIfParentAccountIsAuthed(accountConfig);
targetProjectAccountId = accountConfig.parentAccountId;
} else {
targetProjectAccountId = accountId;
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ en:
noProjectConfig: "No project detected. Please run this command again from a project directory."
invalidProjectComponents: "Projects cannot contain both private and public apps. Move your apps to separate projects before attempting local development."
noRunnableComponents: "No supported components were found in this project. Run {{ command }} to see a list of available components and add one to your project."
parentAccountNotConfigured: "To develop this project locally, run {{ authCommand }} to authenticate the App Developer Account {{ accountId }} associated with {{ accountIdentifier }}."
examples:
default: "Start local dev for the current project"
create:
Expand Down Expand Up @@ -1023,6 +1022,8 @@ en:
createInitialBuildForNewProject:
initialUploadMessage: "HubSpot Local Dev Server Startup"
projectLockedError: "Your project is locked. This may mean that another user is running the {{#bold}}`hs project watch`{{/bold}} command for this project. If this is you, unlock the project in Projects UI."
checkIfParentAccountIsAuthed:
notAuthedError: "To develop this project locally, run {{ authCommand }} to authenticate the App Developer Account {{ accountId }} associated with {{ accountIdentifier }}."
projects:
config:
srcOutsideProjectDir: "Invalid value for 'srcDir' in {{ projectConfig }}: {{#bold}}srcDir: \"{{ srcDir }}\"{{/bold}}\n\t'srcDir' must be a relative path to a folder under the project root, such as \".\" or \"./src\""
Expand Down
31 changes: 25 additions & 6 deletions packages/cli/lib/localDev.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,34 @@ const checkIfAppDeveloperAccount = accountConfig => {
}
};

// Confirm the default account is a developer account if developing public apps
const validateAccountOption = (accountConfig, hasPublicApps) => {
if (hasPublicApps && !isDeveloperTestAccount(accountConfig)) {
const checkIfParentAccountIsAuthed = accountConfig => {
if (!getAccountConfig(accountConfig.parentAccountId)) {
logger.error(
i18n(`${i18nKey}.validateAccountOption.invalidPublicAppAccount`, {
useCommand: uiCommandReference('hs accounts use'),
devCommand: uiCommandReference('hs project dev'),
i18n(`${i18nKey}.checkIfParentAccountIsAuthed.notAuthedError`, {
accountId: accountConfig.parentAccountId,
accountIdentifier: uiAccountDescription(accountConfig.portalId),
authCommand: uiCommandReference(
`hs auth --account=${accountConfig.parentAccountId}`
),
})
);
process.exit(EXIT_CODES.SUCCESS);
}
};

// Confirm the default account is a developer account if developing public apps
const validateAccountOption = (accountConfig, hasPublicApps) => {
if (hasPublicApps) {
if (!isDeveloperTestAccount) {
logger.error(
i18n(`${i18nKey}.validateAccountOption.invalidPublicAppAccount`, {
useCommand: uiCommandReference('hs accounts use'),
devCommand: uiCommandReference('hs project dev'),
})
);
process.exit(EXIT_CODES.SUCCESS);
}
checkIfParentAccountIsAuthed(accountConfig);
} else if (isAppDeveloperAccount(accountConfig)) {
logger.error(
i18n(`${i18nKey}.validateAccountOption.invalidPrivateAppAccount`, {
Expand Down Expand Up @@ -456,4 +474,5 @@ module.exports = {
createNewProjectForLocalDev,
createInitialBuildForNewProject,
getAccountHomeUrl,
checkIfParentAccountIsAuthed,
};
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hubspot/cli",
"version": "5.4.1-beta.0",
"version": "6.0.0",
"description": "CLI for working with HubSpot",
"license": "Apache-2.0",
"repository": {
Expand All @@ -9,7 +9,7 @@
},
"dependencies": {
"@hubspot/local-dev-lib": "1.13.0",
"@hubspot/serverless-dev-runtime": "5.4.1-beta.0",
"@hubspot/serverless-dev-runtime": "6.0.0",
"@hubspot/theme-preview-dev-server": "0.0.7",
"@hubspot/ui-extensions-dev-server": "0.8.33",
"archiver": "^5.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless-dev-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hubspot/serverless-dev-runtime",
"version": "5.4.1-beta.0",
"version": "6.0.0",
"description": "A tool for testing HubSpot CMS serverless functions locally",
"main": "index.js",
"repository": "https://github.com/HubSpot/hubspot-cli",
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-cms-plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hubspot/webpack-cms-plugins",
"version": "5.4.1-beta.0",
"version": "6.0.0",
"description": "Webpack plugins for using with the HubSpot CMS",
"license": "Apache-2.0",
"repository": {
Expand Down
Loading

0 comments on commit 795ec89

Please sign in to comment.