(options: Options)
| 19 | import type { Environment, FileBundleHandler, Options } from './types.js' |
| 20 | |
| 21 | function 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 | |
| 60 | async function writeFiles(environment: Environment, options: Options) { |
| 61 | const templateFileFromContent = createTemplateFile(environment, options) |
no test coverage detected