@getcortexlabs/create-mavis 0.1.0-rc.12.2 → 0.1.0-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +6 -6
  2. package/package.json +1 -1
  3. package/src/adapters.mjs +76 -0
  4. package/src/add-target.mjs +1 -1
  5. package/src/capabilities.mjs +626 -0
  6. package/src/cli.mjs +43 -12
  7. package/src/doctor.mjs +77 -36
  8. package/src/macos.mjs +223 -56
  9. package/src/package-manager.mjs +12 -4
  10. package/src/portability.mjs +2 -1
  11. package/src/presets.mjs +15 -108
  12. package/src/scaffold.mjs +11 -3
  13. package/src/ui.mjs +115 -82
  14. package/templates/macos/examples/tasks/shared/TaskDetail.lite.tsx +57 -0
  15. package/templates/macos/examples/tasks/shared/TaskRow.lite.tsx +33 -0
  16. package/templates/macos/examples/tasks/shared/Tasks.lite.tsx +251 -0
  17. package/templates/macos/examples/tasks/shared/types.ts +9 -0
  18. package/templates/macos/mobile/src/App.vue +12 -0
  19. package/templates/macos/mobile/src/app.ts +7 -0
  20. package/templates/macos/native/Package.swift +9 -1
  21. package/templates/macos/native/Sources/MavisDesktop/App.swift +4 -4
  22. package/templates/macos/root/tsconfig.json +14 -0
  23. package/templates/macos/scripts/generate.mjs +35 -16
  24. package/templates/macos/scripts/macos.mjs +8 -3
  25. package/templates/macos/scripts/portable/emit-swift.mjs +1287 -0
  26. package/templates/macos/scripts/portable/emit-vue.mjs +615 -0
  27. package/templates/macos/scripts/portable/index.mjs +95 -0
  28. package/templates/macos/scripts/portable/model.mjs +1441 -0
  29. package/templates/macos/scripts/portable/program.mjs +163 -0
  30. package/templates/macos/shared/Welcome.lite.tsx +8 -6
  31. package/templates/macos/{index.html → web/index.html} +1 -1
  32. package/templates/macos/web/src/main.js +39 -0
  33. package/templates/macos/web/{style.css → src/style.css} +1 -1
  34. package/templates/macos/web/vite.config.mjs +3 -0
  35. package/templates/macos/scripts/portable.mjs +0 -395
  36. package/templates/macos/vite.config.mjs +0 -3
  37. package/templates/macos/web/main.js +0 -15
@@ -0,0 +1,626 @@
1
+ import { adapters } from './adapters.mjs'
2
+
3
+ /** Shape of `--capabilities --json`, for tools that read it. */
4
+ export const catalogVersion = 1
5
+ /** Version of mavis.config.json this creator writes. Older ones are migrated when read. */
6
+ export const schemaVersion = 2
7
+
8
+ /** Baseline pins; coordinated releases update Mavis after validating source templates with matching tarballs. */
9
+ export const versions = Object.freeze({
10
+ mavis: '0.1.0-rc.13',
11
+ jolt: '0.1.0-rc.13',
12
+ vue: '3.5.44',
13
+ nuxt: '4.6.3',
14
+ vite: '6.4.5',
15
+ vuePlugin: '5.2.4',
16
+ typescript: '6.0.3',
17
+ nodeTypes: '26.6.6',
18
+ vueTsc: '3.3.13',
19
+ nativeCore: '9.1.3',
20
+ nativeVue: '3.1.3',
21
+ android: '9.1.1',
22
+ ios: '9.1.0',
23
+ webpack: '5.0.39',
24
+ webpackCore: '5.112.2',
25
+ webpackCli: '6.0.1',
26
+ router: '4.6.4',
27
+ nativeRouter: '0.1.0-rc.4',
28
+ })
29
+
30
+ /** Tools a project needs. The creator and doctor check against these, not their own numbers. */
31
+ export const requirements = Object.freeze({
32
+ node: '22.16',
33
+ packageManagers: Object.freeze({ npm: null, pnpm: '10.26', yarn: null }),
34
+ native: 'the NativeScript CLI, a JDK and the Android SDK; macOS and Xcode for iOS',
35
+ macos: 'macOS 14+ and Xcode',
36
+ })
37
+
38
+ const issueOf = (id) => adapters.planned.find((adapter) => adapter.id === id)?.issue
39
+ const planned = (issue, label) => Object.freeze({ label, status: 'planned', issue })
40
+
41
+ /**
42
+ * Everything a project can be made of. `status` is validated, experimental or planned;
43
+ * `since` is the first published creator with it, or null while it only exists in the
44
+ * repository. Frameworks and hosts that are not built yet come from Mavis core's capabilities.
45
+ */
46
+ export const catalog = Object.freeze({
47
+ targets: Object.freeze({
48
+ web: {
49
+ label: 'Web',
50
+ hint: 'Vue in the browser',
51
+ toolkit: 'mavis-web',
52
+ adapter: 'vue-web',
53
+ status: 'validated',
54
+ },
55
+ native: {
56
+ label: 'Native',
57
+ hint: 'iOS and Android apps with NativeScript',
58
+ toolkit: 'nativescript',
59
+ adapter: 'vue-nativescript',
60
+ platforms: ['ios', 'android'],
61
+ status: 'validated',
62
+ },
63
+ macos: {
64
+ label: 'Mac',
65
+ hint: 'A SwiftUI app · experimental shared TSX',
66
+ toolkit: 'swiftui',
67
+ adapter: null,
68
+ status: 'experimental',
69
+ },
70
+ }),
71
+ frameworks: Object.freeze({
72
+ vue: { label: 'Vue', status: 'validated' },
73
+ react: planned(issueOf('react-web'), 'React'),
74
+ angular: planned(issueOf('angular-web'), 'Angular'),
75
+ svelte: planned(issueOf('svelte-web'), 'Svelte'),
76
+ solid: planned(issueOf('solid-web'), 'Solid'),
77
+ }),
78
+ // How screens are written, and what runs: the components directly, or code generated from them.
79
+ authoring: Object.freeze({
80
+ vue: { label: 'Vue templates', mode: 'direct', execution: 'components', status: 'validated' },
81
+ mitosis: {
82
+ label: 'Shared TSX',
83
+ mode: 'portable',
84
+ execution: 'generated',
85
+ status: 'experimental',
86
+ },
87
+ jsx: planned(167, 'React-style JSX compiled for Vue'),
88
+ }),
89
+ execution: Object.freeze({
90
+ components: { label: 'Mavis components in the app', status: 'validated' },
91
+ generated: { label: 'Code generated for each target', status: 'experimental' },
92
+ sdui: planned(173, 'Screens delivered as data'),
93
+ }),
94
+ hosts: Object.freeze({
95
+ vite: {
96
+ label: 'Vue + Vite',
97
+ hint: 'A client-side app, ready to build on',
98
+ rendering: ['client'],
99
+ status: 'validated',
100
+ },
101
+ nuxt: {
102
+ label: 'Nuxt',
103
+ hint: 'Server rendering or a static website',
104
+ rendering: ['ssr', 'ssg'],
105
+ status: 'validated',
106
+ },
107
+ next: planned(issueOf('next'), 'Next.js'),
108
+ }),
109
+ rendering: Object.freeze({
110
+ client: { label: 'Client rendering' },
111
+ ssr: { label: 'Server rendering', hint: 'Render pages on each request' },
112
+ ssg: { label: 'Static generation', hint: 'Build pages ahead of time' },
113
+ }),
114
+ examples: Object.freeze({
115
+ welcome: {
116
+ label: 'Basic project',
117
+ hint: 'One shared screen to build on',
118
+ authoring: ['vue', 'mitosis'],
119
+ since: '0.1.0-alpha.6',
120
+ },
121
+ directory: {
122
+ label: 'Search, details and editing',
123
+ hint: 'Shared routes, forms and local persistence',
124
+ authoring: ['vue'],
125
+ since: '0.1.0-alpha.9',
126
+ },
127
+ tasks: {
128
+ label: 'Tasks',
129
+ hint: 'List and detail, forms, shortcuts and motion from one source',
130
+ authoring: ['mitosis'],
131
+ since: '0.1.0-rc.13',
132
+ },
133
+ }),
134
+ themes: Object.freeze({
135
+ mavis: { label: 'Mavis', hint: 'Light, warm and soft' },
136
+ midnight: { label: 'Midnight', hint: 'Dark, calm and crisp' },
137
+ }),
138
+ packageManagers: Object.freeze(['npm', 'pnpm', 'yarn']),
139
+ // What a developer already knows. It only shapes the recommendation, never what runs.
140
+ familiar: Object.freeze(['vue', 'react', 'angular', 'svelte', 'solid', 'other']),
141
+ })
142
+
143
+ /** The combinations of targets the creator scaffolds, and how each has been validated. */
144
+ export const combinations = Object.freeze([
145
+ { targets: ['web'], authoring: 'vue', status: 'validated', since: '0.1.0-alpha.6' },
146
+ { targets: ['native'], authoring: 'vue', status: 'validated', since: '0.1.0-alpha.6' },
147
+ { targets: ['web', 'native'], authoring: 'vue', status: 'validated', since: '0.1.0-alpha.6' },
148
+ { targets: ['macos'], authoring: 'mitosis', status: 'experimental', since: '0.1.0-rc.13' },
149
+ {
150
+ targets: ['web', 'macos'],
151
+ authoring: 'mitosis',
152
+ status: 'experimental',
153
+ since: '0.1.0-rc.12.2',
154
+ },
155
+ {
156
+ targets: ['native', 'macos'],
157
+ authoring: 'mitosis',
158
+ status: 'experimental',
159
+ since: '0.1.0-rc.13',
160
+ },
161
+ {
162
+ targets: ['web', 'native', 'macos'],
163
+ authoring: 'mitosis',
164
+ status: 'experimental',
165
+ since: '0.1.0-rc.13',
166
+ },
167
+ ])
168
+
169
+ export const targetNames = Object.freeze(Object.keys(catalog.targets))
170
+
171
+ // --target values from earlier versions; macos was the Web + Mac starter.
172
+ const legacyTargets = Object.freeze({
173
+ web: ['web'],
174
+ mobile: ['native'],
175
+ both: ['web', 'native'],
176
+ macos: ['web', 'macos'],
177
+ })
178
+
179
+ /** A choice that cannot be created, with what to do instead. Nothing is written when it is thrown. */
180
+ export class ProjectError extends Error {
181
+ constructor(problem) {
182
+ super(
183
+ [
184
+ problem.message,
185
+ ...(problem.issue
186
+ ? [`Tracked in https://github.com/getcortexlabs/mavis-ui/issues/${problem.issue}.`]
187
+ : []),
188
+ ...(problem.alternatives?.length ? [`Available: ${problem.alternatives.join(', ')}.`] : []),
189
+ ].join('\n'),
190
+ )
191
+ this.name = 'ProjectError'
192
+ this.problem = Object.freeze({ ...problem })
193
+ }
194
+ }
195
+ const reject = (problem) => {
196
+ throw new ProjectError(problem)
197
+ }
198
+ const available = (family) =>
199
+ Object.entries(family)
200
+ .filter(([, entry]) => entry.status !== 'planned')
201
+ .map(([name]) => name)
202
+
203
+ export function validateProjectName(name) {
204
+ if (!/^[a-z][a-z0-9-]{0,63}$/.test(name ?? ''))
205
+ return 'Use a project name of 1–64 lowercase letters, numbers or hyphens, starting with a letter.'
206
+ }
207
+
208
+ export function parseTargets(value) {
209
+ const list = Array.isArray(value)
210
+ ? value
211
+ : String(value ?? '')
212
+ .split(',')
213
+ .map((name) => name.trim())
214
+ .filter(Boolean)
215
+ const unknown = list.filter((name) => !targetNames.includes(name))
216
+ if (unknown.length || !list.length)
217
+ reject({
218
+ code: 'unknown',
219
+ option: '--targets',
220
+ message: `Targets are a comma-separated list of web, native and macos, for example --targets web,native,macos.`,
221
+ })
222
+ return targetNames.filter((name) => list.includes(name))
223
+ }
224
+
225
+ /** Targets of a project's mavis.config.json, schema 2 or the schema 1 target field. */
226
+ export function projectTargets(config) {
227
+ if (Array.isArray(config.targets)) return parseTargets(config.targets)
228
+ const legacy = legacyTargets[config.target]
229
+ if (!legacy) throw new Error('mavis.config.json has no valid targets.')
230
+ return [...legacy]
231
+ }
232
+
233
+ // The scaffold each combination uses. Combinations with Mac share TSX sources.
234
+ export function layoutOf(targets) {
235
+ if (targets.includes('macos')) return 'macos'
236
+ if (targets.length === 2) return 'both'
237
+ return targets[0] === 'native' ? 'mobile' : 'web'
238
+ }
239
+
240
+ export function targetLabel(targets) {
241
+ return targets.map((name) => catalog.targets[name].label).join(' + ')
242
+ }
243
+
244
+ /** The targets an options object asks for: --targets, the older --target, or Web. */
245
+ export function chosenTargets(options) {
246
+ if (options.targets !== undefined) return parseTargets(options.targets)
247
+ return [...(legacyTargets[options.target ?? 'web'] ?? [])]
248
+ }
249
+
250
+ /** Published and validated, published as an experiment, or only in the repository so far. */
251
+ export function availabilityOf({ targets, example }) {
252
+ const combination = combinations.find((entry) => entry.targets.join() === targets.join())
253
+ if (combination.since === null || catalog.examples[example].since === null) return 'repository'
254
+ return combination.status === 'validated' ? 'published' : 'published-experimental'
255
+ }
256
+ const availabilityLabels = {
257
+ published: 'published and validated',
258
+ 'published-experimental': 'published, experimental',
259
+ repository: 'in the repository; ships with the next release',
260
+ }
261
+ export const availabilityLabel = (availability) => availabilityLabels[availability]
262
+
263
+ // One entry per target: what renders it and how. Vue runs the Web and Native apps today.
264
+ function appsOf({ targets, framework, web, rendering }) {
265
+ return Object.fromEntries(
266
+ targets.map((target) => {
267
+ const { toolkit, platforms } = catalog.targets[target]
268
+ if (target === 'web') return [target, { toolkit, framework, host: web, rendering }]
269
+ if (target === 'native') return [target, { toolkit, framework, platforms: [...platforms] }]
270
+ return [target, { toolkit, framework: null }]
271
+ }),
272
+ )
273
+ }
274
+
275
+ /**
276
+ * Checks a set of choices against the catalog and returns the project to create. Choices are
277
+ * never changed to make them fit: what cannot be created is rejected with the reason, the
278
+ * issue that tracks it when it is planned, and what is available instead.
279
+ */
280
+ export function resolvePreset(options) {
281
+ let targets
282
+ if (options.targets !== undefined) {
283
+ targets = parseTargets(options.targets)
284
+ if (options.target !== undefined && legacyTargets[options.target]?.join() !== targets.join())
285
+ reject({
286
+ code: 'conflict',
287
+ option: '--target',
288
+ message: 'Use either --target or --targets, not both with different values.',
289
+ })
290
+ } else {
291
+ if (options.target !== undefined && !legacyTargets[options.target])
292
+ reject({
293
+ code: 'unknown',
294
+ option: '--target',
295
+ message: 'Target must be mobile, web, both or macos; or use --targets web,native,macos.',
296
+ })
297
+ targets = [...legacyTargets[options.target ?? 'web']]
298
+ }
299
+ const target = layoutOf(targets)
300
+ const mac = target === 'macos'
301
+ const {
302
+ name,
303
+ web = 'vite',
304
+ rendering = web === 'nuxt' ? 'ssr' : 'client',
305
+ theme = 'mavis',
306
+ framework = 'vue',
307
+ authoring = mac ? 'mitosis' : 'vue',
308
+ example = 'welcome',
309
+ packageManager = 'npm',
310
+ familiar,
311
+ } = options
312
+ const invalidName = validateProjectName(name)
313
+ if (invalidName) reject({ code: 'invalid', option: 'name', message: invalidName })
314
+ if (!catalog.packageManagers.includes(packageManager))
315
+ reject({
316
+ code: 'unknown',
317
+ option: '--package-manager',
318
+ message: 'Package manager must be npm, pnpm or yarn.',
319
+ })
320
+ if (!catalog.examples[example])
321
+ reject({
322
+ code: 'unknown',
323
+ option: '--example',
324
+ message: 'Example must be welcome, directory or tasks.',
325
+ })
326
+ if (familiar !== undefined && !catalog.familiar.includes(familiar))
327
+ reject({
328
+ code: 'unknown',
329
+ option: '--familiar',
330
+ message: `--familiar is one of ${catalog.familiar.join(', ')}. It only shapes the recommendation.`,
331
+ })
332
+ if (framework !== 'vue')
333
+ reject({
334
+ code: catalog.frameworks[framework] ? 'planned' : 'unknown',
335
+ option: '--framework',
336
+ message:
337
+ 'This creator currently supports Vue. Other framework adapters are tracked in Mavis #145 and #35–39.',
338
+ issue: catalog.frameworks[framework]?.issue,
339
+ alternatives: available(catalog.frameworks).map((name) => `--framework ${name}`),
340
+ })
341
+ if (!catalog.themes[theme])
342
+ reject({ code: 'unknown', option: '--theme', message: 'Theme must be mavis or midnight.' })
343
+ const hasWeb = targets.includes('web')
344
+ const describe = (preset) =>
345
+ Object.freeze({
346
+ ...preset,
347
+ availability: availabilityOf(preset),
348
+ })
349
+ if (mac) {
350
+ if (authoring !== 'mitosis')
351
+ reject({
352
+ code: 'incompatible',
353
+ option: '--authoring',
354
+ message:
355
+ 'With Mac, shared screens are TSX sources compiled for every target; Vue templates are for projects without Mac.',
356
+ alternatives: [
357
+ '--authoring mitosis',
358
+ `--targets ${targets.filter((t) => t !== 'macos').join(',') || 'web'}`,
359
+ ],
360
+ })
361
+ if (hasWeb && (web !== 'vite' || rendering !== 'client'))
362
+ reject({
363
+ code: 'incompatible',
364
+ option: web !== 'vite' ? '--web' : '--rendering',
365
+ message:
366
+ 'With Mac, the Web app uses Vue + Vite. The shared-source compiler does not support Nuxt rendering yet.',
367
+ issue: 157,
368
+ alternatives: [
369
+ '--web vite',
370
+ `--targets ${targets.filter((t) => t !== 'macos').join(',')} --web nuxt`,
371
+ ],
372
+ })
373
+ if (!catalog.examples[example].authoring.includes('mitosis'))
374
+ reject({
375
+ code: 'incompatible',
376
+ option: '--example',
377
+ message:
378
+ 'With Mac, the welcome and tasks examples are available. The directory example uses Vue routes that the compiler does not support.',
379
+ alternatives: ['--example welcome', '--example tasks'],
380
+ })
381
+ return describe({
382
+ schemaVersion,
383
+ name,
384
+ targets,
385
+ target,
386
+ apps: appsOf({
387
+ targets,
388
+ framework,
389
+ web: hasWeb ? web : null,
390
+ rendering: hasWeb ? rendering : null,
391
+ }),
392
+ framework,
393
+ authoring,
394
+ mode: catalog.authoring[authoring].mode,
395
+ execution: catalog.authoring[authoring].execution,
396
+ example,
397
+ web: hasWeb ? web : null,
398
+ rendering: hasWeb ? rendering : null,
399
+ theme,
400
+ packageManager,
401
+ ...(familiar ? { familiar } : {}),
402
+ experimental: 'shared-tsx',
403
+ versions,
404
+ })
405
+ }
406
+ if (authoring === 'mitosis')
407
+ reject({
408
+ code: 'incompatible',
409
+ option: '--authoring',
410
+ message:
411
+ 'Shared TSX sources come with the Mac target (--targets web,native,macos). Without Mac, use Vue templates.',
412
+ alternatives: ['--authoring vue', `--targets ${[...targets, 'macos'].join(',')}`],
413
+ })
414
+ if (!catalog.examples[example].authoring.includes('vue'))
415
+ reject({
416
+ code: 'incompatible',
417
+ option: '--example',
418
+ message:
419
+ 'The tasks example is written as shared TSX and comes with the Mac target, for example --targets web,native,macos --example tasks.',
420
+ alternatives: [
421
+ '--example welcome',
422
+ '--example directory',
423
+ `--targets ${[...targets, 'macos'].join(',')}`,
424
+ ],
425
+ })
426
+ if (authoring !== 'vue')
427
+ reject({
428
+ code: catalog.authoring[authoring] ? 'planned' : 'unknown',
429
+ option: '--authoring',
430
+ message:
431
+ 'Portable JSX/React-style authoring for Vue is planned in Mavis #167; use Vue templates in this version.',
432
+ issue: catalog.authoring.jsx.issue,
433
+ alternatives: ['--authoring vue'],
434
+ })
435
+ if (!catalog.hosts[web] || catalog.hosts[web].status === 'planned')
436
+ reject({
437
+ code: catalog.hosts[web] ? 'planned' : 'unknown',
438
+ option: '--web',
439
+ message: 'Web host must be vite or nuxt. React/Next are not available yet.',
440
+ issue: catalog.hosts[web]?.issue,
441
+ alternatives: available(catalog.hosts).map((host) => `--web ${host}`),
442
+ })
443
+ if (!hasWeb && (web !== 'vite' || rendering !== 'client'))
444
+ reject({
445
+ code: 'incompatible',
446
+ option: web !== 'vite' ? '--web' : '--rendering',
447
+ message: 'A project without Web has no Web rendering mode.',
448
+ alternatives: [`--targets web,${targets.join(',')}`],
449
+ })
450
+ if (!catalog.hosts[web].rendering.includes(rendering))
451
+ reject({
452
+ code: 'incompatible',
453
+ option: '--rendering',
454
+ message: 'Choose client rendering for Vite or ssr/ssg for Nuxt.',
455
+ alternatives: catalog.hosts[web].rendering.map((mode) => `--rendering ${mode}`),
456
+ })
457
+ return describe({
458
+ schemaVersion,
459
+ name,
460
+ targets,
461
+ target,
462
+ apps: appsOf({
463
+ targets,
464
+ framework,
465
+ web: hasWeb ? web : null,
466
+ rendering: hasWeb ? rendering : null,
467
+ }),
468
+ framework,
469
+ authoring,
470
+ mode: catalog.authoring[authoring].mode,
471
+ execution: catalog.authoring[authoring].execution,
472
+ example,
473
+ web: hasWeb ? web : null,
474
+ rendering: hasWeb ? rendering : null,
475
+ theme,
476
+ packageManager,
477
+ ...(familiar ? { familiar } : {}),
478
+ versions,
479
+ })
480
+ }
481
+
482
+ /** The same check without throwing: the project, or the problem with its alternatives. */
483
+ export function checkProject(options) {
484
+ try {
485
+ return { ok: true, preset: resolvePreset(options) }
486
+ } catch (error) {
487
+ if (!(error instanceof ProjectError)) throw error
488
+ return { ok: false, problem: error.problem, message: error.message }
489
+ }
490
+ }
491
+
492
+ /** What someone coming from another framework should pick. Advice only: nothing is preselected. */
493
+ export function recommendation(familiar, targets) {
494
+ if (!familiar || familiar === 'vue' || familiar === 'other') return undefined
495
+ const mac = targets.includes('macos')
496
+ if (familiar === 'react')
497
+ return mac
498
+ ? 'Coming from React: shared TSX screens read like function components with a store. They are compiled to Vue for the Web and Native; React itself is not running.'
499
+ : `Coming from React: screens here are Vue templates and Vue runs them. A React adapter is tracked in #${catalog.frameworks.react.issue}; shared TSX, which reads closer to React, comes with the Mac target.`
500
+ return `Coming from ${catalog.frameworks[familiar].label}: Vue runs the Web and Native apps today. A ${catalog.frameworks[familiar].label} adapter is tracked in #${catalog.frameworks[familiar].issue}.`
501
+ }
502
+
503
+ /** What mavis.config.json records: targets instead of the internal layout name. */
504
+ export function configOf(preset) {
505
+ const { target: _layout, availability: _availability, ...config } = preset
506
+ return config
507
+ }
508
+
509
+ /**
510
+ * A project's config in the current shape, whatever creator wrote it. Schema 1 had one
511
+ * `target`; early schema 2 files have no `apps`, `mode` or `execution`.
512
+ */
513
+ export function migrateConfig(config) {
514
+ if (!config || (config.targets === undefined && config.target === undefined)) return config
515
+ if (Number(config.schemaVersion) > schemaVersion)
516
+ throw new Error(
517
+ `This project was created by a newer creator (configuration schema ${config.schemaVersion}). Update @getcortexlabs/create-mavis.`,
518
+ )
519
+ const targets = projectTargets(config)
520
+ const hasWeb = targets.includes('web')
521
+ const framework = config.framework ?? 'vue'
522
+ const authoring = config.authoring ?? (targets.includes('macos') ? 'mitosis' : 'vue')
523
+ const web = hasWeb ? (config.web ?? 'vite') : null
524
+ const rendering = hasWeb ? (config.rendering ?? (web === 'nuxt' ? 'ssr' : 'client')) : null
525
+ const { target: _target, ...rest } = config
526
+ return {
527
+ ...rest,
528
+ schemaVersion,
529
+ targets,
530
+ apps: config.apps ?? appsOf({ targets, framework, web, rendering }),
531
+ framework,
532
+ authoring,
533
+ mode: config.mode ?? catalog.authoring[authoring]?.mode ?? 'direct',
534
+ execution: config.execution ?? catalog.authoring[authoring]?.execution ?? 'components',
535
+ web,
536
+ rendering,
537
+ }
538
+ }
539
+
540
+ /** A migrated config plus the internal layout name the scaffold and doctor branch on. */
541
+ export function normalizeConfig(config) {
542
+ const migrated = migrateConfig(config)
543
+ if (!migrated?.targets) return migrated
544
+ return { ...migrated, target: layoutOf(migrated.targets) }
545
+ }
546
+
547
+ /** The catalog as data: what `--capabilities --json` prints and CI reads. */
548
+ export function describeCapabilities() {
549
+ const entries = (family) => Object.entries(family).map(([id, entry]) => ({ id, ...entry }))
550
+ return {
551
+ catalogVersion,
552
+ schemaVersion,
553
+ creator: versions.mavis,
554
+ combinations: combinations.map((combination) => ({
555
+ ...combination,
556
+ label: targetLabel(combination.targets),
557
+ hosts: combination.targets.includes('web')
558
+ ? combination.authoring === 'vue'
559
+ ? available(catalog.hosts)
560
+ : ['vite']
561
+ : [],
562
+ examples: Object.entries(catalog.examples)
563
+ .filter(([, example]) => example.authoring.includes(combination.authoring))
564
+ .map(([id]) => ({
565
+ id,
566
+ availability: availabilityOf({ targets: combination.targets, example: id }),
567
+ })),
568
+ })),
569
+ targets: entries(catalog.targets),
570
+ frameworks: entries(catalog.frameworks),
571
+ authoring: entries(catalog.authoring),
572
+ execution: entries(catalog.execution),
573
+ hosts: entries(catalog.hosts),
574
+ examples: entries(catalog.examples),
575
+ themes: Object.keys(catalog.themes),
576
+ packageManagers: [...catalog.packageManagers],
577
+ requirements,
578
+ versions,
579
+ planned: [...adapters.planned],
580
+ research: [...adapters.research],
581
+ }
582
+ }
583
+
584
+ /** The same catalog for people: what can be created now, and what is planned with its issue. */
585
+ export function formatCapabilities() {
586
+ const data = describeCapabilities()
587
+ const issue = (number) => `https://github.com/getcortexlabs/mavis-ui/issues/${number}`
588
+ const lines = ['What this creator can scaffold', '']
589
+ for (const combination of data.combinations) {
590
+ lines.push(
591
+ ` --targets ${combination.targets.join(',').padEnd(18)} ${combination.label} · ${catalog.authoring[combination.authoring].label}`,
592
+ )
593
+ if (combination.hosts.length)
594
+ lines.push(
595
+ ` Web: ${combination.hosts.map((host) => `${host} (${catalog.hosts[host].rendering.join('/')})`).join(', ')}`,
596
+ )
597
+ for (const example of combination.examples)
598
+ lines.push(
599
+ ` --example ${example.id.padEnd(10)} ${availabilityLabel(example.availability)}`,
600
+ )
601
+ }
602
+ lines.push(
603
+ '',
604
+ `Themes: ${data.themes.join(', ')} · Package managers: ${data.packageManagers.join(', ')}`,
605
+ `Needs Node.js ${requirements.node}+${requirements.packageManagers.pnpm ? `, pnpm ${requirements.packageManagers.pnpm}+ when used` : ''}.`,
606
+ `Native needs ${requirements.native}. Mac needs ${requirements.macos}.`,
607
+ `Pins: Mavis ${versions.mavis}, Jolt ${versions.jolt}, Vue ${versions.vue}, Nuxt ${versions.nuxt}, NativeScript ${versions.nativeCore}.`,
608
+ '',
609
+ 'Not available yet',
610
+ '',
611
+ )
612
+ for (const [family, flag] of [
613
+ ['frameworks', '--framework'],
614
+ ['hosts', '--web'],
615
+ ['authoring', '--authoring'],
616
+ ['execution', 'execution'],
617
+ ])
618
+ for (const entry of data[family].filter((item) => item.status === 'planned'))
619
+ lines.push(` ${`${flag} ${entry.id}`.padEnd(22)} ${entry.label} · ${issue(entry.issue)}`)
620
+ lines.push(
621
+ '',
622
+ '--familiar vue|react|angular|svelte|solid|other tells the creator what you already know.',
623
+ 'It changes the advice, never the framework that runs.',
624
+ )
625
+ return lines.join('\n')
626
+ }