Skip to content

Commit 78f4ec5

Browse files
committed
Delete the env file after migration
1 parent 73c7be2 commit 78f4ec5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/app/src/cli/models/app/identifiers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ export async function updateAppIdentifiers(
8282
const envFileContent = dotEnvFileExists ? await readFile(dotenvFile.path) : ''
8383
const updatedEnvFileContent = patchEnvFile(envFileContent, updatedVariables)
8484
await writeFile(dotenvFile.path, updatedEnvFileContent)
85+
86+
// eslint-disable-next-line require-atomic-updates
87+
app.dotenv = dotenvFile
8588
}
8689

87-
// eslint-disable-next-line require-atomic-updates
88-
app.dotenv = dotenvFile
8990
return app
9091
}
9192

packages/app/src/cli/services/deploy.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {reloadApp} from '../models/app/loader.js'
1212
import {ExtensionRegistration} from '../api/graphql/all_app_extension_registrations.js'
1313
import {getTomls} from '../utilities/app/config/getTomls.js'
1414
import {renderInfo, renderSuccess, renderTasks, renderConfirmationPrompt, isTTY} from '@shopify/cli-kit/node/ui'
15-
import {mkdir} from '@shopify/cli-kit/node/fs'
15+
import {fileExistsSync, mkdir, removeFile} from '@shopify/cli-kit/node/fs'
1616
import {joinPath, dirname} from '@shopify/cli-kit/node/path'
1717
import {outputNewline, outputInfo, formatPackageManagerCommand} from '@shopify/cli-kit/node/output'
1818
import {getArrayRejectingUndefined} from '@shopify/cli-kit/common/array'
@@ -265,6 +265,9 @@ export async function deploy(options: DeployOptions) {
265265

266266
await renderTasks(tasks)
267267

268+
// Delete the .env file after the first successful deploy to the Dev Dashboard
269+
if (didMigrateExtensionsToDevDash && uploadExtensionsBundleResult.versionTag) await deleteEnvFile(app)
270+
268271
await outputCompletionMessage({
269272
app,
270273
release,
@@ -285,6 +288,10 @@ export async function deploy(options: DeployOptions) {
285288
return {app}
286289
}
287290

291+
async function deleteEnvFile(app: AppLinkedInterface) {
292+
if (app.dotenv && fileExistsSync(app.dotenv.path)) await removeFile(app.dotenv.path)
293+
}
294+
288295
async function outputCompletionMessage({
289296
app,
290297
release,

0 commit comments

Comments
 (0)