MCPcopy Create free account
hub / github.com/formkit/formkit / inputsBuildExtras

Function inputsBuildExtras

scripts/build.mjs:183–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181 * Output a typescript input file for each `type` key.
182 */
183export async function inputsBuildExtras() {
184 progress.step = 'Exporting inputs by type'
185 const inputs = getInputs()
186 const distDir = resolve(packagesDir, 'inputs/dist/exports')
187 await fs.mkdir(distDir, { recursive: true })
188 await Promise.all(
189 inputs.map(async (input) => {
190 // await execa('cp', [input.filePath, resolve(distDir, `${input.name}.ts`)])
191 let fileData = await fs.readFile(input.filePath, { encoding: 'utf8' })
192 fileData = fileData.replace(
193 "} from '../compose'",
194 "} from '../index.mjs'"
195 )
196 await fs.writeFile(resolve(distDir, `${input.name}.ts`), fileData)
197 })
198 )
199 const tsconfig = resolve(distDir, 'tsconfig.json')
200
201 const tsConfigStr = await fs.readFile(
202 resolve(rootDir, 'tsconfig.json'),
203 'utf-8'
204 )
205
206 const tsData = JSON.parse(
207 tsConfigStr.replace(
208 './types/globals.d.ts',
209 resolve(rootDir, './types/globals.d.ts').split(path.sep).join(path.posix.sep)
210 )
211 )
212 tsData.compilerOptions.outDir = './'
213 await fs.writeFile(tsconfig, JSON.stringify(tsData, null, 2))
214 await execa('npx', ['tsc', '--project', tsconfig])
215 await execa('npx', [
216 'prettier',
217 '--no-semi',
218 '--single-quote',
219 '--write',
220 resolve(distDir, '*.js'),
221 ])
222 await fs.unlink(tsconfig)
223}
224
225/**
226 * Special considerations for building the themes package.

Callers 1

buildPackageFunction · 0.85

Calls 1

getInputsFunction · 0.90

Tested by

no test coverage detected