( starterId: string, preferredFramework?: string, )
| 96 | } |
| 97 | |
| 98 | function resolveMonorepoStarterById( |
| 99 | starterId: string, |
| 100 | preferredFramework?: string, |
| 101 | ) { |
| 102 | const normalized = starterId.toLowerCase().trim() |
| 103 | const idVariants = Array.from( |
| 104 | new Set([ |
| 105 | normalized, |
| 106 | normalized.replace(/-template$/i, ''), |
| 107 | normalized.replace(/-starter$/i, ''), |
| 108 | ]), |
| 109 | ).filter(Boolean) |
| 110 | |
| 111 | const cwd = process.cwd() |
| 112 | const rootCandidates = [ |
| 113 | cwd, |
| 114 | resolve(cwd, '..'), |
| 115 | resolve(cwd, '../..'), |
| 116 | resolve(cwd, '../../..'), |
| 117 | ] |
| 118 | |
| 119 | const frameworkOrder = preferredFramework |
| 120 | ? [preferredFramework, ...['react', 'solid'].filter((f) => f !== preferredFramework)] |
| 121 | : ['react', 'solid'] |
| 122 | |
| 123 | for (const root of rootCandidates) { |
| 124 | for (const framework of frameworkOrder) { |
| 125 | for (const id of idVariants) { |
| 126 | const templatePath = resolve(root, 'examples', framework, id, 'template.json') |
| 127 | if (fs.existsSync(templatePath)) { |
| 128 | return templatePath |
| 129 | } |
| 130 | |
| 131 | const starterPath = resolve(root, 'examples', framework, id, 'starter.json') |
| 132 | if (fs.existsSync(starterPath)) { |
| 133 | return starterPath |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | return undefined |
| 140 | } |
| 141 | |
| 142 | export async function resolveStarterSpecifier( |
| 143 | starterSpecifier: string, |
no test coverage detected