-
Notifications
You must be signed in to change notification settings - Fork 66
feat: Add migration for existing project #1424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 61 commits
193c571
307a833
2d96fbb
503b2c8
99f343e
b9e1611
175e36c
e7350b4
0d20207
143ad49
ac26a4b
009fe74
84013dd
3f556b3
78cb580
79ee7c8
e4bee05
54ca912
80e3001
87fd9d5
39393cf
505df3d
bbbed83
4907c78
8bb55a6
bfafd18
9ce5273
3ac138b
8d3af4f
8321037
adfcc01
91b557e
cd6fe01
1e5b7c0
2fcbaa9
d1b3243
110baf1
2a11251
210cb5f
223f554
6daa0df
8ac0831
6bff187
9d60f24
04e54f6
7a8f442
eb40310
e2d634c
61831b7
7266130
e645adb
4c0996b
9c02037
d538391
25542fc
3dd7e93
f0c5f3d
2138f4c
309c64f
b0591ee
e0e8123
0ed6cc3
7aa2be2
ed0586f
bae540f
5f9a4fb
0e14601
170693b
153ad7e
037aa18
4176b02
6bd9bc3
910b81f
f5a8e72
56e2aa7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { i18n } from '../../lib/lang'; | ||
|
||
import { ArgumentsCamelCase, Argv, CommandModule } from 'yargs'; | ||
import { logger } from '@hubspot/local-dev-lib/logger'; | ||
import { ProjectMigrateOptions } from '../../types/Yargs'; | ||
import { | ||
addAccountOptions, | ||
addConfigOptions, | ||
addGlobalOptions, | ||
} from '../../lib/commonOpts'; | ||
import { migrateApp2025_2 } from '../../lib/app/migrate'; | ||
import { getProjectConfig } from '../../lib/projects'; | ||
import { PLATFORM_VERSIONS } from '@hubspot/local-dev-lib/constants/projects'; | ||
import { logError } from '../../lib/errorHandlers'; | ||
import { EXIT_CODES } from '../../lib/enums/exitCodes'; | ||
|
||
export const command = 'migrate'; | ||
|
||
export const describe = undefined; // i18n('commands.project.subcommands.migrate.noProjectConfig') | ||
|
||
export async function handler( | ||
options: ArgumentsCamelCase<ProjectMigrateOptions> | ||
) { | ||
const projectConfig = await getProjectConfig(); | ||
|
||
if (!projectConfig.projectConfig) { | ||
logger.error( | ||
i18n('commands.project.subcommands.migrate.errors.noProjectConfig') | ||
); | ||
return process.exit(EXIT_CODES.ERROR); | ||
} | ||
|
||
const { derivedAccountId } = options; | ||
try { | ||
await migrateApp2025_2( | ||
derivedAccountId, | ||
{ | ||
...options, | ||
name: projectConfig?.projectConfig?.name, | ||
platformVersion: PLATFORM_VERSIONS.unstable, | ||
}, | ||
projectConfig | ||
); | ||
} catch (error) { | ||
logError(error); | ||
return process.exit(EXIT_CODES.ERROR); | ||
} | ||
return process.exit(EXIT_CODES.SUCCESS); | ||
} | ||
|
||
export function builder(yargs: Argv) { | ||
addConfigOptions(yargs); | ||
addAccountOptions(yargs); | ||
addGlobalOptions(yargs); | ||
|
||
return yargs as Argv<ProjectMigrateOptions>; | ||
} | ||
const migrateAppCommand: CommandModule<unknown, ProjectMigrateOptions> = { | ||
command, | ||
describe, | ||
handler, | ||
builder, | ||
}; | ||
|
||
export default migrateAppCommand; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// @ts-nocheck | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious why the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because it has javascript functions inside of it. So it wants those all to be typed 😞 |
||
import chalk from 'chalk'; | ||
|
||
export const commands = { | ||
|
@@ -994,35 +995,6 @@ export const commands = { | |
appWithAppIdNotFound: appId => | ||
`Could not find an app with the id ${appId} `, | ||
}, | ||
prompt: { | ||
chooseApp: 'Which app would you like to migrate?', | ||
inputName: '[--name] What would you like to name the project?', | ||
inputDest: '[--dest] Where would you like to save the project?', | ||
uidForComponent: componentName => | ||
`What UID would you like to use for ${componentName}?`, | ||
proceed: 'Would you like to proceed?', | ||
}, | ||
spinners: { | ||
beginningMigration: 'Beginning migration', | ||
migrationStarted: 'Migration started', | ||
unableToStartMigration: 'Unable to begin migration', | ||
finishingMigration: 'Wrapping up migration', | ||
migrationComplete: 'Migration completed', | ||
migrationFailed: 'Migration failed', | ||
downloadingProjectContents: 'Downloading migrated project files', | ||
downloadingProjectContentsComplete: 'Migrated project files downloaded', | ||
downloadingProjectContentsFailed: | ||
'Unable to download migrated project files', | ||
copyingProjectFiles: 'Copying migrated project files', | ||
copyingProjectFilesComplete: 'Migrated project files copied', | ||
copyingProjectFilesFailed: 'Unable to copy migrated project files', | ||
}, | ||
migrationNotAllowedReasons: { | ||
upToDate: 'App is already up to date', | ||
isPrivateApp: 'Private apps are not currently migratable', | ||
listedInMarketplace: 'Listed apps are not currently migratable', | ||
generic: reasonCode => `Unable to migrate app: ${reasonCode}`, | ||
}, | ||
}, | ||
cloneApp: { | ||
describe: 'Clone a public app using the projects framework.', | ||
|
@@ -3448,4 +3420,60 @@ export const lib = { | |
oauth: { | ||
missingClientId: 'Error building oauth URL: missing client ID.', | ||
}, | ||
migrate: { | ||
componentsToBeMigrated: components => | ||
kemmerle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`The following component types will be migrated: ${components}`, | ||
componentsThatWillNotBeMigrated: components => | ||
`[NOTE] These component types are not yet supported for migration but will be available later: ${components}`, | ||
errors: { | ||
project: { | ||
invalidConfig: | ||
'The project configuration file is invalid. Please check the config file and try again.', | ||
doesNotExist: 'Project does not exist, unable to migrate', | ||
multipleApps: | ||
'Multiple apps found in project, this is not allowed in 2025.2', | ||
alreadyExists: projectName => | ||
`A project with name ${projectName} already exists. Please choose another name.`, | ||
}, | ||
unmigratableReasons: { | ||
upToDate: 'App is already up to date', | ||
isPrivateApp: 'Private apps are not currently migratable', | ||
listedInMarketplace: 'Listed apps are not currently migratable', | ||
generic: reasonCode => `Unable to migrate app: ${reasonCode}`, | ||
}, | ||
noAppsEligible: (accountId, reasons) => | ||
`No apps in account ${accountId} are currently migratable${reasons.length ? `\n - ${reasons.join('\n - ')}` : ''}`, | ||
|
||
invalidAccountTypeTitle: () => | ||
`${chalk.bold('Developer account not targeted')}`, | ||
invalidAccountTypeDescription: (useCommand, authCommand) => | ||
joe-yeager marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`Only public apps created in a developer account can be converted to a project component. Select a connected developer account with ${useCommand} or ${authCommand} and try again.`, | ||
appWithAppIdNotFound: appId => | ||
`Could not find an app with the id ${appId} `, | ||
noAppsForProject: 'No apps associated with project {{ projectName }}', | ||
joe-yeager marked this conversation as resolved.
Show resolved
Hide resolved
|
||
migrationFailed: 'Migration Failed', | ||
}, | ||
prompt: { | ||
chooseApp: 'Which app would you like to migrate?', | ||
inputName: '[--name] What would you like to name the project?', | ||
inputDest: '[--dest] Where would you like to save the project?', | ||
uidForComponent: componentName => | ||
`What UID would you like to use for ${componentName}?`, | ||
proceed: 'Would you like to proceed?', | ||
}, | ||
spinners: { | ||
beginningMigration: 'Beginning migration', | ||
unableToStartMigration: 'Unable to begin migration', | ||
finishingMigration: 'Wrapping up migration', | ||
migrationComplete: 'Migration completed', | ||
migrationFailed: 'Migration failed', | ||
downloadingProjectContents: 'Downloading migrated project files', | ||
downloadingProjectContentsComplete: 'Migrated project files downloaded', | ||
downloadingProjectContentsFailed: | ||
'Unable to download migrated project files', | ||
copyingProjectFiles: 'Copying migrated project files', | ||
copyingProjectFilesComplete: 'Migrated project files copied', | ||
copyingProjectFilesFailed: 'Unable to copy migrated project files', | ||
}, | ||
}, | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.