Skip to content

Commit

Permalink
Merge pull request #1193 from HubSpot/br/dependency-cleanup
Browse files Browse the repository at this point in the history
Cleaning up some older dependencies
  • Loading branch information
brandenrodgers authored Oct 3, 2024
2 parents a349774 + 4867d7f commit 262bc74
Show file tree
Hide file tree
Showing 9 changed files with 460 additions and 731 deletions.
6 changes: 0 additions & 6 deletions acceptance-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,3 @@ A couple of accounts have been set up specifically for testing. They are QA Acco
## Issues

The `.env` file does not get recognized when running [act](https://github.com/nektos/act) locally to run the tests within the github action. To bypass this, you can comment out the `.env` line in the `.gitignore` file and run `act again`. See https://github.com/nektos/act/issues/193 for more info.

## Gotchas

- Currently the personal-access-key test is flakey. Run the tests again and it should pass.

- The tests seem to trip up on usages of the `ora` library. To get around this, we have a list of blacklisted strings. If your test is being picky about ora, add the error message to the blacklist in `cmd.js`
2 changes: 1 addition & 1 deletion acceptance-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"devDependencies": {
"concat-stream": "^2.0.0",
"cross-spawn": "^7.0.3",
"dotenv": "^8.2.0",
"dotenv": "^16.4.5",
"jasmine": "^3.7.0",
"jasmine-terminal-reporter": "^1.0.3",
"js-yaml": "^4.0.0",
Expand Down
1 change: 0 additions & 1 deletion acceptance-tests/tests/helpers/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ function executeWithInput(
const handleStderr = err => {
// Ignore any allowed errors so tests can continue
const allowedErrors = [
'Loading available API samples', // When we use 'ora' it is throwing the loading error
'DeprecationWarning', // Ignore package deprecation warnings.
'[WARNING]', // Ignore our own CLI warning messages
];
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"devDependencies": {
"depcheck": "1.3.1",
"eslint": "^8.56.0",
"husky": "^1.3.1",
"husky": "^4.3.8",
"lerna": "^6.6.1",
"lint-staged": "^10.5.4",
"madge": "^6.1.0",
"madge": "^8.0.0",
"prettier": "^1.19.1",
"sass": "~1.29.0"
},
Expand Down
6 changes: 2 additions & 4 deletions packages/cli/commands/create/api-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const {
const { logger } = require('@hubspot/local-dev-lib/logger');
const path = require('path');
const fs = require('fs-extra');
const ora = require('ora');
const {
fetchFileFromRepository,
cloneGithubRepo,
Expand Down Expand Up @@ -37,14 +36,13 @@ module.exports = {
return;
}
}
const downloadSpinner = ora(i18n(`${i18nKey}.loading.apiSamples`));
downloadSpinner.start();

const samplesConfig = await fetchFileFromRepository(
'HubSpot/sample-apps-list',
'samples.json',
'main'
);
downloadSpinner.stop();

if (!samplesConfig) {
logger.error(i18n(`${i18nKey}.errors.noSamples`));
return;
Expand Down
34 changes: 21 additions & 13 deletions packages/cli/commands/functions/deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const ora = require('ora');
const SpinniesManager = require('../../lib/ui/SpinniesManager');
const {
addAccountOptions,
addConfigOptions,
Expand All @@ -7,7 +7,7 @@ const {
} = require('../../lib/commonOpts');
const { trackCommandUsage } = require('../../lib/usageTracking');
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');

const { uiAccountDescription } = require('../../lib/ui');
const { poll } = require('../../lib/polling');
const { logger } = require('@hubspot/local-dev-lib/logger');
const {
Expand All @@ -30,7 +30,6 @@ exports.handler = async options => {
const { path: functionPath } = options;
const accountId = getAccountId(options);
const splitFunctionPath = functionPath.split('.');
let spinner;

trackCommandUsage('functions-deploy', null, accountId);

Expand All @@ -52,17 +51,22 @@ exports.handler = async options => {
})
);

SpinniesManager.init();

SpinniesManager.add('loading', {
text: i18n(`${i18nKey}.loading`, {
account: uiAccountDescription(accountId),
functionPath,
}),
});

try {
spinner = ora(
i18n(`${i18nKey}.loading`, {
accountId,
functionPath,
})
).start();
const { data: buildId } = await buildPackage(accountId, functionPath);
const successResp = await poll(getBuildStatus, accountId, buildId);
const buildTimeSeconds = (successResp.buildTime / 1000).toFixed(2);
spinner.stop();

SpinniesManager.succeed('loading');

await outputBuildLog(successResp.cdnUrl);
logger.success(
i18n(`${i18nKey}.success.deployed`, {
Expand All @@ -72,15 +76,19 @@ exports.handler = async options => {
})
);
} catch (e) {
spinner && spinner.stop && spinner.stop();
SpinniesManager.fail('loading', {
text: i18n(`${i18nKey}.loadingFailed`, {
account: uiAccountDescription(accountId),
functionPath,
}),
});

if (isHubSpotHttpError(e) && e.status === 404) {
logger.error(
i18n(`${i18nKey}.errors.noPackageJson`, {
functionPath,
})
);
} else if (isHubSpotHttpError(e) && e.status === 400) {
logger.error(e.error.message);
} else if (e.status === 'ERROR') {
await outputBuildLog(e.cdnUrl);
logger.error(
Expand Down
5 changes: 2 additions & 3 deletions packages/cli/lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ en:
noSamples: "Currently there are no samples available, please, try again later."
info:
sampleChosen: "You've chosen {{ sampleType }} sample written on {{ sampleLanguage }} language"
loading:
apiSamples: "Loading available API samples"
success:
sampleCreated: "Please, follow {{ filePath }}/README.md to find out how to run the sample"
module:
Expand Down Expand Up @@ -335,7 +333,8 @@ en:
notFunctionsFolder: "Specified path {{ functionPath }} is not a .functions folder."
examples:
default: "Build and deploy a new bundle for all functions within the myFunctionFolder.functions folder"
loading: "Building and deploying bundle for \"{{ functionPath }}\" on account \"{{ accountId }}\".\n"
loading: "Building and deploying bundle for \"{{ functionPath }}\" on {{ account }}"
loadingFailed: "Failed to build and deploy bundle for \"{{ functionPath }}\" on {{ account }}"
positionals:
path:
describe: "Path to .functions folder"
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
"js-yaml": "^4.1.0",
"moment": "^2.29.1",
"open": "^7.0.3",
"ora": "^4.0.3",
"p-queue": "^6.0.2",
"strip-ansi": "^5.2.0",
"table": "^6.6.0",
"tmp": "^0.2.1",
"update-notifier": "^5.1.0",
"yargs": "15.4.1"
"yargs": "17.7.2"
},
"devDependencies": {
"axios": "^1.7.2",
Expand Down
Loading

0 comments on commit 262bc74

Please sign in to comment.