Skip to content

Commit

Permalink
Merge pull request #955 from HubSpot/swap-cli-lib-deps-3
Browse files Browse the repository at this point in the history
Swap deps to local dev lib part 3
  • Loading branch information
camden11 authored Nov 30, 2023
2 parents b2d2711 + 27828a2 commit 9adec5f
Show file tree
Hide file tree
Showing 30 changed files with 131 additions and 113 deletions.
2 changes: 1 addition & 1 deletion packages/cli/commands/accounts/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {
} = require('../../lib/commonOpts');
const { getAccountName } = require('../../lib/sandboxes');
const { promptUser } = require('../../lib/prompts/promptUtils');
const { getTableContents } = require('@hubspot/cli-lib/lib/table');
const { getTableContents } = require('@hubspot/local-dev-lib/logging/table');
const SpinniesManager = require('../../lib/SpinniesManager');
const { getConfig, deleteAccount } = require('@hubspot/local-dev-lib/config');
const {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/commands/accounts/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
} = require('../../lib/commonOpts');
const { loadAndValidateOptions } = require('../../lib/validation');
const { i18n } = require('../../lib/lang');
const { getTableContents } = require('@hubspot/cli-lib/lib/table');
const { getTableContents } = require('@hubspot/local-dev-lib/logging/table');

const i18nKey = 'cli.commands.accounts.subcommands.info';
exports.describe = i18n(`${i18nKey}.describe`);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/commands/accounts/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { getConfig, getConfigPath } = require('@hubspot/local-dev-lib/config');
const {
getTableContents,
getTableHeader,
} = require('@hubspot/cli-lib/lib/table');
} = require('@hubspot/local-dev-lib/logging/table');

const {
addConfigOptions,
Expand Down
10 changes: 8 additions & 2 deletions packages/cli/commands/cms/convertFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fs = require('fs');
const { createIgnoreFilter } = require('@hubspot/local-dev-lib/ignoreRules');
const { isAllowedExtension, getCwd } = require('@hubspot/cli-lib/path');
const { logger } = require('@hubspot/cli-lib/logger');
const { walk } = require('@hubspot/cli-lib/lib/walk');
const { walk } = require('@hubspot/local-dev-lib/fs');
const { getThemeJSONPath } = require('@hubspot/cli-lib/lib/files');
const { i18n } = require('../../lib/lang');
const {
Expand All @@ -12,6 +12,7 @@ const {
} = require('@hubspot/cli-lib/lib/handleFieldsJs');

const { trackConvertFieldsUsage } = require('../../lib/usageTracking');
const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
const i18nKey = 'cli.commands.convertFields';

exports.command = 'convert-fields';
Expand Down Expand Up @@ -54,7 +55,12 @@ exports.handler = async options => {
if (fieldsJs.rejected) return;
fieldsJs.saveOutput();
} else if (stats.isDirectory()) {
const filePaths = await walk(src);
let filePaths = [];
try {
filePaths = await walk(src);
} catch (e) {
logErrorInstance(e);
}
const allowedFilePaths = filePaths
.filter(file => {
if (!isAllowedExtension(file)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/commands/cms/lighthouseScore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
const {
getTableContents,
getTableHeader,
} = require('@hubspot/cli-lib/lib/table');
} = require('@hubspot/local-dev-lib/logging/table');
const { loadAndValidateOptions } = require('../../lib/validation');
const { promptUser } = require('../../lib/prompts/promptUtils');
const { i18n } = require('../../lib/lang');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/commands/customObject/schema/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { createSchema } = require('@hubspot/cli-lib/api/schema');
const {
createSchema: createSchemaFromHubFile,
} = require('@hubspot/cli-lib/api/fileTransport');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const { i18n } = require('../../../lib/lang');

const i18nKey =
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/commands/customObject/schema/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { updateSchema } = require('@hubspot/cli-lib/api/schema');
const {
updateSchema: updateSchemaFromHubFile,
} = require('@hubspot/cli-lib/api/fileTransport');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const { i18n } = require('../../../lib/lang');

const i18nKey =
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/commands/functions/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { getFunctionArrays } = require('../../lib/getFunctionArrays');
const {
getTableContents,
getTableHeader,
} = require('@hubspot/cli-lib/lib/table');
} = require('@hubspot/local-dev-lib/logging/table');

const {
addConfigOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/commands/project/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const {

const { buildSandbox } = require('../../lib/sandbox-create');
const { syncSandbox } = require('../../lib/sandbox-sync');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const {
logApiErrorInstance,
ApiErrorContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/commands/project/listBuilds.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {
const {
getTableContents,
getTableHeader,
} = require('@hubspot/cli-lib/lib/table');
} = require('@hubspot/local-dev-lib/logging/table');
const { getCwd } = require('@hubspot/cli-lib/path');
const { uiBetaTag, uiLink } = require('../../lib/ui');
const { loadAndValidateOptions } = require('../../lib/validation');
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/commands/project/logs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { getEnv } = require('@hubspot/local-dev-lib/config');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const { ENVIRONMENTS } = require('@hubspot/cli-lib/lib/constants');
const {
addAccountOptions,
Expand All @@ -17,7 +17,7 @@ const {
const {
getTableContents,
getTableHeader,
} = require('@hubspot/cli-lib/lib/table');
} = require('@hubspot/local-dev-lib/logging/table');
// const {
// getProjectAppFunctionLogs,
// getLatestProjectAppFunctionLog,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/commands/sandbox/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const { promptUser } = require('../../lib/prompts/promptUtils');
const { syncSandbox } = require('../../lib/sandbox-sync');
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
const { isMissingScopeError } = require('../../lib/errorHandlers/apiErrors');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');

const i18nKey = 'cli.commands.sandbox.subcommands.create';

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/commands/sandbox/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {
isSpecifiedError,
isSpecifiedHubSpotAuthError,
} = require('../../lib/errorHandlers/apiErrors');
const { deleteSandbox } = require('@hubspot/cli-lib/sandboxes');
const { deleteSandbox } = require('@hubspot/local-dev-lib/sandboxes');
const { i18n } = require('../../lib/lang');
const { deleteSandboxPrompt } = require('../../lib/prompts/sandboxesPrompt');
const {
Expand All @@ -31,7 +31,7 @@ const {
} = require('../../lib/prompts/accountsPrompt');
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
const { promptUser } = require('../../lib/prompts/promptUtils');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');

const { getAccountName } = require('../../lib/sandboxes');
const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/commands/sandbox/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { loadAndValidateOptions } = require('../../lib/validation');
const { i18n } = require('../../lib/lang');
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
const { getAccountConfig, getEnv } = require('@hubspot/local-dev-lib/config');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const { promptUser } = require('../../lib/prompts/promptUtils');
const { uiLine } = require('../../lib/ui');
const {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/lib/links.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { getEnv } = require('@hubspot/local-dev-lib/config');
const { ENVIRONMENTS } = require('@hubspot/cli-lib/lib/constants');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const { logger } = require('@hubspot/cli-lib/logger');
const {
getTableContents,
getTableHeader,
} = require('@hubspot/cli-lib/lib/table');
} = require('@hubspot/local-dev-lib/logging/table');

const open = require('open');

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const OAuth2Manager = require('@hubspot/cli-lib/lib/models/OAuth2Manager');
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
const { addOauthToAccountConfig } = require('@hubspot/cli-lib/oauth');
const { handleExit } = require('./process');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const { logger } = require('@hubspot/cli-lib/logger');
const { ENVIRONMENTS } = require('@hubspot/cli-lib/lib/constants');

Expand Down
10 changes: 8 additions & 2 deletions packages/cli/lib/projectStructure.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const fs = require('fs');
const path = require('path');
const { walk } = require('@hubspot/cli-lib/lib/walk');
const { walk } = require('@hubspot/local-dev-lib/fs');
const { logger } = require('@hubspot/cli-lib/logger');
const { logErrorInstance } = require('./errorHandlers/standardErrors');

const COMPONENT_TYPES = Object.freeze({
app: 'app',
Expand Down Expand Up @@ -73,8 +74,13 @@ function getIsLegacyApp(appConfig, appPath) {

async function findProjectComponents(projectSourceDir) {
const components = [];
let projectFiles = [];

const projectFiles = await walk(projectSourceDir);
try {
projectFiles = await walk(projectSourceDir);
} catch (e) {
logErrorInstance(e);
}

projectFiles.forEach(projectFile => {
// Find app components
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const chalk = require('chalk');
const findup = require('findup-sync');
const { logger } = require('@hubspot/cli-lib/logger');
const { getEnv } = require('@hubspot/local-dev-lib/config');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const {
ENVIRONMENTS,
FEEDBACK_INTERVAL,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/prompts/personalAccessKeyPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
DEFAULT_OAUTH_SCOPES,
} = require('@hubspot/cli-lib/lib/constants');
const { deleteEmptyConfigFile } = require('@hubspot/local-dev-lib/config');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const { logger } = require('@hubspot/cli-lib/logger');
const { promptUser } = require('./promptUtils');
const { accountNamePrompt } = require('./enterAccountNamePrompt');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/prompts/projectDevTargetAccountPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { i18n } = require('../lang');
const { uiAccountDescription, uiCommandReference } = require('../ui');
const { isSandbox, getAccountName } = require('../sandboxes');
const { getAccountId } = require('@hubspot/local-dev-lib/config');
const { getSandboxUsageLimits } = require('@hubspot/cli-lib/sandboxes');
const { getSandboxUsageLimits } = require('@hubspot/local-dev-lib/sandboxes');
const { logger } = require('@hubspot/cli-lib/logger');

const i18nKey = 'cli.lib.prompts.projectDevTargetAccountPrompt';
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/lib/sandbox-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const {
isMissingScopeError,
isSpecifiedError,
} = require('./errorHandlers/apiErrors');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const { getEnv, getAccountId } = require('@hubspot/local-dev-lib/config');
const { createSandbox } = require('@hubspot/cli-lib/sandboxes');
const { createSandbox } = require('@hubspot/local-dev-lib/sandboxes');
const { getValidEnv } = require('@hubspot/local-dev-lib/environment');

const i18nKey = 'cli.lib.sandbox.create';
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/lib/sandbox-sync.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const SpinniesManager = require('./SpinniesManager');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const { logger } = require('@hubspot/cli-lib/logger');
const { i18n } = require('./lang');
const {
Expand All @@ -10,7 +10,7 @@ const {
sandboxTypeMap,
syncTypes,
} = require('./sandboxes');
const { initiateSync } = require('@hubspot/cli-lib/sandboxes');
const { initiateSync } = require('@hubspot/local-dev-lib/sandboxes');
const {
debugErrorAndContext,
logErrorInstance,
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/lib/sandboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
fetchTaskStatus,
fetchTypes,
getSandboxUsageLimits,
} = require('@hubspot/cli-lib/sandboxes');
} = require('@hubspot/local-dev-lib/sandboxes');
const {
accountNameExistsInConfig,
getConfig,
Expand All @@ -21,7 +21,7 @@ const {
} = require('@hubspot/local-dev-lib/config');
const CliProgressMultibarManager = require('./CliProgressMultibarManager');
const { promptUser } = require('./prompts/promptUtils');
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const {
personalAccessKeyPrompt,
} = require('./prompts/personalAccessKeyPrompt');
Expand Down
10 changes: 8 additions & 2 deletions packages/cli/lib/upload.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
const path = require('path');
const { walk } = require('@hubspot/cli-lib/lib/walk');
const { walk } = require('@hubspot/local-dev-lib/fs');
const { createIgnoreFilter } = require('@hubspot/local-dev-lib/ignoreRules');
const { fieldsJsPrompt } = require('../lib/prompts/cmsFieldPrompt');
const { isAllowedExtension } = require('@hubspot/cli-lib/path');
const { isConvertableFieldJs } = require('@hubspot/cli-lib/lib/handleFieldsJs');
const { logErrorInstance } = require('./errorHandlers/standardErrors');

/*
* Walks the src folder for files, filters them based on ignore filter.
* If convertFields is true then will check for any JS fields conflicts (i.e., JS fields file and fields.json file) and prompt to resolve
*/
const getUploadableFileList = async (src, convertFields) => {
const filePaths = await walk(src);
let filePaths = [];
try {
filePaths = await walk(src);
} catch (e) {
logErrorInstance(e);
}
const allowedFiles = filePaths
.filter(file => {
if (!isAllowedExtension(file)) {
Expand Down
6 changes: 2 additions & 4 deletions packages/cli/lib/usageTracking.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { trackUsage } = require('@hubspot/cli-lib/api/fileMapper');
const { trackUsage } = require('@hubspot/local-dev-lib/trackUsage');
const {
isTrackingAllowed,
getAccountConfig,
Expand Down Expand Up @@ -138,16 +138,14 @@ const trackAuthAction = async (command, authType, step, accountId) => {
step,
};
try {
const response = await trackUsage(
await trackUsage(
'cli-interaction',
EventClass.INTERACTION,
usageTrackingEvent,
accountId
);

logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);

return response;
} catch (e) {
logger.debug('Auth action tracking failed: %s', e.message);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@hubspot/cli-lib": "^7.0.0",
"@hubspot/local-dev-lib": "^0.0.9",
"@hubspot/local-dev-lib": "^0.0.10",
"@hubspot/serverless-dev-runtime": "5.0.3-beta.1",
"@hubspot/ui-extensions-dev-server": "^0.8.0",
"archiver": "^5.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless-dev-runtime/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { logger, setLogLevel, LOG_LEVEL } = require('@hubspot/cli-lib/logger');
const {
getTableContents,
getTableHeader,
} = require('@hubspot/cli-lib/lib/table');
} = require('@hubspot/local-dev-lib/logging/table');

const { validateInputs } = require('./validation');
const { getValidatedFunctionData } = require('./data');
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless-dev-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "Apache-2.0",
"dependencies": {
"@hubspot/cli-lib": "^7.0.0",
"@hubspot/local-dev-lib": "^0.0.9",
"@hubspot/local-dev-lib": "^0.0.10",
"body-parser": "^1.19.0",
"chalk": "^4.1.0",
"chokidar": "^3.4.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-cms-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {
"@hubspot/cli-lib": "^7.0.0",
"@hubspot/local-dev-lib": "^0.0.9"
"@hubspot/local-dev-lib": "^0.0.10"
},
"gitHead": "0659fd19cabc3645af431b177c11d0c1b089e0f8"
}
Loading

0 comments on commit 9adec5f

Please sign in to comment.