Skip to content

Commit

Permalink
Merge branch 'main' of github.com:HubSpot/hubspot-cli into next
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-yeager committed Aug 27, 2024
2 parents 8b79343 + 4b63d83 commit 1e699d9
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 46 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/latestPublish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
on:
workflow_dispatch:
push:
tags:
- '*'
Expand All @@ -9,6 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Sleep when triggered by new tag to wait for npm publish
- name: Sleep For 3 Mins
run: sleep 180s
Expand All @@ -32,7 +34,7 @@ jobs:
status: ${{ job.status }}
notify_when: 'failure'
notification_title: 'CLI latest release failure'
message_format: '{emoji} *Release* {status_message}'
message_format: '{emoji} *NPM Release* {status_message}'
footer: '<{run_url}|View Run> | <https://www.npmjs.com/package/@hubspot/cli?activeTab=versions|View in NPM>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
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.2.1-beta.12",
"version": "5.4.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.3.1"
"version": "5.4.0"
}
15 changes: 10 additions & 5 deletions packages/cli/commands/project/cloneApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const {
checkCloneStatus,
downloadClonedProject,
} = require('@hubspot/local-dev-lib/api/projects');
const { getCwd } = require('@hubspot/local-dev-lib/path');
const { getCwd, sanitizeFileName } = require('@hubspot/local-dev-lib/path');
const { logger } = require('@hubspot/local-dev-lib/logger');
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
const { extractZipArchive } = require('@hubspot/local-dev-lib/archive');
Expand Down Expand Up @@ -123,10 +123,15 @@ exports.handler = async options => {
accountId,
exportId
);
await extractZipArchive(zippedApp, name, absoluteDestPath, {
includesRootDir: true,
hideLogs: true,
});
await extractZipArchive(
zippedApp,
sanitizeFileName(name),
absoluteDestPath,
{
includesRootDir: true,
hideLogs: true,
}
);

// Create hsproject.json file
const configPath = path.join(baseDestPath, PROJECT_CONFIG_FILE);
Expand Down
12 changes: 7 additions & 5 deletions packages/cli/commands/project/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ const {
confirmDefaultAccountIsTarget,
suggestRecommendedNestedAccount,
checkIfAppDeveloperAccount,
checkIfDeveloperTestAccount,
createSandboxForLocalDev,
createDeveloperTestAccountForLocalDev,
createNewProjectForLocalDev,
createInitialBuildForNewProject,
useExistingDevTestAccount,
validateAccountOption,
} = require('../../lib/localDev');

const i18nKey = 'commands.project.subcommands.dev';
Expand Down Expand Up @@ -106,10 +106,12 @@ exports.handler = async options => {
// The account that we are locally testing against
let targetTestingAccountId = options.account ? accountId : null;

if (options.account && hasPublicApps) {
checkIfDeveloperTestAccount(accountConfig);
targetProjectAccountId = accountConfig.parentAccountId;
targetTestingAccountId = accountId;
if (options.account) {
validateAccountOption(accountConfig, hasPublicApps);

if (hasPublicApps) {
targetProjectAccountId = accountConfig.parentAccountId;
}
}

let createNewSandbox = false;
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/commands/project/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {
addUseEnvironmentOptions,
} = require('../../lib/commonOpts');
const { trackCommandUsage } = require('../../lib/usageTracking');
const { getCwd } = require('@hubspot/local-dev-lib/path');
const { getCwd, sanitizeFileName } = require('@hubspot/local-dev-lib/path');
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
const { logger } = require('@hubspot/local-dev-lib/logger');
const { extractZipArchive } = require('@hubspot/local-dev-lib/archive');
Expand Down Expand Up @@ -93,7 +93,7 @@ exports.handler = async options => {

await extractZipArchive(
zippedProject,
projectName,
sanitizeFileName(projectName),
path.resolve(absoluteDestPath),
{ includesRootDir: false }
);
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/commands/project/migrateApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const {
migrateApp,
checkMigrationStatus,
} = require('@hubspot/local-dev-lib/api/projects');
const { getCwd } = require('@hubspot/local-dev-lib/path');
const { getCwd, sanitizeFileName } = require('@hubspot/local-dev-lib/path');
const { logger } = require('@hubspot/local-dev-lib/logger');
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
const { downloadProject } = require('@hubspot/local-dev-lib/api/projects');
Expand Down Expand Up @@ -194,7 +194,7 @@ exports.handler = async options => {

await extractZipArchive(
zippedProject,
projectName,
sanitizeFileName(projectName),
path.resolve(absoluteDestPath),
{ includesRootDir: true, hideLogs: true }
);
Expand All @@ -217,7 +217,9 @@ exports.handler = async options => {
logger.log(
uiLink(
i18n(`${i18nKey}.projectDetailsLink`),
`${baseUrl}/developer-projects/${accountId}/project/${project.name}`
`${baseUrl}/developer-projects/${accountId}/project/${encodeURIComponent(
project.name
)}`
)
);
process.exit(EXIT_CODES.SUCCESS);
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,9 +1018,10 @@ en:
localDev:
confirmDefaultAccountIsTarget:
declineDefaultAccountExplanation: "To develop on a different account, run {{ useCommand }} to change your default account, then re-run {{ devCommand }}."
checkIfAppDevloperAccount: "This project contains a public app. Local development of public apps is only supported on developer accounts and developer test accounts. Change your default account using {{#bold}}`hs accounts use`{{/bold}}, or link a new account with {{#bold}}`hs auth`{{/bold}}."
checkIfDeveloperTestAccount: "This project contains a public app. The \"--account\" flag must point to a developer test account to develop this project locally. Alternatively, change your default account to an App Developer Account using {{#bold}}`hs accounts use`{{/bold}} and run {{#bold}}`hs project dev`{{/bold}} to set up a new Developer Test Account."
suggestRecommendedNestedAccount:
checkIfAppDevloperAccount: "This project contains a public app. Local development of public apps is only supported on developer accounts and developer test accounts. Change your default account using {{ useCommand }}, or link a new account with {{ authCommand }}."
validateAccountOption:
invalidPublicAppAccount: "This project contains a public app. The \"--account\" flag must point to a developer test account to develop this project locally. Alternatively, change your default account to an App Developer Account using {{ useCommand }} and run {{ devCommand }} to set up a new Developer Test Account."
invalidPrivateAppAccount: "This project contains a private app. The account specified with the \"--account\" flag points to a developer account, which do not support the local development of private apps. Update the \"--account\" flag to point to a standard, sandbox, or developer test account, or change your default account by running {{ useCommand }}."
nonSandboxWarning: "Testing in a sandbox is strongly recommended. To switch the target account, select an option below or run {{#bold}}`hs accounts use`{{/bold}} before running the command again."
publicAppNonDeveloperTestAccountWarning: "Local development of public apps is only supported in {{#bold}}developer test accounts{{/bold}}."
privateAppInAppDeveloperAccountError: "Local development of private apps is not supported in {{#bold}}app developer accounts{{/bold}}"
Expand Down
35 changes: 25 additions & 10 deletions packages/cli/lib/localDev.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,32 @@ const confirmDefaultAccountIsTarget = async accountConfig => {
// Confirm the default account is a developer account if developing public apps
const checkIfAppDeveloperAccount = accountConfig => {
if (!isAppDeveloperAccount(accountConfig)) {
logger.error(i18n(`${i18nKey}.checkIfAppDevloperAccount`));
logger.error(
i18n(`${i18nKey}.checkIfAppDevloperAccount`, {
useCommand: uiCommandReference('hs accounts use'),
authCommand: uiCommandReference('hs auth'),
})
);
process.exit(EXIT_CODES.SUCCESS);
}
};

// Confirm the default account is a developer account if developing public apps
const checkIfDeveloperTestAccount = accountConfig => {
if (!isDeveloperTestAccount(accountConfig)) {
logger.error(i18n(`${i18nKey}.checkIfDeveloperTestAccount`));
const validateAccountOption = (accountConfig, hasPublicApps) => {
if (hasPublicApps && !isDeveloperTestAccount(accountConfig)) {
logger.error(
i18n(`${i18nKey}.validateAccountOption.invalidPublicAppAccount`, {
useCommand: uiCommandReference('hs accounts use'),
devCommand: uiCommandReference('hs project dev'),
})
);
process.exit(EXIT_CODES.SUCCESS);
} else if (isAppDeveloperAccount(accountConfig)) {
logger.error(
i18n(`${i18nKey}.validateAccountOption.invalidPrivateAppAccount`, {
useCommand: uiCommandReference('hs accounts use'),
})
);
process.exit(EXIT_CODES.SUCCESS);
}
};
Expand All @@ -105,20 +122,18 @@ const suggestRecommendedNestedAccount = async (
if (hasPublicApps) {
logger.log(
i18n(
`${i18nKey}.suggestRecommendedNestedAccount.publicAppNonDeveloperTestAccountWarning`
`${i18nKey}.validateAccountOption.publicAppNonDeveloperTestAccountWarning`
)
);
} else if (isAppDeveloperAccount(accountConfig)) {
logger.error(
i18n(
`${i18nKey}.suggestRecommendedNestedAccount.privateAppInAppDeveloperAccountError`
`${i18nKey}.validateAccountOption.privateAppInAppDeveloperAccountError`
)
);
process.exit(EXIT_CODES.ERROR);
} else {
logger.log(
i18n(`${i18nKey}.suggestRecommendedNestedAccount.nonSandboxWarning`)
);
logger.log(i18n(`${i18nKey}.validateAccountOption.nonSandboxWarning`));
}
uiLine();
logger.log();
Expand Down Expand Up @@ -438,7 +453,7 @@ const getAccountHomeUrl = accountId => {
module.exports = {
confirmDefaultAccountIsTarget,
checkIfAppDeveloperAccount,
checkIfDeveloperTestAccount,
validateAccountOption,
suggestRecommendedNestedAccount,
createSandboxForLocalDev,
createDeveloperTestAccountForLocalDev,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ const handleProjectUpload = async (
buildId
);
}
resolve(uploadResult);
resolve(uploadResult || {});
})
);

Expand Down
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.3.1",
"version": "5.4.0",
"description": "CLI for working with HubSpot",
"license": "Apache-2.0",
"repository": {
Expand All @@ -11,7 +11,7 @@
"@hubspot/local-dev-lib": "1.10.0",
"@hubspot/serverless-dev-runtime": "5.3.0",
"@hubspot/theme-preview-dev-server": "0.0.7",
"@hubspot/ui-extensions-dev-server": "0.8.20",
"@hubspot/ui-extensions-dev-server": "0.8.30",
"archiver": "^5.3.0",
"chalk": "^4.1.2",
"chokidar": "^3.0.1",
Expand Down
49 changes: 37 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,10 @@
node-fetch "^2.6.0"
url-parse "^1.4.3"

"@hubspot/[email protected].20":
version "0.8.20"
resolved "https://registry.yarnpkg.com/@hubspot/app-functions-dev-server/-/app-functions-dev-server-0.8.20.tgz#b6fd7f394a6f2c57b3713bfca5e7df15dd9275f4"
integrity sha512-0hFHwIynId1VKxr9bQQ8tTDJxzJEZQ7c0No0Qw33eJ/MxiuAUIy5M+a5pQN2xwkJikTceeOxw39/KwAYfKP7ew==
"@hubspot/[email protected].30":
version "0.8.30"
resolved "https://registry.yarnpkg.com/@hubspot/app-functions-dev-server/-/app-functions-dev-server-0.8.30.tgz#180731099f4b9fd323c96dcf6498260f944f2c59"
integrity sha512-aovkWpBLX4wjtAGr14tg8ofaeiFEV42wkRqxJ0EU9Xqr1K5v4eitziLxyr2LFRktVxGyLZgDwLUBqrfx9DR+RA==
dependencies:
"@hubspot/api-client" "^10.0.0"
axios "^1.6.8"
Expand Down Expand Up @@ -508,12 +508,12 @@
express "^4.18.2"
node-fetch "2.7.0"

"@hubspot/[email protected].20":
version "0.8.20"
resolved "https://registry.yarnpkg.com/@hubspot/ui-extensions-dev-server/-/ui-extensions-dev-server-0.8.20.tgz#8102ae1a3d4277b144389c62542e629a6bbbba78"
integrity sha512-nKvKkB35CQn2eyBBVsL2DuWBEJQLeUpGPWQHyd7ygY2RpxlY1yVIhMpjTmI4SZ6N4gi0gjbrbzXo7yKFWb08qQ==
"@hubspot/[email protected].30":
version "0.8.30"
resolved "https://registry.yarnpkg.com/@hubspot/ui-extensions-dev-server/-/ui-extensions-dev-server-0.8.30.tgz#02f955fda61b0a0ca6f9c3e723a88daaf8414192"
integrity sha512-S4x++uE+EfAZ5AM3q4S+Dx+/IykjJK7axjS9dkLQpUPTfBHIOLKrquhwQpnSI+RH5LMnlHzwTOcv1NySFWVSGg==
dependencies:
"@hubspot/app-functions-dev-server" "0.8.20"
"@hubspot/app-functions-dev-server" "0.8.30"
cors "^2.8.5"
detect-port "1.5.1"
estraverse "^5.3.0"
Expand Down Expand Up @@ -8098,7 +8098,16 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -8139,7 +8148,7 @@ stringify-object@^3.2.1, stringify-object@^3.3.0:
is-obj "^1.0.1"
is-regexp "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -8153,6 +8162,13 @@ strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -8841,7 +8857,7 @@ wordwrap@^1.0.0:
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -8859,6 +8875,15 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 1e699d9

Please sign in to comment.