diff --git a/commands/app/migrate.ts b/commands/app/migrate.ts index 2dc4d90c7..ab05b4603 100644 --- a/commands/app/migrate.ts +++ b/commands/app/migrate.ts @@ -16,8 +16,9 @@ import { i18n } from '../../lib/lang'; import { ApiErrorContext, logError } from '../../lib/errorHandlers'; import { EXIT_CODES } from '../../lib/enums/exitCodes'; import { migrateApp2025_2, MigrateAppArgs } from '../../lib/app/migrate'; -import { uiBetaTag, uiLink } from '../../lib/ui'; +import { uiBetaTag, uiCommandReference, uiLink } from '../../lib/ui'; import { migrateApp2023_2 } from '../../lib/app/migrate_legacy'; +import { getIsInProject } from '../../lib/projects'; const { v2023_2, v2025_2, unstable } = PLATFORM_VERSIONS; export const validMigrationTargets = [v2023_2, v2025_2, unstable]; @@ -54,6 +55,16 @@ export async function handler(options: ArgumentsCamelCase) { try { if (platformVersion === v2025_2 || platformVersion === unstable) { + if (getIsInProject()) { + logger.error( + i18n( + `commands.project.subcommands.migrateApp.errors.notAllowedWithinProject`, + { command: uiCommandReference('hs project migrate') } + ) + ); + process.exit(EXIT_CODES.ERROR); + } + await migrateApp2025_2(derivedAccountId, options); } else { await migrateApp2023_2(derivedAccountId, options, accountConfig); diff --git a/lang/en.lyaml b/lang/en.lyaml index c1023d34c..3fb387b23 100644 --- a/lang/en.lyaml +++ b/lang/en.lyaml @@ -655,6 +655,7 @@ en: projectAlreadyExists: "A project with name {{ projectName }} already exists. Please choose another name." invalidApp: "Could not migrate appId {{ appId }}. This app cannot be migrated at this time. Please choose another public app." migrationFailed: 'Migration Failed' + notAllowedWithinProject: 'This command cannot be run from within a project directory. Run the command again from outside a project directory. If you are trying to migrate a project, run {{ command }}' cloneApp: describe: "Clone a public app using the projects framework." examples: diff --git a/lang/en.ts b/lang/en.ts index 24ae5604c..277abf3ec 100644 --- a/lang/en.ts +++ b/lang/en.ts @@ -994,6 +994,8 @@ export const commands = { `Could not migrate appId ${appId}. This app cannot be migrated at this time. Please choose another public app.`, appWithAppIdNotFound: appId => `Could not find an app with the id ${appId} `, + notAllowedWithinProject: command => + `This command cannot be run from within a project directory. Run the command again from outside a project directory. If you are trying to migrate a project, run ${command}`, }, }, cloneApp: {