Skip to content

Commit

Permalink
Merge pull request #4186 from Shopify/clear-cache-on-app-init
Browse files Browse the repository at this point in the history
Clear cache on app init
  • Loading branch information
gonzaloriestra committed Jul 11, 2024
2 parents b1ebda4 + 00d80ea commit 74e88d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/chilly-taxis-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/create-app': patch
---

Clear cache on app init
11 changes: 10 additions & 1 deletion packages/create-app/src/services/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import {
readFile,
writeFile,
} from '@shopify/cli-kit/node/fs'
import {joinPath} from '@shopify/cli-kit/node/path'
import {joinPath, normalizePath} from '@shopify/cli-kit/node/path'
import {username} from '@shopify/cli-kit/node/os'
import {AbortError} from '@shopify/cli-kit/node/error'
import {formatPackageManagerCommand} from '@shopify/cli-kit/node/output'
import {LocalStorage} from '@shopify/cli-kit/node/local-storage'

interface InitOptions {
name: string
Expand All @@ -47,6 +48,8 @@ async function init(options: InitOptions) {
const githubRepo = parseGitHubRepositoryReference(options.template)

await ensureAppDirectoryIsAvailable(outputDirectory, hyphenizedName)
// Remove cache from previous projects in the same directory
await clearCache(outputDirectory)

renderInfo({
body: [
Expand Down Expand Up @@ -208,6 +211,12 @@ async function ensureAppDirectoryIsAvailable(directory: string, name: string): P
throw new AbortError(`\nA directory with this name (${name}) already exists.\nChoose a new name for your app.`)
}

async function clearCache(directory: string) {
const appCache = new LocalStorage({projectName: 'shopify-cli-app'})
const normalizedDirectory = normalizePath(directory)
appCache.delete(normalizedDirectory)
}

function detectAdditionalWorkspacesFolders(directory: string) {
return ['web', 'web/frontend'].filter((folder) => fileExistsSync(joinPath(directory, folder)))
}
Expand Down

0 comments on commit 74e88d3

Please sign in to comment.