@sdxc/kit 0.0.0-stage → 2026.10.17

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 (298) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +93 -2
  3. package/changelog.jsonl +1097 -0
  4. package/config.schema.json +89 -0
  5. package/dist/author.d.ts +36 -0
  6. package/dist/author.js +107 -0
  7. package/dist/bin.d.ts +9 -0
  8. package/dist/bin.js +10 -0
  9. package/dist/cli.d.ts +33 -0
  10. package/dist/cli.js +58 -0
  11. package/dist/commands/create.d.ts +20 -0
  12. package/dist/commands/create.js +169 -0
  13. package/dist/commands/init.d.ts +16 -0
  14. package/dist/commands/init.js +27 -0
  15. package/dist/commands/make.d.ts +335 -0
  16. package/dist/commands/make.js +152 -0
  17. package/dist/commands/run.d.ts +23 -0
  18. package/dist/commands/run.js +53 -0
  19. package/dist/commands/ui/add.d.ts +23 -0
  20. package/dist/commands/ui/add.js +50 -0
  21. package/dist/commands/ui/diff.d.ts +20 -0
  22. package/dist/commands/ui/diff.js +28 -0
  23. package/dist/commands/ui/list.d.ts +24 -0
  24. package/dist/commands/ui/list.js +45 -0
  25. package/dist/commands/ui/remove.d.ts +22 -0
  26. package/dist/commands/ui/remove.js +48 -0
  27. package/dist/commands/ui/update.d.ts +23 -0
  28. package/dist/commands/ui/update.js +37 -0
  29. package/dist/commands/upgrade.d.ts +30 -0
  30. package/dist/commands/upgrade.js +184 -0
  31. package/dist/config.d.ts +81 -0
  32. package/dist/config.js +157 -0
  33. package/dist/contract.d.ts +161 -0
  34. package/dist/contract.js +308 -0
  35. package/dist/create/github.d.ts +63 -0
  36. package/dist/create/github.js +172 -0
  37. package/dist/create/target.d.ts +31 -0
  38. package/dist/create/target.js +56 -0
  39. package/dist/create/templates.d.ts +69 -0
  40. package/dist/create/templates.js +251 -0
  41. package/dist/dependencies.d.ts +34 -0
  42. package/dist/dependencies.js +76 -0
  43. package/dist/diff.d.ts +14 -0
  44. package/dist/diff.js +103 -0
  45. package/dist/format.d.ts +21 -0
  46. package/dist/format.js +40 -0
  47. package/dist/init.d.ts +40 -0
  48. package/dist/init.js +100 -0
  49. package/dist/lock.d.ts +74 -0
  50. package/dist/lock.js +214 -0
  51. package/dist/make/declare.d.ts +54 -0
  52. package/dist/make/declare.js +598 -0
  53. package/dist/make/generate.d.ts +62 -0
  54. package/dist/make/generate.js +160 -0
  55. package/dist/make/imports.d.ts +43 -0
  56. package/dist/make/imports.js +105 -0
  57. package/dist/make/index.d.ts +43 -0
  58. package/dist/make/index.js +140 -0
  59. package/dist/make/kinds.d.ts +40 -0
  60. package/dist/make/kinds.js +96 -0
  61. package/dist/make/migrations.d.ts +41 -0
  62. package/dist/make/migrations.js +116 -0
  63. package/dist/make/names.d.ts +31 -0
  64. package/dist/make/names.js +47 -0
  65. package/dist/make/stubs.d.ts +44 -0
  66. package/dist/make/stubs.js +89 -0
  67. package/dist/middleware.d.ts +44 -0
  68. package/dist/middleware.js +49 -0
  69. package/dist/package-manager.d.ts +41 -0
  70. package/dist/package-manager.js +80 -0
  71. package/dist/project.d.ts +19 -0
  72. package/dist/project.js +42 -0
  73. package/dist/releases.d.ts +40 -0
  74. package/dist/releases.js +110 -0
  75. package/dist/testing.d.ts +60 -0
  76. package/dist/testing.js +148 -0
  77. package/dist/ui/commands.d.ts +114 -0
  78. package/dist/ui/commands.js +432 -0
  79. package/dist/ui/imports.d.ts +46 -0
  80. package/dist/ui/imports.js +160 -0
  81. package/dist/ui/layout.d.ts +48 -0
  82. package/dist/ui/layout.js +138 -0
  83. package/dist/ui/registry.d.ts +58 -0
  84. package/dist/ui/registry.js +82 -0
  85. package/dist/upgrade/changelog.d.ts +50 -0
  86. package/dist/upgrade/changelog.js +69 -0
  87. package/dist/upgrade/project.d.ts +62 -0
  88. package/dist/upgrade/project.js +132 -0
  89. package/dist/upgrade/prompt.d.ts +51 -0
  90. package/dist/upgrade/prompt.js +227 -0
  91. package/dist/upgrade/registry.d.ts +33 -0
  92. package/dist/upgrade/registry.js +50 -0
  93. package/lock.schema.json +60 -0
  94. package/package.json +44 -5
  95. package/registry/ui/accordion.json +15 -0
  96. package/registry/ui/alert-dialog.json +20 -0
  97. package/registry/ui/alert.json +15 -0
  98. package/registry/ui/aspect-ratio.json +13 -0
  99. package/registry/ui/attachment.json +15 -0
  100. package/registry/ui/avatar.json +15 -0
  101. package/registry/ui/badge.json +13 -0
  102. package/registry/ui/breadcrumbs.json +15 -0
  103. package/registry/ui/bubble.json +13 -0
  104. package/registry/ui/button.json +16 -0
  105. package/registry/ui/calendar.json +16 -0
  106. package/registry/ui/card.json +18 -0
  107. package/registry/ui/carousel.json +15 -0
  108. package/registry/ui/chart.json +13 -0
  109. package/registry/ui/checkbox-group.json +13 -0
  110. package/registry/ui/checkbox.json +16 -0
  111. package/registry/ui/color-area.json +13 -0
  112. package/registry/ui/color-field.json +20 -0
  113. package/registry/ui/color-picker.json +17 -0
  114. package/registry/ui/color-slider.json +13 -0
  115. package/registry/ui/color-swatch-picker.json +15 -0
  116. package/registry/ui/color-swatch.json +13 -0
  117. package/registry/ui/color-wheel.json +13 -0
  118. package/registry/ui/combobox.json +15 -0
  119. package/registry/ui/command.json +13 -0
  120. package/registry/ui/confirm.json +19 -0
  121. package/registry/ui/context-menu.json +16 -0
  122. package/registry/ui/date-field.json +19 -0
  123. package/registry/ui/date-picker.json +15 -0
  124. package/registry/ui/date-range-picker.json +16 -0
  125. package/registry/ui/description.json +13 -0
  126. package/registry/ui/dialog.json +19 -0
  127. package/registry/ui/disclosure.json +18 -0
  128. package/registry/ui/drawer.json +18 -0
  129. package/registry/ui/drop-indicator.json +13 -0
  130. package/registry/ui/drop-zone.json +13 -0
  131. package/registry/ui/empty.json +15 -0
  132. package/registry/ui/field-error.json +13 -0
  133. package/registry/ui/file-trigger.json +13 -0
  134. package/registry/ui/form.json +21 -0
  135. package/registry/ui/grid-list.json +18 -0
  136. package/registry/ui/group.json +13 -0
  137. package/registry/ui/header.json +13 -0
  138. package/registry/ui/heading-scope.json +20 -0
  139. package/registry/ui/heading.json +15 -0
  140. package/registry/ui/highlight.json +16 -0
  141. package/registry/ui/hover-card.json +13 -0
  142. package/registry/ui/image-placeholder.json +16 -0
  143. package/registry/ui/input.json +13 -0
  144. package/registry/ui/item.json +13 -0
  145. package/registry/ui/keyboard.json +13 -0
  146. package/registry/ui/label.json +13 -0
  147. package/registry/ui/link-button.json +16 -0
  148. package/registry/ui/link.json +13 -0
  149. package/registry/ui/listbox.json +15 -0
  150. package/registry/ui/logo.json +15 -0
  151. package/registry/ui/marker.json +13 -0
  152. package/registry/ui/menu.json +19 -0
  153. package/registry/ui/menubar.json +13 -0
  154. package/registry/ui/message-scroller.json +16 -0
  155. package/registry/ui/message.json +13 -0
  156. package/registry/ui/meter.json +13 -0
  157. package/registry/ui/modal.json +15 -0
  158. package/registry/ui/nav-link.json +13 -0
  159. package/registry/ui/navigation-menu.json +15 -0
  160. package/registry/ui/number-field.json +15 -0
  161. package/registry/ui/otp-field.json +15 -0
  162. package/registry/ui/overlay-arrow.json +13 -0
  163. package/registry/ui/pagination.json +16 -0
  164. package/registry/ui/popover.json +13 -0
  165. package/registry/ui/progress-bar.json +13 -0
  166. package/registry/ui/radio-group.json +13 -0
  167. package/registry/ui/range-calendar.json +16 -0
  168. package/registry/ui/resizable.json +13 -0
  169. package/registry/ui/scroll-area.json +13 -0
  170. package/registry/ui/search-field.json +16 -0
  171. package/registry/ui/section.json +13 -0
  172. package/registry/ui/select.json +13 -0
  173. package/registry/ui/selection-indicator.json +13 -0
  174. package/registry/ui/sentinel-row.json +16 -0
  175. package/registry/ui/separator.json +13 -0
  176. package/registry/ui/shared-element.json +13 -0
  177. package/registry/ui/sheet.json +15 -0
  178. package/registry/ui/shortcut-list.json +18 -0
  179. package/registry/ui/sidebar.json +20 -0
  180. package/registry/ui/skeleton.json +13 -0
  181. package/registry/ui/slider.json +16 -0
  182. package/registry/ui/spinner.json +13 -0
  183. package/registry/ui/switch.json +16 -0
  184. package/registry/ui/table.json +16 -0
  185. package/registry/ui/tabs.json +17 -0
  186. package/registry/ui/tag-group.json +18 -0
  187. package/registry/ui/text-field.json +19 -0
  188. package/registry/ui/text.json +13 -0
  189. package/registry/ui/textarea.json +13 -0
  190. package/registry/ui/time-field.json +19 -0
  191. package/registry/ui/toast.json +16 -0
  192. package/registry/ui/toggle-button.json +17 -0
  193. package/registry/ui/toolbar.json +13 -0
  194. package/registry/ui/tooltip.json +16 -0
  195. package/registry/ui/tree.json +18 -0
  196. package/registry/ui/typeset.json +16 -0
  197. package/registry/ui/youtube-embed.json +16 -0
  198. package/stubs/command.stub +16 -0
  199. package/stubs/command.test.stub +21 -0
  200. package/stubs/controller.api.stub +21 -0
  201. package/stubs/controller.api.test.stub +18 -0
  202. package/stubs/controller.form.stub +63 -0
  203. package/stubs/controller.form.test.stub +61 -0
  204. package/stubs/controller.stub +24 -0
  205. package/stubs/controller.test.stub +18 -0
  206. package/stubs/email.stub +26 -0
  207. package/stubs/email.test.stub +21 -0
  208. package/stubs/factory.stub +13 -0
  209. package/stubs/initializer.stub +9 -0
  210. package/stubs/initializer.test.stub +16 -0
  211. package/stubs/job.cron.stub +16 -0
  212. package/stubs/job.stub +15 -0
  213. package/stubs/job.test.stub +18 -0
  214. package/stubs/mcp.resource.stub +15 -0
  215. package/stubs/mcp.stub +13 -0
  216. package/stubs/mcp.test.stub +18 -0
  217. package/stubs/middleware.stub +16 -0
  218. package/stubs/middleware.test.stub +16 -0
  219. package/stubs/migration.stub +1 -0
  220. package/stubs/model.stub +33 -0
  221. package/stubs/model.test.stub +18 -0
  222. package/stubs/policy.stub +16 -0
  223. package/stubs/policy.test.stub +20 -0
  224. package/stubs/service.stub +17 -0
  225. package/stubs/service.test.stub +17 -0
  226. package/stubs/validator.stub +17 -0
  227. package/stubs/validator.test.stub +25 -0
  228. package/templates/app/.env.example +16 -0
  229. package/templates/app/README.md +84 -0
  230. package/templates/app/app/commands/about.test.ts +29 -0
  231. package/templates/app/app/commands/about.ts +34 -0
  232. package/templates/app/app/commands/db/console.ts +6 -0
  233. package/templates/app/app/commands/db/migrate.test.ts +30 -0
  234. package/templates/app/app/commands/db/migrate.ts +55 -0
  235. package/templates/app/app/commands/index.ts +31 -0
  236. package/templates/app/app/commands/typegen.test.ts +17 -0
  237. package/templates/app/app/commands/typegen.ts +16 -0
  238. package/templates/app/app/http/controllers/api/health.tsx +15 -0
  239. package/templates/app/app/http/controllers/api/not-found.tsx +16 -0
  240. package/templates/app/app/http/controllers/api/openapi.tsx +17 -0
  241. package/templates/app/app/http/controllers/home.tsx +30 -0
  242. package/templates/app/app/http/controllers/mcp.tsx +16 -0
  243. package/templates/app/app/http/controllers/not-found.tsx +30 -0
  244. package/templates/app/app/http/controllers/robots.test.ts +18 -0
  245. package/templates/app/app/http/controllers/robots.ts +24 -0
  246. package/templates/app/app/http/controllers/sitemap.test.ts +28 -0
  247. package/templates/app/app/http/controllers/sitemap.ts +25 -0
  248. package/templates/app/app/http/middleware/api.ts +10 -0
  249. package/templates/app/app/http/middleware/page.test.ts +40 -0
  250. package/templates/app/app/http/middleware/page.ts +49 -0
  251. package/templates/app/app/http/middleware/server-timing.test.ts +15 -0
  252. package/templates/app/app/http/middleware/server-timing.ts +42 -0
  253. package/templates/app/app/initializers/assets.ts +11 -0
  254. package/templates/app/app/initializers/captcha.ts +11 -0
  255. package/templates/app/app/initializers/cli.ts +75 -0
  256. package/templates/app/app/initializers/database.test.ts +18 -0
  257. package/templates/app/app/initializers/database.ts +18 -0
  258. package/templates/app/app/initializers/dispatcher.ts +36 -0
  259. package/templates/app/app/initializers/honeypot.ts +11 -0
  260. package/templates/app/app/initializers/i18n.test.ts +16 -0
  261. package/templates/app/app/initializers/i18n.ts +28 -0
  262. package/templates/app/app/initializers/local-database.test.ts +33 -0
  263. package/templates/app/app/initializers/local-database.ts +53 -0
  264. package/templates/app/app/initializers/logger.ts +10 -0
  265. package/templates/app/app/initializers/mail.test.ts +27 -0
  266. package/templates/app/app/initializers/mail.ts +11 -0
  267. package/templates/app/app/initializers/mcp.ts +16 -0
  268. package/templates/app/app/initializers/openapi.ts +21 -0
  269. package/templates/app/app/initializers/router.test.ts +61 -0
  270. package/templates/app/app/initializers/router.tsx +111 -0
  271. package/templates/app/app/initializers/seo.ts +15 -0
  272. package/templates/app/app/initializers/session.test.ts +34 -0
  273. package/templates/app/app/initializers/session.ts +29 -0
  274. package/templates/app/app/initializers/spam.ts +10 -0
  275. package/templates/app/app/jobs/index.ts +10 -0
  276. package/templates/app/app/mcp/resources/index.ts +9 -0
  277. package/templates/app/app/mcp/tools/index.ts +10 -0
  278. package/templates/app/app/models/index.ts +10 -0
  279. package/templates/app/app/services/migrations.test.ts +45 -0
  280. package/templates/app/app/services/migrations.ts +60 -0
  281. package/templates/app/app/test/cloudflare-workers.ts +25 -0
  282. package/templates/app/bootstrap/browser.ts +27 -0
  283. package/templates/app/bootstrap/cli.ts +9 -0
  284. package/templates/app/bootstrap/worker.ts +31 -0
  285. package/templates/app/cloudflare.config.ts +56 -0
  286. package/templates/app/config/constants.ts +19 -0
  287. package/templates/app/config/problems.ts +24 -0
  288. package/templates/app/config/security-policy.ts +34 -0
  289. package/templates/app/config/security-txt.ts +28 -0
  290. package/templates/app/database/migrations/.gitkeep +0 -0
  291. package/templates/app/gitignore +9 -0
  292. package/templates/app/package.json +68 -0
  293. package/templates/app/resources/layouts/document.tsx +79 -0
  294. package/templates/app/resources/locales/en.json +10 -0
  295. package/templates/app/routes/api.ts +29 -0
  296. package/templates/app/routes/web.ts +14 -0
  297. package/templates/app/tsconfig.json +40 -0
  298. package/templates/app/vite.config.ts +44 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * GitHub templates: any repository, folder and ref, downloaded as the tarball GitHub serves and
3
+ * extracted in memory through `remix/tar-parser`. Only regular files and directories under the
4
+ * requested folder are kept, every path is checked to stay inside the project, and links are
5
+ * skipped, so an archive can only ever write plain files where `create` puts the project.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import type { Result } from "@sdxc/result";
11
+ import type { TemplateSource, TemplateTree } from "./templates.js";
12
+ /** A GitHub repository, as `--template org/repo[/path][#ref]` names it. */
13
+ export type GitHubTemplate = Extract<TemplateSource, {
14
+ kind: "github";
15
+ }>;
16
+ /** What a download produced: the template's files and the commit they came from. */
17
+ export interface Extracted {
18
+ tree: TemplateTree;
19
+ /** The abbreviated commit GitHub archived, read from the archive's top-level folder. */
20
+ commit: string | null;
21
+ }
22
+ /**
23
+ * The extraction limits, set explicitly so a template's size is bounded by this module rather
24
+ * than by the parser's defaults. Sizes count decompressed bytes.
25
+ */
26
+ export declare const LIMITS: {
27
+ /** Bytes one file may hold. */
28
+ maxEntrySize: number;
29
+ /** Bytes the whole archive may hold, headers and padding included. */
30
+ maxTotalSize: number;
31
+ /** Entries the archive may hold, files and directories alike. */
32
+ maxEntries: number;
33
+ };
34
+ /** GitHub refused the download; `status` says why, so a caller can ask for a token and retry. */
35
+ export declare class GitHubRefusal extends Error {
36
+ name: string;
37
+ /** The HTTP status GitHub answered. */
38
+ status: number;
39
+ /**
40
+ * @param message - What went wrong, worded for what the user can do about it
41
+ * @param status - The HTTP status GitHub answered
42
+ */
43
+ constructor(message: string, status: number);
44
+ }
45
+ /**
46
+ * Downloads and extracts `template`. `GITHUB_TOKEN`, else `GH_TOKEN`, is sent as a bearer
47
+ * token when set, which private repositories and the higher rate limit need. A folder that
48
+ * holds nothing in the archive is a failure naming it.
49
+ *
50
+ * @param env - The variables the token is read from.
51
+ * @param signal - Stops the download, as Ctrl+C does.
52
+ */
53
+ export declare function downloadTemplate(template: GitHubTemplate, env: Readonly<Record<string, string | undefined>>, signal?: AbortSignal): Promise<Result<Extracted, Error>>;
54
+ /**
55
+ * Reads a GitHub tarball into a tree: the archive's top-level folder is dropped, only entries
56
+ * under `path` are kept (relative to it), and links and any other special entry are skipped.
57
+ * An exceeded limit is a failure naming it.
58
+ */
59
+ export declare function extract(archive: ReadableStream<Uint8Array>, path: string | null): Promise<Result<Extracted, Error>>;
60
+ /** The token `downloadTemplate` sends: `GITHUB_TOKEN`, else `GH_TOKEN`, when either is set. */
61
+ export declare function githubToken(env: Readonly<Record<string, string | undefined>>): string | undefined;
62
+ /** `org/repo`, with its folder and ref when given, as messages name a template. */
63
+ export declare function describe(template: GitHubTemplate): string;
@@ -0,0 +1,172 @@
1
+ /**
2
+ * GitHub templates: any repository, folder and ref, downloaded as the tarball GitHub serves and
3
+ * extracted in memory through `remix/tar-parser`. Only regular files and directories under the
4
+ * requested folder are kept, every path is checked to stay inside the project, and links are
5
+ * skipped, so an archive can only ever write plain files where `create` puts the project.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import { failure, isFailure, success, wrap } from "@sdxc/result";
11
+ import { MaxEntriesExceededError, MaxEntrySizeExceededError, MaxTotalSizeExceededError, parseTar, } from "remix/tar-parser";
12
+ /**
13
+ * The extraction limits, set explicitly so a template's size is bounded by this module rather
14
+ * than by the parser's defaults. Sizes count decompressed bytes.
15
+ */
16
+ export const LIMITS = {
17
+ /** Bytes one file may hold. */
18
+ maxEntrySize: 10 * 1024 * 1024,
19
+ /** Bytes the whole archive may hold, headers and padding included. */
20
+ maxTotalSize: 100 * 1024 * 1024,
21
+ /** Entries the archive may hold, files and directories alike. */
22
+ maxEntries: 10_000,
23
+ };
24
+ /** GitHub refused the download; `status` says why, so a caller can ask for a token and retry. */
25
+ export class GitHubRefusal extends Error {
26
+ name = "GitHubRefusal";
27
+ /** The HTTP status GitHub answered. */
28
+ status;
29
+ /**
30
+ * @param message - What went wrong, worded for what the user can do about it
31
+ * @param status - The HTTP status GitHub answered
32
+ */
33
+ constructor(message, status) {
34
+ super(message);
35
+ this.status = status;
36
+ }
37
+ }
38
+ /** The API host the tarball is requested from. */
39
+ const GITHUB_API = "https://api.github.com";
40
+ /**
41
+ * Downloads and extracts `template`. `GITHUB_TOKEN`, else `GH_TOKEN`, is sent as a bearer
42
+ * token when set, which private repositories and the higher rate limit need. A folder that
43
+ * holds nothing in the archive is a failure naming it.
44
+ *
45
+ * @param env - The variables the token is read from.
46
+ * @param signal - Stops the download, as Ctrl+C does.
47
+ */
48
+ export async function downloadTemplate(template, env, signal) {
49
+ let label = describe(template);
50
+ let response = await wrap(() => fetch(tarballURL(template), { headers: headers(githubToken(env)), signal }));
51
+ if (isFailure(response)) {
52
+ return failure(new Error(`Could not reach GitHub for ${label}: ${response.error.message}`));
53
+ }
54
+ if (!response.data.ok)
55
+ return failure(refusal(response.data, template, label));
56
+ let body = response.data.body;
57
+ if (body === null)
58
+ return failure(new Error(`GitHub sent an empty archive for ${label}`));
59
+ let extracted = await extract(body.pipeThrough(new DecompressionStream("gzip")), template.path);
60
+ if (isFailure(extracted)) {
61
+ return failure(new Error(`Could not extract ${label}: ${extracted.error.message}`));
62
+ }
63
+ let { tree } = extracted.data;
64
+ if (tree.files.size === 0 && tree.directories.size === 0) {
65
+ if (template.path === null)
66
+ return failure(new Error(`${label} is empty`));
67
+ let repository = describe({ ...template, path: null });
68
+ return failure(new Error(`${repository} has no folder ${template.path}, or it is empty`));
69
+ }
70
+ return extracted;
71
+ }
72
+ /**
73
+ * Reads a GitHub tarball into a tree: the archive's top-level folder is dropped, only entries
74
+ * under `path` are kept (relative to it), and links and any other special entry are skipped.
75
+ * An exceeded limit is a failure naming it.
76
+ */
77
+ export async function extract(archive, path) {
78
+ let tree = { files: new Map(), directories: new Set() };
79
+ let seen = { top: null };
80
+ let prefix = path === null ? "" : `${path}/`;
81
+ let parsed = await wrap(() => parseTar(archive, LIMITS, async (entry) => {
82
+ let [root = "", ...rest] = entry.name.split("/");
83
+ seen.top ??= root;
84
+ let relative = rest.filter((segment) => segment !== "" && segment !== ".").join("/");
85
+ if (prefix !== "") {
86
+ if (!`${relative}/`.startsWith(prefix))
87
+ return;
88
+ relative = relative.slice(prefix.length);
89
+ }
90
+ if (relative === "")
91
+ return;
92
+ let unsafe = relative.split("/").some((segment) => segment === "..");
93
+ if (unsafe)
94
+ return;
95
+ if (entry.header.type === "file")
96
+ tree.files.set(relative, await entry.bytes());
97
+ else if (entry.header.type === "directory")
98
+ tree.directories.add(relative);
99
+ }));
100
+ if (isFailure(parsed))
101
+ return failure(limitError(parsed.error));
102
+ for (let file of tree.files.keys()) {
103
+ let parent = file.split("/");
104
+ while (parent.pop() !== undefined && parent.length > 0)
105
+ tree.directories.delete(parent.join("/"));
106
+ }
107
+ let commit = /-([0-9a-f]{7,40})$/.exec(seen.top ?? "")?.[1] ?? null;
108
+ return success({ tree, commit });
109
+ }
110
+ /** The token `downloadTemplate` sends: `GITHUB_TOKEN`, else `GH_TOKEN`, when either is set. */
111
+ export function githubToken(env) {
112
+ let token = env.GITHUB_TOKEN ?? env.GH_TOKEN;
113
+ return token === "" ? undefined : token;
114
+ }
115
+ /** `org/repo`, with its folder and ref when given, as messages name a template. */
116
+ export function describe(template) {
117
+ let path = template.path === null ? "" : `/${template.path}`;
118
+ let ref = template.ref === null ? "" : `#${template.ref}`;
119
+ return `${template.owner}/${template.repo}${path}${ref}`;
120
+ }
121
+ /** The tarball endpoint for the template's ref, or for the default branch without one. */
122
+ function tarballURL({ owner, repo, ref }) {
123
+ let base = `${GITHUB_API}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/tarball`;
124
+ if (ref === null)
125
+ return base;
126
+ return `${base}/${ref.split("/").map(encodeURIComponent).join("/")}`;
127
+ }
128
+ /** The request headers GitHub's API expects, with the token when there is one. */
129
+ function headers(token) {
130
+ let result = new Headers({
131
+ accept: "application/vnd.github+json",
132
+ "user-agent": "sdxc",
133
+ "x-github-api-version": "2022-11-28",
134
+ });
135
+ if (token !== undefined && token !== "")
136
+ result.set("authorization", `Bearer ${token}`);
137
+ return result;
138
+ }
139
+ /** Why GitHub refused the download, worded for what the user can do about it. */
140
+ function refusal(response, template, label) {
141
+ let tokenHint = "set GITHUB_TOKEN or GH_TOKEN";
142
+ if (response.status === 404) {
143
+ let ref = template.ref === null ? "" : ` or no ref ${template.ref}`;
144
+ return new GitHubRefusal(`GitHub has no repository ${template.owner}/${template.repo}${ref}; for a private repository, ${tokenHint}`, 404);
145
+ }
146
+ if (response.status === 401) {
147
+ return new GitHubRefusal(`GitHub rejected the token sent for ${label}; check GITHUB_TOKEN or GH_TOKEN`, 401);
148
+ }
149
+ let limited = response.status === 429 ||
150
+ (response.status === 403 && response.headers.get("x-ratelimit-remaining") === "0");
151
+ if (limited) {
152
+ return new GitHubRefusal(`GitHub's rate limit refused ${label}; wait for it to reset or ${tokenHint}`, response.status);
153
+ }
154
+ return new GitHubRefusal(`GitHub answered ${response.status} for ${label}`, response.status);
155
+ }
156
+ /** An extraction failure, naming the limit when one was exceeded. */
157
+ function limitError(error) {
158
+ if (error instanceof MaxEntrySizeExceededError) {
159
+ return new Error(`a file is larger than the ${mebibytes(LIMITS.maxEntrySize)} limit per file`);
160
+ }
161
+ if (error instanceof MaxTotalSizeExceededError) {
162
+ return new Error(`the archive is larger than the ${mebibytes(LIMITS.maxTotalSize)} limit`);
163
+ }
164
+ if (error instanceof MaxEntriesExceededError) {
165
+ return new Error(`the archive holds more than the ${LIMITS.maxEntries} entries allowed`);
166
+ }
167
+ return error;
168
+ }
169
+ /** `bytes` in whole mebibytes. */
170
+ function mebibytes(bytes) {
171
+ return `${bytes / 1024 / 1024} MiB`;
172
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Where `sdxc create` writes a project: a directory that is missing or holds nothing but a
3
+ * `.git` folder, so `git init && sdxc create` works and an existing project is never written
4
+ * over. The project takes its `package.json` name from the directory's last path segment.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { Result } from "@sdxc/result";
10
+ /** The directory a project is created in, as the command found it. */
11
+ export interface Target {
12
+ /** Absolute path. */
13
+ directory: string;
14
+ /** The project's `package.json` name, derived from the directory's last segment. */
15
+ name: string;
16
+ /** `false` when the directory does not exist yet, so `create` makes it. */
17
+ exists: boolean;
18
+ /** Whether the directory already holds a `.git` folder. */
19
+ hasGit: boolean;
20
+ }
21
+ /**
22
+ * Resolves `directory` against `cwd` (the current directory when omitted) and checks it can
23
+ * take a project. A file, or a directory holding anything besides `.git`, is a failure that
24
+ * names the first entries in the way.
25
+ */
26
+ export declare function resolveTarget(cwd: string, directory: string | undefined): Promise<Result<Target, Error>>;
27
+ /**
28
+ * A directory name as an npm package name: lower case, with each run of characters npm
29
+ * refuses collapsed to one `-`, and `app` when nothing usable is left.
30
+ */
31
+ export declare function packageName(segment: string): string;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Where `sdxc create` writes a project: a directory that is missing or holds nothing but a
3
+ * `.git` folder, so `git init && sdxc create` works and an existing project is never written
4
+ * over. The project takes its `package.json` name from the directory's last path segment.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { readdir, stat } from "node:fs/promises";
10
+ import { basename, resolve } from "node:path";
11
+ import { failure, isFailure, success, wrap } from "@sdxc/result";
12
+ /**
13
+ * Resolves `directory` against `cwd` (the current directory when omitted) and checks it can
14
+ * take a project. A file, or a directory holding anything besides `.git`, is a failure that
15
+ * names the first entries in the way.
16
+ */
17
+ export async function resolveTarget(cwd, directory) {
18
+ let absolute = resolve(cwd, directory ?? ".");
19
+ let name = packageName(basename(absolute));
20
+ let info = await wrap(() => stat(absolute));
21
+ if (isFailure(info)) {
22
+ if (info.error.code === "ENOENT") {
23
+ return success({ directory: absolute, name, exists: false, hasGit: false });
24
+ }
25
+ return info;
26
+ }
27
+ if (!info.data.isDirectory()) {
28
+ return failure(new Error(`${absolute} is a file; sdxc create needs an empty directory`));
29
+ }
30
+ let entries = await wrap(() => readdir(absolute));
31
+ if (isFailure(entries))
32
+ return entries;
33
+ let others = entries.data.filter((entry) => entry !== ".git").sort();
34
+ if (others.length > 0) {
35
+ let shown = others.slice(0, 3).join(", ");
36
+ let more = others.length > 3 ? ` and ${others.length - 3} more` : "";
37
+ return failure(new Error(`${absolute} is not empty (${shown}${more}); sdxc create needs an empty directory`));
38
+ }
39
+ return success({
40
+ directory: absolute,
41
+ name,
42
+ exists: true,
43
+ hasGit: entries.data.includes(".git"),
44
+ });
45
+ }
46
+ /**
47
+ * A directory name as an npm package name: lower case, with each run of characters npm
48
+ * refuses collapsed to one `-`, and `app` when nothing usable is left.
49
+ */
50
+ export function packageName(segment) {
51
+ let name = segment
52
+ .toLowerCase()
53
+ .replace(/[^a-z0-9._~-]+/g, "-")
54
+ .replace(/^[._-]+|-+$/g, "");
55
+ return name === "" ? "app" : name;
56
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The templates `sdxc create` starts a project from: a name without a slash is a template
3
+ * shipped in the `@sdxc/kit` package, and `org/repo[/path][#ref]` is a GitHub repository. Either
4
+ * way the template becomes an in-memory file tree, completed for the new project, then written.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { Result } from "@sdxc/result";
10
+ /** The template `create` uses without `--template`. */
11
+ export declare const DEFAULT_TEMPLATE = "app";
12
+ /**
13
+ * The built-in templates `sdxc create` offers to pick from on a terminal, in the order it lists
14
+ * them; a test keeps it equal to the package's `templates/` folder.
15
+ */
16
+ export declare const BUILTIN_TEMPLATES: readonly string[];
17
+ /** Where a template comes from, as `--template` spells it. */
18
+ export type TemplateSource = {
19
+ kind: "builtin";
20
+ name: string;
21
+ } | {
22
+ kind: "github";
23
+ owner: string;
24
+ repo: string;
25
+ path: string | null;
26
+ ref: string | null;
27
+ };
28
+ /**
29
+ * A template's files and directories by project-relative POSIX path. Directories are listed
30
+ * only when a template carries one with nothing in it.
31
+ */
32
+ export interface TemplateTree {
33
+ files: Map<string, Uint8Array>;
34
+ directories: Set<string>;
35
+ }
36
+ /** The directory of the installed `@sdxc/kit` package, which holds `templates/` and `package.json`. */
37
+ export declare function defaultPackageRoot(): string;
38
+ /**
39
+ * Reads `--template`. A `host:` prefix is reserved for hosts besides GitHub and refused; a
40
+ * GitHub path may not climb with `..` or hold empty segments.
41
+ */
42
+ export declare function parseTemplate(spec: string): Result<TemplateSource, Error>;
43
+ /** The built-in template names shipped in the package at `packageRoot`, sorted. */
44
+ export declare function builtinTemplates(packageRoot: string): Promise<Result<string[], Error>>;
45
+ /**
46
+ * Reads the built-in template `name` into a tree. An unknown name is a failure listing the
47
+ * templates the package ships.
48
+ */
49
+ export declare function readBuiltinTemplate(packageRoot: string, name: string): Promise<Result<TemplateTree, Error>>;
50
+ /**
51
+ * Completes a built-in template for the project `name`: names it, pins every `@sdxc/*` package it
52
+ * lists to the version npm calls `latest` and `remix` to the peer the kit declares, and writes
53
+ * `.config/sdxc.jsonc` as `sdxc init` renders it with the template's formatter, so a new
54
+ * configuration key reaches new projects. It copies `.env.example` to `.dev.vars`, so the
55
+ * development secrets it lists are in place for the project's first `bun dev`.
56
+ */
57
+ export declare function completeBuiltin(tree: TemplateTree, name: string, packageRoot: string, signal?: AbortSignal): Promise<Result<void, Error>>;
58
+ /**
59
+ * Adds `tags` to the module JSDoc of every TypeScript module in a built-in template, so the new
60
+ * project's files credit its author the way the files `sdxc make` writes do.
61
+ */
62
+ export declare function creditTemplate(tree: TemplateTree, tags: string): void;
63
+ /** Names the project in a template's `package.json`, when the template has one. */
64
+ export declare function nameProject(tree: TemplateTree, name: string): Result<void, Error>;
65
+ /**
66
+ * Writes `tree` under `directory`, creating it and every parent. Each path is checked to stay
67
+ * inside `directory` before anything is written, so a tree that would escape writes nothing.
68
+ */
69
+ export declare function writeTree(directory: string, tree: TemplateTree): Promise<Result<void, Error>>;
@@ -0,0 +1,251 @@
1
+ /**
2
+ * The templates `sdxc create` starts a project from: a name without a slash is a template
3
+ * shipped in the `@sdxc/kit` package, and `org/repo[/path][#ref]` is a GitHub repository. Either
4
+ * way the template becomes an in-memory file tree, completed for the new project, then written.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
10
+ import { dirname, join, posix } from "node:path";
11
+ import { fileURLToPath } from "node:url";
12
+ import { failure, isFailure, success, wrap } from "@sdxc/result";
13
+ import { addHeaderTags } from "../author.js";
14
+ import { renderConfig } from "../init.js";
15
+ import { resolveInside } from "../project.js";
16
+ import { resolveRelease, scopedPackageOf } from "../releases.js";
17
+ /** The template `create` uses without `--template`. */
18
+ export const DEFAULT_TEMPLATE = "app";
19
+ /**
20
+ * The built-in templates `sdxc create` offers to pick from on a terminal, in the order it lists
21
+ * them; a test keeps it equal to the package's `templates/` folder.
22
+ */
23
+ export const BUILTIN_TEMPLATES = ["app"];
24
+ /**
25
+ * Built-in template files stored under another name, because npm drops a `.gitignore` from a
26
+ * published tarball; each is written under the name it maps to.
27
+ */
28
+ const RENAMED_FILES = new Map([["gitignore", ".gitignore"]]);
29
+ /**
30
+ * The configuration every built-in template ships beyond `sdxc init`'s defaults: each one checks
31
+ * with Vite+, so the files `make` and `ui add` write are formatted as `vp check` expects.
32
+ */
33
+ const BUILTIN_CONFIG = { format: ["bunx", "vp", "fmt"] };
34
+ /** The directory of the installed `@sdxc/kit` package, which holds `templates/` and `package.json`. */
35
+ export function defaultPackageRoot() {
36
+ return fileURLToPath(new URL("../../", import.meta.url));
37
+ }
38
+ /**
39
+ * Reads `--template`. A `host:` prefix is reserved for hosts besides GitHub and refused; a
40
+ * GitHub path may not climb with `..` or hold empty segments.
41
+ */
42
+ export function parseTemplate(spec) {
43
+ let host = /^([A-Za-z][\w.-]*):/.exec(spec);
44
+ if (host !== null) {
45
+ return failure(new Error(`Template host "${host[1]}:" is not supported; name a GitHub repository as org/repo`));
46
+ }
47
+ if (!spec.includes("/")) {
48
+ if (!/^[a-z0-9][a-z0-9-]*$/.test(spec)) {
49
+ return failure(new Error(`"${spec}" is not a template name`));
50
+ }
51
+ return success({ kind: "builtin", name: spec });
52
+ }
53
+ let hash = spec.indexOf("#");
54
+ let location = hash === -1 ? spec : spec.slice(0, hash);
55
+ let ref = hash === -1 ? null : spec.slice(hash + 1);
56
+ if (ref === "")
57
+ return failure(new Error(`${spec} names an empty ref after #`));
58
+ let segments = location.split("/");
59
+ let [owner, repo, ...rest] = segments;
60
+ let invalid = segments.some((segment) => segment === "" || segment === "." || segment === "..");
61
+ if (owner === undefined || repo === undefined || invalid) {
62
+ return failure(new Error(`${spec} is not a template; write org/repo[/path][#ref]`));
63
+ }
64
+ return success({
65
+ kind: "github",
66
+ owner,
67
+ repo,
68
+ path: rest.length === 0 ? null : rest.join("/"),
69
+ ref,
70
+ });
71
+ }
72
+ /** The built-in template names shipped in the package at `packageRoot`, sorted. */
73
+ export async function builtinTemplates(packageRoot) {
74
+ let entries = await wrap(() => readdir(join(packageRoot, "templates"), { withFileTypes: true }));
75
+ if (isFailure(entries))
76
+ return entries;
77
+ return success(entries.data
78
+ .filter((entry) => entry.isDirectory())
79
+ .map((entry) => entry.name)
80
+ .sort());
81
+ }
82
+ /**
83
+ * Reads the built-in template `name` into a tree. An unknown name is a failure listing the
84
+ * templates the package ships.
85
+ */
86
+ export async function readBuiltinTemplate(packageRoot, name) {
87
+ let available = await builtinTemplates(packageRoot);
88
+ if (isFailure(available))
89
+ return available;
90
+ if (!available.data.includes(name)) {
91
+ return failure(new Error(`No built-in template "${name}"; choose one of: ${available.data.join(", ")}`));
92
+ }
93
+ let root = join(packageRoot, "templates", name);
94
+ let tree = { files: new Map(), directories: new Set() };
95
+ let read = await wrap(() => readInto(root, "", tree));
96
+ if (isFailure(read))
97
+ return read;
98
+ return success(tree);
99
+ }
100
+ /** Adds every file under `directory` to `tree`, keyed by its path relative to the template. */
101
+ async function readInto(directory, prefix, tree) {
102
+ for (let entry of await readdir(directory, { withFileTypes: true })) {
103
+ let path = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
104
+ let source = join(directory, entry.name);
105
+ if (entry.isDirectory()) {
106
+ await readInto(source, path, tree);
107
+ }
108
+ else if (entry.isFile()) {
109
+ let renamed = prefix === "" ? (RENAMED_FILES.get(entry.name) ?? path) : path;
110
+ tree.files.set(renamed, new Uint8Array(await readFile(source)));
111
+ }
112
+ }
113
+ }
114
+ /**
115
+ * Completes a built-in template for the project `name`: names it, pins every `@sdxc/*` package it
116
+ * lists to the version npm calls `latest` and `remix` to the peer the kit declares, and writes
117
+ * `.config/sdxc.jsonc` as `sdxc init` renders it with the template's formatter, so a new
118
+ * configuration key reaches new projects. It copies `.env.example` to `.dev.vars`, so the
119
+ * development secrets it lists are in place for the project's first `bun dev`.
120
+ */
121
+ export async function completeBuiltin(tree, name, packageRoot, signal) {
122
+ let text = await wrap(() => readFile(join(packageRoot, "package.json"), "utf8"));
123
+ if (isFailure(text))
124
+ return text;
125
+ let own = wrap(() => JSON.parse(text.data));
126
+ if (isFailure(own))
127
+ return own;
128
+ let remix = own.data.peerDependencies?.remix;
129
+ let listed = treeDependencies(tree);
130
+ if (isFailure(listed))
131
+ return listed;
132
+ let pins = await resolveRelease(listed.data.filter((dependency) => scopedPackageOf(dependency) === dependency), null, signal);
133
+ if (isFailure(pins))
134
+ return pins;
135
+ let renamed = editManifest(tree, (manifest) => {
136
+ manifest.name = name;
137
+ for (let field of ["dependencies", "devDependencies"]) {
138
+ let section = record(manifest[field]);
139
+ for (let dependency of Object.keys(section)) {
140
+ let pin = pins.data.get(dependency);
141
+ if (pin !== undefined)
142
+ section[dependency] = pin;
143
+ }
144
+ if (field === "dependencies" && remix !== undefined)
145
+ section.remix = remix;
146
+ if (Object.keys(section).length > 0)
147
+ manifest[field] = section;
148
+ }
149
+ });
150
+ if (isFailure(renamed))
151
+ return renamed;
152
+ let example = tree.files.get(".env.example");
153
+ if (example !== undefined && !tree.files.has(".dev.vars"))
154
+ tree.files.set(".dev.vars", example);
155
+ if (!tree.files.has(".config/sdxc.jsonc")) {
156
+ let config = renderConfig(BUILTIN_CONFIG);
157
+ if (isFailure(config))
158
+ return config;
159
+ tree.files.set(".config/sdxc.jsonc", new TextEncoder().encode(config.data));
160
+ }
161
+ return success(undefined);
162
+ }
163
+ /**
164
+ * Adds `tags` to the module JSDoc of every TypeScript module in a built-in template, so the new
165
+ * project's files credit its author the way the files `sdxc make` writes do.
166
+ */
167
+ export function creditTemplate(tree, tags) {
168
+ for (let [path, bytes] of tree.files) {
169
+ if (!/\.tsx?$/.test(path))
170
+ continue;
171
+ let source = new TextDecoder().decode(bytes);
172
+ tree.files.set(path, new TextEncoder().encode(addHeaderTags(source, tags)));
173
+ }
174
+ }
175
+ /** Every package the tree's `package.json` lists under `dependencies` or `devDependencies`. */
176
+ function treeDependencies(tree) {
177
+ let bytes = tree.files.get("package.json");
178
+ if (bytes === undefined)
179
+ return success([]);
180
+ let parsed = wrap(() => JSON.parse(new TextDecoder().decode(bytes)));
181
+ if (isFailure(parsed)) {
182
+ return failure(new Error(`The template's package.json is not JSON: ${parsed.error.message}`));
183
+ }
184
+ return success([
185
+ ...Object.keys(record(parsed.data.dependencies)),
186
+ ...Object.keys(record(parsed.data.devDependencies)),
187
+ ]);
188
+ }
189
+ /** Names the project in a template's `package.json`, when the template has one. */
190
+ export function nameProject(tree, name) {
191
+ return editManifest(tree, (manifest) => {
192
+ manifest.name = name;
193
+ });
194
+ }
195
+ /**
196
+ * Applies `edit` to the tree's `package.json`, keeping its indentation and moving `name` to
197
+ * the top when the template had none. A tree without one is left as it is.
198
+ */
199
+ function editManifest(tree, edit) {
200
+ let bytes = tree.files.get("package.json");
201
+ if (bytes === undefined)
202
+ return success(undefined);
203
+ let text = new TextDecoder().decode(bytes);
204
+ let parsed = wrap(() => JSON.parse(text));
205
+ if (isFailure(parsed)) {
206
+ return failure(new Error(`The template's package.json is not JSON: ${parsed.error.message}`));
207
+ }
208
+ if (typeof parsed.data !== "object" || parsed.data === null || Array.isArray(parsed.data)) {
209
+ return failure(new Error("The template's package.json is not an object"));
210
+ }
211
+ let manifest = { name: undefined, ...parsed.data };
212
+ edit(manifest);
213
+ let indent = /^[ \t]+/m.exec(text)?.[0] ?? "\t";
214
+ tree.files.set("package.json", new TextEncoder().encode(`${JSON.stringify(manifest, null, indent)}\n`));
215
+ return success(undefined);
216
+ }
217
+ /** `value` as a string record, or a fresh one when it is missing or another shape. */
218
+ function record(value) {
219
+ if (typeof value !== "object" || value === null || Array.isArray(value))
220
+ return {};
221
+ return value;
222
+ }
223
+ /**
224
+ * Writes `tree` under `directory`, creating it and every parent. Each path is checked to stay
225
+ * inside `directory` before anything is written, so a tree that would escape writes nothing.
226
+ */
227
+ export async function writeTree(directory, tree) {
228
+ let targets = [];
229
+ for (let path of tree.directories)
230
+ targets.push([path, null]);
231
+ for (let [path, bytes] of tree.files)
232
+ targets.push([path, bytes]);
233
+ let resolved = [];
234
+ for (let [path, bytes] of targets) {
235
+ let inside = resolveInside(directory, posix.normalize(path));
236
+ if (isFailure(inside))
237
+ return inside;
238
+ resolved.push([inside.data, bytes]);
239
+ }
240
+ return wrap(async () => {
241
+ await mkdir(directory, { recursive: true });
242
+ for (let [path, bytes] of resolved) {
243
+ if (bytes === null) {
244
+ await mkdir(path, { recursive: true });
245
+ continue;
246
+ }
247
+ await mkdir(dirname(path), { recursive: true });
248
+ await writeFile(path, bytes, { flag: "wx" });
249
+ }
250
+ });
251
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Keeps a project's `package.json` listing every `@sdxc/*` package its generated code imports:
3
+ * a package missing from it is added at the project's own release, so code `sdxc make` writes
4
+ * installs beside packages of the same day and never pulls a newer one in on its own.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { Result } from "@sdxc/result";
10
+ /** A file's path relative to the project root and its whole content. */
11
+ export interface SourceText {
12
+ path: string;
13
+ content: string;
14
+ }
15
+ /** The `package.json` edit that lists the missing packages, and what it added. */
16
+ export interface DependencyEdit {
17
+ path: "package.json";
18
+ before: string;
19
+ after: string;
20
+ /** Each added package with its exact version, sorted by name. */
21
+ added: Array<{
22
+ name: string;
23
+ version: string;
24
+ }>;
25
+ }
26
+ /** Every `@sdxc/*` package `files` import, statically or dynamically, sorted. */
27
+ export declare function importedPackages(files: readonly SourceText[]): string[];
28
+ /**
29
+ * The edit adding to the project at `root` every `@sdxc/*` package `files` import that its
30
+ * `package.json` does not list, each at its newest version on or before the project's release,
31
+ * the newest date among its `@sdxc/*` pins, or at `latest` when it pins none. `null` when
32
+ * nothing is missing.
33
+ */
34
+ export declare function missingDependencies(root: string, files: readonly SourceText[], signal?: AbortSignal): Promise<Result<DependencyEdit | null, Error>>;