@getcortexlabs/create-mavis 0.1.0-rc.14 → 0.1.0-rc.16
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.
- package/README.md +21 -28
- package/package.json +2 -4
- package/src/adapters.mjs +45 -23
- package/src/add-desktop.mjs +354 -0
- package/src/capabilities.mjs +233 -134
- package/src/cli.mjs +64 -60
- package/src/desktop.mjs +155 -0
- package/src/doctor.mjs +77 -108
- package/src/native-framework.mjs +144 -0
- package/src/portability.mjs +7 -106
- package/src/scaffold.mjs +36 -12
- package/src/shared-api.mjs +3 -0
- package/src/ui.mjs +30 -42
- package/templates/desktop/common/LICENSE +21 -0
- package/templates/desktop/common/build.mjs +49 -0
- package/templates/desktop/common/src/components.ts +60 -0
- package/templates/desktop/common/src/contract.mjs +35 -0
- package/templates/desktop/common/src/renderer.ts +76 -0
- package/templates/desktop/common/src/storage.ts +29 -0
- package/templates/desktop/directory/main.ts +35 -0
- package/templates/desktop/macos/launch.mjs +6 -0
- package/templates/desktop/macos/package.mjs +114 -0
- package/templates/desktop/macos/src/host.mjs +471 -0
- package/templates/desktop/welcome/Welcome.vue +56 -0
- package/templates/desktop/welcome/main.ts +24 -0
- package/templates/desktop/windows/NativeScript-LICENSE +19 -0
- package/templates/desktop/windows/launch.mjs +16 -0
- package/templates/desktop/windows/package.mjs +54 -0
- package/templates/desktop/windows/prepare-host.mjs +73 -0
- package/templates/desktop/windows/src/host.mjs +294 -0
- package/templates/native-framework/angular/screen.ts +84 -0
- package/templates/native-framework/common/nativescript.config.ts +6 -0
- package/templates/native-framework/common/src/app.ts +5 -0
- package/templates/native-framework/common/src/model.ts +40 -0
- package/templates/native-framework/common/src/references.d.ts +8 -0
- package/templates/native-framework/common/tsconfig.json +16 -0
- package/templates/native-framework/common/webpack.config.js +67 -0
- package/templates/native-framework/plain/screen.ts +102 -0
- package/templates/native-framework/react/screen.ts +83 -0
- package/templates/native-framework/solid/screen.ts +111 -0
- package/templates/native-framework/svelte/Welcome.svelte +26 -0
- package/templates/native-framework/svelte/screen.ts +14 -0
- package/templates/native-framework/svelte-tooling/svelte.config.js +20 -0
- package/src/add-macos.mjs +0 -386
- package/src/macos-capabilities.generated.mjs +0 -4190
- package/src/macos.mjs +0 -394
- package/src/migrate-directory.mjs +0 -121
- package/templates/directory/macos/DirectoryStorage.swift +0 -68
- package/templates/macos/examples/tasks/shared/TaskDetail.lite.tsx +0 -57
- package/templates/macos/examples/tasks/shared/TaskRow.lite.tsx +0 -33
- package/templates/macos/examples/tasks/shared/Tasks.lite.tsx +0 -251
- package/templates/macos/examples/tasks/shared/types.ts +0 -10
- package/templates/macos/mobile/src/App.vue +0 -14
- package/templates/macos/mobile/src/app.ts +0 -7
- package/templates/macos/native/Package.swift +0 -19
- package/templates/macos/native/Sources/MavisDesktop/App.swift +0 -35
- package/templates/macos/native/Sources/MavisDesktop/Fonts/LICENSE +0 -45
- package/templates/macos/native/Sources/MavisDesktop/Fonts/lucide.ttf +0 -0
- package/templates/macos/root/tsconfig.json +0 -14
- package/templates/macos/scripts/generate.mjs +0 -13
- package/templates/macos/scripts/macos-manifest.mjs +0 -33
- package/templates/macos/scripts/macos.mjs +0 -58
- package/templates/macos/shared/Welcome.lite.tsx +0 -42
- package/templates/macos/web/index.html +0 -12
- package/templates/macos/web/src/main.js +0 -212
- package/templates/macos/web/src/mavis.js +0 -2
- package/templates/macos/web/src/style.css +0 -14
- package/templates/macos/web/vite.config.mjs +0 -14
- package/templates/migrations/directory-rc13.json +0 -36
package/src/cli.mjs
CHANGED
|
@@ -5,9 +5,8 @@ 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 {
|
|
9
|
-
import {
|
|
10
|
-
import { checkPortability, formatMacReadiness } from './portability.mjs'
|
|
8
|
+
import { planDesktop, applyDesktop } from './add-desktop.mjs'
|
|
9
|
+
import { checkPortability } from './portability.mjs'
|
|
11
10
|
import { doctor } from './doctor.mjs'
|
|
12
11
|
import {
|
|
13
12
|
atLeast,
|
|
@@ -27,22 +26,23 @@ import {
|
|
|
27
26
|
import { nextSteps, projectSummary, sharedEntry, terminalUI, wizard } from './ui.mjs'
|
|
28
27
|
|
|
29
28
|
const { version } = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'))
|
|
30
|
-
const help = `Create Mavis — Web, Native (iOS/Android)
|
|
29
|
+
const help = `Create Mavis — Web, Native (iOS/Android), Mac and Windows
|
|
31
30
|
|
|
32
31
|
npm create @getcortexlabs/mavis@latest
|
|
33
32
|
create-mavis my-app --targets web,native,macos --package-manager pnpm --no-install
|
|
34
33
|
create-mavis my-app --targets web,native --web nuxt
|
|
35
34
|
|
|
36
|
-
--targets web,native,macos
|
|
37
|
-
|
|
35
|
+
--targets web,native,macos,windows
|
|
36
|
+
Default: web. Desktop uses shared Vue (experimental)
|
|
37
|
+
--macos-runtime appkit NativeScript AppKit is the macOS runtime
|
|
38
38
|
--target mobile|web|both|macos
|
|
39
39
|
Earlier names: native, web, web+native, web+macos
|
|
40
40
|
--add-native Add apps/mobile to an existing Vue/Vite or Nuxt app
|
|
41
41
|
--add-web Add apps/web to an existing NativeScript-Vue app
|
|
42
|
-
--add-macos Preview adding
|
|
43
|
-
--
|
|
44
|
-
--shared-root path Source roots for
|
|
45
|
-
--entry path.vue Shared Vue
|
|
42
|
+
--add-macos Preview adding NativeScript AppKit; --write applies
|
|
43
|
+
--add-windows Preview adding NativeScript Windows; --write applies
|
|
44
|
+
--shared-root path Source roots for desktop adoption (comma-separated)
|
|
45
|
+
--entry path.vue Shared Vue entry for --add-macos
|
|
46
46
|
--screen path.vue Reuse an existing screen without moving it
|
|
47
47
|
--screen-root screen|content Existing MScreen or content to wrap (auto-detected)
|
|
48
48
|
--web vite|nuxt Default: vite
|
|
@@ -51,9 +51,7 @@ const help = `Create Mavis — Web, Native (iOS/Android) and Mac in any combinat
|
|
|
51
51
|
validated and what is planned (add --json for tools)
|
|
52
52
|
--familiar vue|react|angular|svelte|solid|other
|
|
53
53
|
What you already know. Changes the advice, not what runs
|
|
54
|
-
--example welcome|directory
|
|
55
|
-
Starter, shared search/detail/edit reference, or the
|
|
56
|
-
Tasks app (with macos: one source for every target)
|
|
54
|
+
--example welcome|directory Starter or shared search/detail/edit reference
|
|
57
55
|
--check-portability Audit shared sources without SDK checks
|
|
58
56
|
--path directory Override the configured shared source directory
|
|
59
57
|
--fix-imports Preview safe renderer-import replacements
|
|
@@ -62,8 +60,9 @@ const help = `Create Mavis — Web, Native (iOS/Android) and Mac in any combinat
|
|
|
62
60
|
--theme mavis|midnight Default: mavis
|
|
63
61
|
--package-manager npm|pnpm|yarn
|
|
64
62
|
Default: the invoking manager, or npm
|
|
65
|
-
--framework vue
|
|
66
|
-
|
|
63
|
+
--framework vue|plain|react|angular|svelte|solid
|
|
64
|
+
Direct frameworks: iOS/Android only; desktop/Web use Vue
|
|
65
|
+
--authoring vue|native Vue or direct native framework authoring
|
|
67
66
|
--yes, -y Use defaults without prompts (skip installation)
|
|
68
67
|
--install / --no-install Install dependencies now or later
|
|
69
68
|
--dry-run Show the complete file plan without writing
|
|
@@ -93,7 +92,8 @@ try {
|
|
|
93
92
|
'add-native': { type: 'boolean' },
|
|
94
93
|
'add-web': { type: 'boolean' },
|
|
95
94
|
'add-macos': { type: 'boolean' },
|
|
96
|
-
'
|
|
95
|
+
'add-windows': { type: 'boolean' },
|
|
96
|
+
'macos-runtime': { type: 'string' },
|
|
97
97
|
'shared-root': { type: 'string' },
|
|
98
98
|
entry: { type: 'string' },
|
|
99
99
|
screen: { type: 'string' },
|
|
@@ -127,67 +127,75 @@ try {
|
|
|
127
127
|
values.json ? JSON.stringify(describeCapabilities(), null, 2) : formatCapabilities(),
|
|
128
128
|
)
|
|
129
129
|
else if (values.version) console.log(version)
|
|
130
|
-
else if (values['add-macos']) {
|
|
130
|
+
else if (values['add-windows'] || values['add-macos']) {
|
|
131
131
|
if (
|
|
132
132
|
positionals.length ||
|
|
133
|
+
values.targets ||
|
|
134
|
+
values.target ||
|
|
133
135
|
values['add-native'] ||
|
|
134
136
|
values['add-web'] ||
|
|
135
|
-
values
|
|
136
|
-
values.targets ||
|
|
137
|
+
(values['add-macos'] && values['add-windows']) ||
|
|
137
138
|
values['check-portability'] ||
|
|
138
139
|
values['fix-imports'] ||
|
|
139
|
-
values.path ||
|
|
140
140
|
values.doctor ||
|
|
141
|
+
values.authoring ||
|
|
142
|
+
values.framework ||
|
|
141
143
|
values.example ||
|
|
142
144
|
values.theme ||
|
|
143
|
-
values.framework ||
|
|
144
|
-
values.authoring ||
|
|
145
145
|
values.screen ||
|
|
146
146
|
values['screen-root'] ||
|
|
147
147
|
values.web ||
|
|
148
|
-
values.rendering
|
|
148
|
+
values.rendering ||
|
|
149
|
+
values.path
|
|
149
150
|
)
|
|
150
151
|
throw new Error(
|
|
151
|
-
'Run --add-macos in the existing project
|
|
152
|
+
'Run --add-macos or --add-windows in the existing project, with --shared-root and --entry if needed. Add one target at a time.',
|
|
152
153
|
)
|
|
154
|
+
if (values['add-windows'] && values['macos-runtime'])
|
|
155
|
+
throw new Error('--macos-runtime belongs to --add-macos.')
|
|
156
|
+
if (values['macos-runtime'] && values['macos-runtime'] !== 'appkit')
|
|
157
|
+
throw new Error('The macOS runtime is NativeScript AppKit.')
|
|
153
158
|
if (values.install || values['no-install'])
|
|
154
159
|
throw new Error(
|
|
155
|
-
'
|
|
160
|
+
'Desktop adoption previews changes; use --write, then install in the new host directory.',
|
|
156
161
|
)
|
|
157
162
|
if (values.write && values['dry-run']) throw new Error('Choose --write or --dry-run, not both.')
|
|
158
|
-
const
|
|
163
|
+
const target = values['add-windows'] ? 'windows' : 'macos'
|
|
164
|
+
const preview = await planDesktop({
|
|
165
|
+
target,
|
|
159
166
|
roots: values['shared-root']?.split(',').map((root) => root.trim()),
|
|
160
167
|
entry: values.entry,
|
|
161
168
|
packageManager: values['package-manager'],
|
|
162
|
-
migrateDirectory: values['migrate-directory'],
|
|
163
169
|
})
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
170
|
+
if (values.write) await applyDesktop(preview, { signal: cancellation.signal })
|
|
171
|
+
if (values.json)
|
|
172
|
+
console.log(
|
|
173
|
+
JSON.stringify(
|
|
174
|
+
{
|
|
175
|
+
directory: preview.destination,
|
|
176
|
+
entry: preview.entry,
|
|
177
|
+
files: [...preview.files.keys()],
|
|
178
|
+
alreadyAdded: preview.alreadyAdded,
|
|
179
|
+
applied: Boolean(values.write && !preview.alreadyAdded),
|
|
180
|
+
diagnostics: preview.diagnostics,
|
|
181
|
+
},
|
|
182
|
+
null,
|
|
183
|
+
2,
|
|
184
|
+
),
|
|
185
|
+
)
|
|
178
186
|
else {
|
|
179
187
|
ui.message(
|
|
180
|
-
`${
|
|
188
|
+
`${preview.alreadyAdded ? 'Already configured' : values.write ? 'Added' : 'Preview'}: NativeScript ${target} in ${preview.destination}`,
|
|
181
189
|
)
|
|
182
|
-
for (const
|
|
183
|
-
|
|
184
|
-
|
|
190
|
+
for (const path of preview.files.keys())
|
|
191
|
+
console.log(` ${preview.original.get(path) === undefined ? '+' : '~'} ${path}`)
|
|
192
|
+
for (const diagnostic of preview.diagnostics) console.log(diagnostic)
|
|
185
193
|
console.log(
|
|
186
|
-
|
|
194
|
+
preview.alreadyAdded
|
|
187
195
|
? 'Existing files were preserved.'
|
|
188
196
|
: values.write
|
|
189
|
-
? `
|
|
190
|
-
: 'No files changed. Review
|
|
197
|
+
? `Install dependencies in ${preview.destination}, then run ${packageCommands(preview.manager).run(target)} on ${target === 'macos' ? 'macOS' : 'Windows'}.`
|
|
198
|
+
: 'No files changed. Review and rerun with --write.',
|
|
191
199
|
)
|
|
192
200
|
}
|
|
193
201
|
} else if (values['add-native'] || values['add-web']) {
|
|
@@ -217,8 +225,8 @@ try {
|
|
|
217
225
|
throw new Error('--web and --rendering belong to --add-web.')
|
|
218
226
|
if (values.install && values['no-install'])
|
|
219
227
|
throw new Error('Choose either --install or --no-install.')
|
|
220
|
-
if (values.entry || values['shared-root']
|
|
221
|
-
throw new Error('--entry and --shared-root require --add-macos.')
|
|
228
|
+
if (values.entry || values['shared-root'])
|
|
229
|
+
throw new Error('--entry and --shared-root require --add-macos or --add-windows.')
|
|
222
230
|
if (values['screen-root'] && !values.screen) throw new Error('--screen-root requires --screen.')
|
|
223
231
|
const target = await planTarget({
|
|
224
232
|
target: values['add-native'] ? 'mobile' : 'web',
|
|
@@ -306,20 +314,15 @@ try {
|
|
|
306
314
|
console.log(
|
|
307
315
|
`${result.files.length} files checked; ${result.diagnostics.length} findings. ${values['fix-imports'] && !values.write ? 'Preview only. Use --write to apply safe import changes.' : ''}`,
|
|
308
316
|
)
|
|
309
|
-
console.log(formatMacReadiness(result.macos))
|
|
310
317
|
}
|
|
311
|
-
|
|
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
|
|
318
|
+
if (result.diagnostics.length) process.exitCode = 1
|
|
316
319
|
} else if (values.doctor) {
|
|
317
320
|
const results = await doctor()
|
|
318
321
|
for (const item of results) console.log(`${item.ok ? '✓' : '—'} ${item.name}: ${item.detail}`)
|
|
319
322
|
if (results.some((item) => !item.ok)) process.exitCode = 1
|
|
320
323
|
} else {
|
|
321
|
-
if (values.entry || values['shared-root']
|
|
322
|
-
throw new Error('--entry and --shared-root require --add-macos.')
|
|
324
|
+
if (values.entry || values['shared-root'])
|
|
325
|
+
throw new Error('--entry and --shared-root require --add-macos or --add-windows.')
|
|
323
326
|
if (values.screen || values['screen-root'])
|
|
324
327
|
throw new Error('--screen requires --add-native or --add-web.')
|
|
325
328
|
if (values.write || values.path || values.json)
|
|
@@ -334,6 +337,7 @@ try {
|
|
|
334
337
|
let options = {
|
|
335
338
|
...values,
|
|
336
339
|
name: positionals[0],
|
|
340
|
+
macosRuntime: values['macos-runtime'],
|
|
337
341
|
packageManager: values['package-manager'],
|
|
338
342
|
install: values['no-install'] ? false : values.install,
|
|
339
343
|
dryRun: Boolean(values['dry-run']),
|
|
@@ -375,9 +379,9 @@ try {
|
|
|
375
379
|
})
|
|
376
380
|
ui.note(nextSteps(plan.preset, options.install), 'Next steps')
|
|
377
381
|
ui.message(`Make it yours: ${sharedEntry(plan.preset)}`)
|
|
378
|
-
if (plan.preset.target === '
|
|
382
|
+
if (plan.preset.target === 'desktop')
|
|
379
383
|
ui.message(
|
|
380
|
-
|
|
384
|
+
'Experimental NativeScript desktop subset: check the generated README and --doctor for platform requirements and supported components.',
|
|
381
385
|
)
|
|
382
386
|
else if (plan.preset.target !== 'web')
|
|
383
387
|
ui.message(
|
package/src/desktop.mjs
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { posix } from 'node:path'
|
|
2
|
+
const { join } = posix
|
|
3
|
+
import { configOf, versions as v } from './capabilities.mjs'
|
|
4
|
+
import { packageCommands } from './package-manager.mjs'
|
|
5
|
+
const json = (value) => JSON.stringify(value, null, 2) + '\n'
|
|
6
|
+
|
|
7
|
+
/** Every desktop host owns its runtime dependencies; shared Vue never imports an OS bridge. */
|
|
8
|
+
export async function desktopFiles(preset, copyTemplate, projectFiles) {
|
|
9
|
+
// Reuse the existing web/mobile hosts and their shared import configuration.
|
|
10
|
+
const base = await projectFiles({
|
|
11
|
+
...preset,
|
|
12
|
+
targets: ['web', 'native'],
|
|
13
|
+
target: undefined,
|
|
14
|
+
macosRuntime: undefined,
|
|
15
|
+
'macos-runtime': undefined,
|
|
16
|
+
web: preset.web ?? 'vite',
|
|
17
|
+
rendering: preset.rendering ?? 'client',
|
|
18
|
+
})
|
|
19
|
+
const files = base.files
|
|
20
|
+
for (const [prefix, target] of [
|
|
21
|
+
['apps/web/', 'web'],
|
|
22
|
+
['apps/mobile/', 'native'],
|
|
23
|
+
])
|
|
24
|
+
if (!preset.targets.includes(target))
|
|
25
|
+
for (const path of files.keys()) if (path.startsWith(prefix)) files.delete(path)
|
|
26
|
+
if (preset.example === 'welcome') {
|
|
27
|
+
await copyTemplate(files, 'desktop/welcome', '.desktop-welcome', { NAME: preset.name })
|
|
28
|
+
files.set('shared/Welcome.vue', files.get('.desktop-welcome/Welcome.vue'))
|
|
29
|
+
for (const path of files.keys()) if (path.startsWith('.desktop-welcome/')) files.delete(path)
|
|
30
|
+
}
|
|
31
|
+
const commands = packageCommands(preset.packageManager)
|
|
32
|
+
const root = JSON.parse(files.get('package.json'))
|
|
33
|
+
if (!preset.targets.includes('web')) delete root.workspaces
|
|
34
|
+
for (const script of ['dev:web', 'build:web'])
|
|
35
|
+
if (!preset.targets.includes('web')) delete root.scripts[script]
|
|
36
|
+
for (const script of ['ios', 'android'])
|
|
37
|
+
if (!preset.targets.includes('native')) delete root.scripts[script]
|
|
38
|
+
root.engines.node = '>=22.23.3'
|
|
39
|
+
root.scripts['install:apps'] = 'node scripts/install-apps.mjs'
|
|
40
|
+
const hosts = []
|
|
41
|
+
for (const target of ['macos', 'windows']) {
|
|
42
|
+
if (!preset.targets.includes(target)) continue
|
|
43
|
+
hosts.push({ directory: `apps/${target}`, platform: target === 'macos' ? 'darwin' : 'win32' })
|
|
44
|
+
const generated = await desktopHostFiles(preset, target, copyTemplate)
|
|
45
|
+
generated.set(
|
|
46
|
+
'mavis.host.json',
|
|
47
|
+
json({
|
|
48
|
+
schemaVersion: 1,
|
|
49
|
+
kind: 'nativescript-desktop',
|
|
50
|
+
target,
|
|
51
|
+
entry: `shared/${preset.example === 'directory' ? 'Directory' : 'Welcome'}.vue`,
|
|
52
|
+
}),
|
|
53
|
+
)
|
|
54
|
+
for (const [path, source] of generated) files.set(join(`apps/${target}`, path), source)
|
|
55
|
+
root.scripts[target] = commands.run('dev', `apps/${target}`)
|
|
56
|
+
root.scripts[`build:${target}`] = commands.run('build', `apps/${target}`)
|
|
57
|
+
root.scripts[`package:${target}`] = commands.run('package', `apps/${target}`)
|
|
58
|
+
}
|
|
59
|
+
if (preset.targets.includes('native')) hosts.unshift({ directory: 'apps/mobile' })
|
|
60
|
+
files.set(
|
|
61
|
+
'scripts/install-apps.mjs',
|
|
62
|
+
`import { spawnSync } from 'node:child_process'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nconst root = resolve(dirname(fileURLToPath(import.meta.url)), '..')\nconst hosts = ${json([{ directory: '.' }, ...hosts])}\nfor (const host of hosts) {\n if (host.platform && host.platform !== process.platform) { console.log('Install ' + host.directory + ' on ' + host.platform + '.'); continue }\n const result = spawnSync(${JSON.stringify(preset.packageManager)}, ['install'], { cwd: resolve(root, host.directory), stdio: 'inherit', shell: process.platform === 'win32' })\n if (result.error) throw result.error\n if (result.status !== 0) process.exit(result.status ?? 1)\n}\n`,
|
|
63
|
+
)
|
|
64
|
+
files.set('package.json', json(root))
|
|
65
|
+
if (preset.packageManager === 'pnpm' && !preset.targets.includes('web'))
|
|
66
|
+
files.set(
|
|
67
|
+
'pnpm-workspace.yaml',
|
|
68
|
+
files.get('pnpm-workspace.yaml').replace('packages:\n - apps/web', 'packages: []'),
|
|
69
|
+
)
|
|
70
|
+
files.set(
|
|
71
|
+
'mavis.config.json',
|
|
72
|
+
json({
|
|
73
|
+
...configOf(preset),
|
|
74
|
+
portability: { roots: ['shared'], alias: '#mavis', allowImports: [] },
|
|
75
|
+
}),
|
|
76
|
+
)
|
|
77
|
+
files.set('.gitignore', files.get('.gitignore') + '.mavis/\nartifacts/\n')
|
|
78
|
+
files.set(
|
|
79
|
+
'README.md',
|
|
80
|
+
`# ${preset.name}\n\nShared Vue screens with NativeScript desktop hosts. This is an experimental component subset.\n\n## Start\n\n\`\`\`sh\n${commands.run('install:apps')}\n${preset.targets
|
|
81
|
+
.filter((t) => ['macos', 'windows'].includes(t))
|
|
82
|
+
.map((t) => commands.run(t))
|
|
83
|
+
.join(
|
|
84
|
+
'\n',
|
|
85
|
+
)}\n\`\`\`\n\nThe setup command installs desktop dependencies only on their matching OS. Run Mac commands on macOS and Windows commands on Windows. ${preset.targets.includes('web') ? `Web: \`${commands.run('dev:web')}\`.` : ''} ${preset.targets.includes('native') ? `Mobile: \`${commands.run('ios')}\` or \`${commands.run('android')}\`, with NativeScript CLI and platform SDKs.` : ''}\n\nEdit \`shared/${preset.example === 'directory' ? 'Directory' : 'Welcome'}.vue\`. State, Vue logic and screens stay shared. Each host supplies native controls and local storage.\n\n## Desktop requirements and packaging\n\nMac: macOS 13.3+, Apple Silicon, Node 22.23.3+ and Xcode command line tools for packaging. Windows: Windows 10 build 18362+ on x64/arm64, Node 22.23.3+ and Windows SDK (mt.exe). Set MAVIS_MT only if the SDK is installed outside its usual location. The launcher prepares a project-local copy of Node with the XAML compatibility manifest; it never changes the system installation.\n\n${preset.targets
|
|
86
|
+
.filter((t) => ['macos', 'windows'].includes(t))
|
|
87
|
+
.map(
|
|
88
|
+
(t) =>
|
|
89
|
+
`- \`${commands.run('build:' + t)}\`: bundle the Vue source.\n- \`${commands.run('package:' + t)}\`: package on ${t === 'macos' ? 'macOS as an ad-hoc signed .app (not notarized)' : 'Windows as an unsigned portable folder (not an installer)'}. Output: \`apps/${t}/artifacts/\`.`,
|
|
90
|
+
)
|
|
91
|
+
.join(
|
|
92
|
+
'\n',
|
|
93
|
+
)}\n\nPackaged apps include Node and the NativeScript runtime. They do not need a globally installed Node or a development server. For distribution, add your own signing and installer/notarization workflow.\n\n## Current component contract\n\nMScreen, MColumn, MRow, MGrid, MText, MInput, MButton, MLink, MCard, MAlert, MEmptyState and MReveal. See \`apps/*/src/host.mjs\` for accepted properties; unsupported properties produce an error. MRow divides space evenly; MGrid adapts to minColumnWidth. NativeScript Core mobile widgets are not desktop controls. Existing Mavis components outside this subset require a desktop implementation.\n\nAppKit uses native menus and Core Animation. Windows uses XAML controls and Storyboards. MReveal fades in on both through the public Jolt desktop drivers and respects system motion settings. The built-in themes are supported; arbitrary theme overrides and motion recipes are outside this starter's contract.\n\nDesktop storage stays under the user's application-data directory, in \`${preset.name}\`. Nothing is sent to a server. Commit generated lockfiles.\n`,
|
|
94
|
+
)
|
|
95
|
+
return { preset, files: new Map([...files].sort(([a], [b]) => a.localeCompare(b))) }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function desktopHostFiles(preset, target, copyTemplate, sharedRoot = '../../shared') {
|
|
99
|
+
const files = new Map()
|
|
100
|
+
const replacements = {
|
|
101
|
+
NAME: preset.name,
|
|
102
|
+
APPID: preset.name.replaceAll('-', ''),
|
|
103
|
+
THEME: preset.theme,
|
|
104
|
+
SHARED: '#shared-ui',
|
|
105
|
+
SHARED_ROOT: sharedRoot,
|
|
106
|
+
STORAGE_FILE: preset.example === 'directory' ? 'directory.json' : 'project.txt',
|
|
107
|
+
}
|
|
108
|
+
await copyTemplate(files, 'desktop/common', '', replacements)
|
|
109
|
+
await copyTemplate(files, `desktop/${target}`, '', replacements)
|
|
110
|
+
await copyTemplate(files, `desktop/${preset.example}`, '.entry', replacements)
|
|
111
|
+
files.set('src/main.ts', files.get('.entry/main.ts'))
|
|
112
|
+
for (const path of files.keys()) if (path.startsWith('.entry/')) files.delete(path)
|
|
113
|
+
if (preset.example === 'directory')
|
|
114
|
+
await copyTemplate(files, 'directory/host', 'src', replacements)
|
|
115
|
+
const runtime = target === 'macos' ? '@nativescript/macos-node-api' : '@nativescript/windows-napi'
|
|
116
|
+
files.set(
|
|
117
|
+
'package.json',
|
|
118
|
+
json({
|
|
119
|
+
name: `${preset.name}-${target}`,
|
|
120
|
+
private: true,
|
|
121
|
+
version: '0.0.0',
|
|
122
|
+
type: 'module',
|
|
123
|
+
engines: { node: '>=22.23.3' },
|
|
124
|
+
os: [target === 'macos' ? 'darwin' : 'win32'],
|
|
125
|
+
cpu: target === 'macos' ? ['arm64'] : ['x64', 'arm64'],
|
|
126
|
+
scripts: {
|
|
127
|
+
build: 'node build.mjs',
|
|
128
|
+
dev: 'node build.mjs && node launch.mjs',
|
|
129
|
+
start: 'node launch.mjs',
|
|
130
|
+
package: 'node build.mjs && node package.mjs',
|
|
131
|
+
},
|
|
132
|
+
dependencies: {
|
|
133
|
+
[runtime]: target === 'macos' ? v.macosNodeApi : v.windowsNapi,
|
|
134
|
+
'@getcortexlabs/mavis-core': v.mavis,
|
|
135
|
+
'@rafaelaugusto/jolt': v.jolt,
|
|
136
|
+
vue: v.vue,
|
|
137
|
+
'vue-router': v.router,
|
|
138
|
+
},
|
|
139
|
+
devDependencies: { esbuild: v.esbuild, '@vue/compiler-sfc': v.vue },
|
|
140
|
+
...(preset.packageManager === 'yarn'
|
|
141
|
+
? { dependenciesMeta: { esbuild: { built: true } } }
|
|
142
|
+
: {}),
|
|
143
|
+
}),
|
|
144
|
+
)
|
|
145
|
+
if (preset.packageManager === 'pnpm')
|
|
146
|
+
files.set(
|
|
147
|
+
'pnpm-workspace.yaml',
|
|
148
|
+
'packages: []\nnodeLinker: hoisted\nallowBuilds:\n esbuild: true\n',
|
|
149
|
+
)
|
|
150
|
+
if (preset.packageManager === 'yarn') {
|
|
151
|
+
files.set('yarn.lock', '')
|
|
152
|
+
files.set('.yarnrc.yml', 'nodeLinker: node-modules\n')
|
|
153
|
+
}
|
|
154
|
+
return files
|
|
155
|
+
}
|
package/src/doctor.mjs
CHANGED
|
@@ -13,13 +13,15 @@ import {
|
|
|
13
13
|
normalizeConfig,
|
|
14
14
|
requirements,
|
|
15
15
|
targetLabel,
|
|
16
|
+
versions,
|
|
16
17
|
} from './capabilities.mjs'
|
|
17
18
|
|
|
18
19
|
export async function doctor(cwd = process.cwd()) {
|
|
19
20
|
let config
|
|
20
21
|
try {
|
|
21
22
|
config = normalizeConfig(JSON.parse(await readFile(join(cwd, 'mavis.config.json'), 'utf8')))
|
|
22
|
-
} catch {
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error.message.includes('archived SwiftUI')) throw error
|
|
23
25
|
throw new Error('Run --doctor from a generated project containing mavis.config.json.')
|
|
24
26
|
}
|
|
25
27
|
// The same check the creator runs before writing a project, on what this one records.
|
|
@@ -29,7 +31,7 @@ export async function doctor(cwd = process.cwd()) {
|
|
|
29
31
|
name: 'Project configuration',
|
|
30
32
|
ok: project.ok,
|
|
31
33
|
detail: project.ok
|
|
32
|
-
? `${targetLabel(config.targets)} · ${catalog.authoring[config.authoring].
|
|
34
|
+
? `${targetLabel(config.targets)} · ${catalog.authoring[config.authoring]?.label ?? config.framework} · ${config.portability?.existing ? 'existing application; experimental Mac target' : availabilityLabel(availabilityOf(config))}`
|
|
33
35
|
: project.message.split('\n')[0],
|
|
34
36
|
},
|
|
35
37
|
{
|
|
@@ -39,56 +41,78 @@ export async function doctor(cwd = process.cwd()) {
|
|
|
39
41
|
},
|
|
40
42
|
checkPackageManager(config.packageManager ?? 'npm'),
|
|
41
43
|
]
|
|
42
|
-
if (config.target === '
|
|
43
|
-
const result =
|
|
44
|
-
process.platform === 'darwin'
|
|
45
|
-
? spawnSync('xcrun', ['swift', '--version'], { encoding: 'utf8', timeout: 10000 })
|
|
46
|
-
: null
|
|
44
|
+
if (config.target === 'desktop') {
|
|
47
45
|
results.push({
|
|
48
|
-
name: '
|
|
49
|
-
ok:
|
|
50
|
-
detail:
|
|
51
|
-
? (result.error?.message ?? (result.stdout || result.stderr)).trim().split('\n')[0]
|
|
52
|
-
: 'macOS 14+ and Xcode are required for the native app. Web remains available.',
|
|
46
|
+
name: 'Desktop Node.js 22.23.3+',
|
|
47
|
+
ok: atLeast(process.versions.node, '22.23.3'),
|
|
48
|
+
detail: process.version,
|
|
53
49
|
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
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)
|
|
73
|
-
results.push({
|
|
74
|
-
name: 'Shared sources',
|
|
75
|
-
ok: true,
|
|
76
|
-
detail: `${model.components.length} component(s) type-checked for ${config.targets.join(', ')}. Run generate to write them; this does not prove a build.`,
|
|
77
|
-
})
|
|
78
|
-
} catch (error) {
|
|
50
|
+
for (const target of ['macos', 'windows']) {
|
|
51
|
+
if (!config.targets.includes(target)) continue
|
|
52
|
+
const matching = process.platform === (target === 'macos' ? 'darwin' : 'win32')
|
|
79
53
|
results.push({
|
|
80
|
-
name:
|
|
81
|
-
ok:
|
|
82
|
-
detail:
|
|
83
|
-
error.code === 'ERR_MODULE_NOT_FOUND'
|
|
84
|
-
? 'Install the project dependencies, then run doctor again.'
|
|
85
|
-
: error.message,
|
|
54
|
+
name: `${target} build host`,
|
|
55
|
+
ok: matching && (target !== 'macos' || process.arch === 'arm64'),
|
|
56
|
+
detail: requirements[target],
|
|
86
57
|
})
|
|
58
|
+
const name =
|
|
59
|
+
target === 'macos' ? '@nativescript/macos-node-api' : '@nativescript/windows-napi'
|
|
60
|
+
try {
|
|
61
|
+
const manifest = JSON.parse(
|
|
62
|
+
await readFile(join(cwd, 'apps', target, 'package.json'), 'utf8'),
|
|
63
|
+
)
|
|
64
|
+
const expected = config.versions?.[target === 'macos' ? 'macosNodeApi' : 'windowsNapi']
|
|
65
|
+
const resolver = createRequire(join(cwd, 'apps', target, 'package.json'))
|
|
66
|
+
// Resolve only. Importing a native runtime would open platform resources during a diagnostic.
|
|
67
|
+
resolver.resolve(name)
|
|
68
|
+
results.push({
|
|
69
|
+
name: `${target} runtime`,
|
|
70
|
+
ok: manifest.dependencies?.[name] === expected,
|
|
71
|
+
detail: `${name} ${manifest.dependencies?.[name] ?? 'missing'}; expected ${expected}`,
|
|
72
|
+
})
|
|
73
|
+
} catch (error) {
|
|
74
|
+
results.push({
|
|
75
|
+
name: `${target} runtime`,
|
|
76
|
+
ok: false,
|
|
77
|
+
detail: `Install dependencies in apps/${target} on the matching OS. ${error.message.split('\n')[0]}`,
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
if (matching && target === 'windows') {
|
|
81
|
+
const { findManifestTool } = await import('../templates/desktop/windows/prepare-host.mjs')
|
|
82
|
+
const tool = findManifestTool()
|
|
83
|
+
results.push({
|
|
84
|
+
name: 'Windows SDK Manifest Tool',
|
|
85
|
+
ok: Boolean(tool),
|
|
86
|
+
detail: tool ?? 'Install the Windows SDK, or set MAVIS_MT to mt.exe.',
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
if (matching && target === 'macos') {
|
|
90
|
+
const clang = spawnSync('xcrun', ['--find', 'clang'], { encoding: 'utf8', timeout: 10000 })
|
|
91
|
+
results.push({
|
|
92
|
+
name: 'AppKit packaging toolchain',
|
|
93
|
+
ok: clang.status === 0,
|
|
94
|
+
detail: (clang.error?.message ?? clang.stdout ?? clang.stderr).trim(),
|
|
95
|
+
})
|
|
96
|
+
}
|
|
87
97
|
}
|
|
88
98
|
if (config.targets.includes('native')) nativeChecks(results)
|
|
99
|
+
results.push({
|
|
100
|
+
name: 'Desktop component contract',
|
|
101
|
+
ok: true,
|
|
102
|
+
detail:
|
|
103
|
+
'Experimental subset; build and run each host to validate its controls. --capabilities --json lists exact accepted props.',
|
|
104
|
+
})
|
|
89
105
|
return results
|
|
90
106
|
}
|
|
91
107
|
if (config.target !== 'web') nativeChecks(results)
|
|
108
|
+
if (config.framework !== 'vue') {
|
|
109
|
+
results.push({
|
|
110
|
+
name: 'Direct native adapter',
|
|
111
|
+
ok: true,
|
|
112
|
+
detail: `${config.framework}: MBox, MRow, MColumn, MText, MButton and MInput. Run typecheck and bundle:ios/bundle:android in this project.`,
|
|
113
|
+
})
|
|
114
|
+
return results
|
|
115
|
+
}
|
|
92
116
|
const portability = await checkPortability(cwd)
|
|
93
117
|
results.push({
|
|
94
118
|
name: 'Shared source portability',
|
|
@@ -100,19 +124,24 @@ export async function doctor(cwd = process.cwd()) {
|
|
|
100
124
|
|
|
101
125
|
/** Configuration choices only; compiler diagnostics validate custom theme modules separately. */
|
|
102
126
|
export function checkRecordedProject(config) {
|
|
103
|
-
if (config.
|
|
127
|
+
if (config.desktop?.existing)
|
|
128
|
+
return {
|
|
129
|
+
ok:
|
|
130
|
+
config.mode === 'direct' &&
|
|
131
|
+
config.framework === 'vue' &&
|
|
132
|
+
config.targets.every((target) => catalog.targets[target]),
|
|
133
|
+
message: 'Invalid NativeScript desktop configuration.',
|
|
134
|
+
}
|
|
104
135
|
return checkProject({
|
|
105
136
|
name: config.name,
|
|
106
137
|
targets: config.targets,
|
|
107
138
|
web: config.web ?? undefined,
|
|
108
139
|
rendering: config.rendering ?? undefined,
|
|
109
140
|
framework: config.framework,
|
|
141
|
+
macosRuntime: config.macosRuntime,
|
|
110
142
|
authoring: config.authoring,
|
|
111
143
|
example: config.example,
|
|
112
|
-
theme:
|
|
113
|
-
config.targets?.includes('macos') && typeof config.theme === 'object'
|
|
114
|
-
? undefined
|
|
115
|
-
: config.theme,
|
|
144
|
+
theme: config.theme,
|
|
116
145
|
packageManager: config.packageManager,
|
|
117
146
|
})
|
|
118
147
|
}
|
|
@@ -143,63 +172,3 @@ function nativeChecks(results) {
|
|
|
143
172
|
detail: 'iOS builds require macOS and Xcode; Android remains available.',
|
|
144
173
|
})
|
|
145
174
|
}
|
|
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
|
-
}
|