Skip to content

Commit

Permalink
Merge pull request #1169 from HubSpot/fix/migration-tracking
Browse files Browse the repository at this point in the history
Refactor: Simplify migration tracking
  • Loading branch information
kemmerle authored Sep 9, 2024
2 parents 4357d61 + 46d7909 commit d2b6658
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
19 changes: 3 additions & 16 deletions packages/cli/commands/project/cloneApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ const { getCwd, sanitizeFileName } = require('@hubspot/local-dev-lib/path');
const { logger } = require('@hubspot/local-dev-lib/logger');
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
const { extractZipArchive } = require('@hubspot/local-dev-lib/archive');
const {
fetchPublicAppMetadata,
} = require('@hubspot/local-dev-lib/api/appsDev');

const i18nKey = 'commands.project.subcommands.cloneApp';

Expand Down Expand Up @@ -76,8 +73,6 @@ exports.handler = async options => {
let appId;
let name;
let location;
let preventProjectMigrations;
let listingInfo;
try {
appId = options.appId;
if (!appId) {
Expand All @@ -89,11 +84,6 @@ exports.handler = async options => {
});
appId = appIdResponse.appId;
}
const selectedApp = await fetchPublicAppMetadata(appId, accountId);
// preventProjectMigrations returns true if we have not added app to allowlist config.
// listingInfo will only exist for marketplace apps
preventProjectMigrations = selectedApp.preventProjectMigrations;
listingInfo = selectedApp.listingInfo;

const projectResponse = await createProjectPrompt('', options, true);
name = projectResponse.name;
Expand Down Expand Up @@ -138,15 +128,12 @@ exports.handler = async options => {
};
const success = writeProjectConfig(configPath, configContent);

const isListed = Boolean(listingInfo);
trackCommandMetadataUsage(
'clone-app',
{
projectName: name,
appId,
status,
preventProjectMigrations,
isListed,
type: name,
assetType: appId,
successful: success,
},
accountId
);
Expand Down
9 changes: 3 additions & 6 deletions packages/cli/commands/project/migrateApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ exports.handler = async options => {
});

let appName;
let preventProjectMigrations;
let listingInfo;
try {
const selectedApp = await fetchPublicAppMetadata(appId, accountId);
// preventProjectMigrations returns true if we have not added app to allowlist config.
// listingInfo will only exist for marketplace apps
preventProjectMigrations = selectedApp.preventProjectMigrations;
listingInfo = selectedApp.listingInfo;
const preventProjectMigrations = selectedApp.preventProjectMigrations;
const listingInfo = selectedApp.listingInfo;
if (preventProjectMigrations && listingInfo) {
logger.error(i18n(`${i18nKey}.errors.invalidApp`, { appId }));
process.exit(EXIT_CODES.ERROR);
Expand Down Expand Up @@ -191,10 +189,9 @@ exports.handler = async options => {
{ includesRootDir: true, hideLogs: true }
);

const isListed = Boolean(listingInfo);
trackCommandMetadataUsage(
'migrate-app',
{ projectName, appId, status, preventProjectMigrations, isListed },
{ type: projectName, assetType: appId, successful: status },
accountId
);

Expand Down

0 comments on commit d2b6658

Please sign in to comment.