@getcortexlabs/create-mavis 0.0.0-stage → 0.1.0-alpha.6
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/LICENSE +21 -0
- package/README.md +24 -2
- package/package.json +27 -4
- package/src/cli.mjs +165 -0
- package/src/doctor.mjs +47 -0
- package/src/presets.mjs +63 -0
- package/src/scaffold.mjs +210 -0
- package/templates/mobile/App_Resources/Android/app.gradle +10 -0
- package/templates/mobile/App_Resources/Android/src/main/AndroidManifest.xml +18 -0
- package/templates/mobile/App_Resources/Android/src/main/res/values/styles.xml +15 -0
- package/templates/mobile/App_Resources/iOS/Info.plist +20 -0
- package/templates/mobile/App_Resources/iOS/LaunchScreen.storyboard +18 -0
- package/templates/mobile/App_Resources/iOS/build.xcconfig +1 -0
- package/templates/mobile/nativescript.config.ts +6 -0
- package/templates/mobile/src/App.vue +8 -0
- package/templates/mobile/src/app.css +3 -0
- package/templates/mobile/src/app.ts +13 -0
- package/templates/mobile/src/env.d.ts +5 -0
- package/templates/mobile/tsconfig.json +14 -0
- package/templates/mobile/webpack.config.js +22 -0
- package/templates/nuxt/app/app.vue +11 -0
- package/templates/nuxt/app/assets/main.css +13 -0
- package/templates/nuxt/app/plugins/mavis.ts +14 -0
- package/templates/nuxt/nuxt.config.ts +6 -0
- package/templates/nuxt/tsconfig.json +1 -0
- package/templates/shared/Welcome.vue +85 -0
- package/templates/shared/services.ts +11 -0
- package/templates/vite/index.html +13 -0
- package/templates/vite/src/main.ts +15 -0
- package/templates/vite/src/style.css +13 -0
- package/templates/vite/tsconfig.json +12 -0
- package/templates/vite/vite.config.ts +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rafael Augusto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Create Mavis
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Start with Vue on the Web, NativeScript, or both. Web projects use Vue + Vite or Nuxt with server rendering/static generation. The generated example shares a Vue screen and gives each host its own service implementation.
|
|
4
|
+
|
|
5
|
+
Run `npm create @getcortexlabs/mavis@alpha` for the interactive wizard, or pass a project name and options:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm create @getcortexlabs/mavis@alpha my-app -- --target both --web nuxt --rendering ssr --theme midnight --no-install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Without flags, a terminal wizard asks for target, Web host, rendering and theme. `back` revisits a choice; `cancel` or Ctrl-C stops it. Explicit flags are preserved. In CI, supply a project name and flags, or `--yes` for defaults.
|
|
12
|
+
|
|
13
|
+
- `--dry-run` prints the file plan without writing or installing.
|
|
14
|
+
- Existing directories are never merged or overwritten.
|
|
15
|
+
- `--install` runs npm after creating the project. A failed install preserves the source for retry.
|
|
16
|
+
- `--doctor` checks a generated project's Node and native prerequisites without installing tools.
|
|
17
|
+
- `mavis.config.json` records the resolved choices and dependency versions.
|
|
18
|
+
|
|
19
|
+
Node.js 22.16+ is required. Native projects also need the NativeScript CLI and the platform SDK. iOS requires macOS and Xcode. A shared project keeps native dependencies separate from its Web workspace so each renderer loads the correct Vue runtime.
|
|
20
|
+
|
|
21
|
+
Templates pin **Mavis 0.1.0-alpha.6** and **Jolt 0.1.0-rc.8**. They use APIs available in those releases, independently of newer repository capabilities. Commit the lockfile npm generates.
|
|
22
|
+
|
|
23
|
+
React, Next, Angular, Svelte, portable authoring and SDUI are roadmap work. The creator reports unsupported choices instead of generating placeholder integrations.
|
|
24
|
+
|
|
25
|
+
MIT · [Mavis UI](https://github.com/getcortexlabs/mavis-ui)
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getcortexlabs/create-mavis",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
|
+
"description": "Create Vue Web, Nuxt and NativeScript projects with Mavis UI.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-mavis": "./src/cli.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"templates",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=22.16"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Rafael Augusto",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/getcortexlabs/mavis-ui.git",
|
|
23
|
+
"directory": "packages/create-mavis"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"tag": "alpha"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/cli.mjs
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs } from 'node:util'
|
|
3
|
+
import { createInterface } from 'node:readline/promises'
|
|
4
|
+
import { scaffold, installProject } from './scaffold.mjs'
|
|
5
|
+
import { doctor } from './doctor.mjs'
|
|
6
|
+
|
|
7
|
+
const help = `Create Mavis — Vue Web, Nuxt and NativeScript
|
|
8
|
+
|
|
9
|
+
create-mavis [name] [options]
|
|
10
|
+
create-mavis my-app --target both --web nuxt --rendering ssr --no-install
|
|
11
|
+
|
|
12
|
+
--target mobile|web|both Default: web
|
|
13
|
+
--web vite|nuxt Default: vite
|
|
14
|
+
--rendering client|ssr|ssg Default: client (Vite), ssr (Nuxt)
|
|
15
|
+
--theme mavis|midnight Default: mavis
|
|
16
|
+
--framework vue Other adapters are planned, not generated
|
|
17
|
+
--authoring vue Portable JSX/React-style authoring is planned
|
|
18
|
+
--yes Use defaults without prompts
|
|
19
|
+
--install / --no-install npm is the supported package manager
|
|
20
|
+
--dry-run Show the complete file plan without writing
|
|
21
|
+
--doctor Check the current generated project prerequisites
|
|
22
|
+
--help Show this help
|
|
23
|
+
|
|
24
|
+
Interactive prompts accept "back" or "cancel". Existing directories are never overwritten.
|
|
25
|
+
`
|
|
26
|
+
|
|
27
|
+
async function wizard(initial, signal) {
|
|
28
|
+
const answers = { ...initial }
|
|
29
|
+
const supplied = new Set(Object.keys(initial).filter((key) => initial[key] !== undefined))
|
|
30
|
+
const io = createInterface({ input: process.stdin, output: process.stdout })
|
|
31
|
+
const steps = [
|
|
32
|
+
{ key: 'name', question: 'Project name', fallback: 'my-mavis-app' },
|
|
33
|
+
{
|
|
34
|
+
key: 'target',
|
|
35
|
+
question: 'Where will it run? 1 Web · 2 Mobile · 3 Mobile + Web',
|
|
36
|
+
choices: ['web', 'mobile', 'both'],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
key: 'web',
|
|
40
|
+
question: 'Web host? 1 Vue + Vite · 2 Nuxt',
|
|
41
|
+
choices: ['vite', 'nuxt'],
|
|
42
|
+
when: () => answers.target !== 'mobile',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: 'rendering',
|
|
46
|
+
question: 'Rendering? 1 Server rendering · 2 Static generation',
|
|
47
|
+
choices: ['ssr', 'ssg'],
|
|
48
|
+
when: () => answers.target !== 'mobile' && answers.web === 'nuxt',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: 'theme',
|
|
52
|
+
question: 'Initial theme? 1 Mavis · 2 Midnight',
|
|
53
|
+
choices: ['mavis', 'midnight'],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: 'install',
|
|
57
|
+
question: 'Install dependencies with npm? 1 No · 2 Yes',
|
|
58
|
+
choices: [false, true],
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
console.log(
|
|
62
|
+
'Vue templates are available today. React-style authoring for Vue is on the roadmap.\n',
|
|
63
|
+
)
|
|
64
|
+
try {
|
|
65
|
+
for (let index = 0; index < steps.length;) {
|
|
66
|
+
const step = steps[index]
|
|
67
|
+
if (supplied.has(step.key)) {
|
|
68
|
+
index++
|
|
69
|
+
continue
|
|
70
|
+
}
|
|
71
|
+
if (step.when && !step.when()) {
|
|
72
|
+
delete answers[step.key]
|
|
73
|
+
index++
|
|
74
|
+
continue
|
|
75
|
+
}
|
|
76
|
+
const value = (
|
|
77
|
+
await io.question(`${step.question} [${answers[step.key] ?? step.fallback ?? '1'}]: `, {
|
|
78
|
+
signal,
|
|
79
|
+
})
|
|
80
|
+
).trim()
|
|
81
|
+
if (value.toLowerCase() === 'cancel') return null
|
|
82
|
+
if (value.toLowerCase() === 'back') {
|
|
83
|
+
do {
|
|
84
|
+
index = Math.max(0, index - 1)
|
|
85
|
+
} while (
|
|
86
|
+
index > 0 &&
|
|
87
|
+
(supplied.has(steps[index].key) || (steps[index].when && !steps[index].when()))
|
|
88
|
+
)
|
|
89
|
+
continue
|
|
90
|
+
}
|
|
91
|
+
if (step.choices) {
|
|
92
|
+
const selection =
|
|
93
|
+
value === '' ? (answers[step.key] ?? step.choices[0]) : step.choices[Number(value) - 1]
|
|
94
|
+
if (selection === undefined) {
|
|
95
|
+
console.log('Choose one of the numbered options.')
|
|
96
|
+
continue
|
|
97
|
+
}
|
|
98
|
+
answers[step.key] = selection
|
|
99
|
+
} else answers[step.key] = value || answers[step.key] || step.fallback
|
|
100
|
+
index++
|
|
101
|
+
}
|
|
102
|
+
} finally {
|
|
103
|
+
io.close()
|
|
104
|
+
}
|
|
105
|
+
return answers
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const cancellation = new AbortController()
|
|
109
|
+
const cancel = () => cancellation.abort()
|
|
110
|
+
process.once('SIGINT', cancel)
|
|
111
|
+
try {
|
|
112
|
+
const { values, positionals } = parseArgs({
|
|
113
|
+
allowPositionals: true,
|
|
114
|
+
options: {
|
|
115
|
+
target: { type: 'string' },
|
|
116
|
+
web: { type: 'string' },
|
|
117
|
+
rendering: { type: 'string' },
|
|
118
|
+
theme: { type: 'string' },
|
|
119
|
+
framework: { type: 'string' },
|
|
120
|
+
authoring: { type: 'string' },
|
|
121
|
+
yes: { type: 'boolean' },
|
|
122
|
+
install: { type: 'boolean' },
|
|
123
|
+
'no-install': { type: 'boolean' },
|
|
124
|
+
'dry-run': { type: 'boolean' },
|
|
125
|
+
doctor: { type: 'boolean' },
|
|
126
|
+
help: { type: 'boolean', short: 'h' },
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
if (values.help) console.log(help)
|
|
130
|
+
else if (values.doctor) {
|
|
131
|
+
const results = await doctor()
|
|
132
|
+
for (const item of results) console.log(`${item.ok ? '✓' : '—'} ${item.name}: ${item.detail}`)
|
|
133
|
+
if (results.some((item) => !item.ok)) process.exitCode = 1
|
|
134
|
+
} else {
|
|
135
|
+
if (positionals.length > 1) throw new Error('Provide one project name.')
|
|
136
|
+
if (values.install && values['no-install'])
|
|
137
|
+
throw new Error('Choose either --install or --no-install.')
|
|
138
|
+
let options = {
|
|
139
|
+
...values,
|
|
140
|
+
name: positionals[0],
|
|
141
|
+
install: values['no-install'] ? false : values.install,
|
|
142
|
+
dryRun: Boolean(values['dry-run']),
|
|
143
|
+
}
|
|
144
|
+
if (process.stdin.isTTY && process.stdout.isTTY && !values.yes && !values['dry-run'])
|
|
145
|
+
options = await wizard(options, cancellation.signal)
|
|
146
|
+
if (!options) console.log('Cancelled. No files written.')
|
|
147
|
+
else {
|
|
148
|
+
if (!options.name)
|
|
149
|
+
throw new Error('Provide a project name in non-interactive mode. Use --help for examples.')
|
|
150
|
+
const plan = await scaffold({ ...options, signal: cancellation.signal })
|
|
151
|
+
console.log(`${options.dryRun ? 'Planned' : 'Created'} ${plan.destination}`)
|
|
152
|
+
for (const file of plan.files.keys()) console.log(` ${file}`)
|
|
153
|
+
if (options.install && !options.dryRun) await installProject(plan)
|
|
154
|
+
if (!options.dryRun)
|
|
155
|
+
console.log(
|
|
156
|
+
`\ncd ${plan.preset.name}\n${options.install ? '' : plan.preset.target === 'both' ? 'npm run install:apps\n' : 'npm install\n'}${plan.preset.target === 'mobile' ? 'npm run ios # or npm run android' : plan.preset.target === 'both' ? 'npm run dev:web' : 'npm run dev'}`,
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.error(cancellation.signal.aborted ? '\nCancelled.' : `\n${error.message}`)
|
|
162
|
+
process.exitCode = cancellation.signal.aborted ? 130 : 1
|
|
163
|
+
} finally {
|
|
164
|
+
process.off('SIGINT', cancel)
|
|
165
|
+
}
|
package/src/doctor.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process'
|
|
2
|
+
import { readFile } from 'node:fs/promises'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
|
|
5
|
+
export async function doctor(cwd = process.cwd()) {
|
|
6
|
+
let config
|
|
7
|
+
try {
|
|
8
|
+
config = JSON.parse(await readFile(join(cwd, 'mavis.config.json'), 'utf8'))
|
|
9
|
+
} catch {
|
|
10
|
+
throw new Error('Run --doctor from a generated project containing mavis.config.json.')
|
|
11
|
+
}
|
|
12
|
+
const [major, minor] = process.versions.node.split('.').map(Number)
|
|
13
|
+
const results = [
|
|
14
|
+
{
|
|
15
|
+
name: 'Node.js 22.16+',
|
|
16
|
+
ok: major > 22 || (major === 22 && minor >= 16),
|
|
17
|
+
detail: process.version,
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
if (config.target !== 'web') {
|
|
21
|
+
const probe = (name, command, args) => {
|
|
22
|
+
const result = spawnSync(command, args, { encoding: 'utf8', timeout: 10000 })
|
|
23
|
+
results.push({
|
|
24
|
+
name,
|
|
25
|
+
ok: result.status === 0,
|
|
26
|
+
detail: (result.error?.message ?? (result.stdout || result.stderr || 'No output'))
|
|
27
|
+
.trim()
|
|
28
|
+
.split('\n')[0],
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
probe('NativeScript CLI', process.platform === 'win32' ? 'ns.cmd' : 'ns', ['--version'])
|
|
32
|
+
probe('Java (Android)', 'java', ['-version'])
|
|
33
|
+
results.push({
|
|
34
|
+
name: 'Android SDK',
|
|
35
|
+
ok: Boolean(process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT),
|
|
36
|
+
detail: 'Set ANDROID_HOME for Android builds.',
|
|
37
|
+
})
|
|
38
|
+
if (process.platform === 'darwin') probe('Xcode (iOS)', 'xcodebuild', ['-version'])
|
|
39
|
+
else
|
|
40
|
+
results.push({
|
|
41
|
+
name: 'iOS host',
|
|
42
|
+
ok: false,
|
|
43
|
+
detail: 'iOS builds require macOS and Xcode; Android remains available.',
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
return results
|
|
47
|
+
}
|
package/src/presets.mjs
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Validated published dependencies, deliberately separate from unreleased source capabilities. */
|
|
2
|
+
export const versions = Object.freeze({
|
|
3
|
+
mavis: '0.1.0-alpha.6',
|
|
4
|
+
jolt: '0.1.0-rc.8',
|
|
5
|
+
vue: '3.5.44',
|
|
6
|
+
nuxt: '4.6.3',
|
|
7
|
+
vite: '6.4.5',
|
|
8
|
+
vuePlugin: '5.2.4',
|
|
9
|
+
typescript: '6.0.3',
|
|
10
|
+
vueTsc: '3.3.13',
|
|
11
|
+
nativeCore: '9.1.3',
|
|
12
|
+
nativeVue: '3.1.3',
|
|
13
|
+
android: '9.1.1',
|
|
14
|
+
ios: '9.1.0',
|
|
15
|
+
webpack: '5.0.39',
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export function resolvePreset(options) {
|
|
19
|
+
const {
|
|
20
|
+
name,
|
|
21
|
+
target = 'web',
|
|
22
|
+
web = 'vite',
|
|
23
|
+
rendering = web === 'nuxt' ? 'ssr' : 'client',
|
|
24
|
+
theme = 'mavis',
|
|
25
|
+
framework = 'vue',
|
|
26
|
+
authoring = 'vue',
|
|
27
|
+
} = options
|
|
28
|
+
if (!/^[a-z][a-z0-9-]{0,63}$/.test(name ?? ''))
|
|
29
|
+
throw new Error(
|
|
30
|
+
'Use a project name of 1–64 lowercase letters, numbers or hyphens, starting with a letter.',
|
|
31
|
+
)
|
|
32
|
+
if (framework !== 'vue')
|
|
33
|
+
throw new Error(
|
|
34
|
+
'This creator currently supports Vue. Other framework adapters are tracked in Mavis #145 and #35–39.',
|
|
35
|
+
)
|
|
36
|
+
if (authoring !== 'vue')
|
|
37
|
+
throw new Error(
|
|
38
|
+
'Portable JSX/React-style authoring for Vue is planned in Mavis #167; use Vue templates in this version.',
|
|
39
|
+
)
|
|
40
|
+
if (!['mobile', 'web', 'both'].includes(target))
|
|
41
|
+
throw new Error('Target must be mobile, web or both.')
|
|
42
|
+
if (!['vite', 'nuxt'].includes(web))
|
|
43
|
+
throw new Error('Web host must be vite or nuxt. React/Next are not available yet.')
|
|
44
|
+
if (!['mavis', 'midnight'].includes(theme)) throw new Error('Theme must be mavis or midnight.')
|
|
45
|
+
if (target === 'mobile' && (web !== 'vite' || rendering !== 'client'))
|
|
46
|
+
throw new Error('A mobile-only project has no Web rendering mode.')
|
|
47
|
+
if (
|
|
48
|
+
(web === 'vite' && rendering !== 'client') ||
|
|
49
|
+
(web === 'nuxt' && !['ssr', 'ssg'].includes(rendering))
|
|
50
|
+
)
|
|
51
|
+
throw new Error('Choose client rendering for Vite or ssr/ssg for Nuxt.')
|
|
52
|
+
return Object.freeze({
|
|
53
|
+
schemaVersion: 1,
|
|
54
|
+
name,
|
|
55
|
+
target,
|
|
56
|
+
framework,
|
|
57
|
+
authoring,
|
|
58
|
+
web: target === 'mobile' ? null : web,
|
|
59
|
+
rendering: target === 'mobile' ? null : rendering,
|
|
60
|
+
theme,
|
|
61
|
+
versions,
|
|
62
|
+
})
|
|
63
|
+
}
|
package/src/scaffold.mjs
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
|
+
import { mkdir, mkdtemp, readFile, readdir, rename, rm, rmdir, writeFile } from 'node:fs/promises'
|
|
3
|
+
import { dirname, join, relative, resolve, sep } from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import { spawn } from 'node:child_process'
|
|
6
|
+
import { resolvePreset, versions as v } from './presets.mjs'
|
|
7
|
+
|
|
8
|
+
const templates = fileURLToPath(new URL('../templates/', import.meta.url))
|
|
9
|
+
const json = (value) => `${JSON.stringify(value, null, 2)}\n`
|
|
10
|
+
|
|
11
|
+
async function copyTemplate(files, source, destination, replacements) {
|
|
12
|
+
for (const entry of await readdir(join(templates, source), { withFileTypes: true })) {
|
|
13
|
+
const from = join(source, entry.name),
|
|
14
|
+
to = join(destination, entry.name.replace(/^_gitignore$/, '.gitignore'))
|
|
15
|
+
if (entry.isDirectory()) await copyTemplate(files, from, to, replacements)
|
|
16
|
+
else {
|
|
17
|
+
let content = await readFile(join(templates, from), 'utf8')
|
|
18
|
+
for (const [key, value] of Object.entries(replacements))
|
|
19
|
+
content = content.replaceAll(`__MAVIS_${key}__`, value)
|
|
20
|
+
files.set(to, content)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function projectFiles(options) {
|
|
26
|
+
const preset = resolvePreset(options)
|
|
27
|
+
const files = new Map()
|
|
28
|
+
const shared = preset.target === 'both'
|
|
29
|
+
const replacements = {
|
|
30
|
+
NAME: preset.name,
|
|
31
|
+
APPID: preset.name.replaceAll('-', ''),
|
|
32
|
+
THEME: preset.theme,
|
|
33
|
+
APPEARANCE: preset.theme === 'midnight' ? 'dark' : 'light',
|
|
34
|
+
SHARED: shared ? '../../../shared' : './shared',
|
|
35
|
+
}
|
|
36
|
+
await copyTemplate(
|
|
37
|
+
files,
|
|
38
|
+
'shared',
|
|
39
|
+
shared ? 'shared' : preset.web === 'nuxt' ? 'app/shared' : 'src/shared',
|
|
40
|
+
replacements,
|
|
41
|
+
)
|
|
42
|
+
const webDir = shared ? 'apps/web' : ''
|
|
43
|
+
const mobileDir = shared ? 'apps/mobile' : ''
|
|
44
|
+
const common = { private: true, version: '0.0.0', engines: { node: '>=22.16' } }
|
|
45
|
+
const dependencies = { '@getcortexlabs/mavis-core': v.mavis, '@rafaelaugusto/jolt': v.jolt }
|
|
46
|
+
if (preset.target !== 'mobile') {
|
|
47
|
+
await copyTemplate(files, preset.web, webDir, {
|
|
48
|
+
...replacements,
|
|
49
|
+
SHARED: shared ? '../../../shared' : './shared',
|
|
50
|
+
})
|
|
51
|
+
const scripts =
|
|
52
|
+
preset.web === 'vite'
|
|
53
|
+
? { dev: 'vite', build: 'vue-tsc --noEmit && vite build', preview: 'vite preview' }
|
|
54
|
+
: {
|
|
55
|
+
dev: 'nuxt dev',
|
|
56
|
+
build: 'nuxt build',
|
|
57
|
+
generate: 'nuxt generate',
|
|
58
|
+
preview: 'nuxt preview',
|
|
59
|
+
typecheck: 'nuxt typecheck',
|
|
60
|
+
postinstall: 'nuxt prepare',
|
|
61
|
+
}
|
|
62
|
+
files.set(
|
|
63
|
+
join(webDir, 'package.json'),
|
|
64
|
+
json({
|
|
65
|
+
...common,
|
|
66
|
+
name: `${preset.name}${shared ? '-web' : ''}`,
|
|
67
|
+
type: 'module',
|
|
68
|
+
scripts,
|
|
69
|
+
dependencies: {
|
|
70
|
+
...dependencies,
|
|
71
|
+
'@getcortexlabs/mavis-web': v.mavis,
|
|
72
|
+
vue: v.vue,
|
|
73
|
+
...(preset.web === 'nuxt' ? { nuxt: v.nuxt } : {}),
|
|
74
|
+
},
|
|
75
|
+
devDependencies: {
|
|
76
|
+
typescript: v.typescript,
|
|
77
|
+
'vue-tsc': v.vueTsc,
|
|
78
|
+
...(preset.web === 'vite' ? { vite: v.vite, '@vitejs/plugin-vue': v.vuePlugin } : {}),
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
if (preset.target !== 'web') {
|
|
84
|
+
await copyTemplate(files, 'mobile', mobileDir, {
|
|
85
|
+
...replacements,
|
|
86
|
+
SHARED: shared ? '../../../shared' : './shared',
|
|
87
|
+
})
|
|
88
|
+
files.set(
|
|
89
|
+
join(mobileDir, 'package.json'),
|
|
90
|
+
json({
|
|
91
|
+
...common,
|
|
92
|
+
name: `${preset.name}${shared ? '-mobile' : ''}`,
|
|
93
|
+
main: 'src/app.ts',
|
|
94
|
+
scripts: {
|
|
95
|
+
android: 'ns run android',
|
|
96
|
+
ios: 'ns run ios',
|
|
97
|
+
'bundle:android': 'webpack --env android',
|
|
98
|
+
'bundle:ios': 'webpack --env ios',
|
|
99
|
+
},
|
|
100
|
+
dependencies: {
|
|
101
|
+
...dependencies,
|
|
102
|
+
'@getcortexlabs/mavis': v.mavis,
|
|
103
|
+
'@nativescript/core': v.nativeCore,
|
|
104
|
+
'nativescript-vue': v.nativeVue,
|
|
105
|
+
},
|
|
106
|
+
devDependencies: {
|
|
107
|
+
'@nativescript/android': v.android,
|
|
108
|
+
'@nativescript/ios': v.ios,
|
|
109
|
+
'@nativescript/webpack': v.webpack,
|
|
110
|
+
typescript: v.typescript,
|
|
111
|
+
},
|
|
112
|
+
}),
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
if (shared)
|
|
116
|
+
files.set(
|
|
117
|
+
'package.json',
|
|
118
|
+
json({
|
|
119
|
+
...common,
|
|
120
|
+
name: preset.name,
|
|
121
|
+
workspaces: ['apps/web'],
|
|
122
|
+
scripts: {
|
|
123
|
+
'dev:web': 'npm --prefix apps/web run dev',
|
|
124
|
+
'build:web': `npm --prefix apps/web run ${preset.rendering === 'ssg' ? 'generate' : 'build'}`,
|
|
125
|
+
android: 'npm --prefix apps/mobile run android',
|
|
126
|
+
ios: 'npm --prefix apps/mobile run ios',
|
|
127
|
+
'install:apps': 'npm install && npm --prefix apps/mobile install',
|
|
128
|
+
},
|
|
129
|
+
}),
|
|
130
|
+
)
|
|
131
|
+
files.set('mavis.config.json', json(preset))
|
|
132
|
+
files.set(
|
|
133
|
+
'.gitignore',
|
|
134
|
+
'node_modules/\n.npm/\ndist/\n.nuxt/\n.output/\nplatforms/\nhooks/\n.DS_Store\n*.log\n',
|
|
135
|
+
)
|
|
136
|
+
const location = shared
|
|
137
|
+
? '`shared/Welcome.vue`'
|
|
138
|
+
: preset.web === 'nuxt'
|
|
139
|
+
? '`app/shared/Welcome.vue`'
|
|
140
|
+
: '`src/shared/Welcome.vue`'
|
|
141
|
+
files.set(
|
|
142
|
+
'README.md',
|
|
143
|
+
`# ${preset.name}\n\nA Mavis ${preset.target === 'both' ? 'NativeScript + Web' : preset.target} application using Vue templates.\n\n## Start\n\n\`\`\`sh\n${shared ? 'npm run install:apps' : 'npm install'}\n${preset.target === 'mobile' ? 'npm run ios # or npm run android' : shared ? 'npm run dev:web' : 'npm run dev'}\n\`\`\`\n\nEdit ${location}. Its state and components are shared; each host provides the save service. The included service is a local demo and does not send data to a server.\n\n${preset.target !== 'web' ? 'Mobile requires the NativeScript CLI and the selected platform SDK. iOS builds require macOS/Xcode; Android requires a JDK and Android SDK. Run `ns doctor` inside the mobile app directory.\n\n' : ''}${preset.web === 'nuxt' ? 'Nuxt server rendering: `npm run build`. Static output: `npm run generate`. In a shared project, run these inside `apps/web`. The initial appearance is deterministic during hydration; device appearance is applied after mount.\n\n' : ''}${shared ? 'The native and DOM renderers have separate dependency trees so each uses its own Vue runtime. No compiler converts arbitrary Vue/React code.\n\n' : ''}Dependencies are pinned in package.json. Commit the lockfile generated by npm install. Mavis and Jolt are prereleases; see https://mavis-ui.getcortexlabs.com/ for current contracts.\n`,
|
|
144
|
+
)
|
|
145
|
+
return { preset, files: new Map([...files].sort(([a], [b]) => a.localeCompare(b))) }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function scaffold(options, cwd = process.cwd()) {
|
|
149
|
+
options.signal?.throwIfAborted()
|
|
150
|
+
const plan = await projectFiles(options)
|
|
151
|
+
const destination = resolve(cwd, plan.preset.name)
|
|
152
|
+
if (existsSync(destination))
|
|
153
|
+
throw new Error(
|
|
154
|
+
`Destination already exists: ${destination}. Choose a new directory; existing files are never overwritten.`,
|
|
155
|
+
)
|
|
156
|
+
if (options.dryRun) return { ...plan, destination }
|
|
157
|
+
const staging = await mkdtemp(join(cwd, '.mavis-create-'))
|
|
158
|
+
try {
|
|
159
|
+
for (const [file, contents] of plan.files) {
|
|
160
|
+
options.signal?.throwIfAborted()
|
|
161
|
+
const output = resolve(staging, file)
|
|
162
|
+
if (relative(staging, output).startsWith(`..${sep}`))
|
|
163
|
+
throw new Error('Invalid template path.')
|
|
164
|
+
await mkdir(dirname(output), { recursive: true })
|
|
165
|
+
await writeFile(output, contents, { flag: 'wx' })
|
|
166
|
+
}
|
|
167
|
+
// The parent remains owned by the user; never merge into an existing destination.
|
|
168
|
+
options.signal?.throwIfAborted()
|
|
169
|
+
await mkdir(destination)
|
|
170
|
+
const written = []
|
|
171
|
+
try {
|
|
172
|
+
for (const entry of await readdir(staging)) {
|
|
173
|
+
options.signal?.throwIfAborted()
|
|
174
|
+
await rename(join(staging, entry), join(destination, entry))
|
|
175
|
+
written.push(entry)
|
|
176
|
+
}
|
|
177
|
+
} catch (error) {
|
|
178
|
+
for (const entry of written)
|
|
179
|
+
await rm(join(destination, entry), { recursive: true, force: true })
|
|
180
|
+
// Leave anything independently added to the directory alone.
|
|
181
|
+
await rmdir(destination).catch(() => {})
|
|
182
|
+
throw error
|
|
183
|
+
}
|
|
184
|
+
} finally {
|
|
185
|
+
await rm(staging, { recursive: true, force: true })
|
|
186
|
+
}
|
|
187
|
+
return { ...plan, destination }
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export async function installProject(plan) {
|
|
191
|
+
const directories = plan.preset.target === 'both' ? ['', 'apps/mobile'] : ['']
|
|
192
|
+
for (const directory of directories)
|
|
193
|
+
await new Promise((resolve, reject) => {
|
|
194
|
+
const child = spawn(process.platform === 'win32' ? 'npm.cmd' : 'npm', ['install'], {
|
|
195
|
+
cwd: join(plan.destination, directory),
|
|
196
|
+
stdio: 'inherit',
|
|
197
|
+
shell: false,
|
|
198
|
+
})
|
|
199
|
+
child.on('error', reject)
|
|
200
|
+
child.on('exit', (code, signal) =>
|
|
201
|
+
code === 0
|
|
202
|
+
? resolve()
|
|
203
|
+
: reject(
|
|
204
|
+
new Error(
|
|
205
|
+
`npm install stopped (${signal ?? code}). Project files were preserved; retry in ${join(plan.destination, directory)}.`,
|
|
206
|
+
),
|
|
207
|
+
),
|
|
208
|
+
)
|
|
209
|
+
})
|
|
210
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="__PACKAGE__">
|
|
3
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
4
|
+
<application android:name="com.tns.NativeScriptApplication" android:label="__MAVIS_NAME__"
|
|
5
|
+
android:theme="@style/AppTheme" android:allowBackup="false" tools:replace="android:allowBackup" android:supportsRtl="true"
|
|
6
|
+
android:enableOnBackInvokedCallback="true" android:hardwareAccelerated="true">
|
|
7
|
+
<activity android:name="com.tns.NativeScriptActivity" android:label="__MAVIS_NAME__"
|
|
8
|
+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
|
|
9
|
+
android:theme="@style/AppTheme" android:exported="true" android:windowSoftInputMode="adjustResize">
|
|
10
|
+
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
|
|
11
|
+
<intent-filter>
|
|
12
|
+
<action android:name="android.intent.action.MAIN" />
|
|
13
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
|
14
|
+
</intent-filter>
|
|
15
|
+
</activity>
|
|
16
|
+
<activity android:name="com.tns.ErrorReportActivity" />
|
|
17
|
+
</application>
|
|
18
|
+
</manifest>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
<style name="AppThemeBase" parent="Theme.AppCompat.DayNight.NoActionBar">
|
|
4
|
+
<item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>
|
|
5
|
+
<item name="android:windowBackground">#FAF7FA</item>
|
|
6
|
+
<item name="android:statusBarColor">#FAF7FA</item>
|
|
7
|
+
<item name="android:navigationBarColor">#FAF7FA</item>
|
|
8
|
+
<item name="android:windowLightStatusBar">false</item>
|
|
9
|
+
<item name="android:windowLightNavigationBar">false</item>
|
|
10
|
+
<item name="colorAccent">#B83670</item>
|
|
11
|
+
</style>
|
|
12
|
+
<style name="AppTheme" parent="AppThemeBase" />
|
|
13
|
+
<style name="NativeScriptToolbarStyleBase" parent="Widget.AppCompat.Toolbar" />
|
|
14
|
+
<style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase" />
|
|
15
|
+
</resources>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0"><dict>
|
|
4
|
+
<key>CFBundleDisplayName</key><string>__MAVIS_NAME__</string>
|
|
5
|
+
<key>CFBundleName</key><string>__MAVIS_NAME__</string>
|
|
6
|
+
<key>CFBundleExecutable</key><string>${EXECUTABLE_NAME}</string>
|
|
7
|
+
<key>CFBundlePackageType</key><string>APPL</string>
|
|
8
|
+
<key>CFBundleShortVersionString</key><string>0.0.0</string>
|
|
9
|
+
<key>CFBundleVersion</key><string>1</string>
|
|
10
|
+
<key>LSRequiresIPhoneOS</key><true/>
|
|
11
|
+
<key>UILaunchStoryboardName</key><string>LaunchScreen</string>
|
|
12
|
+
<key>UISupportedInterfaceOrientations</key><array>
|
|
13
|
+
<string>UIInterfaceOrientationPortrait</string>
|
|
14
|
+
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
15
|
+
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
16
|
+
</array>
|
|
17
|
+
<key>UIApplicationSceneManifest</key><dict>
|
|
18
|
+
<key>UIApplicationSupportsMultipleScenes</key><false/>
|
|
19
|
+
</dict>
|
|
20
|
+
</dict></plist>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="launch">
|
|
3
|
+
<device id="retina5_9" orientation="portrait"><adaptation id="fullscreen"/></device>
|
|
4
|
+
<dependencies>
|
|
5
|
+
<deployment identifier="iOS"/>
|
|
6
|
+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
|
|
7
|
+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
|
8
|
+
</dependencies>
|
|
9
|
+
<scenes><scene sceneID="scene"><objects>
|
|
10
|
+
<viewController id="launch" sceneMemberID="viewController">
|
|
11
|
+
<view key="view" contentMode="scaleToFill" id="background">
|
|
12
|
+
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
|
|
13
|
+
<color key="backgroundColor" red="0.980" green="0.969" blue="0.980" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
|
14
|
+
</view>
|
|
15
|
+
</viewController>
|
|
16
|
+
<placeholder placeholderIdentifier="IBFirstResponder" id="responder" sceneMemberID="firstResponder"/>
|
|
17
|
+
</objects></scene></scenes>
|
|
18
|
+
</document>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
IPHONEOS_DEPLOYMENT_TARGET = 15.0
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createApp } from 'nativescript-vue'
|
|
2
|
+
import { createMavis } from '@getcortexlabs/mavis/vue'
|
|
3
|
+
import { mavis, midnight } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { projectServiceKey } from '__MAVIS_SHARED__/services'
|
|
5
|
+
import App from './App.vue'
|
|
6
|
+
createApp(App)
|
|
7
|
+
.use(createMavis({ theme: mavis, darkTheme: midnight, appearance: '__MAVIS_APPEARANCE__' }))
|
|
8
|
+
.provide(projectServiceKey, {
|
|
9
|
+
async save(_name) {
|
|
10
|
+
/* Replace with your application service. */
|
|
11
|
+
},
|
|
12
|
+
})
|
|
13
|
+
.start()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"lib": ["ES2023", "DOM"],
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"paths": { "vue": ["./node_modules/nativescript-vue"] }
|
|
11
|
+
},
|
|
12
|
+
"vueCompilerOptions": { "target": 3, "lib": "nativescript-vue" },
|
|
13
|
+
"include": ["src", "../../shared"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { resolve } = require('node:path')
|
|
2
|
+
const webpack = require('@nativescript/webpack')
|
|
3
|
+
module.exports = (env) => {
|
|
4
|
+
webpack.init(env)
|
|
5
|
+
webpack.Utils.addCopyRule({
|
|
6
|
+
from: 'lucide.ttf',
|
|
7
|
+
to: 'fonts',
|
|
8
|
+
context: resolve(__dirname, 'node_modules/@getcortexlabs/mavis/fonts'),
|
|
9
|
+
})
|
|
10
|
+
webpack.chainWebpack((config) => {
|
|
11
|
+
config.resolve.alias.set('vue$', resolve(__dirname, 'node_modules/nativescript-vue'))
|
|
12
|
+
for (const name of [
|
|
13
|
+
'nativescript-vue',
|
|
14
|
+
'@nativescript/core',
|
|
15
|
+
'@vue/runtime-core',
|
|
16
|
+
'@vue/reactivity',
|
|
17
|
+
'@vue/shared',
|
|
18
|
+
])
|
|
19
|
+
config.resolve.alias.set(name, resolve(__dirname, 'node_modules', name))
|
|
20
|
+
})
|
|
21
|
+
return webpack.resolveConfig()
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { provide } from 'vue'
|
|
3
|
+
import Welcome from '__MAVIS_SHARED__/Welcome.vue'
|
|
4
|
+
import { projectServiceKey } from '__MAVIS_SHARED__/services'
|
|
5
|
+
provide(projectServiceKey, {
|
|
6
|
+
async save(_name) {
|
|
7
|
+
/* Replace with your application service. */
|
|
8
|
+
},
|
|
9
|
+
})
|
|
10
|
+
</script>
|
|
11
|
+
<template><Welcome /></template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createMavis, mavis, midnight, useMavisTheme } from '@getcortexlabs/mavis-web'
|
|
2
|
+
export default defineNuxtPlugin(({ vueApp }) => {
|
|
3
|
+
const saved = useCookie<string>('appearance')
|
|
4
|
+
const initial = useState<'light' | 'dark'>('mavis:appearance', () =>
|
|
5
|
+
saved.value === 'dark' ? 'dark' : saved.value === 'light' ? 'light' : '__MAVIS_APPEARANCE__',
|
|
6
|
+
)
|
|
7
|
+
vueApp.use(createMavis({ theme: mavis, darkTheme: midnight, appearance: initial.value }))
|
|
8
|
+
const context = vueApp.runWithContext(useMavisTheme)
|
|
9
|
+
onNuxtReady(() =>
|
|
10
|
+
context.setAppearance(
|
|
11
|
+
saved.value === 'dark' || saved.value === 'light' ? saved.value : 'system',
|
|
12
|
+
),
|
|
13
|
+
)
|
|
14
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "extends": "./.nuxt/tsconfig.json" }
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
import { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
4
|
+
import { useProjectService } from './services'
|
|
5
|
+
|
|
6
|
+
const { theme, setAppearance } = useMavisTheme()
|
|
7
|
+
const service = useProjectService()
|
|
8
|
+
const name = ref('A new beginning')
|
|
9
|
+
const saving = ref(false)
|
|
10
|
+
const saved = ref(false)
|
|
11
|
+
const error = ref('')
|
|
12
|
+
const canSave = computed(() => name.value.trim().length > 0)
|
|
13
|
+
async function save() {
|
|
14
|
+
if (!canSave.value || saving.value) return
|
|
15
|
+
saving.value = true
|
|
16
|
+
saved.value = false
|
|
17
|
+
error.value = ''
|
|
18
|
+
try {
|
|
19
|
+
await service.save(name.value.trim())
|
|
20
|
+
saved.value = true
|
|
21
|
+
} catch {
|
|
22
|
+
error.value = 'Could not save. Your draft is still here; try again.'
|
|
23
|
+
} finally {
|
|
24
|
+
saving.value = false
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<m-screen scroll>
|
|
31
|
+
<m-column padding="lg" gap="xl">
|
|
32
|
+
<m-row justify="between" gap="md" wrap>
|
|
33
|
+
<m-column gap="xs">
|
|
34
|
+
<m-text variant="overline" tone="primary">__MAVIS_NAME__</m-text>
|
|
35
|
+
<m-text variant="caption" tone="muted">Made with Mavis</m-text>
|
|
36
|
+
</m-column>
|
|
37
|
+
<m-button
|
|
38
|
+
variant="ghost"
|
|
39
|
+
size="sm"
|
|
40
|
+
:icon="theme.appearance === 'dark' ? 'sun' : 'moon'"
|
|
41
|
+
accessibilityLabel="Change appearance"
|
|
42
|
+
@click="setAppearance(theme.appearance === 'dark' ? 'light' : 'dark')"
|
|
43
|
+
/>
|
|
44
|
+
</m-row>
|
|
45
|
+
<m-column paddingY="xl" gap="md">
|
|
46
|
+
<m-text variant="overline" tone="accent">A LITTLE SPACE. A BIG IDEA.</m-text>
|
|
47
|
+
<m-text as="h1" variant="display">Make room for what’s next.</m-text>
|
|
48
|
+
<m-text tone="muted">Your first screen is ready. Give your next project a name.</m-text>
|
|
49
|
+
</m-column>
|
|
50
|
+
<m-card gap="lg">
|
|
51
|
+
<m-row justify="between" gap="sm">
|
|
52
|
+
<m-text variant="heading">Start something</m-text>
|
|
53
|
+
<m-icon name="sparkles" tone="primary" />
|
|
54
|
+
</m-row>
|
|
55
|
+
<m-input
|
|
56
|
+
v-model="name"
|
|
57
|
+
label="Project name"
|
|
58
|
+
name="project-name"
|
|
59
|
+
autocomplete="off"
|
|
60
|
+
helperText="A small beginning is still a beginning."
|
|
61
|
+
@update:modelValue="saved = false"
|
|
62
|
+
@submit="save"
|
|
63
|
+
/>
|
|
64
|
+
<m-alert v-if="error" tone="error" title="Let’s try again" :description="error" />
|
|
65
|
+
<m-button
|
|
66
|
+
:disabled="!canSave"
|
|
67
|
+
:loading="saving"
|
|
68
|
+
loadingText="Saving…"
|
|
69
|
+
icon="arrow-right"
|
|
70
|
+
@click="save"
|
|
71
|
+
>Create project</m-button
|
|
72
|
+
>
|
|
73
|
+
<m-reveal :show="saved">
|
|
74
|
+
<m-text tone="success"
|
|
75
|
+
>Your draft is ready. Connect the host service to make it yours.</m-text
|
|
76
|
+
>
|
|
77
|
+
</m-reveal>
|
|
78
|
+
</m-card>
|
|
79
|
+
<m-row gap="sm" wrap>
|
|
80
|
+
<m-icon name="layers" tone="accent" />
|
|
81
|
+
<m-text variant="caption" tone="muted">One screen. Your theme. Your platform.</m-text>
|
|
82
|
+
</m-row>
|
|
83
|
+
</m-column>
|
|
84
|
+
</m-screen>
|
|
85
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { inject, type InjectionKey } from 'vue'
|
|
2
|
+
|
|
3
|
+
export interface ProjectService {
|
|
4
|
+
save(name: string): Promise<void>
|
|
5
|
+
}
|
|
6
|
+
export const projectServiceKey: InjectionKey<ProjectService> = Symbol('project-service')
|
|
7
|
+
export function useProjectService() {
|
|
8
|
+
const service = inject(projectServiceKey)
|
|
9
|
+
if (!service) throw new Error('Provide a ProjectService from the application host.')
|
|
10
|
+
return service
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta name="theme-color" content="#FAF7FA" />
|
|
7
|
+
<title>__MAVIS_NAME__</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.ts"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createApp } from 'vue'
|
|
2
|
+
import { createMavis, mavis, midnight } from '@getcortexlabs/mavis-web'
|
|
3
|
+
import Welcome from '__MAVIS_SHARED__/Welcome.vue'
|
|
4
|
+
import { projectServiceKey } from '__MAVIS_SHARED__/services'
|
|
5
|
+
import '@getcortexlabs/mavis-web/style.css'
|
|
6
|
+
import './style.css'
|
|
7
|
+
|
|
8
|
+
createApp(Welcome)
|
|
9
|
+
.use(createMavis({ theme: mavis, darkTheme: midnight, appearance: '__MAVIS_APPEARANCE__' }))
|
|
10
|
+
.provide(projectServiceKey, {
|
|
11
|
+
async save(_name) {
|
|
12
|
+
/* Replace with your application service. */
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
.mount('#app')
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"lib": ["ES2023", "DOM"],
|
|
9
|
+
"types": ["vite/client"]
|
|
10
|
+
},
|
|
11
|
+
"include": ["src", "../../shared", "vite.config.ts"]
|
|
12
|
+
}
|