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

Function writeFiles

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

Source from the content-addressed store, hash-verified

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

Callers 1

createAppFunction · 0.70

Calls 7

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

Tested by

no test coverage detected