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

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 (46) hide show
  1. package/README.md +26 -5
  2. package/package.json +4 -2
  3. package/src/adapters.mjs +7 -0
  4. package/src/add-macos.mjs +386 -0
  5. package/src/capabilities.mjs +78 -57
  6. package/src/cli.mjs +86 -4
  7. package/src/doctor.mjs +100 -18
  8. package/src/macos-capabilities.generated.mjs +4190 -0
  9. package/src/macos.mjs +147 -29
  10. package/src/migrate-directory.mjs +121 -0
  11. package/src/portability.mjs +108 -5
  12. package/src/scaffold.mjs +21 -2
  13. package/src/ui.mjs +21 -12
  14. package/templates/directory/host/directory-storage.ts +78 -0
  15. package/templates/directory/macos/DirectoryStorage.swift +68 -0
  16. package/templates/directory/mobile/src/app.ts +11 -8
  17. package/templates/directory/nuxt/app/plugins/mavis.ts +11 -8
  18. package/templates/directory/shared/Edit.vue +8 -5
  19. package/templates/directory/shared/directory-store.ts +42 -46
  20. package/templates/directory/vite/src/main.ts +11 -8
  21. package/templates/macos/examples/tasks/shared/TaskDetail.lite.tsx +2 -2
  22. package/templates/macos/examples/tasks/shared/Tasks.lite.tsx +2 -2
  23. package/templates/macos/examples/tasks/shared/types.ts +1 -0
  24. package/templates/macos/mobile/src/App.vue +4 -2
  25. package/templates/macos/native/Package.swift +3 -1
  26. package/templates/macos/native/Sources/MavisDesktop/App.swift +26 -11
  27. package/templates/macos/native/Sources/MavisDesktop/Fonts/LICENSE +45 -0
  28. package/templates/macos/native/Sources/MavisDesktop/Fonts/lucide.ttf +0 -0
  29. package/templates/macos/scripts/generate.mjs +3 -26
  30. package/templates/macos/scripts/macos-manifest.mjs +33 -0
  31. package/templates/macos/scripts/macos.mjs +20 -18
  32. package/templates/macos/web/index.html +1 -1
  33. package/templates/macos/web/src/main.js +176 -3
  34. package/templates/macos/web/src/mavis.js +2 -0
  35. package/templates/macos/web/src/style.css +2 -1
  36. package/templates/macos/web/vite.config.mjs +12 -1
  37. package/templates/migrations/directory-rc13.json +36 -0
  38. package/templates/mobile/src/mavis.ts +2 -82
  39. package/templates/mobile/webpack.config.js +4 -0
  40. package/templates/nuxt/app/mavis.ts +2 -84
  41. package/templates/vite/src/mavis.ts +2 -84
  42. package/templates/macos/scripts/portable/emit-swift.mjs +0 -1287
  43. package/templates/macos/scripts/portable/emit-vue.mjs +0 -615
  44. package/templates/macos/scripts/portable/index.mjs +0 -95
  45. package/templates/macos/scripts/portable/model.mjs +0 -1441
  46. package/templates/macos/scripts/portable/program.mjs +0 -163
@@ -1,4 +1,5 @@
1
1
  import { adapters } from './adapters.mjs'
2
+ import { macosCapabilities } from './macos-capabilities.generated.mjs'
2
3
 
3
4
  /** Shape of `--capabilities --json`, for tools that read it. */
4
5
  export const catalogVersion = 1
@@ -7,8 +8,8 @@ export const schemaVersion = 2
7
8
 
8
9
  /** Baseline pins; coordinated releases update Mavis after validating source templates with matching tarballs. */
9
10
  export const versions = Object.freeze({
10
- mavis: '0.1.0-rc.13',
11
- jolt: '0.1.0-rc.13',
11
+ mavis: '0.1.0-rc.14',
12
+ jolt: '0.1.0-rc.15',
12
13
  vue: '3.5.44',
13
14
  nuxt: '4.6.3',
14
15
  vite: '6.4.5',
@@ -62,9 +63,9 @@ export const catalog = Object.freeze({
62
63
  },
63
64
  macos: {
64
65
  label: 'Mac',
65
- hint: 'A SwiftUI app · experimental shared TSX',
66
+ hint: 'A SwiftUI app · shared Vue or TSX (experimental)',
66
67
  toolkit: 'swiftui',
67
- adapter: null,
68
+ adapter: 'macos-swiftui',
68
69
  status: 'experimental',
69
70
  },
70
71
  }),
@@ -103,6 +104,7 @@ export const catalog = Object.freeze({
103
104
  hint: 'Server rendering or a static website',
104
105
  rendering: ['ssr', 'ssg'],
105
106
  status: 'validated',
107
+ portableSince: '0.1.0-rc.14',
106
108
  },
107
109
  next: planned(issueOf('next'), 'Next.js'),
108
110
  }),
@@ -122,6 +124,8 @@ export const catalog = Object.freeze({
122
124
  label: 'Search, details and editing',
123
125
  hint: 'Shared routes, forms and local persistence',
124
126
  authoring: ['vue'],
127
+ portableAuthoring: 'vue',
128
+ portableSince: '0.1.0-rc.14',
125
129
  since: '0.1.0-alpha.9',
126
130
  },
127
131
  tasks: {
@@ -248,9 +252,15 @@ export function chosenTargets(options) {
248
252
  }
249
253
 
250
254
  /** Published and validated, published as an experiment, or only in the repository so far. */
251
- export function availabilityOf({ targets, example }) {
255
+ export function availabilityOf({ targets, example, web }) {
252
256
  const combination = combinations.find((entry) => entry.targets.join() === targets.join())
253
- if (combination.since === null || catalog.examples[example].since === null) return 'repository'
257
+ if (
258
+ combination.since === null ||
259
+ catalog.examples[example].since === null ||
260
+ (targets.includes('macos') && catalog.examples[example].portableSince === null) ||
261
+ (targets.includes('macos') && web && catalog.hosts[web]?.portableSince === null)
262
+ )
263
+ return 'repository'
254
264
  return combination.status === 'validated' ? 'published' : 'published-experimental'
255
265
  }
256
266
  const availabilityLabels = {
@@ -304,7 +314,7 @@ export function resolvePreset(options) {
304
314
  rendering = web === 'nuxt' ? 'ssr' : 'client',
305
315
  theme = 'mavis',
306
316
  framework = 'vue',
307
- authoring = mac ? 'mitosis' : 'vue',
317
+ authoring = mac && options.example !== 'directory' ? 'mitosis' : 'vue',
308
318
  example = 'welcome',
309
319
  packageManager = 'npm',
310
320
  familiar,
@@ -346,37 +356,46 @@ export function resolvePreset(options) {
346
356
  ...preset,
347
357
  availability: availabilityOf(preset),
348
358
  })
359
+ if (!catalog.hosts[web] || catalog.hosts[web].status === 'planned')
360
+ reject({
361
+ code: catalog.hosts[web] ? 'planned' : 'unknown',
362
+ option: '--web',
363
+ message: 'Web host must be vite or nuxt. React/Next are not available yet.',
364
+ issue: catalog.hosts[web]?.issue,
365
+ alternatives: available(catalog.hosts).map((host) => `--web ${host}`),
366
+ })
367
+ if (!hasWeb && (web !== 'vite' || rendering !== 'client'))
368
+ reject({
369
+ code: 'incompatible',
370
+ option: web !== 'vite' ? '--web' : '--rendering',
371
+ message: 'A project without Web has no Web rendering mode.',
372
+ alternatives: [`--targets web,${targets.join(',')}`],
373
+ })
374
+ if (!catalog.hosts[web].rendering.includes(rendering))
375
+ reject({
376
+ code: 'incompatible',
377
+ option: '--rendering',
378
+ message: 'Choose client rendering for Vite or ssr/ssg for Nuxt.',
379
+ alternatives: catalog.hosts[web].rendering.map((mode) => `--rendering ${mode}`),
380
+ })
349
381
  if (mac) {
350
- if (authoring !== 'mitosis')
382
+ const portableAuthoring = catalog.examples[example].portableAuthoring ?? 'mitosis'
383
+ if (authoring !== portableAuthoring)
351
384
  reject({
352
385
  code: 'incompatible',
353
386
  option: '--authoring',
354
- message:
355
- 'With Mac, shared screens are TSX sources compiled for every target; Vue templates are for projects without Mac.',
387
+ message: `With Mac, ${example} uses ${portableAuthoring === 'vue' ? 'shared Vue screens compiled to SwiftUI' : 'shared TSX sources compiled for every target'}. Choose --example directory for shared Vue.`,
356
388
  alternatives: [
357
- '--authoring mitosis',
389
+ `--authoring ${portableAuthoring}`,
358
390
  `--targets ${targets.filter((t) => t !== 'macos').join(',') || 'web'}`,
359
391
  ],
360
392
  })
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'))
393
+ if (!catalog.examples[example].authoring.includes(portableAuthoring))
374
394
  reject({
375
395
  code: 'incompatible',
376
396
  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'],
397
+ message: `The ${example} example does not provide shared ${portableAuthoring} sources for Mac.`,
398
+ alternatives: ['--example welcome', '--example directory', '--example tasks'],
380
399
  })
381
400
  return describe({
382
401
  schemaVersion,
@@ -391,8 +410,8 @@ export function resolvePreset(options) {
391
410
  }),
392
411
  framework,
393
412
  authoring,
394
- mode: catalog.authoring[authoring].mode,
395
- execution: catalog.authoring[authoring].execution,
413
+ mode: 'portable',
414
+ execution: 'generated',
396
415
  example,
397
416
  web: hasWeb ? web : null,
398
417
  rendering: hasWeb ? rendering : null,
@@ -432,28 +451,6 @@ export function resolvePreset(options) {
432
451
  issue: catalog.authoring.jsx.issue,
433
452
  alternatives: ['--authoring vue'],
434
453
  })
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
454
  return describe({
458
455
  schemaVersion,
459
456
  name,
@@ -550,17 +547,29 @@ export function describeCapabilities() {
550
547
  return {
551
548
  catalogVersion,
552
549
  schemaVersion,
550
+ macos: macosCapabilities,
553
551
  creator: versions.mavis,
552
+ migrations: {
553
+ macos: {
554
+ flag: '--add-macos',
555
+ apply: '--write',
556
+ status: 'experimental',
557
+ since: null,
558
+ hosts: ['vite', 'nuxt', 'nativescript'],
559
+ preservesSources: true,
560
+ compiler: '@getcortexlabs/mavis-compiler',
561
+ },
562
+ },
554
563
  combinations: combinations.map((combination) => ({
555
564
  ...combination,
556
565
  label: targetLabel(combination.targets),
557
- hosts: combination.targets.includes('web')
558
- ? combination.authoring === 'vue'
559
- ? available(catalog.hosts)
560
- : ['vite']
561
- : [],
566
+ hosts: combination.targets.includes('web') ? available(catalog.hosts) : [],
562
567
  examples: Object.entries(catalog.examples)
563
- .filter(([, example]) => example.authoring.includes(combination.authoring))
568
+ .filter(
569
+ ([, example]) =>
570
+ example.authoring.includes(combination.authoring) ||
571
+ (combination.targets.includes('macos') && example.portableAuthoring),
572
+ )
564
573
  .map(([id]) => ({
565
574
  id,
566
575
  availability: availabilityOf({ targets: combination.targets, example: id }),
@@ -599,6 +608,18 @@ export function formatCapabilities() {
599
608
  ` --example ${example.id.padEnd(10)} ${availabilityLabel(example.availability)}`,
600
609
  )
601
610
  }
611
+ lines.push('', 'Mac components · experimental source inventory (not runtime validation)')
612
+ for (const [name, component] of Object.entries(data.macos.components)) {
613
+ lines.push(
614
+ ` ${name}: ${component.status} · ${component.props.length} Vue props · #${component.issue}`,
615
+ )
616
+ for (const limit of component.limits) lines.push(` ${limit.en}`)
617
+ if (component.rejectedProps.length)
618
+ lines.push(` Rejected props: ${component.rejectedProps.join(', ')}`)
619
+ }
620
+ lines.push(
621
+ ' Exact props, events and slots: --capabilities --json. Validate your sources with --check-portability.',
622
+ )
602
623
  lines.push(
603
624
  '',
604
625
  `Themes: ${data.themes.join(', ')} · Package managers: ${data.packageManagers.join(', ')}`,
package/src/cli.mjs CHANGED
@@ -5,7 +5,9 @@ import { confirm, isCancel } from '@clack/prompts'
5
5
  import { readFile } from 'node:fs/promises'
6
6
  import { scaffold, installProject } from './scaffold.mjs'
7
7
  import { planTarget, applyTarget } from './add-target.mjs'
8
- import { checkPortability } from './portability.mjs'
8
+ import { planMacos, applyMacos } from './add-macos.mjs'
9
+ import { migrationDiff } from './migrate-directory.mjs'
10
+ import { checkPortability, formatMacReadiness } from './portability.mjs'
9
11
  import { doctor } from './doctor.mjs'
10
12
  import {
11
13
  atLeast,
@@ -37,6 +39,10 @@ const help = `Create Mavis — Web, Native (iOS/Android) and Mac in any combinat
37
39
  Earlier names: native, web, web+native, web+macos
38
40
  --add-native Add apps/mobile to an existing Vue/Vite or Nuxt app
39
41
  --add-web Add apps/web to an existing NativeScript-Vue app
42
+ --add-macos Preview adding SwiftUI to an existing app; --write applies
43
+ --migrate-directory Opt in to migrate an unmodified RC.13 Directory example
44
+ --shared-root path Source roots for --add-macos (comma-separated)
45
+ --entry path.vue Shared Vue/TSX entry for --add-macos
40
46
  --screen path.vue Reuse an existing screen without moving it
41
47
  --screen-root screen|content Existing MScreen or content to wrap (auto-detected)
42
48
  --web vite|nuxt Default: vite
@@ -51,7 +57,7 @@ const help = `Create Mavis — Web, Native (iOS/Android) and Mac in any combinat
51
57
  --check-portability Audit shared sources without SDK checks
52
58
  --path directory Override the configured shared source directory
53
59
  --fix-imports Preview safe renderer-import replacements
54
- --write Apply the previewed import migration
60
+ --write Apply the previewed import migration or Mac target
55
61
  --json Machine-readable portability diagnostics
56
62
  --theme mavis|midnight Default: mavis
57
63
  --package-manager npm|pnpm|yarn
@@ -86,6 +92,10 @@ try {
86
92
  targets: { type: 'string' },
87
93
  'add-native': { type: 'boolean' },
88
94
  'add-web': { type: 'boolean' },
95
+ 'add-macos': { type: 'boolean' },
96
+ 'migrate-directory': { type: 'boolean' },
97
+ 'shared-root': { type: 'string' },
98
+ entry: { type: 'string' },
89
99
  screen: { type: 'string' },
90
100
  'screen-root': { type: 'string' },
91
101
  web: { type: 'string' },
@@ -117,7 +127,70 @@ try {
117
127
  values.json ? JSON.stringify(describeCapabilities(), null, 2) : formatCapabilities(),
118
128
  )
119
129
  else if (values.version) console.log(version)
120
- else if (values['add-native'] || values['add-web']) {
130
+ else if (values['add-macos']) {
131
+ if (
132
+ positionals.length ||
133
+ values['add-native'] ||
134
+ values['add-web'] ||
135
+ values.target ||
136
+ values.targets ||
137
+ values['check-portability'] ||
138
+ values['fix-imports'] ||
139
+ values.path ||
140
+ values.doctor ||
141
+ values.example ||
142
+ values.theme ||
143
+ values.framework ||
144
+ values.authoring ||
145
+ values.screen ||
146
+ values['screen-root'] ||
147
+ values.web ||
148
+ values.rendering
149
+ )
150
+ throw new Error(
151
+ 'Run --add-macos in the existing project. Choose source roots with --shared-root and an entry with --entry.',
152
+ )
153
+ if (values.install || values['no-install'])
154
+ throw new Error(
155
+ '--add-macos does not install dependencies; review and apply with --write, then run your package manager.',
156
+ )
157
+ if (values.write && values['dry-run']) throw new Error('Choose --write or --dry-run, not both.')
158
+ const plan = await planMacos({
159
+ roots: values['shared-root']?.split(',').map((root) => root.trim()),
160
+ entry: values.entry,
161
+ packageManager: values['package-manager'],
162
+ migrateDirectory: values['migrate-directory'],
163
+ })
164
+ const summary = {
165
+ directory: 'apps/macos',
166
+ entry: plan.entry,
167
+ roots: plan.roots,
168
+ manager: plan.manager,
169
+ alreadyAdded: plan.alreadyAdded,
170
+ components: plan.components,
171
+ files: [...plan.files.keys()],
172
+ config: plan.config,
173
+ migration: plan.migration ?? [],
174
+ applied: Boolean(values.write && !plan.alreadyAdded),
175
+ }
176
+ if (values.write) await applyMacos(plan, { signal: cancellation.signal })
177
+ if (values.json) console.log(JSON.stringify(summary, null, 2))
178
+ else {
179
+ ui.message(
180
+ `${plan.alreadyAdded ? 'Already configured' : values.write ? 'Added' : 'Preview'}: SwiftUI in apps/macos; ${plan.components} shared components`,
181
+ )
182
+ for (const diff of summary.migration) console.log(migrationDiff(diff))
183
+ for (const name of summary.files)
184
+ console.log(` ${plan.original.get(name) === undefined ? '+' : '~'} ${name}`)
185
+ console.log(
186
+ plan.alreadyAdded
187
+ ? 'Existing files were preserved.'
188
+ : values.write
189
+ ? `Run ${packageCommands(plan.manager).install}, then ${packageCommands(plan.manager).run('build:macos')}.`
190
+ : 'No files changed. Review this plan and rerun with --write to add Mac and migrate mavis.config.json to schema 2.',
191
+ )
192
+ }
193
+ } else if (values['add-native'] || values['add-web']) {
121
194
  if (!atLeast(process.versions.node, requirements.node))
122
195
  throw new Error(
123
196
  `Mavis needs Node.js ${requirements.node} or newer. You are using ${process.version}.`,
@@ -144,6 +217,8 @@ try {
144
217
  throw new Error('--web and --rendering belong to --add-web.')
145
218
  if (values.install && values['no-install'])
146
219
  throw new Error('Choose either --install or --no-install.')
220
+ if (values.entry || values['shared-root'] || values['migrate-directory'])
221
+ throw new Error('--entry and --shared-root require --add-macos.')
147
222
  if (values['screen-root'] && !values.screen) throw new Error('--screen-root requires --screen.')
148
223
  const target = await planTarget({
149
224
  target: values['add-native'] ? 'mobile' : 'web',
@@ -231,13 +306,20 @@ try {
231
306
  console.log(
232
307
  `${result.files.length} files checked; ${result.diagnostics.length} findings. ${values['fix-imports'] && !values.write ? 'Preview only. Use --write to apply safe import changes.' : ''}`,
233
308
  )
309
+ console.log(formatMacReadiness(result.macos))
234
310
  }
235
- if (result.diagnostics.length) process.exitCode = 1
311
+ // A project without a Mac target is only told; one with it has to be ready.
312
+ const config = await readFile('mavis.config.json', 'utf8').then(JSON.parse, () => ({}))
313
+ const blocked =
314
+ config.targets?.includes('macos') && result.macos.files?.some((file) => !file.ready)
315
+ if (result.diagnostics.length || blocked) process.exitCode = 1
236
316
  } else if (values.doctor) {
237
317
  const results = await doctor()
238
318
  for (const item of results) console.log(`${item.ok ? '✓' : '—'} ${item.name}: ${item.detail}`)
239
319
  if (results.some((item) => !item.ok)) process.exitCode = 1
240
320
  } else {
321
+ if (values.entry || values['shared-root'] || values['migrate-directory'])
322
+ throw new Error('--entry and --shared-root require --add-macos.')
241
323
  if (values.screen || values['screen-root'])
242
324
  throw new Error('--screen requires --add-native or --add-web.')
243
325
  if (values.write || values.path || values.json)
package/src/doctor.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { pathToFileURL } from 'node:url'
2
+ import { createRequire } from 'node:module'
2
3
  import { spawnSync } from 'node:child_process'
3
4
  import { readFile } from 'node:fs/promises'
4
5
  import { checkPortability } from './portability.mjs'
@@ -22,23 +23,13 @@ export async function doctor(cwd = process.cwd()) {
22
23
  throw new Error('Run --doctor from a generated project containing mavis.config.json.')
23
24
  }
24
25
  // The same check the creator runs before writing a project, on what this one records.
25
- const project = checkProject({
26
- name: config.name,
27
- targets: config.targets,
28
- web: config.web ?? undefined,
29
- rendering: config.rendering ?? undefined,
30
- framework: config.framework,
31
- authoring: config.authoring,
32
- example: config.example,
33
- theme: config.theme,
34
- packageManager: config.packageManager,
35
- })
26
+ const project = checkRecordedProject(config)
36
27
  const results = [
37
28
  {
38
29
  name: 'Project configuration',
39
30
  ok: project.ok,
40
31
  detail: project.ok
41
- ? `${targetLabel(config.targets)} · ${catalog.authoring[config.authoring].label} · ${availabilityLabel(availabilityOf(config))}`
32
+ ? `${targetLabel(config.targets)} · ${catalog.authoring[config.authoring].label} · ${config.portability?.existing ? 'existing application; experimental Mac target' : availabilityLabel(availabilityOf(config))}`
42
33
  : project.message.split('\n')[0],
43
34
  },
44
35
  {
@@ -60,13 +51,25 @@ export async function doctor(cwd = process.cwd()) {
60
51
  ? (result.error?.message ?? (result.stdout || result.stderr)).trim().split('\n')[0]
61
52
  : 'macOS 14+ and Xcode are required for the native app. Web remains available.',
62
53
  })
63
- // The project's own compiler copy, with its installed TypeScript and theme packages.
54
+ // Use the compiler installed in this project, not a copied implementation.
64
55
  try {
65
- const compiler = await import(pathToFileURL(join(cwd, 'scripts/portable/index.mjs')))
66
- const { model } = await compiler.compileProject(await compiler.readShared(cwd), {
67
- theme: config.theme,
68
- root: config.portability?.entry ?? 'Welcome',
69
- })
56
+ const compiler = await import(
57
+ pathToFileURL(
58
+ createRequire(join(cwd, 'package.json')).resolve('@getcortexlabs/mavis-compiler'),
59
+ )
60
+ )
61
+ results.push(...(await checkMacVersions(cwd, config, compiler)))
62
+ compiler.macAppSettings(config.macos, config.name)
63
+ const { model } = await compiler.compileProject(
64
+ await compiler.readShared(cwd, { roots: config.portability?.roots }),
65
+ {
66
+ theme: config.theme,
67
+ root: config.portability?.entry ?? 'Welcome',
68
+ sourceRoot: config.portability?.sourceRoot ?? config.portability?.roots?.[0] ?? 'shared',
69
+ destinations: config.portability?.destinations,
70
+ },
71
+ )
72
+ compiler.startupPlan(model, config.portability?.startup)
70
73
  results.push({
71
74
  name: 'Shared sources',
72
75
  ok: true,
@@ -95,6 +98,25 @@ export async function doctor(cwd = process.cwd()) {
95
98
  return results
96
99
  }
97
100
 
101
+ /** Configuration choices only; compiler diagnostics validate custom theme modules separately. */
102
+ export function checkRecordedProject(config) {
103
+ if (config.portability?.existing) return existingProject(config)
104
+ return checkProject({
105
+ name: config.name,
106
+ targets: config.targets,
107
+ web: config.web ?? undefined,
108
+ rendering: config.rendering ?? undefined,
109
+ framework: config.framework,
110
+ authoring: config.authoring,
111
+ example: config.example,
112
+ theme:
113
+ config.targets?.includes('macos') && typeof config.theme === 'object'
114
+ ? undefined
115
+ : config.theme,
116
+ packageManager: config.packageManager,
117
+ })
118
+ }
119
+
98
120
  function nativeChecks(results) {
99
121
  const probe = (name, command, args) => {
100
122
  const result = spawnSync(command, args, { encoding: 'utf8', timeout: 10000 })
@@ -121,3 +143,63 @@ function nativeChecks(results) {
121
143
  detail: 'iOS builds require macOS and Xcode; Android remains available.',
122
144
  })
123
145
  }
146
+
147
+ function existingProject(config) {
148
+ const ok =
149
+ Array.isArray(config.targets) &&
150
+ config.targets.includes('macos') &&
151
+ config.targets.every((target) => catalog.targets[target]) &&
152
+ ['vue', 'mitosis'].includes(config.authoring) &&
153
+ catalog.packageManagers.includes(config.packageManager) &&
154
+ (!config.targets.includes('web') ||
155
+ catalog.hosts[config.web]?.rendering?.includes(config.rendering))
156
+ return {
157
+ ok,
158
+ message:
159
+ 'Invalid targets, authoring, package manager or Web host/rendering in mavis.config.json.',
160
+ }
161
+ }
162
+
163
+ /** Read-only release alignment check, independent of the Swift/NativeScript SDK probes. */
164
+ export async function checkMacVersions(cwd, config, compiler) {
165
+ const results = []
166
+ const manifests = []
167
+ for (const name of ['package.json', 'apps/web/package.json', 'apps/mobile/package.json']) {
168
+ try {
169
+ manifests.push(JSON.parse(await readFile(join(cwd, name), 'utf8')))
170
+ } catch (error) {
171
+ if (error.code !== 'ENOENT') throw error
172
+ }
173
+ }
174
+ const dependencies = manifests.map((pkg) => ({ ...pkg.devDependencies, ...pkg.dependencies }))
175
+ const declared = dependencies[0]?.['@getcortexlabs/mavis-compiler']
176
+ const expected = config.versions?.mavis ?? compiler.compilerVersion
177
+ const renderers = dependencies.flatMap((dep) =>
178
+ ['@getcortexlabs/mavis-core', '@getcortexlabs/mavis-web', '@getcortexlabs/mavis'].flatMap(
179
+ (name) => (dep[name] ? [dep[name]] : []),
180
+ ),
181
+ )
182
+ results.push({
183
+ name: 'Mavis compiler version',
184
+ ok:
185
+ declared === compiler.compilerVersion &&
186
+ compiler.compilerVersion === expected &&
187
+ renderers.every((version) => [expected, '^' + expected, '~' + expected].includes(version)),
188
+ detail: `Installed compiler ${compiler.compilerVersion}; requested ${declared ?? 'missing'}; Mavis ${expected}. Upgrade Mavis and the compiler together.`,
189
+ })
190
+ const jolts = dependencies.flatMap((dep) =>
191
+ dep['@rafaelaugusto/jolt'] ? [dep['@rafaelaugusto/jolt']] : [],
192
+ )
193
+ const swift = await readFile(join(cwd, 'apps/macos/Package.swift'), 'utf8')
194
+ const pin = /jolt-swift[^\n]*exact:\s*"([^"]+)"/.exec(swift)?.[1]
195
+ const expectedJolt = config.versions?.jolt ?? compiler.joltSwift.version
196
+ results.push({
197
+ name: 'Jolt / SwiftUI version',
198
+ ok:
199
+ pin === expectedJolt &&
200
+ pin === compiler.joltSwift.version &&
201
+ jolts.every((version) => version === pin),
202
+ detail: `Jolt ${[...new Set(jolts)].join(', ') || expectedJolt}; SwiftUI ${pin ?? 'missing exact pin'}; compiler expects ${compiler.joltSwift.version}.`,
203
+ })
204
+ return results
205
+ }