MCPcopy Create free account
hub / github.com/TanStack/cli / readConfigFileFromEnvironment

Function readConfigFileFromEnvironment

packages/create/src/config-file.ts:41–74  ·  view source on GitHub ↗
(
  environment: Environment,
  targetDir: string,
)

Source from the content-addressed store, hash-verified

39}
40
41export async function readConfigFileFromEnvironment(
42 environment: Environment,
43 targetDir: string,
44): Promise<PersistedOptions | null> {
45 try {
46 const configFile = resolve(targetDir, CONFIG_FILE)
47 const config = await environment.readFile(configFile)
48
49 const originalJSON = JSON.parse(config)
50
51 // Look for markers out outdated config files and upgrade the format on the fly (it will be written in the updated version after we add add-ons)
52 if (originalJSON.existingAddOns) {
53 if (originalJSON.framework === 'react-cra') {
54 originalJSON.framework = 'react'
55 }
56 originalJSON.chosenAddOns = originalJSON.existingAddOns
57 delete originalJSON.existingAddOns
58 delete originalJSON.addOns
59 if (originalJSON.toolchain && originalJSON.toolchain !== 'none') {
60 originalJSON.chosenAddOns.push(originalJSON.toolchain)
61 }
62 delete originalJSON.toolchain
63 delete originalJSON.variableValues
64 }
65
66 if (originalJSON.framework === 'react-cra') {
67 originalJSON.framework = 'react'
68 }
69
70 return originalJSON
71 } catch {
72 return null
73 }
74}
75
76export async function readConfigFile(
77 targetDir: string,

Callers 4

getCurrentConfigurationFunction · 0.85
readConfigFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected