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

feat: Add translation to IR #1252

Open
wants to merge 13 commits into
base: next
Choose a base branch
from
10 changes: 9 additions & 1 deletion commands/project/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ exports.handler = async options => {

const { projectConfig, projectDir } = await getProjectConfig();

trackCommandUsage('project-upload', { type: accountType }, derivedAccountId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a duplicate tracking call?


validateProjectConfig(projectConfig, projectDir);

await ensureProjectExists(derivedAccountId, projectConfig.name, {
Expand All @@ -56,7 +58,8 @@ exports.handler = async options => {
projectConfig,
projectDir,
pollProjectBuildAndDeploy,
message
message,
options.translate
);

if (result.uploadError) {
Expand Down Expand Up @@ -128,6 +131,11 @@ exports.builder = yargs => {
type: 'string',
default: '',
},
translate: {
hidden: true,
type: 'boolean',
default: false,
},
Comment on lines +134 to +138
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to hs project upload but not hs project watch primarily because hs project watch gets almost no usage, and there were some other road bumps, such as hs project watch doesn't work unless your project already has a successful build, which is not currently achievable with the new system.

I can add the options to hs project watch if we think it is worthwhile, but the command won't work until build scheduling is in place and component teams have begun to implement their builds.

});

yargs.example([['$0 project upload', i18n(`${i18nKey}.examples.default`)]]);
Expand Down
35 changes: 30 additions & 5 deletions lib/projects/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { uiAccountDescription } from '../ui';
import { i18n } from '../lang';
import { EXIT_CODES } from '../enums/exitCodes';
import { ProjectConfig } from '../../types/Projects';
import { isTranslationError, translate } from '@hubspot/project-parsing-lib';
import { logError } from '../errorHandlers';

const i18nKey = 'lib.projectUpload';

Expand All @@ -19,7 +21,8 @@ async function uploadProjectFiles(
projectName: string,
filePath: string,
uploadMessage: string,
platformVersion: string
platformVersion: string,
intermediateRepresentation?: unknown
): Promise<{ buildId?: number; error: unknown }> {
SpinniesManager.init({});
const accountIdentifier = uiAccountDescription(accountId);
Expand All @@ -41,10 +44,11 @@ async function uploadProjectFiles(
projectName,
filePath,
uploadMessage,
platformVersion
platformVersion,
intermediateRepresentation
);

buildId = upload.buildId;
buildId = upload.buildId!;

SpinniesManager.succeed('upload', {
text: i18n(`${i18nKey}.uploadProjectFiles.succeed`, {
Expand Down Expand Up @@ -89,7 +93,8 @@ export async function handleProjectUpload<T = ProjectUploadDefaultResult>(
projectConfig: ProjectConfig,
projectDir: string,
callbackFunc: ProjectUploadCallbackFunction<T>,
uploadMessage: string
uploadMessage: string,
sendIR: boolean = false
) {
const srcDir = path.resolve(projectDir, projectConfig.srcDir);

Expand Down Expand Up @@ -124,12 +129,32 @@ export async function handleProjectUpload<T = ProjectUploadDefaultResult>(
})
);

let intermediateRepresentation;

if (sendIR) {
try {
intermediateRepresentation = await translate({
projectSourceDir: path.join(projectDir, projectConfig.srcDir),
platformVersion: projectConfig.platformVersion,
accountId,
});
} catch (e) {
if (isTranslationError(e)) {
logger.error(e.toString());
} else {
logError(e);
}
return process.exit(EXIT_CODES.ERROR);
}
}

const { buildId, error } = await uploadProjectFiles(
accountId,
projectConfig.name,
tempFile.name,
uploadMessage,
projectConfig.platformVersion
projectConfig.platformVersion,
intermediateRepresentation
);

if (error) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "Apache-2.0",
"repository": "https://github.com/HubSpot/hubspot-cli",
"dependencies": {
"@hubspot/local-dev-lib": "3.0.2",
"@hubspot/local-dev-lib": "3.1.0",
"@hubspot/project-parsing-lib": "0.0.1",
"@hubspot/serverless-dev-runtime": "7.0.0",
"@hubspot/theme-preview-dev-server": "0.0.10",
"@hubspot/ui-extensions-dev-server": "0.8.33",
Expand Down
56 changes: 23 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1463,10 +1463,10 @@
semver "^6.3.0"
unixify "^1.0.0"

"@hubspot/local-dev-lib@3.0.2":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@hubspot/local-dev-lib/-/local-dev-lib-3.0.2.tgz#8412c26c51d26cdb015312f5c5ac2daeced5e30f"
integrity sha512-brpFWcQIdP71YzwQ2ZMKqChzIEo4cCLJYPCTTVmMUwmuXtL35T/7vL06OukNEND5+B8VlmZeJ4PMrvsAT4YuWA==
"@hubspot/local-dev-lib@3.1.0", "@hubspot/local-dev-lib@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@hubspot/local-dev-lib/-/local-dev-lib-3.1.0.tgz#76b5d524aa694aad2bfc6e199ee1dac314f15774"
integrity sha512-iop3PgZ0ZWejCH6PmSeYnnGwV8vGIuA4F+w7SxukdX3QfhivlczClATWPaZanv1CYJHdflqoItq1kdF8ASJJmA==
dependencies:
address "^2.0.1"
axios "^1.3.5"
Expand All @@ -1487,6 +1487,15 @@
semver "^6.3.0"
unixify "^1.0.0"

"@hubspot/[email protected]":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@hubspot/project-parsing-lib/-/project-parsing-lib-0.0.1.tgz#fd1f823abbe410d97446bd5fc804b2e9bf40402e"
integrity sha512-7Qqc6YplKTYG2skswVtNc02iCIuPd816vZT3I4HTYzJRQ9EqYTPZ7QLrL9VSTkLNkUyHw0AJE1qeQJqye1eAfQ==
dependencies:
"@hubspot/local-dev-lib" "^3.1.0"
ajv "^8.17.1"
ajv-draft-04 "^1.0.0"

"@hubspot/[email protected]":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@hubspot/serverless-dev-runtime/-/serverless-dev-runtime-7.0.0.tgz#dffe8101e3a9b79fa768691daa2c9ba1f86c25d6"
Expand Down Expand Up @@ -3914,6 +3923,11 @@ aggregate-error@^3.0.0:
clean-stack "^2.0.0"
indent-string "^4.0.0"

ajv-draft-04@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ajv-draft-04/-/ajv-draft-04-1.0.0.tgz#3b64761b268ba0b9e668f0b41ba53fce0ad77fc8"
integrity sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==

ajv@^6.12.3, ajv@^6.12.4:
version "6.12.6"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
Expand All @@ -3924,7 +3938,7 @@ ajv@^6.12.3, ajv@^6.12.4:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"

ajv@^8.0.1:
ajv@^8.0.1, ajv@^8.17.1:
version "8.17.1"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.17.1.tgz#37d9a5c776af6bc92d7f4f9510eba4c0a60d11a6"
integrity sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==
Expand Down Expand Up @@ -10485,16 +10499,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@^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@^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 @@ -10563,7 +10568,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 @@ -10577,13 +10582,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 @@ -11570,7 +11568,8 @@ 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:
name wrap-ansi-cjs
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 @@ -11588,15 +11587,6 @@ 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
Loading