create-octane-xplat 0.19.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.
Files changed (63) hide show
  1. package/README.md +2 -147
  2. package/compatibility.json +74 -61
  3. package/compatibility.ts +134 -79
  4. package/dist/compatibility.js +45 -13
  5. package/dist/index.js +127 -64
  6. package/dist/package-manager.js +62 -0
  7. package/dist/scaffold.js +362 -57
  8. package/index.ts +256 -156
  9. package/library-template/AGENTS.md +1 -1
  10. package/library-template/README.md +4 -3
  11. package/library-template/bunfig +4 -0
  12. package/library-template/package.json +73 -70
  13. package/library-template/patches/@nativescript-community__octane@0.2.5.patch +161 -24
  14. package/library-template/patches/@nativescript__core@9.1.3.patch +98 -0
  15. package/library-template/patches/@nativescript__vite@8.0.20.patch +532 -17
  16. package/library-template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
  17. package/library-template/patches/octane@0.16.3.patch +56 -2
  18. package/library-template/src/Badge.tsx +5 -5
  19. package/library-template/src/Badge.web.tsx +5 -5
  20. package/library-template/src/Welcome.stories.tsx +12 -0
  21. package/library-template/src/normalizeBadgeLabel.ts +1 -1
  22. package/library-template/src/props.ts +11 -11
  23. package/library-template/tests/normalizeBadgeLabel.test.ts +1 -1
  24. package/library-template/tests/packed-consumer.mjs +140 -123
  25. package/library-template/tsconfig.envs.json +1 -0
  26. package/library-template/tsconfig.json +1 -0
  27. package/library-template/tsconfig.types.json +15 -1
  28. package/library-template/tsrx-typegen.json +1 -1
  29. package/library-template/workshop.config.ts +3 -0
  30. package/package-manager.ts +93 -0
  31. package/package.json +10 -5
  32. package/scaffold.ts +1061 -449
  33. package/template/.agents/skills/xplat/SKILL.md +1 -1
  34. package/template/.agents/skills/xplat/references/styling.md +10 -10
  35. package/template/AGENTS.md +2 -2
  36. package/template/bunfig +4 -0
  37. package/template/nativescript.config.ts +13 -13
  38. package/template/package.json +69 -64
  39. package/template/patches/@nativescript-community__octane@0.2.5.patch +161 -24
  40. package/template/patches/@nativescript__core@9.1.3.patch +98 -0
  41. package/template/patches/@nativescript__vite@8.0.20.patch +532 -17
  42. package/template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
  43. package/template/patches/octane@0.16.3.patch +56 -2
  44. package/template/src/App.tsrx +66 -64
  45. package/template/src/Welcome.stories.tsx +22 -0
  46. package/template/src/app.spec.tsrx +168 -158
  47. package/template/src/app.web.test.tsx +18 -13
  48. package/template/src/failure-reporting.spec.ts +3 -3
  49. package/template/src/main.ts +14 -13
  50. package/template/src/main.tsrx +2 -0
  51. package/template/src/native-runtime.spec.ts +13 -11
  52. package/template/src/test-setup.web.ts +9 -8
  53. package/template/src/test.ts +6 -6
  54. package/template/tsconfig.json +17 -1
  55. package/template/vite.config.native.mts +1 -2
  56. package/template/vite.config.ts +29 -23
  57. package/template/vitest.config.mts +17 -17
  58. package/template/vitest.web.config.mts +7 -7
  59. package/template/workshop.config.ts +3 -0
  60. package/library-template/patches/@tsrx__typescript-plugin@0.4.11.patch +0 -11
  61. package/template/patches/@tsrx__typescript-plugin@0.4.11.patch +0 -11
  62. /package/library-template/patches/{@octanejs__tiptap@0.0.61.patch → @octanejs__tiptap@0.0.62.patch} +0 -0
  63. /package/template/patches/{@octanejs__tiptap@0.0.61.patch → @octanejs__tiptap@0.0.62.patch} +0 -0
package/README.md CHANGED
@@ -1,150 +1,5 @@
1
1
  # create-octane-xplat
2
2
 
3
- > Get a TypeScript app running, then build its first useful flow with your
4
- > coding agent.
3
+ [Documentation](https://octane-xplat.goddardai.org/package-create).
5
4
 
6
- Xplat's target direction spans web, iOS, Android, macOS, Windows, and Linux.
7
- This starter configures **web, iOS, and Android**. macOS, Windows, and Linux
8
- are separate experiments — an AppKit host, a WinUI 3 scaffold with runtime
9
- verification pending, and a WebKitGTK webview host. See
10
- [target support](https://octane-xplat.goddardai.org/spec#choose-your-targets).
11
- The framework is `0.x` and its API surface is still changing.
12
-
13
- With Node.js and Bun 1.4.4 installed:
14
-
15
- ```sh
16
- bun create octane-xplat my-app
17
- ```
18
-
19
- The starter's `tsconfig.json` selects the shared native JSX types from its
20
- direct `@octane-xplat/jsx` dependency. Browser JSX leaves select DOM types on
21
- their first line, as `src/main.web.tsrx` does:
22
-
23
- ```tsx
24
- /** @jsxImportSource @octane-xplat/jsx/dom */
25
- export function BrowserMessage() {
26
- return <p>Ready</p>
27
- }
28
- ```
29
-
30
- See [platform files and JSX types](https://octane-xplat.goddardai.org/module-resolution#typescript)
31
- when adding a native or browser implementation.
32
-
33
- ## Start a library package
34
-
35
- To start a reusable package instead of an app, select the library template:
36
-
37
- ```sh
38
- bun create octane-xplat my-controls --template library
39
- cd my-controls
40
- bun run typecheck
41
- bun run typegen
42
- bun run test:packed
43
- ```
44
-
45
- The library starter publishes source for web, iOS, and Android, which the
46
- consuming app compiles. It includes conditional exports, generated `.d.ts`
47
- declarations, lint and unit-test
48
- scripts, and a packed-consumer check. Pass `--name @acme/my-controls` to set a
49
- scoped npm package name; otherwise the folder name becomes the package name.
50
- Library creation installs dependencies but does not start an app dev server.
51
- Desktop targets are not included in this starter.
52
- Follow [Publish a reusable component library](../../docs/app/component-libraries.md)
53
- for app-based development, generated types, packed consumers, assets and npm
54
- publication.
55
-
56
- The creator asks which platforms to target — web, iOS, and Android are all
57
- pre-selected. Pass `--targets` to skip the prompt:
58
-
59
- ```sh
60
- bun create octane-xplat my-app --targets web # web only
61
- bun create octane-xplat my-app --targets web,android # web + Android
62
- ```
63
-
64
- Platforms skipped here can be enabled later with `bun run xplat add <platform>`
65
- inside the app. (Non-interactive runs without `--targets` scaffold all
66
- three.)
67
-
68
- The creator copies the template, installs dependencies with Bun, and starts
69
- the web dev server when the web target is included. Open the printed URL and
70
- open `my-app` in your agent.
71
- Ask it to read `AGENTS.md` and `.agents/skills/xplat/SKILL.md`, then build a
72
- packing checklist with add, pack, and remove actions using in-memory state.
73
- Check the result before asking for the next feature: add “Passport” and
74
- “Charger,” pack Passport, and confirm that one item remains. Reloading should
75
- clear the list in this in-memory version. The
76
- [first-flow guide](https://octane-xplat.goddardai.org/toolchain#build-and-check-your-first-flow)
77
- includes the full prompt and failure checks.
78
-
79
- The generated app pins Bun 1.4.4. Its `package.json` owns named catalogs
80
- and patch registrations. Local `patches/` files are available before the first
81
- install; keep them and `bun.lock` in Git.
82
-
83
- Apps start with the runtime, build packages, and tests their selected platforms
84
- need. Feature packages are added when you use them.
85
-
86
- ## Run app tests
87
-
88
- New apps include Vitest, configuration, sample tests, and scripts. From your
89
- app's folder, run the command for a platform you enabled:
90
-
91
- ```sh
92
- bun run test:web # when web is enabled
93
- bun run test:ios -- --device DEVICE_UDID # when iOS is enabled
94
- bun run test:android -- --device DEVICE_SERIAL # when Android is enabled
95
- ```
96
-
97
- Web tests use jsdom, which simulates a browser's
98
- document on your computer; phone tests use NativeScript's test runner on a
99
- selected simulator or device. The runners are explicit development dependencies
100
- with framework-managed versions in `catalog:xplat`. Adapt the sample tests to
101
- your app as you replace the starter screen.
102
-
103
- Platforms added later also receive their test setup. The library template
104
- includes its component tests and publishing checks.
105
- See [checking an app](https://octane-xplat.goddardai.org/testing#add-automated-tests) for the
106
- commands, file conventions, and checks that still need a browser or phone.
107
-
108
- ## Keep compatible versions
109
-
110
- App and library starters share the framework's compatible compiler, runtime,
111
- and tool versions through `catalog:xplat`. To update an existing project,
112
- preview and apply a published CLI release's set, then check the installed
113
- packages:
114
-
115
- ```sh
116
- bunx @octane-xplat/cli@latest upgrade --check
117
- bunx @octane-xplat/cli@latest upgrade
118
- bun run xplat doctor
119
- ```
120
-
121
- An upgrade covers the workspace's managed dependencies and patches. Your
122
- app-specific packages and library consumer peer ranges remain yours. See
123
- [compatible versions](https://github.com/octane-xplat/octane-xplat/blob/main/packages/cli/README.md#compatible-versions) for local links,
124
- custom patches, deferred installs, and failure recovery.
125
-
126
- Leave the server running while you edit. After stopping it, restart from the
127
- app directory:
128
-
129
- ```sh
130
- cd my-app
131
- bun run dev # web
132
- ```
133
-
134
- From that directory, these commands run other targets or check the app — the
135
- `dev:*`/`build:*` entries exist only for platforms chosen at create time
136
- (`bun run xplat add` adds the rest later):
137
-
138
- ```sh
139
- bun run dev:ios # needs macOS, Xcode, and NativeScript setup
140
- bun run dev:android # needs Android SDK, compatible JDK, and NativeScript setup
141
- bun run lint
142
- bun run typecheck # tsconfig.json + every declared environment
143
- bun run build # web production bundle
144
- ```
145
-
146
- [Get a working app and iterate](https://octane-xplat.goddardai.org/toolchain)
147
- provides prerequisites, live-update boundaries, and version guidance. The
148
- starter's Xplat skill is included; NativeScript's official skills are optional
149
- and installed separately. Ask your agent to report checks and targets actually
150
- run. [llms.txt](https://octane-xplat.goddardai.org/llms.txt) indexes the docs.
5
+ [API reference](https://octane-xplat.goddardai.org/api-create).
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$comment": "Release compatibility set, shared by create-octane-xplat and xplat doctor/upgrade. Edit external pins here, then run bun run sync:compatibility. Framework package names are generated from the lockstep release set. Optional packages are managed only when declared; library consumer peer ranges remain app-owned.",
3
3
  "schemaVersion": 1,
4
- "frameworkVersion": "0.19.0",
4
+ "frameworkVersion": "0.20.0",
5
5
  "tools": {
6
6
  "nodeMinimum": "22.22.2",
7
7
  "bun": "1.4.4",
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "frameworkPackages": [
11
11
  "@octane-xplat/ads",
12
+ "@octane-xplat/app-menu",
12
13
  "@octane-xplat/audio",
13
14
  "@octane-xplat/auth",
14
15
  "@octane-xplat/background-tasks",
@@ -16,6 +17,7 @@
16
17
  "@octane-xplat/barcode-scanner",
17
18
  "@octane-xplat/billing",
18
19
  "@octane-xplat/biometrics",
20
+ "@octane-xplat/build",
19
21
  "@octane-xplat/calendar",
20
22
  "@octane-xplat/camera",
21
23
  "@octane-xplat/canvas",
@@ -28,15 +30,18 @@
28
30
  "@octane-xplat/date-picker",
29
31
  "@octane-xplat/desktop-webview",
30
32
  "@octane-xplat/dnd-kit",
33
+ "@octane-xplat/docs-search",
31
34
  "@octane-xplat/drawer",
32
35
  "@octane-xplat/effects",
33
36
  "@octane-xplat/files",
34
37
  "@octane-xplat/fingerprint",
35
38
  "@octane-xplat/firebase-analytics",
36
39
  "@octane-xplat/firebase-crashlytics",
40
+ "@octane-xplat/form",
37
41
  "@octane-xplat/geofencing",
38
42
  "@octane-xplat/geolocation",
39
43
  "@octane-xplat/gif",
44
+ "@octane-xplat/global-shortcuts",
40
45
  "@octane-xplat/haptics",
41
46
  "@octane-xplat/icons",
42
47
  "@octane-xplat/image",
@@ -51,10 +56,12 @@
51
56
  "@octane-xplat/lint",
52
57
  "@octane-xplat/linux-gtk",
53
58
  "@octane-xplat/lottie",
54
- "@octane-xplat/macos-renderer",
59
+ "@octane-xplat/macos-appkit",
60
+ "@octane-xplat/macos-build",
55
61
  "@octane-xplat/maps",
56
62
  "@octane-xplat/mcp",
57
63
  "@octane-xplat/media",
64
+ "@octane-xplat/media-converter",
58
65
  "@octane-xplat/media-library",
59
66
  "@octane-xplat/motion",
60
67
  "@octane-xplat/nano-icons",
@@ -79,6 +86,7 @@
79
86
  "@octane-xplat/shortcuts",
80
87
  "@octane-xplat/smooth-corners",
81
88
  "@octane-xplat/sounds",
89
+ "@octane-xplat/speech-recognition",
82
90
  "@octane-xplat/splash-screen",
83
91
  "@octane-xplat/sqlite",
84
92
  "@octane-xplat/store-review",
@@ -86,6 +94,7 @@
86
94
  "@octane-xplat/table",
87
95
  "@octane-xplat/tiptap",
88
96
  "@octane-xplat/tracking-transparency",
97
+ "@octane-xplat/tray",
89
98
  "@octane-xplat/ui",
90
99
  "@octane-xplat/updates",
91
100
  "@octane-xplat/video",
@@ -93,7 +102,8 @@
93
102
  "@octane-xplat/web-browser",
94
103
  "@octane-xplat/web-host",
95
104
  "@octane-xplat/workshop",
96
- "create-octane-xplat"
105
+ "create-octane-xplat",
106
+ "octane-xplat"
97
107
  ],
98
108
  "packages": {
99
109
  "octane": {
@@ -112,23 +122,19 @@
112
122
  "singleton": true
113
123
  },
114
124
  "typescript": {
115
- "version": "5.9.3",
125
+ "version": "7.1.0-beta",
116
126
  "group": "compiler"
117
127
  },
118
128
  "@tsrx/oxc": {
119
129
  "version": "0.20.0",
120
130
  "group": "compiler"
121
131
  },
122
- "@tsrx/typescript-plugin": {
123
- "version": "0.4.11",
124
- "group": "compiler"
125
- },
126
132
  "tsrx-typegen": {
127
- "version": "0.5.0",
133
+ "version": "0.6.0",
128
134
  "group": "compiler"
129
135
  },
130
136
  "vite": {
131
- "version": "8.3.0",
137
+ "version": "8.3.6",
132
138
  "group": "bundler"
133
139
  },
134
140
  "@octanejs/vite-plugin": {
@@ -168,11 +174,11 @@
168
174
  "group": "native-toolchain"
169
175
  },
170
176
  "@nativescript/macos-node-api": {
171
- "version": "0.4.4-next.2026-08-09-31292056208",
177
+ "version": "0.5.0-beta.0",
172
178
  "group": "native-toolchain"
173
179
  },
174
180
  "@nativescript/windows": {
175
- "version": "0.1.0-alpha.144",
181
+ "version": "0.1.0-alpha.146",
176
182
  "group": "native-toolchain"
177
183
  },
178
184
  "vitest": {
@@ -200,7 +206,7 @@
200
206
  "group": "plugin"
201
207
  },
202
208
  "@octane-xplat/nativescript-mason-core": {
203
- "version": "1.0.0-beta.5",
209
+ "version": "1.0.0-beta.7",
204
210
  "group": "runtime"
205
211
  },
206
212
  "@octane-xplat/nativescript-masonkit": {
@@ -214,6 +220,11 @@
214
220
  "@nativescript/font-manager": {
215
221
  "version": "1.0.20",
216
222
  "group": "plugin"
223
+ },
224
+ "typescript-classic": {
225
+ "version": "5.9.3",
226
+ "specifier": "npm:typescript@5.9.3",
227
+ "group": "compiler"
217
228
  }
218
229
  },
219
230
  "profiles": {
@@ -240,53 +251,55 @@
240
251
  "vite>esbuild": "0.27.7",
241
252
  "regenerate": "1.5.0",
242
253
  "oxlint-tsgolint": "7.0.2005",
243
- "@lexical/a11y": "0.52.0",
244
- "@lexical/code": "0.52.0",
245
- "@lexical/devtools-core": "0.52.0",
246
- "@lexical/dragon": "0.52.0",
247
- "@lexical/extension": "0.52.0",
248
- "@lexical/hashtag": "0.52.0",
249
- "@lexical/history": "0.52.0",
250
- "@lexical/html": "0.52.0",
251
- "@lexical/internal": "0.52.0",
252
- "@lexical/link": "0.52.0",
253
- "@lexical/list": "0.52.0",
254
- "@lexical/mark": "0.52.0",
255
- "@lexical/markdown": "0.52.0",
256
- "@lexical/overflow": "0.52.0",
257
- "@lexical/plain-text": "0.52.0",
258
- "@lexical/rich-text": "0.52.0",
259
- "@lexical/selection": "0.52.0",
260
- "@lexical/table": "0.52.0",
261
- "@lexical/text": "0.52.0",
262
- "@lexical/utils": "0.52.0",
263
- "@lexical/yjs": "0.52.0",
264
- "lexical": "0.52.0",
265
- "@tiptap/core": "3.32.0",
266
- "@tiptap/pm": "3.32.0",
267
- "@tiptap/starter-kit": "3.32.0",
268
- "@tiptap/static-renderer": "3.32.0",
269
- "@tiptap/extensions": "3.32.0",
270
- "@tiptap/extension-blockquote": "3.32.0",
271
- "@tiptap/extension-bold": "3.32.0",
272
- "@tiptap/extension-bullet-list": "3.32.0",
273
- "@tiptap/extension-code": "3.32.0",
274
- "@tiptap/extension-code-block": "3.32.0",
275
- "@tiptap/extension-document": "3.32.0",
276
- "@tiptap/extension-dropcursor": "3.32.0",
277
- "@tiptap/extension-gapcursor": "3.32.0",
278
- "@tiptap/extension-hard-break": "3.32.0",
279
- "@tiptap/extension-heading": "3.32.0",
280
- "@tiptap/extension-horizontal-rule": "3.32.0",
281
- "@tiptap/extension-italic": "3.32.0",
282
- "@tiptap/extension-link": "3.32.0",
283
- "@tiptap/extension-list": "3.32.0",
284
- "@tiptap/extension-list-item": "3.32.0",
285
- "@tiptap/extension-list-keymap": "3.32.0",
286
- "@tiptap/extension-ordered-list": "3.32.0",
287
- "@tiptap/extension-paragraph": "3.32.0",
288
- "@tiptap/extension-strike": "3.32.0",
289
- "@tiptap/extension-text": "3.32.0",
290
- "@tiptap/extension-underline": "3.32.0"
254
+ "@lexical/a11y": "0.53.0",
255
+ "@lexical/code": "0.53.0",
256
+ "@lexical/devtools-core": "0.53.0",
257
+ "@lexical/dragon": "0.53.0",
258
+ "@lexical/extension": "0.53.0",
259
+ "@lexical/hashtag": "0.53.0",
260
+ "@lexical/history": "0.53.0",
261
+ "@lexical/html": "0.53.0",
262
+ "@lexical/internal": "0.53.0",
263
+ "@lexical/link": "0.53.0",
264
+ "@lexical/list": "0.53.0",
265
+ "@lexical/mark": "0.53.0",
266
+ "@lexical/markdown": "0.53.0",
267
+ "@lexical/overflow": "0.53.0",
268
+ "@lexical/plain-text": "0.53.0",
269
+ "@lexical/rich-text": "0.53.0",
270
+ "@lexical/selection": "0.53.0",
271
+ "@lexical/table": "0.53.0",
272
+ "@lexical/text": "0.53.0",
273
+ "@lexical/utils": "0.53.0",
274
+ "@lexical/yjs": "0.53.0",
275
+ "lexical": "0.53.0",
276
+ "@tiptap/core": "3.32.2",
277
+ "@tiptap/pm": "3.32.2",
278
+ "@tiptap/starter-kit": "3.32.2",
279
+ "@tiptap/static-renderer": "3.32.2",
280
+ "@tiptap/extensions": "3.32.2",
281
+ "@tiptap/extension-blockquote": "3.32.2",
282
+ "@tiptap/extension-bold": "3.32.2",
283
+ "@tiptap/extension-bubble-menu": "3.32.2",
284
+ "@tiptap/extension-bullet-list": "3.32.2",
285
+ "@tiptap/extension-code": "3.32.2",
286
+ "@tiptap/extension-code-block": "3.32.2",
287
+ "@tiptap/extension-document": "3.32.2",
288
+ "@tiptap/extension-dropcursor": "3.32.2",
289
+ "@tiptap/extension-floating-menu": "3.32.2",
290
+ "@tiptap/extension-gapcursor": "3.32.2",
291
+ "@tiptap/extension-hard-break": "3.32.2",
292
+ "@tiptap/extension-heading": "3.32.2",
293
+ "@tiptap/extension-horizontal-rule": "3.32.2",
294
+ "@tiptap/extension-italic": "3.32.2",
295
+ "@tiptap/extension-link": "3.32.2",
296
+ "@tiptap/extension-list": "3.32.2",
297
+ "@tiptap/extension-list-item": "3.32.2",
298
+ "@tiptap/extension-list-keymap": "3.32.2",
299
+ "@tiptap/extension-ordered-list": "3.32.2",
300
+ "@tiptap/extension-paragraph": "3.32.2",
301
+ "@tiptap/extension-strike": "3.32.2",
302
+ "@tiptap/extension-text": "3.32.2",
303
+ "@tiptap/extension-underline": "3.32.2"
291
304
  }
292
305
  }
package/compatibility.ts CHANGED
@@ -2,122 +2,177 @@ import { existsSync, globSync, readFileSync, writeFileSync } from 'node:fs'
2
2
  import { createRequire } from 'node:module'
3
3
  import { basename, dirname, join, resolve } from 'node:path'
4
4
  import { fileURLToPath } from 'node:url'
5
+ import { parse } from 'yaml'
5
6
 
6
7
  /** One supported external version, optionally using a preview tarball specifier. */
7
8
  export type ManagedPackage = {
8
- version: string
9
- specifier?: string
10
- group: string
11
- singleton?: boolean
9
+ version: string
10
+ specifier?: string
11
+ group: string
12
+ singleton?: boolean
12
13
  }
13
14
 
14
15
  /** The release-owned pins used by creator, doctor, and upgrade. */
15
16
  export type Compatibility = {
16
- schemaVersion: number
17
- frameworkVersion: string
18
- tools: { nodeMinimum: string; bun: string; pnpm: string }
19
- frameworkPackages: string[]
20
- packages: Record<string, ManagedPackage>
21
- profiles: Record<string, Record<string, Partial<ManagedPackage>>>
22
- overrides: Record<string, string>
17
+ schemaVersion: number
18
+ frameworkVersion: string
19
+ tools: { nodeMinimum: string; bun: string; pnpm: string }
20
+ frameworkPackages: string[]
21
+ packages: Record<string, ManagedPackage>
22
+ profiles: Record<string, Record<string, Partial<ManagedPackage>>>
23
+ overrides: Record<string, string>
23
24
  }
24
25
 
25
26
  const dir = dirname(fileURLToPath(import.meta.url))
26
27
  const root = basename(dir) === 'dist' ? dirname(dir) : dir
28
+
27
29
  // Keep JSON on disk: Vite's asset URL transform produces a data URL here.
28
30
  export const compatibility: Compatibility = createRequire(import.meta.url)(
29
- join(root, 'compatibility.json'),
31
+ join(root, 'compatibility.json'),
30
32
  )
31
33
 
32
34
  /** Look up a known framework package or a profile's external dependency pin. */
33
35
  export function managedPackage(name: string, profile = 'default'): ManagedPackage | undefined {
34
- if (compatibility.frameworkPackages.includes(name)) {
35
- return {
36
- version: compatibility.frameworkVersion,
37
- group: 'framework',
38
- singleton: name === '@octane-xplat/ui',
39
- }
40
- }
41
-
42
- const base = compatibility.packages[name]
43
- return base ? { ...base, ...compatibility.profiles[profile]?.[name] } : undefined
36
+ if (compatibility.frameworkPackages.includes(name)) {
37
+ return {
38
+ version: compatibility.frameworkVersion,
39
+ group: 'framework',
40
+ singleton: name === '@octane-xplat/ui',
41
+ }
42
+ }
43
+
44
+ const base = compatibility.packages[name]
45
+
46
+ return base ? { ...base, ...compatibility.profiles[profile]?.[name] } : undefined
44
47
  }
45
48
 
46
49
  /** Return the install specifier, keeping preview URLs separate from package versions. */
47
50
  export function managedSpecifier(name: string, profile = 'default') {
48
- const entry = managedPackage(name, profile)
49
- return entry?.specifier ?? entry?.version
51
+ const entry = managedPackage(name, profile)
52
+
53
+ return entry?.specifier ?? entry?.version
50
54
  }
51
55
 
52
56
  /** Named catalog reserved for this compatibility profile. */
53
57
  export const managedCatalog = (profile = 'default') =>
54
- profile === 'default' ? 'xplat' : `xplat-${profile}`
58
+ profile === 'default' ? 'xplat' : `xplat-${profile}`
55
59
 
56
60
  /** Installed dependency fields; library consumer peers intentionally keep their ranges. */
57
61
  export const dependencySections = [
58
- 'dependencies',
59
- 'devDependencies',
60
- 'optionalDependencies',
62
+ 'dependencies',
63
+ 'devDependencies',
64
+ 'optionalDependencies',
61
65
  ] as const
62
66
 
63
67
  /** Select Windows preview pins, rejecting a package that also needs mobile pins. */
64
68
  export function projectProfile(pkg: Record<string, any>): string {
65
- const deps = Object.assign({}, ...dependencySections.map((section) => pkg[section]))
66
- const windows = deps['@nativescript/windows'] || pkg.xplat?.targets?.windows
67
- if (windows && (deps['@nativescript/ios'] || deps['@nativescript/android'])) {
68
- throw new Error(
69
- 'Windows preview and mobile need separate workspace packages: their NativeScript pins differ',
70
- )
71
- }
72
-
73
- return windows ? 'windows' : 'default'
69
+ const deps = Object.assign({}, ...dependencySections.map((section) => pkg[section]))
70
+ const windows = deps['@nativescript/windows'] || pkg.xplat?.targets?.windows
71
+
72
+ if (windows && (deps['@nativescript/ios'] || deps['@nativescript/android'])) {
73
+ throw new Error(
74
+ 'Windows preview and mobile need separate workspace packages: their NativeScript pins differ',
75
+ )
76
+ }
77
+
78
+ return windows ? 'windows' : 'default'
79
+ }
80
+
81
+ /**
82
+ * An ancestor's workspace membership patterns: pnpm-workspace.yaml `packages`
83
+ * wins when the ancestor is not Bun-pinned, matching the CLI's root rules.
84
+ */
85
+ function workspacePatterns(root: string): string[] {
86
+ const yamlFile = join(root, 'pnpm-workspace.yaml')
87
+ const pkgFile = join(root, 'package.json')
88
+ const pkg = existsSync(pkgFile) ? JSON.parse(readFileSync(pkgFile, 'utf8')) : {}
89
+
90
+ if (pkg.packageManager?.split('@')[0] !== 'bun' && existsSync(yamlFile)) {
91
+ const packages = parse(readFileSync(yamlFile, 'utf8'))?.packages
92
+
93
+ return Array.isArray(packages) ? packages : []
94
+ }
95
+
96
+ const patterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages
97
+
98
+ return Array.isArray(patterns) ? patterns : []
74
99
  }
75
100
 
76
- /** Find the Bun workspace that owns this app, respecting package membership. */
101
+ /**
102
+ * Find the workspace that owns this app, respecting package membership.
103
+ * Mirrors the CLI's packageManagerRoot: ancestors need a package.json or a
104
+ * pnpm-workspace.yaml, and membership comes from the manager's config home.
105
+ */
77
106
  export function compatibilityRoot(appRoot: string) {
78
- const app = resolve(appRoot)
79
- for (let at = dirname(app); dirname(at) !== at; at = dirname(at)) {
80
- const file = join(at, 'package.json')
81
- if (!existsSync(file)) {
82
- continue
83
- }
84
- const pkg = JSON.parse(readFileSync(file, 'utf8'))
85
- const patterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages
86
- if (!patterns?.length) {
87
- continue
88
- }
89
- const included = patterns.filter((p) => !p.startsWith('!'))
90
- const exclude = [
91
- '**/node_modules/**',
92
- ...patterns.filter((p) => p.startsWith('!')).map((p) => p.slice(1)),
93
- ]
94
- if (globSync(included, { cwd: at, exclude }).some((p) => resolve(at, p) === app)) {
95
- return at
96
- }
97
- }
98
- return app
107
+ const app = resolve(appRoot)
108
+
109
+ for (let at = dirname(app); dirname(at) !== at; at = dirname(at)) {
110
+ if (!existsSync(join(at, 'package.json')) && !existsSync(join(at, 'pnpm-workspace.yaml'))) {
111
+ continue
112
+ }
113
+
114
+ const patterns = workspacePatterns(at)
115
+
116
+ if (!patterns.length) {
117
+ continue
118
+ }
119
+
120
+ const included = patterns.filter((p) => !p.startsWith('!'))
121
+ const exclude = [
122
+ '**/node_modules/**',
123
+ ...patterns.filter((p) => p.startsWith('!')).map((p) => p.slice(1)),
124
+ ]
125
+
126
+ if (globSync(included, { cwd: at, exclude }).some((p) => resolve(at, p) === app)) {
127
+ return at
128
+ }
129
+ }
130
+
131
+ return app
99
132
  }
100
133
 
101
134
  /** Add missing Bun catalog pins when enabling a target. Existing pins stay intact. */
102
135
  export function ensureCompatibilityCatalog(appRoot: string, pkg: Record<string, any>) {
103
- const root = compatibilityRoot(appRoot)
104
- const file = join(root, 'package.json')
105
- const owner = root === resolve(appRoot) ? pkg : JSON.parse(readFileSync(file, 'utf8'))
106
- if (Array.isArray(owner.workspaces)) {
107
- owner.workspaces = { packages: owner.workspaces }
108
- }
109
- owner.workspaces ??= { packages: [] }
110
- const catalogs = owner.catalogs ?? (owner.workspaces.catalogs ??= {})
111
- const profile = projectProfile(pkg)
112
- const catalog = (catalogs[managedCatalog(profile)] ??= {})
113
- for (const section of dependencySections) {
114
- for (const [name, spec] of Object.entries(pkg[section] ?? {})) {
115
- if (spec === `catalog:${managedCatalog(profile)}`) {
116
- catalog[name] ??= managedSpecifier(name, profile)
117
- }
118
- }
119
- }
120
- if (owner !== pkg) {
121
- writeFileSync(file, JSON.stringify(owner, null, '\t') + '\n')
122
- }
136
+ const root = compatibilityRoot(appRoot)
137
+ const file = join(root, 'package.json')
138
+ const owner = root === resolve(appRoot) ? pkg : JSON.parse(readFileSync(file, 'utf8'))
139
+
140
+ mergeCompatibilityCatalog(pkg, owner)
141
+ if (owner !== pkg) {
142
+ writeFileSync(file, JSON.stringify(owner, null, '\t') + '\n')
143
+ }
144
+ }
145
+
146
+ /** Catalog pins a package requests via `catalog:` specifiers, managed set only. */
147
+ export function requestedCatalogPins(pkg: Record<string, any>) {
148
+ const profile = projectProfile(pkg)
149
+ const catalog = managedCatalog(profile)
150
+ const pins: Record<string, string> = {}
151
+
152
+ for (const section of dependencySections) {
153
+ for (const [name, spec] of Object.entries(pkg[section] ?? {})) {
154
+ if (spec === `catalog:${catalog}` && pins[name] === undefined) {
155
+ pins[name] = managedSpecifier(name, profile)!
156
+ }
157
+ }
158
+ }
159
+
160
+ return { catalog, pins }
161
+ }
162
+
163
+ /** Merge catalog policy without filesystem effects; shared by scaffold plans. */
164
+ export function mergeCompatibilityCatalog(pkg: Record<string, any>, owner: Record<string, any>) {
165
+ if (Array.isArray(owner.workspaces)) {
166
+ owner.workspaces = { packages: owner.workspaces }
167
+ }
168
+
169
+ owner.workspaces ??= { packages: [] }
170
+
171
+ const catalogs = owner.catalogs ?? (owner.workspaces.catalogs ??= {})
172
+ const { catalog, pins } = requestedCatalogPins(pkg)
173
+ const target = (catalogs[catalog] ??= {})
174
+
175
+ for (const [name, spec] of Object.entries(pins)) {
176
+ target[name] ??= spec
177
+ }
123
178
  }