-
-
Notifications
You must be signed in to change notification settings - Fork 45
fix(init): save new app ID to capacitor config when original is taken #503
Changes from all commits
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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ import { addChannelInternal } from './channel/add' | |||||||||||||||||||||||||||
| import { createKeyInternal } from './key' | ||||||||||||||||||||||||||||
| import { doLoginExists, loginInternal } from './login' | ||||||||||||||||||||||||||||
| import { createSupabaseClient, findBuildCommandForProjectType, findMainFile, findMainFileForProjectType, findProjectType, findRoot, findSavedKey, getAllPackagesDependencies, getAppId, getBundleVersion, getConfig, getInstalledVersion, getLocalConfig, getOrganization, getPackageScripts, getPMAndCommand, PACKNAME, projectIsMonorepo, promptAndSyncCapacitor, updateConfigbyKey, updateConfigUpdater, validateIosUpdaterSync, verifyUser } from './utils' | ||||||||||||||||||||||||||||
| import { writeConfig } from './config' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| interface SuperOptions extends Options { | ||||||||||||||||||||||||||||
| local: boolean | ||||||||||||||||||||||||||||
|
|
@@ -169,6 +170,24 @@ async function markStep(orgId: string, apikey: string, step: string, appId: stri | |||||||||||||||||||||||||||
| return markSnag('onboarding-v2', orgId, apikey, `onboarding-step-${step}`, appId) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||
| * Save the app ID to the capacitor config file. | ||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||
| async function saveAppIdToCapacitorConfig(appId: string) { | ||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||
| const extConfig = await getConfig() | ||||||||||||||||||||||||||||
| if (extConfig?.config) { | ||||||||||||||||||||||||||||
| extConfig.config.appId = appId | ||||||||||||||||||||||||||||
| await writeConfig('CapacitorUpdater', extConfig, true) | ||||||||||||||||||||||||||||
| pLog.info(`💾 Saved new app ID "${appId}" to capacitor config`) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+179
to
+183
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. Silent skip when If ♻️ Proposed fix const extConfig = await getConfig()
if (extConfig?.config) {
extConfig.config.appId = appId
await writeConfig('CapacitorUpdater', extConfig, true)
pLog.info(`💾 Saved new app ID "${appId}" to capacitor config`)
}
+ else {
+ pLog.warn(`⚠️ Could not find capacitor config to update. Please set appId to "${appId}" manually.`)
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| catch (err) { | ||||||||||||||||||||||||||||
| pLog.warn(`⚠️ Could not save app ID to capacitor config: ${err}`) | ||||||||||||||||||||||||||||
| pLog.info(` You may need to manually update your capacitor.config file with the new app ID: ${appId}`) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| function stopForBrokenIosSync(platformRunner: string, details: string[]): never { | ||||||||||||||||||||||||||||
| pLog.error('Capgo iOS dependency sync verification failed.') | ||||||||||||||||||||||||||||
| for (const detail of details) { | ||||||||||||||||||||||||||||
|
|
@@ -386,6 +405,9 @@ async function addAppStep(organization: Organization, apikey: string, appId: str | |||||||||||||||||||||||||||
| currentAppId = suggestions[suggestionIndex] | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Save the new app ID to capacitor config | ||||||||||||||||||||||||||||
| await saveAppIdToCapacitorConfig(currentAppId) | ||||||||||||||||||||||||||||
|
Comment on lines
+408
to
+409
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.
This writes Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| pLog.info(`🔄 Trying with new app ID: ${currentAppId}`) | ||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||
|
Comment on lines
407
to
412
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.
The save is triggered inside the The save belongs in the success path, guarded by a change check: 🐛 Proposed fix — move save to success path try {
const s = pSpinner()
s.start(`Running: ${pm.runner} `@capgo/cli`@latest app add ${currentAppId}`)
const addRes = await addAppInternal(currentAppId, options, organization, true)
if (!addRes)
s.stop(`App already add ✅`)
else
s.stop(`App add Done ✅`)
+ // Persist the app ID only after it has been successfully registered,
+ // and only when it differs from the one already in the local config.
+ if (currentAppId !== appId) {
+ await saveAppIdToCapacitorConfig(currentAppId)
+ }
+
pLog.info(`This app is accessible to all members of your organization based on their permissions`)
await markStep(organization.gid, apikey, 'add-app', currentAppId)
return currentAppId
}
catch (error) {
...
if (choice === 'custom') { ... }
else { ... }
- // Save the new app ID to capacitor config
- await saveAppIdToCapacitorConfig(currentAppId)
-
pLog.info(`🔄 Trying with new app ID: ${currentAppId}`)
continue
}🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix import ordering to resolve ESLint error.
The static analysis tool reports:
Expected "./config" to come before "./utils"(perfectionist/sort-imports). Move thewriteConfigimport above the./utilsimport.♻️ Proposed fix
🧰 Tools
🪛 ESLint
[error] 19-19: Expected "./config" to come before "./utils".
(perfectionist/sort-imports)
🤖 Prompt for AI Agents