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

Function writeFiles

packages/create/src/edge-create-app.ts:56–138  ·  view source on GitHub ↗
(environment: Environment, options: Options)

Source from the content-addressed store, hash-verified

54}
55
56async function writeFiles(environment: Environment, options: Options) {
57 const templateFileFromContent = createTemplateFile(environment, options)
58
59 async function writeFileBundle(bundle: FileBundleHandler) {
60 const files = await bundle.getFiles()
61
62 for (const file of files) {
63 const contents = await bundle.getFileContents(file)
64
65 if (isBase64(contents)) {
66 await environment.writeFileBase64(
67 joinPaths(options.targetDir, file),
68 contents,
69 )
70 } else {
71 await templateFileFromContent(file, contents)
72 }
73 }
74
75 const deletedFiles = await bundle.getDeletedFiles()
76 for (const file of deletedFiles) {
77 await environment.deleteFile(joinPaths(options.targetDir, file))
78 }
79 }
80
81 environment.startStep({
82 id: 'write-framework-files',
83 type: 'file',
84 message: 'Writing framework files...',
85 })
86 await writeFileBundle(options.framework)
87 environment.finishStep('write-framework-files', 'Framework files written')
88
89 let wroteAddonFiles = false
90 for (const type of ['add-on', 'example', 'toolchain', 'deployment']) {
91 for (const phase of ['setup', 'add-on', 'example']) {
92 for (const addOn of options.chosenAddOns.filter(
93 (addOn) => addOn.phase === phase && addOn.type === type,
94 )) {
95 environment.startStep({
96 id: 'write-addon-files',
97 type: 'file',
98 message: `Writing ${addOn.name} files...`,
99 })
100 await writeFileBundle(addOn)
101 wroteAddonFiles = true
102 }
103 }
104 }
105 if (wroteAddonFiles) {
106 environment.finishStep('write-addon-files', 'Add-on files written')
107 }
108
109 if (options.starter) {
110 environment.startStep({
111 id: 'write-starter-files',
112 type: 'file',
113 message: 'Writing starter files...',

Callers 1

createAppFunction · 0.70

Calls 8

createPackageJSONFunction · 0.90
resolvePackageJSONLatestFunction · 0.85
joinPathsFunction · 0.85
startStepMethod · 0.80
finishStepMethod · 0.80
createTemplateFileFunction · 0.70
writeFileBundleFunction · 0.70

Tested by

no test coverage detected