create-octane-xplat 0.18.0 → 0.20.0
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 +2 -144
- package/compatibility.json +97 -19
- package/compatibility.ts +141 -72
- package/dist/compatibility.js +66 -26
- package/dist/index.js +127 -64
- package/dist/package-manager.js +62 -0
- package/dist/scaffold.js +377 -127
- package/index.ts +256 -154
- package/library-template/AGENTS.md +6 -4
- package/library-template/README.md +22 -18
- package/library-template/bunfig +4 -0
- package/library-template/package.json +115 -18
- package/library-template/patches/@nativescript-community__octane@0.2.5.patch +1018 -0
- package/library-template/patches/@nativescript-community__sqlite-bridge@4.1.1.patch +30 -0
- package/library-template/patches/@nativescript-community__vite-octane@0.2.1.patch +72 -0
- package/library-template/patches/@nativescript__core@9.1.3.patch +1280 -0
- package/library-template/patches/@nativescript__doctor@2.0.18.patch +13 -0
- package/library-template/patches/@nativescript__vite@8.0.20.patch +2019 -0
- package/library-template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
- package/library-template/patches/@octanejs__tiptap@0.0.62.patch +12 -0
- package/library-template/patches/@sveltejs__acorn-typescript@1.0.13.patch +16 -0
- package/library-template/patches/css@3.0.0.patch +52 -0
- package/library-template/patches/octane@0.16.3.patch +1479 -0
- package/library-template/src/Badge.tsx +7 -6
- package/library-template/src/Badge.web.tsx +7 -6
- package/library-template/src/Welcome.stories.tsx +12 -0
- package/library-template/src/normalizeBadgeLabel.ts +1 -1
- package/library-template/src/props.ts +11 -11
- package/library-template/tests/normalizeBadgeLabel.test.ts +1 -1
- package/library-template/tests/packed-consumer.mjs +140 -123
- package/library-template/tsconfig.envs.json +1 -0
- package/library-template/tsconfig.json +1 -0
- package/library-template/tsconfig.types.json +15 -1
- package/library-template/tsrx-typegen.json +1 -1
- package/library-template/workshop.config.ts +3 -0
- package/package-manager.ts +93 -0
- package/package.json +70 -58
- package/scaffold.ts +1056 -526
- package/template/.agents/skills/xplat/SKILL.md +6 -6
- package/template/.agents/skills/xplat/references/components.md +1 -1
- package/template/.agents/skills/xplat/references/navigation.md +1 -1
- package/template/.agents/skills/xplat/references/styling.md +14 -14
- package/template/AGENTS.md +10 -10
- package/template/bunfig +4 -0
- package/template/gitignore +1 -0
- package/template/nativescript.config.ts +13 -16
- package/template/package.json +119 -10
- package/template/patches/@nativescript-community__octane@0.2.5.patch +1018 -0
- package/template/patches/@nativescript-community__sqlite-bridge@4.1.1.patch +30 -0
- package/template/patches/@nativescript-community__vite-octane@0.2.1.patch +72 -0
- package/template/patches/@nativescript__core@9.1.3.patch +1280 -0
- package/template/patches/@nativescript__doctor@2.0.18.patch +13 -0
- package/template/patches/@nativescript__vite@8.0.20.patch +2019 -0
- package/template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
- package/template/patches/@octanejs__tiptap@0.0.62.patch +12 -0
- package/template/patches/@sveltejs__acorn-typescript@1.0.13.patch +16 -0
- package/template/patches/css@3.0.0.patch +52 -0
- package/template/patches/octane@0.16.3.patch +1479 -0
- package/template/src/App.tsrx +77 -42
- package/template/src/Welcome.stories.tsx +22 -0
- package/template/src/app.spec.tsrx +169 -163
- package/template/src/app.web.test.tsx +18 -13
- package/template/src/failure-reporting.spec.ts +3 -3
- package/template/src/main.ts +14 -13
- package/template/src/main.tsrx +2 -0
- package/template/src/main.web.tsrx +5 -5
- package/template/src/native-runtime.spec.ts +13 -11
- package/template/src/test-setup.web.ts +9 -8
- package/template/src/test.ts +6 -6
- package/template/tsconfig.json +17 -1
- package/template/vite.config.native.mts +1 -2
- package/template/vite.config.ts +29 -23
- package/template/vitest.config.mts +18 -18
- package/template/vitest.web.config.mts +7 -7
- package/template/workshop.config.ts +3 -0
- package/library-template/pnpm-workspace.yaml +0 -171
- package/template/pnpm-workspace.yaml +0 -192
package/index.ts
CHANGED
|
@@ -2,202 +2,304 @@
|
|
|
2
2
|
import { existsSync, readdirSync } from 'node:fs'
|
|
3
3
|
import { basename, resolve } from 'node:path'
|
|
4
4
|
import { spawnSync } from 'node:child_process'
|
|
5
|
+
import { parseArgs } from 'node:util'
|
|
5
6
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
composeLibrary,
|
|
8
|
+
composeTargets,
|
|
9
|
+
defaultTargets,
|
|
10
|
+
resolveTargets,
|
|
11
|
+
selectableTargets,
|
|
12
|
+
targets,
|
|
12
13
|
} from './scaffold.ts'
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
templateIndex === -1
|
|
22
|
-
? 'app'
|
|
23
|
-
: templateValueIndex !== -1
|
|
24
|
-
? argv[templateValueIndex]
|
|
25
|
-
: argv[templateIndex].slice('--template='.length)
|
|
26
|
-
|
|
27
|
-
const nameIndex = argv.findIndex((arg) => arg === '--name' || arg.startsWith('--name='))
|
|
28
|
-
const nameValueIndex = nameIndex !== -1 && argv[nameIndex] === '--name' ? nameIndex + 1 : -1
|
|
29
|
-
const nameArg =
|
|
30
|
-
nameIndex === -1
|
|
31
|
-
? undefined
|
|
32
|
-
: nameValueIndex !== -1
|
|
33
|
-
? argv[nameValueIndex]
|
|
34
|
-
: argv[nameIndex].slice('--name='.length)
|
|
15
|
+
import { compatibility } from './compatibility.ts'
|
|
16
|
+
import {
|
|
17
|
+
decidePackageManager,
|
|
18
|
+
installedManagers,
|
|
19
|
+
managerVersion,
|
|
20
|
+
type PackageManager,
|
|
21
|
+
} from './package-manager.ts'
|
|
35
22
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
const fail = (message: string): never => {
|
|
24
|
+
console.error(`✗ ${message}`)
|
|
25
|
+
process.exit(1)
|
|
39
26
|
}
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
function parseCli() {
|
|
29
|
+
try {
|
|
30
|
+
return parseArgs({
|
|
31
|
+
args: process.argv.slice(2),
|
|
32
|
+
allowPositionals: true,
|
|
33
|
+
options: {
|
|
34
|
+
template: { type: 'string', default: 'app' },
|
|
35
|
+
name: { type: 'string' },
|
|
36
|
+
targets: { type: 'string' },
|
|
37
|
+
'package-manager': { type: 'string' },
|
|
38
|
+
'no-install': { type: 'boolean', default: false },
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return fail(error.message)
|
|
43
|
+
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
console.error('✗ --name needs an npm package name')
|
|
48
|
-
process.exit(1)
|
|
49
|
-
}
|
|
46
|
+
const { values, positionals } = parseCli()
|
|
50
47
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
const oneOf = <T extends string>(flag: string, value: string | undefined, choices: readonly T[]) =>
|
|
49
|
+
value === undefined || (choices as readonly string[]).includes(value)
|
|
50
|
+
? (value as T | undefined)
|
|
51
|
+
: fail(`--${flag} must be ${choices.join(' or ')}`)
|
|
54
52
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
: targetsValueIndex !== -1
|
|
59
|
-
? argv[targetsValueIndex]
|
|
60
|
-
: argv[targetsIndex].slice('--targets='.length)
|
|
53
|
+
const templateArg = oneOf('template', values.template, ['app', 'library'] as const)!
|
|
54
|
+
const managerFlag = oneOf('package-manager', values['package-manager'], ['bun', 'pnpm'] as const)
|
|
55
|
+
const noInstall = values['no-install']
|
|
61
56
|
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
process.exit(1)
|
|
57
|
+
if (values.name === '') {
|
|
58
|
+
fail('--name needs an npm package name')
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
if (positionals.length > 1) {
|
|
62
|
+
fail(`expected one project directory, got ${positionals.join(' ')}`)
|
|
63
|
+
}
|
|
70
64
|
|
|
71
|
-
const positional = argv.filter((arg, i) => !arg.startsWith('-') && !optionValues.has(i))
|
|
72
65
|
const defaultDir = templateArg === 'library' ? 'octane-xplat-library' : 'octane-xplat-app'
|
|
73
|
-
const dir = resolve(
|
|
74
|
-
|
|
75
|
-
if (templateArg === 'library' && targetsIndex !== -1) {
|
|
76
|
-
console.error(
|
|
77
|
-
'✗ --targets applies to the app template; libraries start with web and native builds',
|
|
78
|
-
)
|
|
66
|
+
const dir = resolve(positionals[0] ?? defaultDir)
|
|
79
67
|
|
|
80
|
-
|
|
68
|
+
if (templateArg === 'library' && values.targets !== undefined) {
|
|
69
|
+
fail('--targets applies to the app template; libraries start with web and native builds')
|
|
81
70
|
}
|
|
82
71
|
|
|
83
|
-
if (templateArg === 'app' &&
|
|
84
|
-
|
|
85
|
-
process.exit(1)
|
|
72
|
+
if (templateArg === 'app' && values.name !== undefined) {
|
|
73
|
+
fail('--name applies only to the library template')
|
|
86
74
|
}
|
|
87
75
|
|
|
88
76
|
if (existsSync(dir) && readdirSync(dir).length > 0) {
|
|
89
|
-
|
|
90
|
-
process.exit(1)
|
|
77
|
+
fail(`${dir} exists and is not empty`)
|
|
91
78
|
}
|
|
92
79
|
|
|
93
80
|
const parseTargets = (value) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
const ids = value
|
|
82
|
+
.split(',')
|
|
83
|
+
.map((s) => s.trim())
|
|
84
|
+
.filter(Boolean)
|
|
98
85
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
if (ids.length === 0) {
|
|
87
|
+
throw new Error(`--targets needs a comma list: ${selectableTargets.join(', ')}`)
|
|
88
|
+
}
|
|
102
89
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
90
|
+
for (const id of ids) {
|
|
91
|
+
if (!selectableTargets.includes(id)) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`unknown target "${id}" — expected a comma list of: ${selectableTargets.join(', ')}`,
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
110
97
|
|
|
111
|
-
|
|
98
|
+
return resolveTargets(ids)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const decision = decidePackageManager({
|
|
102
|
+
flag: managerFlag,
|
|
103
|
+
userAgent: process.env.npm_config_user_agent,
|
|
104
|
+
installed: installedManagers(),
|
|
105
|
+
interactive: Boolean(process.stdout.isTTY),
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
let packageManager: PackageManager = decision.kind === 'use' ? decision.manager : 'bun'
|
|
109
|
+
let managerNotice: string | undefined
|
|
110
|
+
|
|
111
|
+
if (decision.kind === 'missing') {
|
|
112
|
+
managerNotice = `! Neither Bun nor pnpm was found. Installing dependencies, applying framework
|
|
113
|
+
patches (xplat patches apply) and running the app all need one of them.
|
|
114
|
+
Install Bun ${compatibility.tools.bun}+ (https://bun.sh) or pnpm ${compatibility.tools.pnpm}+ (https://pnpm.io), then:
|
|
115
|
+
cd ${dir} && bun install
|
|
116
|
+
To use pnpm instead, recreate the project with --package-manager pnpm.`
|
|
117
|
+
} else if (decision.kind === 'use' && !decision.installed.includes(decision.manager)) {
|
|
118
|
+
managerNotice = `! ${managerLabel(decision.manager)} was selected but is not installed — the
|
|
119
|
+
${decision.manager} project was scaffolded without installing dependencies.
|
|
120
|
+
Install ${managerLabel(decision.manager)} ${compatibility.tools[decision.manager]}+, then run the
|
|
121
|
+
package manager's install command inside ${dir}.`
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The manager `select`, joining the caller's clack session. */
|
|
125
|
+
async function promptForManager(p: typeof import('@clack/prompts')) {
|
|
126
|
+
const picked = await p.select<PackageManager>({
|
|
127
|
+
message: 'Package manager',
|
|
128
|
+
options: [
|
|
129
|
+
{ value: 'bun', label: 'Bun' },
|
|
130
|
+
{ value: 'pnpm', label: 'pnpm' },
|
|
131
|
+
],
|
|
132
|
+
initialValue: 'bun',
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
if (p.isCancel(picked)) {
|
|
136
|
+
p.cancel('Cancelled')
|
|
137
|
+
process.exit(0)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
packageManager = picked
|
|
112
141
|
}
|
|
113
142
|
|
|
114
143
|
let ids: string[] = []
|
|
144
|
+
|
|
115
145
|
if (templateArg === 'library') {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
146
|
+
const packageName = values.name ?? basename(dir)
|
|
147
|
+
|
|
148
|
+
if (decision.kind === 'prompt') {
|
|
149
|
+
const p = await import('@clack/prompts')
|
|
150
|
+
|
|
151
|
+
p.intro('create-octane-xplat')
|
|
152
|
+
await promptForManager(p)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
composeLibrary(dir, packageName, { packageManager })
|
|
157
|
+
} catch (error) {
|
|
158
|
+
console.error(`✗ ${error.message}`)
|
|
159
|
+
process.exit(1)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
console.log(
|
|
163
|
+
`\n✓ scaffolded ${dir} (library: ${packageName}; web + iOS + Android; ${packageManager})`,
|
|
164
|
+
)
|
|
125
165
|
} else {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
if (values.targets !== undefined) {
|
|
167
|
+
try {
|
|
168
|
+
ids = parseTargets(values.targets)
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.error(`✗ ${error.message}`)
|
|
171
|
+
process.exit(1)
|
|
172
|
+
}
|
|
173
|
+
} else if (process.stdout.isTTY) {
|
|
174
|
+
// Non-interactive creation does not need the prompt module.
|
|
175
|
+
const p = await import('@clack/prompts')
|
|
176
|
+
|
|
177
|
+
p.intro('create-octane-xplat')
|
|
178
|
+
|
|
179
|
+
const picked = await p.multiselect({
|
|
180
|
+
message: 'Target platforms',
|
|
181
|
+
options: selectableTargets.map((id) => ({
|
|
182
|
+
value: id,
|
|
183
|
+
label: targets[id].label,
|
|
184
|
+
hint: targets[id].note,
|
|
185
|
+
})),
|
|
186
|
+
initialValues: [...defaultTargets],
|
|
187
|
+
required: true,
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
if (p.isCancel(picked)) {
|
|
191
|
+
p.cancel('Cancelled')
|
|
192
|
+
process.exit(0)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
ids = picked
|
|
196
|
+
if (decision.kind === 'prompt') {
|
|
197
|
+
await promptForManager(p)
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
ids = defaultTargets
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Targets from the flag skip the multiselect; the manager choice still asks.
|
|
204
|
+
if (decision.kind === 'prompt' && values.targets !== undefined) {
|
|
205
|
+
const p = await import('@clack/prompts')
|
|
206
|
+
|
|
207
|
+
p.intro('create-octane-xplat')
|
|
208
|
+
await promptForManager(p)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
composeTargets(ids, dir, { packageManager })
|
|
212
|
+
console.log(
|
|
213
|
+
`\n✓ scaffolded ${dir} (${[...new Set(resolveTargets(ids))].filter((id) => !targets[id].hidden).join(', ')}; ${packageManager})`,
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (managerNotice) {
|
|
218
|
+
console.log(`\n${managerNotice}`)
|
|
219
|
+
if (decision.kind === 'use') {
|
|
220
|
+
printNextSteps(dir, ids, templateArg, packageManager)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
process.exit(0)
|
|
162
224
|
}
|
|
163
225
|
|
|
164
226
|
if (noInstall) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
227
|
+
console.log('\nSkipped install (--no-install). To run manually:')
|
|
228
|
+
printNextSteps(dir, ids, templateArg, packageManager)
|
|
229
|
+
process.exit(0)
|
|
168
230
|
}
|
|
169
231
|
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
232
|
+
const managerFloor = compatibility.tools[packageManager]
|
|
233
|
+
const managerInstalled = managerVersion(packageManager)
|
|
234
|
+
|
|
235
|
+
if (managerInstalled !== undefined && versionBelow(managerInstalled, managerFloor)) {
|
|
236
|
+
console.log(
|
|
237
|
+
`! ${managerLabel(packageManager)} ${managerInstalled} is below the supported ${managerFloor}+ — install may fail`,
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const install = spawnSync(packageManager, ['install'], {
|
|
242
|
+
cwd: dir,
|
|
243
|
+
stdio: 'inherit',
|
|
244
|
+
shell: process.platform === 'win32',
|
|
174
245
|
})
|
|
175
246
|
|
|
176
247
|
if (install.status !== 0) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
248
|
+
console.log(
|
|
249
|
+
`\nInstall didn't finish (${managerLabel(packageManager)} missing?). To run manually:`,
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
printNextSteps(dir, ids, templateArg, packageManager)
|
|
253
|
+
process.exit(install.status ?? 1)
|
|
180
254
|
}
|
|
181
255
|
|
|
182
256
|
if (templateArg === 'app' && ids.includes('web')) {
|
|
183
|
-
|
|
184
|
-
|
|
257
|
+
console.log('\n✓ installed — starting dev server (Ctrl+C to stop)\n')
|
|
258
|
+
spawnSync(packageManager, ['run', 'dev'], {
|
|
259
|
+
cwd: dir,
|
|
260
|
+
stdio: 'inherit',
|
|
261
|
+
shell: process.platform === 'win32',
|
|
262
|
+
})
|
|
185
263
|
} else {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
264
|
+
console.log('\n✓ installed. Next steps:')
|
|
265
|
+
printNextSteps(dir, ids, templateArg, packageManager)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function managerLabel(manager: PackageManager) {
|
|
269
|
+
return manager === 'bun' ? 'Bun' : 'pnpm'
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function versionBelow(version: string, floor: string) {
|
|
273
|
+
const parts = (value: string) => value.split('.').map((n) => Number.parseInt(n, 10) || 0)
|
|
274
|
+
const got = parts(version)
|
|
275
|
+
const min = parts(floor)
|
|
276
|
+
|
|
277
|
+
for (let i = 0; i < Math.max(got.length, min.length); i++) {
|
|
278
|
+
const a = got[i] ?? 0
|
|
279
|
+
const b = min[i] ?? 0
|
|
280
|
+
|
|
281
|
+
if (a !== b) {
|
|
282
|
+
return a < b
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return false
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function printNextSteps(dir, ids, template, pm: PackageManager) {
|
|
290
|
+
console.log(` cd ${dir}\n ${pm} install`)
|
|
291
|
+
if (template === 'library') {
|
|
292
|
+
console.log(
|
|
293
|
+
` ${pm} run typecheck\n ${pm} run lint\n ${pm} run typegen\n ${pm} run test\n ${pm} run test:packed`,
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
return
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (ids.includes('web')) {
|
|
300
|
+
console.log(` ${pm} run dev`)
|
|
301
|
+
} else {
|
|
302
|
+
// No web entry — `xplat dev` discovers whichever native targets exist.
|
|
303
|
+
console.log(` ${pm} run xplat dev`)
|
|
304
|
+
}
|
|
203
305
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Library package notes
|
|
2
2
|
|
|
3
|
-
- Use
|
|
4
|
-
- Keep build dependencies in `catalog:xplat`. Use `
|
|
3
|
+
- Use the package manager pinned in `package.json` `packageManager`.
|
|
4
|
+
- Keep build dependencies in `catalog:xplat`. Use `bunx @octane-xplat/cli@latest upgrade --check` to preview a workspace-wide version/patch update and `bunx @octane-xplat/cli@latest upgrade` to apply it. Keep consumer peer ranges under the library's control; run `bun run xplat doctor` and the package checks afterward.
|
|
5
5
|
- Keep the public API in `src/index.ts` and `src/index.web.ts`; both barrels
|
|
6
6
|
must export the same names and types.
|
|
7
7
|
- Put shared prop contracts in `src/props.ts` and document public exports.
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
start with `/** @jsxImportSource @octane-xplat/jsx/dom */`.
|
|
12
12
|
- Keep DOM globals out of native files. Use the shared `@octane-xplat/ui`
|
|
13
13
|
elements when behavior can be shared.
|
|
14
|
+
- Give every exported function and value an explicit type; `bun run typegen`
|
|
15
|
+
writes each file's declarations on its own and reports missing ones.
|
|
14
16
|
- Declare every imported package. Runtime plugins belong in `dependencies`;
|
|
15
17
|
Octane and renderer packages belong in `peerDependencies` when consumers
|
|
16
18
|
supply the runtime.
|
|
17
|
-
- Before publishing, run `
|
|
18
|
-
`
|
|
19
|
+
- Before publishing, run `bun run typecheck`, `bun run lint`, `bun run test`,
|
|
20
|
+
`bun run typegen`, and `bun run test:packed`.
|
|
@@ -9,7 +9,7 @@ and check the artifact that will be published.
|
|
|
9
9
|
Install this package in an Octane Xplat app:
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
|
|
12
|
+
bun add octane-xplat-library
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Render the example component from your app:
|
|
@@ -18,7 +18,7 @@ Render the example component from your app:
|
|
|
18
18
|
import { Badge } from 'octane-xplat-library'
|
|
19
19
|
|
|
20
20
|
export function Welcome() {
|
|
21
|
-
|
|
21
|
+
return <Badge label="Ready" />
|
|
22
22
|
}
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -27,12 +27,12 @@ export function Welcome() {
|
|
|
27
27
|
Run these commands from the package directory:
|
|
28
28
|
|
|
29
29
|
```sh
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
bun run typecheck
|
|
31
|
+
bun run lint
|
|
32
|
+
bun run lint:fix
|
|
33
|
+
bun run test
|
|
34
|
+
bun run typegen
|
|
35
|
+
bun run test:packed
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
Linting uses the CLI's bundled framework defaults. Apply safe lint fixes with
|
|
@@ -40,26 +40,27 @@ Linting uses the CLI's bundled framework defaults. Apply safe lint fixes with
|
|
|
40
40
|
without changing files:
|
|
41
41
|
|
|
42
42
|
```sh
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
bun run format
|
|
44
|
+
bun run xplat fmt --check
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
The package publishes authored source for the app's bundler to compile.
|
|
48
|
-
`
|
|
49
|
-
declarations. `
|
|
48
|
+
`bun run typegen` generates `.d.ts` files so consumers' type checkers use
|
|
49
|
+
declarations. `bun run test:packed` packs the package, places that artifact into
|
|
50
50
|
small web and native TypeScript consumers, and checks both export conditions.
|
|
51
51
|
|
|
52
|
-
The
|
|
53
|
-
|
|
52
|
+
The starter configures a hoisted dependency tree
|
|
53
|
+
(`linker = "hoisted"` / `nodeLinker: hoisted`) because the NativeScript
|
|
54
|
+
bundler expects a flat dependency tree.
|
|
54
55
|
|
|
55
56
|
Its `catalog:xplat` build dependencies and patches follow one framework
|
|
56
57
|
compatibility set. Update that set together; consumer `peerDependencies`
|
|
57
58
|
ranges are preserved for you to maintain:
|
|
58
59
|
|
|
59
60
|
```sh
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
bunx @octane-xplat/cli@latest upgrade --check
|
|
62
|
+
bunx @octane-xplat/cli@latest upgrade
|
|
63
|
+
bun run xplat doctor
|
|
63
64
|
```
|
|
64
65
|
|
|
65
66
|
## Platform files
|
|
@@ -79,6 +80,9 @@ metadata to this package.
|
|
|
79
80
|
|
|
80
81
|
Before publishing, replace the generated package name and repository metadata
|
|
81
82
|
in `package.json`, fill in the year and copyright holder in `LICENSE`, and
|
|
82
|
-
confirm that every runtime import is declared. `
|
|
83
|
+
confirm that every runtime import is declared. `bun run test:packed` checks the
|
|
83
84
|
package tarball's web and native type exports; it does not build or launch a
|
|
84
85
|
consuming app on a device.
|
|
86
|
+
|
|
87
|
+
Follow [Publish a reusable component library](https://octane-xplat.goddardai.org/component-libraries)
|
|
88
|
+
for a complete app-to-tarball workflow, runtime ownership, assets and publication.
|