Skip to content

Commit

Permalink
Merge pull request #1154 from HubSpot/fix/slash-bug
Browse files Browse the repository at this point in the history
Fix(migrate-app): project names with slashes causing download issues
  • Loading branch information
kemmerle authored Aug 26, 2024
2 parents 9a30168 + 567f649 commit 46c6645
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
15 changes: 10 additions & 5 deletions packages/cli/commands/project/cloneApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const {
checkCloneStatus,
downloadClonedProject,
} = require('@hubspot/local-dev-lib/api/projects');
const { getCwd } = require('@hubspot/local-dev-lib/path');
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');
Expand Down Expand Up @@ -119,10 +119,15 @@ exports.handler = async options => {

// Extract zipped app files and place them in correct directory
const zippedApp = await downloadClonedProject(accountId, exportId);
await extractZipArchive(zippedApp, name, absoluteDestPath, {
includesRootDir: true,
hideLogs: true,
});
await extractZipArchive(
zippedApp,
sanitizeFileName(name),
absoluteDestPath,
{
includesRootDir: true,
hideLogs: true,
}
);

// Create hsproject.json file
const configPath = path.join(baseDestPath, PROJECT_CONFIG_FILE);
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/commands/project/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {
addUseEnvironmentOptions,
} = require('../../lib/commonOpts');
const { trackCommandUsage } = require('../../lib/usageTracking');
const { getCwd } = require('@hubspot/local-dev-lib/path');
const { getCwd, sanitizeFileName } = require('@hubspot/local-dev-lib/path');
const {
logApiErrorInstance,
ApiErrorContext,
Expand Down Expand Up @@ -95,7 +95,7 @@ exports.handler = async options => {

await extractZipArchive(
zippedProject,
projectName,
sanitizeFileName(projectName),
path.resolve(absoluteDestPath),
{ includesRootDir: false }
);
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/commands/project/migrateApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const {
migrateApp,
checkMigrationStatus,
} = require('@hubspot/local-dev-lib/api/projects');
const { getCwd } = require('@hubspot/local-dev-lib/path');
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 { downloadProject } = require('@hubspot/local-dev-lib/api/projects');
Expand Down Expand Up @@ -186,7 +186,7 @@ exports.handler = async options => {

await extractZipArchive(
zippedProject,
projectName,
sanitizeFileName(projectName),
path.resolve(absoluteDestPath),
{ includesRootDir: true, hideLogs: true }
);
Expand All @@ -209,7 +209,9 @@ exports.handler = async options => {
logger.log(
uiLink(
i18n(`${i18nKey}.projectDetailsLink`),
`${baseUrl}/developer-projects/${accountId}/project/${project.name}`
`${baseUrl}/developer-projects/${accountId}/project/${encodeURIComponent(
project.name
)}`
)
);
process.exit(EXIT_CODES.SUCCESS);
Expand Down

0 comments on commit 46c6645

Please sign in to comment.