Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 16 additions & 12 deletions cli/src/init/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2752,7 +2752,9 @@ async function waitForVerifiedUpdaterInstall(
while (true) {
const state = getUpdaterInstallState(packageJsonPath)
if (state.ready) {
pLog.info(`${CAPGO_UPDATER_PACKAGE} found in package.json and node_modules ✅`)
const declaredAt = formatInitFilePath(state.packageJsonPath)
const versionLabel = state.installedVersion ? ` ${state.installedVersion}` : ''
pLog.info(`${CAPGO_UPDATER_PACKAGE}${versionLabel} is declared in ${declaredAt} and installed in node_modules ✅`)
return state
}

Expand Down Expand Up @@ -2797,7 +2799,7 @@ async function addUpdaterStep(orgId: string, apikey: string, appId: string) {
message: `Install @capgo/capacitor-updater in your project?`,
options: [
{ value: 'yes', label: '✅ Yes, install it' },
{ value: 'no', label: '❌ No, I\'ll do it manually' },
{ value: 'no', label: '📝 I\'ll do it manually' },
],
})
await cancelCommand(installChoice, orgId, apikey)
Expand All @@ -2823,12 +2825,12 @@ async function addUpdaterStep(orgId: string, apikey: string, appId: string) {
const installState = getUpdaterInstallState(path)

if (installState.ready) {
s.stop(`Capgo already installed ✅`)
s.stop(`${CAPGO_UPDATER_PACKAGE} is already declared in ${formatInitFilePath(path)} and installed in node_modules ✅`)
}
else {
try {
runUpdaterInstallCommand(pm, path, versionToInstall)
s.stop(`Install Done ✅`)
s.stop(`Installed ${CAPGO_UPDATER_PACKAGE}; declaration is in ${formatInitFilePath(path)} ✅`)
}
catch (error) {
s.stop('Updater install failed ❌')
Expand All @@ -2837,7 +2839,7 @@ async function addUpdaterStep(orgId: string, apikey: string, appId: string) {
}
}
else {
pLog.info(`Install it manually with: "${getUpdaterInstallCommand(pm, versionToInstall)}"`)
pLog.info(`Install it manually in ${formatInitFilePath(dirname(path))} with: "${getUpdaterInstallCommand(pm, versionToInstall)}"`)
}

await waitForVerifiedUpdaterInstall(orgId, apikey, path, pm, versionToInstall, {
Expand All @@ -2854,13 +2856,13 @@ async function addUpdaterStep(orgId: string, apikey: string, appId: string) {
s.start(`Updating config file`)
delta = !!doDirectInstall
const projectDir = dirname(path)
await withTemporaryCwd(getInitConfigLoadDir(projectDir), async () => {
const updatedConfig = await withTemporaryCwd(getInitConfigLoadDir(projectDir), async () => {
if (doDirectInstall) {
await updateConfigbyKey('SplashScreen', { launchAutoHide: false })
}
await updateConfigUpdater(getInitUpdaterPluginConfig(appId, delta))
return updateConfigUpdater(getInitUpdaterPluginConfig(appId, delta))
})
s.stop(`Config file updated ✅`)
s.stop(`Updated ${formatInitFilePath(updatedConfig.path)} ✅`)
break
}

Expand Down Expand Up @@ -2941,7 +2943,7 @@ async function addCodeStep(orgId: string, apikey: string, appId: string) {
message: `Add the Capacitor Updater import to your main file?`,
options: [
{ value: 'yes', label: '✅ Yes, add it' },
{ value: 'no', label: '❌ No, I\'ll do it manually' },
{ value: 'no', label: '📝 I\'ll do it manually' },
],
})
await cancelCommand(addCodeChoice, orgId, apikey)
Expand All @@ -2962,10 +2964,11 @@ async function addCodeStep(orgId: string, apikey: string, appId: string) {
canAutoInject = getCanAutoInject()
}

const displayFilePath = formatInitFilePath(filePath)
if (addCodeChoice === 'yes') {
if (!canAutoInject) {
pLog.warn(`An existing Nuxt updater plugin was not changed automatically.`)
pLog.info(`Add this plugin code manually:\n\n${getNuxtUpdaterPluginContent()}`)
pLog.info(`Add this plugin code manually to ${displayFilePath}:\n\n${getNuxtUpdaterPluginContent()}`)
await markStep(orgId, apikey, 'add-code-manual', appId)
}
else if (!alreadyConfigured) {
Expand All @@ -2975,11 +2978,12 @@ async function addCodeStep(orgId: string, apikey: string, appId: string) {
mkdirSync(dirname(filePath), { recursive: true })
}
writeFileSync(filePath, newContent, 'utf8')
s.stop()
s.stop(`Added notifyAppReady() to ${displayFilePath} ✅`)
globalCodeDiff = previewDiff
setInitCodeDiff(globalCodeDiff)
}
else {
pLog.info(`notifyAppReady() already in ${displayFilePath} ✅`)
globalCodeDiff = previewDiff
}

Expand All @@ -2992,7 +2996,7 @@ async function addCodeStep(orgId: string, apikey: string, appId: string) {
: getExistingUpdaterBinding(filePath, currentContent)
? getInitCodeCall()
: getInitCodeInjection(filePath)
pLog.info(`${createNuxtPlugin ? 'Add this plugin code manually:' : 'Add to your main file the following code:'}\n\n${manualCode}\n`)
pLog.info(`${createNuxtPlugin ? 'Add this plugin code' : 'Add this code'} manually to ${displayFilePath}:\n\n${manualCode}\n`)
}
}

Expand Down
Loading