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

Function stripExamplesFromOptions

packages/create/src/create-app.ts:21–58  ·  view source on GitHub ↗
(options: Options)

Source from the content-addressed store, hash-verified

19import type { Environment, FileBundleHandler, Options } from './types.js'
20
21function stripExamplesFromOptions(options: Options): Options {
22 if (options.includeExamples !== false) {
23 return options
24 }
25
26 const chosenAddOns = options.chosenAddOns
27 .filter((addOn) => addOn.type !== 'example')
28 .map((addOn) => {
29 const filteredRoutes = (addOn.routes || []).filter(
30 (route) =>
31 !isDemoFilePath(route.path) &&
32 !(route.url && route.url.startsWith('/demo')),
33 )
34
35 const filteredIntegrations = (addOn.integrations || []).filter(
36 (integration) => !isDemoFilePath(integration.path)
37 )
38
39 return {
40 ...addOn,
41 routes: filteredRoutes,
42 integrations: filteredIntegrations,
43 getFiles: async () => {
44 const files = await addOn.getFiles()
45 return files.filter((file) => !isDemoFilePath(file))
46 },
47 getDeletedFiles: async () => {
48 const deletedFiles = await addOn.getDeletedFiles()
49 return deletedFiles.filter((file) => !isDemoFilePath(file))
50 },
51 }
52 })
53
54 return {
55 ...options,
56 chosenAddOns,
57 }
58}
59
60async function writeFiles(environment: Environment, options: Options) {
61 const templateFileFromContent = createTemplateFile(environment, options)

Callers 1

createAppFunction · 0.70

Calls 1

isDemoFilePathFunction · 0.70

Tested by

no test coverage detected