Skip to content

Commit

Permalink
Merge pull request #1019 from HubSpot/akb/fix-platform-version-errors
Browse files Browse the repository at this point in the history
Fix error when displaying platform version errors
  • Loading branch information
kemmerle authored Mar 14, 2024
2 parents ae2685f + d4a7a82 commit 658f618
Show file tree
Hide file tree
Showing 7 changed files with 1,426 additions and 1,457 deletions.
3 changes: 0 additions & 3 deletions packages/cli/commands/project/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const {
ensureProjectExists,
handleProjectUpload,
pollProjectBuildAndDeploy,
showPlatformVersionWarning,
validateProjectConfig,
} = require('../../lib/projects');
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
Expand Down Expand Up @@ -264,8 +263,6 @@ exports.handler = async options => {
}

if (shouldCreateProject) {
await showPlatformVersionWarning(accountId, projectConfig);

SpinniesManager.add('createProject', {
text: i18n(`${i18nKey}.status.creatingProject`, {
accountIdentifier: uiAccountDescription(targetAccountId),
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/commands/project/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const {
logFeedbackMessage,
validateProjectConfig,
pollProjectBuildAndDeploy,
showPlatformVersionWarning,
} = require('../../lib/projects');
const { i18n } = require('../../lib/lang');
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
Expand Down Expand Up @@ -47,8 +46,6 @@ exports.handler = async options => {

validateProjectConfig(projectConfig, projectDir);

await showPlatformVersionWarning(accountId, projectConfig);

await ensureProjectExists(accountId, projectConfig.name, {
forceCreate,
uploadCommand: true,
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/commands/project/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const {
pollDeployStatus,
validateProjectConfig,
logFeedbackMessage,
showPlatformVersionWarning,
} = require('../../lib/projects');
const {
cancelStagedBuild,
Expand Down Expand Up @@ -104,8 +103,6 @@ exports.handler = async options => {

validateProjectConfig(projectConfig, projectDir);

await showPlatformVersionWarning(accountId, projectConfig);

await ensureProjectExists(accountId, projectConfig.name);

try {
Expand Down
6 changes: 1 addition & 5 deletions packages/cli/lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -983,10 +983,6 @@ en:
logFeedbackMessage:
feedbackHeader: "We'd love to hear your feedback!"
feedbackMessage: "How are you liking the new projects and developer tools? \n > Run `{{#yellow}}hs feedback{{/yellow}}` to let us know what you think!\n"
showPlatformVersionWarning:
docsLink: "Projects platform versioning (BETA)"
noPlatformVersion: "No platformVersion found in hsproject.json. Falling back to default version. Starting Mar 31, 2024, new project builds without a specified version will no longer be supported. To update your project to the latest version, see {{ docsLink }}."
deprecatedVersion: "Starting Mar 31, 2024, new project builds with platformVersion 2023.1 or unspecified versions will no longer be supported. It's recommended that you update your project to the latest version. For more info, see {{ docsLink }}."
ui:
betaTag: "{{#bold}}[BETA]{{/bold}}"
betaWarning:
Expand Down Expand Up @@ -1357,7 +1353,7 @@ en:
overrideErrors:
platformVersionErrors:
header: "Platform version update required"
unspecifiedPlatformVersion: "Projects with {{#bold}}unspecified platformVersion{{/bold}} are no longer supported."
unspecifiedPlatformVersion: "Projects with an {{#bold}}{{platformVersion}}{{/bold}} are no longer supported."
platformVersionRetired: "Projects with {{#bold}} platformVersion {{ platformVersion }}{{/bold}} are no longer supported."
nonExistentPlatformVersion: "Projects with {{#bold}} platformVersion {{ platformVersion }}{{/bold}} are not supported."
updateProject: "Please update your project to the latest version and try again."
Expand Down
13 changes: 11 additions & 2 deletions packages/cli/lib/errorHandlers/overrideErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ const { uiLine, uiLink } = require('../ui');

const i18nKey = 'cli.lib.errorHandlers.overrideErrors';

function createPlatformVersionError(subCategory, errorData) {
const platformVersion = errorData.context.PLATFORM_VERSION[0];
function createPlatformVersionError(subCategory, errData) {
const docsLink = uiLink(
i18n(`${i18nKey}.platformVersionErrors.docsLink`),
'https://developers.hubspot.com/docs/platform/platform-versioning'
);

const platformVersionKey = {
[PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED]:
'unspecified platformVersion',
[PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_RETIRED]:
errData.context.RETIRED_PLATFORM_VERSION,
[PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_SPECIFIED_DOES_NOT_EXIST]:
errData.context.PLATFORM_VERSION,
};

const errorTypeToTranslationKey = {
[PLATFORM_VERSION_ERROR_TYPES.PLATFORM_VERSION_NOT_SPECIFIED]:
'unspecifiedPlatformVersion',
Expand All @@ -23,6 +31,7 @@ function createPlatformVersionError(subCategory, errorData) {
'nonExistentPlatformVersion',
};

const platformVersion = platformVersionKey[subCategory] || '';
const translationKey = errorTypeToTranslationKey[subCategory];

uiLine();
Expand Down
27 changes: 0 additions & 27 deletions packages/cli/lib/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,32 +871,6 @@ const createProjectComponent = async (
);
};

const showPlatformVersionWarning = async (accountId, projectConfig) => {
const platformVersion = projectConfig.platformVersion;
const docsLink = uiLink(
i18n(`${i18nKey}.showPlatformVersionWarning.docsLink`),
'https://developers.hubspot.com/docs/platform/platform-versioning'
);

if (!platformVersion) {
logger.log('');
logger.warn(
i18n(`${i18nKey}.showPlatformVersionWarning.noPlatformVersion`, {
docsLink,
})
);
logger.log('');
} else if (platformVersion === '2023.1') {
logger.log('');
logger.warn(
i18n(`${i18nKey}.showPlatformVersionWarning.deprecatedVersion`, {
docsLink,
})
);
logger.log('');
}
};

module.exports = {
writeProjectConfig,
getProjectConfig,
Expand All @@ -913,5 +887,4 @@ module.exports = {
ensureProjectExists,
logFeedbackMessage,
createProjectComponent,
showPlatformVersionWarning,
};
Loading

0 comments on commit 658f618

Please sign in to comment.