Skip to content

Changes pre-ET - #48

Merged
jsines merged 5 commits into
js/hs-previewfrom
js/hs-preview-preempathytest
Feb 8, 2024
Merged

Changes pre-ET#48
jsines merged 5 commits into
js/hs-previewfrom
js/hs-preview-preempathytest

Conversation

@jsines

@jsines jsines commented Feb 7, 2024

Copy link
Copy Markdown

Lots of changes - I'll comment throughout

See also HubSpot/hubspot-cli#996

Comment thread api/domains.js
} catch (err) {
throw err;
}
return result.results;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Since we just throw here we can remove the catch and rethrow

Comment thread lib/config.js
};

module.exports = {
getAuthType,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moving this to config to be useable elsewhere

Comment thread lib/preview.js
} = require('./preview/previewUtils');
const { markRemoteFsDirty } = require('./preview/routes/meta');
const { startShadowDevServer } = require('./preview/shadowDevServer');
const { startSprocketMenuServer } = require('./preview/sprocketMenuServer');

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

shadowDevServer -> sprocketMenuServer to be a little more obvious what it's for

Comment thread lib/preview.js
const { portalId, src, dest } = sessionInfo;

return uploadFolder(portalId, src, dest, fileMapperArgs, {}, filePaths);
const { accountId, src, dest } = sessionInfo;

@jsines jsines Feb 7, 2024

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated the initial upload to be less spammy and only draw attention if there's actually a problem - instead display a progress bar & print out any errors at the end

Screen.Recording.2024-02-07.at.3.17.21.PM.mov

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I generally like this pattern better, because it is cleaner in the terminal -- but I'm not sure if there is discussion to be had about this pattern being globalized as the standard 'upload' pattern for the CLI

cc @brandenrodgers - we have the cli guidelines being formed right now and I saw on the doc that the component library was slotted to include progress indicators - We are somewhat straying from what is the current pattern for uploading here for the moment, do you have any concerns about that for the interim? I'm assuming that once the guidelines are established, we can circle back and match the decided upon pattern.

unlinkSync(`${__dirname}/key.pem`);
unlinkSync(`${__dirname}/cert.pem`);
unlinkSync(`${os.tmpdir()}/hstmp/hsLocalSshKey.pem`);
unlinkSync(`${os.tmpdir()}/hstmp/hsLocalSshCert.pem`);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Put these in the os temp dir feels a little cleaner pattern for the millisecond they exist before they get deleted. Should be cross platform but I'll make sure

nextWait *= BACKOFF_RATIO;
if (nextWait * BACKOFF_RATIO <= MAX_WAIT) {
nextWait *= BACKOFF_RATIO;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Figured I'd cap this while I'm in here and close an open issue

${ domains.length ?
getSiteList(domains, PORT) :
"<p>No domains found. You either don't have any domains set up in your portal or your personal access key is missing a scope 'cms.domains.read' required for this feature.</p>"
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We log the error to console if the scope is missing but good to put one here too.

Comment thread lib/uploadFolder.js
filePaths = []
) {
const { saveOutput, convertFields } = commandOptions;
const {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Adjusted this to allow overriding the places that would otherwise log so that we can hook in the progress bar hooks. Should have no effect to current usage if these aren't passed in.

Comment thread personalAccessKey.js
}

async function getNewAccessToken(accountId, personalAccessKey, expiresAt, env) {
async function getNewAccessToken(accountId, personalAccessKey, expiresAt, env, fullAPIResponse=false) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Previous implementation to get the enabledFeatures fetched to refresh the access key but didn't write it to the config if it got a new one - fixes that

Comment thread lib/uploadFolder.js Outdated

@j-malt j-malt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

One minor style point but looks good!

@TanyaScales TanyaScales left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should go back through and i18n all the strings in here -- however, you might find on porting to local-dev-lib that these errors will be thrown there and i18n might occur on that end, while you just display/log it on this side.

Comment thread lib/preview.js
const { portalId, src, dest } = sessionInfo;

return uploadFolder(portalId, src, dest, fileMapperArgs, {}, filePaths);
const { accountId, src, dest } = sessionInfo;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I generally like this pattern better, because it is cleaner in the terminal -- but I'm not sure if there is discussion to be had about this pattern being globalized as the standard 'upload' pattern for the CLI

cc @brandenrodgers - we have the cli guidelines being formed right now and I saw on the doc that the component library was slotted to include progress indicators - We are somewhat straying from what is the current pattern for uploading here for the moment, do you have any concerns about that for the interim? I'm assuming that once the guidelines are established, we can circle back and match the decided upon pattern.

Comment thread lib/preview.js Outdated
Comment thread lib/preview.js Outdated
Comment thread lib/preview/previewUtils.js
Comment thread lib/preview/previewUtils.js Outdated
Comment thread lib/preview/routes/index.js
Comment thread lib/preview/routes/module.js Outdated
jsines and others added 2 commits February 8, 2024 13:29
Co-authored-by: Tanya Scales <4976331+TanyaScales@users.noreply.github.com>
@jsines
jsines merged commit 832ccae into js/hs-preview Feb 8, 2024
@jsines
jsines deleted the js/hs-preview-preempathytest branch February 8, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants