MCPcopy
hub / github.com/ionic-team/capacitor / migrateCommand

Function migrateCommand

cli/src/tasks/migrate.ts:53–319  ·  view source on GitHub ↗
(config: Config, noprompt: boolean, packagemanager: string)

Source from the content-addressed store, hash-verified

51let installFailed = false;
52
53export async function migrateCommand(config: Config, noprompt: boolean, packagemanager: string): Promise<void> {
54 if (config === null) {
55 fatal('Config data missing');
56 }
57
58 const capMajor = await checkCapacitorMajorVersion(config);
59 if (capMajor < 7) {
60 fatal('Migrate can only be used on Capacitor 7, please use the CLI in Capacitor 7 to upgrade to 7 first');
61 }
62
63 const jdkMajor = await checkJDKMajorVersion();
64
65 if (jdkMajor < 21) {
66 logger.warn('Capacitor 8 requires JDK 21 or higher. Some steps may fail.');
67 }
68
69 const variablesAndClasspaths:
70 | {
71 variables: any;
72 'com.android.tools.build:gradle': string;
73 'com.google.gms:google-services': string;
74 }
75 | undefined = await getAndroidVariablesAndClasspaths(config);
76
77 if (!variablesAndClasspaths) {
78 fatal('Variable and Classpath info could not be read.');
79 }
80
81 allDependencies = {
82 ...config.app.package.dependencies,
83 ...config.app.package.devDependencies,
84 };
85
86 const monorepoWarning =
87 'Please note this tool is not intended for use in a mono-repo environment, you should migrate manually instead. Refer to https://capacitorjs.com/docs/next/updating/8-0';
88
89 logger.info(monorepoWarning);
90
91 const { migrateconfirm } = noprompt
92 ? { migrateconfirm: 'y' }
93 : await logPrompt(`Capacitor 8 sets a deployment target of iOS ${iOSVersion} and Android 16 (SDK 36). \n`, {
94 type: 'text',
95 name: 'migrateconfirm',
96 message: `Are you sure you want to migrate? (Y/n)`,
97 initial: 'y',
98 });
99
100 if (typeof migrateconfirm === 'string' && migrateconfirm.toLowerCase() === 'y') {
101 try {
102 const { depInstallConfirm } = noprompt
103 ? { depInstallConfirm: 'y' }
104 : await logPrompt(
105 `Would you like the migrator to run npm, yarn, pnpm, or bun install to install the latest versions of capacitor packages? (Those using other package managers should answer N)`,
106 {
107 type: 'text',
108 name: 'depInstallConfirm',
109 message: `Run Dependency Install? (Y/n)`,
110 initial: 'y',

Callers 1

runProgramFunction · 0.85

Calls 15

fatalFunction · 0.90
checkJDKMajorVersionFunction · 0.90
logPromptFunction · 0.90
runTaskFunction · 0.90
getMajoriOSVersionFunction · 0.90
runCommandFunction · 0.90
logSuccessFunction · 0.90
installLatestLibsFunction · 0.85
updateFileFunction · 0.85
updateAndroidManifestFunction · 0.85

Tested by

no test coverage detected