Skip to content

Commit

Permalink
Merge branch 'main' into br/scheduled-cli-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brandenrodgers committed Aug 22, 2024
2 parents 71bb21f + 425ef09 commit 1723ffc
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 50 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Build Failure Slack Report
if: ${{ github.ref == 'refs/heads/main' }}
uses: ravsamhq/notify-slack-action@master
with:
status: ${{ job.status }}
notify_when: 'failure'
notification_title: '{workflow} has {status_message}'
message_format: '{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
Expand Down Expand Up @@ -47,3 +37,14 @@ jobs:
env:
PORTAL_ID: ${{ secrets.ACCEPTANCE_TEST_PORTAL_ID }}
PERSONAL_ACCESS_KEY: ${{ secrets.ACCEPTANCE_TEST_PERSONAL_ACCESS_KEY }}
- name: Build Failure Slack Report
uses: ravsamhq/notify-slack-action@v2
if: ${{ always() && github.ref_name == 'main' }}
with:
status: ${{ job.status }}
notify_when: 'failure'
notification_title: 'CLI build failure'
message_format: '{emoji} *Build* {status_message} in <{repo_url}|{repo}> on <{commit_url}|{commit_sha}>"'
footer: '<{run_url}|View Run>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
29 changes: 24 additions & 5 deletions packages/cli/bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const {
const { getIsInProject } = require('../lib/projects');
const pkg = require('../package.json');
const { i18n } = require('../lib/lang');
const { EXIT_CODES } = require('../lib/enums/exitCodes');
const { UI_COLORS, uiCommandReference } = require('../lib/ui');

const removeCommand = require('../commands/remove');
const initCommand = require('../commands/init');
Expand All @@ -41,7 +43,6 @@ const accountsCommand = require('../commands/accounts');
const sandboxesCommand = require('../commands/sandbox');
const cmsCommand = require('../commands/cms');
const feedbackCommand = require('../commands/feedback');
const { EXIT_CODES } = require('../lib/enums/exitCodes');

const notifier = updateNotifier({
pkg: { ...pkg, name: '@hubspot/cli' },
Expand All @@ -51,12 +52,30 @@ const notifier = updateNotifier({

const i18nKey = 'commands.generalErrors';

const CLI_UPGRADE_MESSAGE =
chalk.bold('The CMS CLI is now the HubSpot CLI') +
'\n\nTo upgrade, run:\n\nnpm uninstall -g @hubspot/cms-cli\nand npm install -g @hubspot/cli';
const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';

notifier.notify({
message: pkg.name === '@hubspot/cms-cli' ? CLI_UPGRADE_MESSAGE : null,
message:
pkg.name === CMS_CLI_PACKAGE_NAME
? i18n(`${i18nKey}.updateNotify.cmsUpdateNotification`, {
packageName: CMS_CLI_PACKAGE_NAME,
updateCommand: uiCommandReference('{updateCommand}'),
})
: i18n(`${i18nKey}.updateNotify.cliUpdateNotification`, {
updateCommand: uiCommandReference('{updateCommand}'),
}),
defer: false,
boxenOptions: {
borderColor: UI_COLORS.MARIGOLD_DARK,
margin: 1,
padding: 1,
textAlignment: 'center',
borderStyle: 'round',
title:
pkg.name === CMS_CLI_PACKAGE_NAME
? null
: chalk.bold(i18n(`${i18nKey}.updateNotify.notifyTitle`)),
},
});

const getTerminalWidth = () => {
Expand Down
20 changes: 13 additions & 7 deletions packages/cli/commands/cms/convertFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {

const { trackConvertFieldsUsage } = require('../../lib/usageTracking');
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
const i18nKey = 'commands.convertFields';

exports.command = 'convert-fields';
Expand All @@ -24,23 +25,27 @@ const invalidPath = src => {
path: src,
})
);
process.exit(EXIT_CODES.ERROR);
};

exports.handler = async options => {
const src = path.resolve(getCwd(), options.src);
const themeJSONPath = getThemeJSONPath(src);
const projectRoot = themeJSONPath
? path.dirname(themeJSONPath)
: path.dirname(getCwd());
let stats;
let projectRoot;
let src;

try {
src = path.resolve(getCwd(), options.src);
const themeJSONPath = getThemeJSONPath(options.src);
projectRoot = themeJSONPath
? path.dirname(themeJSONPath)
: path.dirname(getCwd());
stats = fs.statSync(src);
if (!stats.isFile() && !stats.isDirectory()) {
invalidPath(src);
invalidPath(options.src);
return;
}
} catch (e) {
invalidPath(src);
invalidPath(options.src);
}

trackConvertFieldsUsage('process');
Expand Down Expand Up @@ -88,6 +93,7 @@ exports.builder = yargs => {
yargs.option('src', {
describe: i18n(`${i18nKey}.positionals.src.describe`),
type: 'string',
demandOption: i18n(`${i18nKey}.errors.missingSrc`),
});
yargs.option('fieldOptions', {
describe: i18n(`${i18nKey}.options.options.describe`),
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/lang/en.lyaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
en:
commands:
generalErrors:
updateNotify:
notifyTitle: "Update available"
cmsUpdateNotification: "{{#bold}}The CMS CLI is now the HubSpot CLI{{/bold}}\n\nTo upgrade, uninstall {{#bold}}{{ packageName }}{{/bold}}\nand then run {{ updateCommand }}"
cliUpdateNotification: "HubSpot CLI version {{#cyan}}{{#bold}}{currentVersion}{{/bold}}{{/cyan}} is outdated.\nRun {{ updateCommand }} to upgrade to version {{#cyan}}{{#bold}}{latestVersion}{{/bold}}{{/cyan}}"
srcIsProject: "\"{{ src }}\" is in a project folder. Did you mean \"hs project {{command}}\"?"
setDefaultAccountMoved: "This command has moved. Try `hs accounts use` instead"
accounts:
Expand Down Expand Up @@ -964,6 +968,10 @@ en:
options:
options:
describe: "Options to pass to javascript fields files"
errors:
invalidPath: "The path \"{{ path }}\" specified in the \"--src\" flag is not a path to a file or directory"
missingSrc: "Please specify the path to your javascript fields file or directory with the --src flag."

lib:
process:
exitDebug: "Attempting to gracefully exit. Triggered by {{ signal }}"
Expand Down
31 changes: 3 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8098,16 +8098,7 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

"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:
"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:
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 @@ -8148,7 +8139,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-cjs@npm:strip-ansi@^6.0.1", 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==
Expand All @@ -8162,13 +8153,6 @@ 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 @@ -8857,7 +8841,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-cjs@npm:wrap-ansi@^7.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==
Expand All @@ -8875,15 +8859,6 @@ 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 1723ffc

Please sign in to comment.