@devdogsuga/devtools 0.1.25 → 0.1.27

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 (271) hide show
  1. package/README.md +72 -11
  2. package/bin/devtools.mjs +4 -4
  3. package/dist/cli-CZKkNHK5.js +6619 -0
  4. package/dist/failure-log-BBPGejQv.js +256 -0
  5. package/dist/launch.js +267 -281
  6. package/dist/local-env-D8HC2JK_.js +351 -0
  7. package/dist/local-env-DrBCXqD8.js +2 -0
  8. package/dist/menu-CQBsQRgH.js +1684 -0
  9. package/dist/peer-redirect-hooks.js +15 -0
  10. package/dist/peers-RBplwovA.js +229 -0
  11. package/dist/root-C2OmZDwD.js +94 -0
  12. package/dist/stack-Bx-55oi_.js +2 -0
  13. package/dist/stack-BynCgRVS.js +181 -0
  14. package/dist/supabase-project-0knM0mqd.js +426 -0
  15. package/dist/telemetry-C4foD8MD.js +249 -0
  16. package/dist/telemetry.js +2 -148
  17. package/package.json +10 -29
  18. package/bin/devtools-ci-bare.mjs +0 -48
  19. package/bin/devtools-ci.mjs +0 -31
  20. package/dist/args.d.ts +0 -26
  21. package/dist/args.js +0 -78
  22. package/dist/bws/bw.d.ts +0 -18
  23. package/dist/bws/bw.js +0 -70
  24. package/dist/bws/client.d.ts +0 -43
  25. package/dist/bws/client.js +0 -363
  26. package/dist/bws/environments.d.ts +0 -96
  27. package/dist/bws/environments.js +0 -111
  28. package/dist/bws/pace.d.ts +0 -25
  29. package/dist/bws/pace.js +0 -43
  30. package/dist/bws/retry.d.ts +0 -12
  31. package/dist/bws/retry.js +0 -39
  32. package/dist/bws/store.d.ts +0 -1
  33. package/dist/bws/store.js +0 -32
  34. package/dist/bws/token.d.ts +0 -31
  35. package/dist/bws/token.js +0 -88
  36. package/dist/bws/vault.d.ts +0 -29
  37. package/dist/bws/vault.js +0 -200
  38. package/dist/catalog.d.ts +0 -57
  39. package/dist/catalog.js +0 -57
  40. package/dist/cf/build.d.ts +0 -13
  41. package/dist/cf/build.js +0 -65
  42. package/dist/cf/commands.d.ts +0 -1
  43. package/dist/cf/commands.js +0 -172
  44. package/dist/cf/local-env.d.ts +0 -58
  45. package/dist/cf/local-env.js +0 -177
  46. package/dist/ci.d.ts +0 -1
  47. package/dist/ci.js +0 -328
  48. package/dist/cli.d.ts +0 -11
  49. package/dist/cli.js +0 -1094
  50. package/dist/commands.d.ts +0 -261
  51. package/dist/commands.js +0 -1318
  52. package/dist/completions.d.ts +0 -4
  53. package/dist/completions.js +0 -110
  54. package/dist/cron/commands.d.ts +0 -47
  55. package/dist/cron/commands.js +0 -372
  56. package/dist/cron/discovery.d.ts +0 -55
  57. package/dist/cron/discovery.js +0 -85
  58. package/dist/cron/schema.d.ts +0 -45
  59. package/dist/cron/schema.js +0 -35
  60. package/dist/db/config-push.d.ts +0 -8
  61. package/dist/db/config-push.js +0 -11
  62. package/dist/db/connection.d.ts +0 -79
  63. package/dist/db/connection.js +0 -114
  64. package/dist/db/exec.d.ts +0 -1
  65. package/dist/db/exec.js +0 -11
  66. package/dist/db/generate-types.d.ts +0 -1
  67. package/dist/db/generate-types.js +0 -4
  68. package/dist/db/generated-env.d.ts +0 -69
  69. package/dist/db/generated-env.js +0 -113
  70. package/dist/db/introspect.d.ts +0 -1
  71. package/dist/db/introspect.js +0 -122
  72. package/dist/db/local-env.d.ts +0 -65
  73. package/dist/db/local-env.js +0 -23
  74. package/dist/db/new-migration.d.ts +0 -8
  75. package/dist/db/new-migration.js +0 -69
  76. package/dist/db/pooler.d.ts +0 -23
  77. package/dist/db/pooler.js +0 -55
  78. package/dist/db/run.d.ts +0 -68
  79. package/dist/db/run.js +0 -156
  80. package/dist/db/seed-buckets.d.ts +0 -2
  81. package/dist/db/seed-buckets.js +0 -4
  82. package/dist/db/seed-production.d.ts +0 -8
  83. package/dist/db/seed-production.js +0 -79
  84. package/dist/db/seed-roles.d.ts +0 -7
  85. package/dist/db/seed-roles.js +0 -33
  86. package/dist/db/session-refresh.d.ts +0 -43
  87. package/dist/db/session-refresh.js +0 -40
  88. package/dist/deploy/migrations.d.ts +0 -20
  89. package/dist/deploy/migrations.js +0 -68
  90. package/dist/deploy/orphans.d.ts +0 -20
  91. package/dist/deploy/orphans.js +0 -177
  92. package/dist/deploy/preflight.d.ts +0 -53
  93. package/dist/deploy/preflight.js +0 -189
  94. package/dist/deploy/report.d.ts +0 -26
  95. package/dist/deploy/report.js +0 -70
  96. package/dist/deploy/require-planner.d.ts +0 -2
  97. package/dist/deploy/require-planner.js +0 -60
  98. package/dist/deploy/require-token.d.ts +0 -15
  99. package/dist/deploy/require-token.js +0 -78
  100. package/dist/deploy/secrets-file.d.ts +0 -17
  101. package/dist/deploy/secrets-file.js +0 -166
  102. package/dist/deploy/write-env.d.ts +0 -40
  103. package/dist/deploy/write-env.js +0 -395
  104. package/dist/docs/index-pages.d.ts +0 -38
  105. package/dist/docs/index-pages.js +0 -186
  106. package/dist/emails/commands.d.ts +0 -15
  107. package/dist/emails/commands.js +0 -130
  108. package/dist/emails/email-types.d.ts +0 -13
  109. package/dist/emails/email-types.js +0 -1
  110. package/dist/emails/fixtures.d.ts +0 -20
  111. package/dist/emails/fixtures.js +0 -20
  112. package/dist/env/audit.d.ts +0 -206
  113. package/dist/env/audit.js +0 -436
  114. package/dist/env/cloudflare.d.ts +0 -21
  115. package/dist/env/cloudflare.js +0 -61
  116. package/dist/env/commands.d.ts +0 -99
  117. package/dist/env/commands.js +0 -613
  118. package/dist/env/discovery.d.ts +0 -15
  119. package/dist/env/discovery.js +0 -239
  120. package/dist/env/document.d.ts +0 -119
  121. package/dist/env/document.js +0 -323
  122. package/dist/env/example.d.ts +0 -68
  123. package/dist/env/example.js +0 -605
  124. package/dist/env/selection.d.ts +0 -105
  125. package/dist/env/selection.js +0 -228
  126. package/dist/env-entry.d.ts +0 -49
  127. package/dist/env-entry.js +0 -204
  128. package/dist/environment-doctor.d.ts +0 -45
  129. package/dist/environment-doctor.js +0 -429
  130. package/dist/environment.d.ts +0 -92
  131. package/dist/environment.js +0 -185
  132. package/dist/fingerprint.d.ts +0 -10
  133. package/dist/fingerprint.js +0 -18
  134. package/dist/gen/campus-map.d.ts +0 -1
  135. package/dist/gen/campus-map.js +0 -473
  136. package/dist/gen/commands.d.ts +0 -1
  137. package/dist/gen/commands.js +0 -25
  138. package/dist/gen/hypno.d.ts +0 -1
  139. package/dist/gen/hypno.js +0 -134
  140. package/dist/gh/client.d.ts +0 -80
  141. package/dist/gh/client.js +0 -259
  142. package/dist/gh/environments.d.ts +0 -83
  143. package/dist/gh/environments.js +0 -178
  144. package/dist/gh/rulesets/actors.d.ts +0 -14
  145. package/dist/gh/rulesets/actors.js +0 -69
  146. package/dist/gh/rulesets/api.d.ts +0 -15
  147. package/dist/gh/rulesets/api.js +0 -104
  148. package/dist/gh/rulesets/commands.d.ts +0 -3
  149. package/dist/gh/rulesets/commands.js +0 -203
  150. package/dist/gh/rulesets/desired.d.ts +0 -112
  151. package/dist/gh/rulesets/desired.js +0 -271
  152. package/dist/gh/rulesets/diff.d.ts +0 -65
  153. package/dist/gh/rulesets/diff.js +0 -170
  154. package/dist/gh/rulesets/types.d.ts +0 -76
  155. package/dist/gh/rulesets/types.js +0 -13
  156. package/dist/gh/settings/api.d.ts +0 -40
  157. package/dist/gh/settings/api.js +0 -180
  158. package/dist/gh/settings/commands.d.ts +0 -1
  159. package/dist/gh/settings/commands.js +0 -254
  160. package/dist/gh/settings/desired.d.ts +0 -53
  161. package/dist/gh/settings/desired.js +0 -43
  162. package/dist/gh/settings/diff.d.ts +0 -57
  163. package/dist/gh/settings/diff.js +0 -161
  164. package/dist/gh/settings/types.d.ts +0 -92
  165. package/dist/gh/settings/types.js +0 -11
  166. package/dist/gh/settings/workflows.d.ts +0 -41
  167. package/dist/gh/settings/workflows.js +0 -128
  168. package/dist/grantRoot.d.ts +0 -42
  169. package/dist/grantRoot.js +0 -89
  170. package/dist/help.d.ts +0 -18
  171. package/dist/help.js +0 -169
  172. package/dist/images/commands.d.ts +0 -32
  173. package/dist/images/commands.js +0 -231
  174. package/dist/images/events.d.ts +0 -47
  175. package/dist/images/events.js +0 -116
  176. package/dist/images/graphics.d.ts +0 -70
  177. package/dist/images/graphics.js +0 -234
  178. package/dist/images/open-graph-types.d.ts +0 -75
  179. package/dist/images/open-graph-types.js +0 -1
  180. package/dist/images/prompts.d.ts +0 -34
  181. package/dist/images/prompts.js +0 -100
  182. package/dist/images/render.d.ts +0 -21
  183. package/dist/images/render.js +0 -61
  184. package/dist/images/select.d.ts +0 -64
  185. package/dist/images/select.js +0 -96
  186. package/dist/instance.d.ts +0 -69
  187. package/dist/instance.js +0 -102
  188. package/dist/invocation.d.ts +0 -49
  189. package/dist/invocation.js +0 -78
  190. package/dist/launch-ci.d.ts +0 -1
  191. package/dist/launch-ci.js +0 -90
  192. package/dist/launch.d.ts +0 -18
  193. package/dist/menu.d.ts +0 -43
  194. package/dist/menu.js +0 -300
  195. package/dist/moderation.d.ts +0 -70
  196. package/dist/moderation.js +0 -128
  197. package/dist/oauth/browser.d.ts +0 -1
  198. package/dist/oauth/browser.js +0 -13
  199. package/dist/oauth/config.d.ts +0 -24
  200. package/dist/oauth/config.js +0 -24
  201. package/dist/oauth/connect-url.d.ts +0 -17
  202. package/dist/oauth/connect-url.js +0 -23
  203. package/dist/oauth/db.d.ts +0 -37
  204. package/dist/oauth/db.js +0 -108
  205. package/dist/oauth/device.d.ts +0 -93
  206. package/dist/oauth/device.js +0 -198
  207. package/dist/oauth/discovery.d.ts +0 -28
  208. package/dist/oauth/discovery.js +0 -54
  209. package/dist/oauth/env-file.d.ts +0 -6
  210. package/dist/oauth/env-file.js +0 -35
  211. package/dist/oauth/exchange.d.ts +0 -43
  212. package/dist/oauth/exchange.js +0 -93
  213. package/dist/oauth/label.d.ts +0 -1
  214. package/dist/oauth/label.js +0 -25
  215. package/dist/oauth/loopback.d.ts +0 -52
  216. package/dist/oauth/loopback.js +0 -168
  217. package/dist/oauth/pkce.d.ts +0 -6
  218. package/dist/oauth/pkce.js +0 -34
  219. package/dist/oauth/target.d.ts +0 -54
  220. package/dist/oauth/target.js +0 -102
  221. package/dist/oauth/transport.d.ts +0 -41
  222. package/dist/oauth/transport.js +0 -32
  223. package/dist/oauth/wizard.d.ts +0 -40
  224. package/dist/oauth/wizard.js +0 -578
  225. package/dist/persona.d.ts +0 -18
  226. package/dist/persona.js +0 -221
  227. package/dist/pick.d.ts +0 -6
  228. package/dist/pick.js +0 -64
  229. package/dist/pipes.d.ts +0 -1
  230. package/dist/pipes.js +0 -25
  231. package/dist/planner/checks.d.ts +0 -26
  232. package/dist/planner/checks.js +0 -104
  233. package/dist/planner/commands.d.ts +0 -10
  234. package/dist/planner/commands.js +0 -367
  235. package/dist/planner/db.d.ts +0 -15
  236. package/dist/planner/db.js +0 -33
  237. package/dist/planner/role.d.ts +0 -33
  238. package/dist/planner/role.js +0 -68
  239. package/dist/repo/peer-redirect-hooks.d.ts +0 -16
  240. package/dist/repo/peer-redirect-hooks.js +0 -10
  241. package/dist/repo/peer-redirect.d.ts +0 -4
  242. package/dist/repo/peer-redirect.js +0 -26
  243. package/dist/repo/peers.d.ts +0 -39
  244. package/dist/repo/peers.js +0 -139
  245. package/dist/repo/resolve.d.ts +0 -41
  246. package/dist/repo/resolve.js +0 -152
  247. package/dist/repo/root.d.ts +0 -23
  248. package/dist/repo/root.js +0 -91
  249. package/dist/repo/source.d.ts +0 -14
  250. package/dist/repo/source.js +0 -54
  251. package/dist/repo/supabase-project.d.ts +0 -60
  252. package/dist/repo/supabase-project.js +0 -124
  253. package/dist/repo/tsx-loader.d.ts +0 -6
  254. package/dist/repo/tsx-loader.js +0 -41
  255. package/dist/run/pick.d.ts +0 -90
  256. package/dist/run/pick.js +0 -664
  257. package/dist/setup.d.ts +0 -1
  258. package/dist/setup.js +0 -280
  259. package/dist/stack.d.ts +0 -48
  260. package/dist/stack.js +0 -403
  261. package/dist/telemetry.d.ts +0 -59
  262. package/dist/tier.d.ts +0 -40
  263. package/dist/tier.js +0 -96
  264. package/dist/ui.d.ts +0 -40
  265. package/dist/ui.js +0 -71
  266. package/dist/version.d.ts +0 -7
  267. package/dist/version.js +0 -17
  268. package/dist/workers.d.ts +0 -5
  269. package/dist/workers.js +0 -33
  270. package/dist/workflows/commands.d.ts +0 -54
  271. package/dist/workflows/commands.js +0 -763
@@ -1,139 +0,0 @@
1
- /**
2
- * Loads devtools' optional-peer `@devdogsuga/*` libraries — the ones
3
- * published to npm and consumed by the TARGET repo, which devtools reads at
4
- * runtime rather than bundling its own copy of (see this package's
5
- * `package.json`: `peerDependencies` + `peerDependenciesMeta.optional`, and
6
- * `FINDINGS.md` experiment 2).
7
- *
8
- * Every export here is memoized per module (one dynamic `import()` per
9
- * process, not per call) — this is what makes the module-identity guarantee
10
- * in FINDINGS experiment 3 hold: every devtools call site that needs
11
- * `@devdogsuga/env`'s registry gets the exact same module instance the
12
- * repo's own manifests populated via `declare()`/`define()`, because both
13
- * resolve to the identical absolute file path and Node's ESM cache is keyed
14
- * by resolved URL.
15
- */
16
- import { pathToFileURL } from "node:url";
17
- import { findRepoRoot, RepoNotFoundError } from "./root.js";
18
- import { findDependent, resolveFromRepo } from "./resolve.js";
19
- const moduleCache = new Map();
20
- /** The file URL each peer resolved to through the target repo, set only on
21
- * that path (not on either plain bare-specifier fallback). See
22
- * `repoPeerUrl()`. */
23
- const resolvedUrls = new Map();
24
- /**
25
- * Dynamically imports `specifier` as the repo would resolve it, memoized so
26
- * repeated calls in one process return the SAME module instance (required
27
- * for the env-registry identity guarantee above).
28
- *
29
- * Falls back to a plain bare-specifier `import()` when devtools is not
30
- * running inside a DevDogsUGA checkout at all (`findRepoRoot()` throws
31
- * `RepoNotFoundError`). That is not a production affordance — under real
32
- * `pnpm dlx` use, `specifier` is an optional peer devtools' own package
33
- * never installs, so the fallback import fails with the ordinary
34
- * `MODULE_NOT_FOUND` either way. It exists so devtools' OWN test suite
35
- * (which has no target repo to discover, but does have every one of these
36
- * peers as a real Backstage workspace package) exercises this code against
37
- * the genuine package rather than needing every test to mock this module.
38
- */
39
- function loadPeer(specifier) {
40
- const cached = moduleCache.get(specifier);
41
- if (cached)
42
- return cached;
43
- const promise = (async () => {
44
- // See `findRepoRoot()`'s own comment: Backstage's test suite sets this
45
- // so every peer resolves to the real Backstage-workspace copy instead
46
- // of a nonexistent target repo, without a per-test mock.
47
- if (process.env.DEVTOOLS_TEST_REPO_ROOT) {
48
- return import(specifier);
49
- }
50
- let repoRoot;
51
- try {
52
- repoRoot = findRepoRoot();
53
- }
54
- catch (err) {
55
- if (err instanceof RepoNotFoundError) {
56
- return import(specifier);
57
- }
58
- throw err;
59
- }
60
- const resolutionBase = findDependent(repoRoot, specifier);
61
- if (!resolutionBase) {
62
- throw new Error(`Nothing in this repo depends on ${specifier} — expected an app or package under apps/*` +
63
- ` or packages/* to declare it (dependencies/devDependencies/peerDependencies).`);
64
- }
65
- const { resolvedPath } = resolveFromRepo(repoRoot, resolutionBase, specifier);
66
- const url = pathToFileURL(resolvedPath).href;
67
- resolvedUrls.set(specifier, url);
68
- return import(url);
69
- })();
70
- moduleCache.set(specifier, promise);
71
- return promise;
72
- }
73
- /** Test-only: clears the memoized peer modules so a test can re-resolve with a fresh mock. */
74
- export function resetPeerCacheForTests() {
75
- moduleCache.clear();
76
- resolvedUrls.clear();
77
- }
78
- /**
79
- * The file URL `specifier` was loaded from through the target repo, or
80
- * undefined if it has not been loaded yet or came from a plain bare-specifier
81
- * `import()` (the test-suite and not-in-a-repo fallbacks above).
82
- *
83
- * For code devtools imports that itself names a peer by bare specifier --
84
- * today only devtools' own `env.ts` manifest. From an installed copy that
85
- * specifier cannot resolve at all (an optional peer is never installed next
86
- * to devtools under `pnpm dlx`), and even where it can, the only copy that
87
- * keeps module identity is this one. `repo/peer-redirect.ts` uses it to
88
- * point the import here.
89
- */
90
- export function repoPeerUrl(specifier) {
91
- return resolvedUrls.get(specifier);
92
- }
93
- let resolvedEnvModule;
94
- export function loadEnv() {
95
- return loadPeer("@devdogsuga/env").then((mod) => {
96
- resolvedEnvModule = mod;
97
- return mod;
98
- });
99
- }
100
- /**
101
- * The synchronous companion to `loadEnv()`, for the handful of call sites
102
- * (`gh/environments.ts`'s `GITHUB_ENVIRONMENT_SPECS` getters) that cannot
103
- * become async without changing their own callers' contract — they read a
104
- * plain array off a getter, not a Promise. Safe ONLY after `loadEnv()` has
105
- * resolved at least once; every caller of these getters already requires
106
- * `env/discovery.ts`'s `loadRegistry()` (which calls `loadEnv()` itself) to
107
- * have run first, via `assertRegistryLoaded()`'s own guard.
108
- */
109
- export function getEnvSync() {
110
- if (!resolvedEnvModule) {
111
- throw new Error("getEnvSync() called before loadEnv() ever resolved — call loadRegistry() " +
112
- "(env/discovery.ts) first.");
113
- }
114
- return resolvedEnvModule;
115
- }
116
- /** Test-only: clears the sync cache alongside `resetPeerCacheForTests()`. */
117
- export function resetEnvSyncCacheForTests() {
118
- resolvedEnvModule = undefined;
119
- }
120
- export function loadEnvLoad() {
121
- return loadPeer("@devdogsuga/env/load");
122
- }
123
- export function loadEnvSession() {
124
- return loadPeer("@devdogsuga/env/session");
125
- }
126
- export function loadDbTypegen() {
127
- return loadPeer("@devdogsuga/db/typegen");
128
- }
129
- export function loadBrandEvent() {
130
- return loadPeer("@devdogsuga/brand/event");
131
- }
132
- export function loadEvents() {
133
- return loadPeer("@devdogsuga/events");
134
- }
135
- // `@devdogsuga/newsletter` used to be an optional peer here, read by
136
- // devtools' own `newsletter` command. Wave 2, stage A2 moved that command to
137
- // a plain Backstage script (`packages/newsletter-cli`) — see its README —
138
- // since the content it exports lives in Backstage already; devtools has no
139
- // reason to load it at all any more.
@@ -1,41 +0,0 @@
1
- export interface ResolvedFromRepo {
2
- /** Absolute path to the resolved module entry point. */
3
- resolvedPath: string;
4
- /** The version declared in the resolved package's own `package.json`. */
5
- version: string;
6
- /** Absolute path to the resolved package's `package.json`. */
7
- pkgJsonPath: string;
8
- }
9
- /**
10
- * The installable package name a (possibly subpath) specifier belongs to:
11
- * `@devdogsuga/env/load` → `@devdogsuga/env`, `foo/bar` → `foo`. A repo's
12
- * package.json declares the PACKAGE as a dependency, never a subpath, so
13
- * `findDependent` has to search on this rather than the literal specifier a
14
- * caller wants to import.
15
- */
16
- export declare function packageNameOf(specifier: string): string;
17
- /**
18
- * Scans `apps/*` and `packages/*` under `repoRoot` for the first
19
- * `package.json` whose `dependencies`/`devDependencies`/`peerDependencies`
20
- * names `specifier`'s package (see `packageNameOf`). Returns its path
21
- * relative to `repoRoot`, or `null` if nothing in the repo depends on it.
22
- *
23
- * Re-scans the filesystem on every call — fine for a short-lived CLI
24
- * invocation calling this a handful of times; see FINDINGS item 5 if this
25
- * is ever called in a hot loop.
26
- */
27
- export declare function findDependent(repoRoot: string, specifier: string): string | null;
28
- /**
29
- * Resolves `specifier` as `resolutionBase` (a workspace-relative
30
- * `package.json` path known to depend on it, from `findDependent()`) would
31
- * see it.
32
- *
33
- * `opts.condition`, when given, is NOT passed through to Node's resolver —
34
- * `require.resolve` ignores tsx's `register({ conditions })` entirely (see
35
- * this module's header). Instead the target package's own
36
- * `exports["."]` map is read directly and `exports["."][condition]` is
37
- * picked, falling back to `.default`.
38
- */
39
- export declare function resolveFromRepo(repoRoot: string, resolutionBase: string, specifier: string, opts?: {
40
- condition?: string;
41
- }): ResolvedFromRepo;
@@ -1,152 +0,0 @@
1
- /**
2
- * Resolves an `@devdogsuga/*` package FROM the target repo, not from
3
- * devtools' own (dlx-isolated) `node_modules`.
4
- *
5
- * Ported from the `devtools-dlx` prototype
6
- * (`/home/sloan/scratchpad/devdogs/prototypes/devtools-dlx/FINDINGS.md`,
7
- * experiments 2 and 4 — read that file for the two gotchas this module
8
- * exists to avoid). The short version:
9
- *
10
- * - `require.resolve(\`${specifier}/package.json\`)` throws
11
- * `ERR_PACKAGE_PATH_NOT_EXPORTED` on packages (like `@devdogsuga/env`,
12
- * `@devdogsuga/open-graph`) whose `exports` map does not list
13
- * `"./package.json"`, even though the file is on disk.
14
- * - A resolved path cannot be assumed to contain a literal
15
- * `node_modules/<specifier>` segment — pnpm workspace-linked packages
16
- * resolve to their REALPATH (e.g. `packages/open-graph/dist/index.js`),
17
- * which has no such segment at all.
18
- * - `require.resolve` ignores whatever `conditions` a caller has set on
19
- * `tsx`'s `register()` — condition-based resolution (the
20
- * `devdogs-source` condition) has to be done by hand, reading the
21
- * target package's own `exports["."]` map.
22
- *
23
- * Both problems are solved the same way: walk up from the resolved file's
24
- * directory to the nearest `package.json` whose own `"name"` field matches
25
- * the specifier. That works for a real installed dependency AND a
26
- * workspace symlink, uniformly.
27
- */
28
- import { createRequire } from "node:module";
29
- import { existsSync, readFileSync, readdirSync } from "node:fs";
30
- import { dirname, join } from "node:path";
31
- /**
32
- * The installable package name a (possibly subpath) specifier belongs to:
33
- * `@devdogsuga/env/load` → `@devdogsuga/env`, `foo/bar` → `foo`. A repo's
34
- * package.json declares the PACKAGE as a dependency, never a subpath, so
35
- * `findDependent` has to search on this rather than the literal specifier a
36
- * caller wants to import.
37
- */
38
- export function packageNameOf(specifier) {
39
- const parts = specifier.split("/");
40
- return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
41
- }
42
- /**
43
- * Scans `apps/*` and `packages/*` under `repoRoot` for the first
44
- * `package.json` whose `dependencies`/`devDependencies`/`peerDependencies`
45
- * names `specifier`'s package (see `packageNameOf`). Returns its path
46
- * relative to `repoRoot`, or `null` if nothing in the repo depends on it.
47
- *
48
- * Re-scans the filesystem on every call — fine for a short-lived CLI
49
- * invocation calling this a handful of times; see FINDINGS item 5 if this
50
- * is ever called in a hot loop.
51
- */
52
- export function findDependent(repoRoot, specifier) {
53
- const packageName = packageNameOf(specifier);
54
- const groups = ["apps", "packages"];
55
- for (const group of groups) {
56
- const groupDir = join(repoRoot, group);
57
- let entries;
58
- try {
59
- entries = readdirSync(groupDir);
60
- }
61
- catch {
62
- continue;
63
- }
64
- for (const entry of entries) {
65
- const pkgJsonPath = join(groupDir, entry, "package.json");
66
- if (!existsSync(pkgJsonPath))
67
- continue;
68
- let pkg;
69
- try {
70
- pkg = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
71
- }
72
- catch {
73
- continue;
74
- }
75
- const deps = {
76
- ...pkg.dependencies,
77
- ...pkg.devDependencies,
78
- ...pkg.peerDependencies,
79
- };
80
- if (packageName in deps) {
81
- return join(group, entry, "package.json");
82
- }
83
- }
84
- }
85
- return null;
86
- }
87
- /** Walks up from `startDir` to the nearest `package.json` whose `"name"` matches `specifier`. */
88
- function findOwningPackageJson(startDir, specifier) {
89
- const packageName = packageNameOf(specifier);
90
- let dir = startDir;
91
- for (;;) {
92
- const candidate = join(dir, "package.json");
93
- if (existsSync(candidate)) {
94
- try {
95
- const pkg = JSON.parse(readFileSync(candidate, "utf8"));
96
- if (pkg.name === packageName)
97
- return candidate;
98
- }
99
- catch {
100
- // fall through and keep walking
101
- }
102
- }
103
- const parent = dirname(dir);
104
- if (parent === dir) {
105
- throw new Error(`resolveFromRepo: could not find ${specifier}'s own package.json by walking up from ${startDir}`);
106
- }
107
- dir = parent;
108
- }
109
- }
110
- /**
111
- * Resolves `specifier` as `resolutionBase` (a workspace-relative
112
- * `package.json` path known to depend on it, from `findDependent()`) would
113
- * see it.
114
- *
115
- * `opts.condition`, when given, is NOT passed through to Node's resolver —
116
- * `require.resolve` ignores tsx's `register({ conditions })` entirely (see
117
- * this module's header). Instead the target package's own
118
- * `exports["."]` map is read directly and `exports["."][condition]` is
119
- * picked, falling back to `.default`.
120
- */
121
- export function resolveFromRepo(repoRoot, resolutionBase, specifier, opts) {
122
- const baseFile = join(repoRoot, resolutionBase);
123
- const require = createRequire(baseFile);
124
- let resolvedPath;
125
- if (opts?.condition) {
126
- // Find the package's own package.json first (via a plain resolve of the
127
- // specifier itself, which DOES work through node's default conditions),
128
- // then read its exports map by hand.
129
- const defaultEntry = require.resolve(specifier);
130
- const pkgJsonPath = findOwningPackageJson(dirname(defaultEntry), specifier);
131
- const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
132
- const rootExport = pkg.exports?.["."];
133
- const conditioned = rootExport && typeof rootExport === "object"
134
- ? (rootExport[opts.condition] ??
135
- rootExport.default)
136
- : undefined;
137
- if (typeof conditioned !== "string") {
138
- throw new Error(`resolveFromRepo: ${specifier} has no "${opts.condition}" (or "default") export in its exports["."] map`);
139
- }
140
- resolvedPath = join(dirname(pkgJsonPath), conditioned);
141
- }
142
- else {
143
- resolvedPath = require.resolve(specifier);
144
- }
145
- const pkgJsonPath = findOwningPackageJson(dirname(resolvedPath), specifier);
146
- const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
147
- return {
148
- resolvedPath,
149
- version: pkg.version ?? "0.0.0",
150
- pkgJsonPath,
151
- };
152
- }
@@ -1,23 +0,0 @@
1
- export declare class RepoNotFoundError extends Error {
2
- constructor();
3
- }
4
- /**
5
- * Walks up from `startDir` (default `process.cwd()`) looking for the repo
6
- * marker. Returns `null` rather than throwing — `findRepoRoot()` below is
7
- * the throwing convenience most callers want; this is exported for callers
8
- * (like `setup`) that need to know without failing.
9
- */
10
- export declare function discoverRepoRoot(startDir?: string): string | null;
11
- /**
12
- * The memoized, throwing repo-root lookup. Lazy on purpose: importing this
13
- * module must never fail just because nothing has called it yet (`setup`
14
- * and `completions` in `launch.ts` never need a repo at all, and must stay
15
- * that way — see that file's header comment on why).
16
- *
17
- * Resolved once per process: `process.cwd()` does not change mid-invocation
18
- * for this CLI, and re-walking the filesystem on every call would be pure
19
- * waste.
20
- */
21
- export declare function findRepoRoot(): string;
22
- /** Test-only: clears the memoized root so a test can point `process.cwd()` elsewhere. */
23
- export declare function resetRepoRootCacheForTests(): void;
package/dist/repo/root.js DELETED
@@ -1,91 +0,0 @@
1
- /**
2
- * Where devtools finds the DevDogsUGA checkout it is running against.
3
- *
4
- * devtools used to live inside `packages/devtools` of that repo, so its own
5
- * `import.meta.url` WAS a path into the repo (`PROJECT_ROOT` /
6
- * `REPO_ROOT` walked up a fixed number of `..` segments from this file).
7
- * Published as its own package and run through `pnpm dlx`, that assumption
8
- * breaks: this file's `import.meta.url` points into a dlx cache directory
9
- * or an isolated `node_modules` tree that has nothing to do with the repo
10
- * the contributor is standing in.
11
- *
12
- * So repo discovery walks up from `process.cwd()` instead, looking for the
13
- * marker validated in the `devtools-dlx` prototype
14
- * (`/home/sloan/scratchpad/devdogs/prototypes/devtools-dlx/FINDINGS.md`,
15
- * experiment 1): a directory containing `pnpm-workspace.yaml` AND whose
16
- * `package.json` has `"name": "devdogs-monorepo"`. The name check is not
17
- * redundant — a bare `pnpm-workspace.yaml` also matches a Backstage
18
- * checkout (a separate pnpm workspace), which devtools should refuse
19
- * rather than silently "find".
20
- */
21
- import { existsSync, readFileSync } from "node:fs";
22
- import { dirname, join } from "node:path";
23
- /** The `package.json` name every real DevDogsUGA checkout carries at its root. */
24
- const REPO_MARKER_NAME = "devdogs-monorepo";
25
- export class RepoNotFoundError extends Error {
26
- constructor() {
27
- super("run this from inside a DevDogsUGA clone");
28
- this.name = "RepoNotFoundError";
29
- }
30
- }
31
- function looksLikeRepoRoot(dir) {
32
- if (!existsSync(join(dir, "pnpm-workspace.yaml")))
33
- return false;
34
- try {
35
- const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
36
- return pkg.name === REPO_MARKER_NAME;
37
- }
38
- catch {
39
- return false;
40
- }
41
- }
42
- /**
43
- * Walks up from `startDir` (default `process.cwd()`) looking for the repo
44
- * marker. Returns `null` rather than throwing — `findRepoRoot()` below is
45
- * the throwing convenience most callers want; this is exported for callers
46
- * (like `setup`) that need to know without failing.
47
- */
48
- export function discoverRepoRoot(startDir = process.cwd()) {
49
- let dir = startDir;
50
- for (;;) {
51
- if (looksLikeRepoRoot(dir))
52
- return dir;
53
- const parent = dirname(dir);
54
- if (parent === dir)
55
- return null;
56
- dir = parent;
57
- }
58
- }
59
- let cachedRoot;
60
- /**
61
- * The memoized, throwing repo-root lookup. Lazy on purpose: importing this
62
- * module must never fail just because nothing has called it yet (`setup`
63
- * and `completions` in `launch.ts` never need a repo at all, and must stay
64
- * that way — see that file's header comment on why).
65
- *
66
- * Resolved once per process: `process.cwd()` does not change mid-invocation
67
- * for this CLI, and re-walking the filesystem on every call would be pure
68
- * waste.
69
- */
70
- export function findRepoRoot() {
71
- if (cachedRoot === undefined) {
72
- // Backstage's own test suite has no DevDogsUGA checkout to discover —
73
- // it IS a different pnpm workspace — but most of devtools' unit tests
74
- // exercise code that calls `findRepoRoot()` only to build a path string
75
- // that a mocked `node:fs/promises` never actually reads. Rather than
76
- // adding a `vi.mock("../repo/root.js", ...)` to every one of those
77
- // files, `vitest.config.ts` sets this one env var for the whole run so
78
- // `findRepoRoot()` resolves to a stable fake path instead of throwing.
79
- // A test that specifically wants the real "not in a repo" refusal
80
- // (`RepoNotFoundError`) unsets it locally — see `root.test.ts`.
81
- cachedRoot = process.env.DEVTOOLS_TEST_REPO_ROOT ?? discoverRepoRoot();
82
- }
83
- if (cachedRoot === null) {
84
- throw new RepoNotFoundError();
85
- }
86
- return cachedRoot;
87
- }
88
- /** Test-only: clears the memoized root so a test can point `process.cwd()` elsewhere. */
89
- export function resetRepoRootCacheForTests() {
90
- cachedRoot = undefined;
91
- }
@@ -1,14 +0,0 @@
1
- /** Test-only: clears the memoized source modules. */
2
- export declare function resetSourceCacheForTests(): void;
3
- import type { OpenGraphModule } from "../images/open-graph-types.js";
4
- export declare function loadOpenGraph(): Promise<OpenGraphModule>;
5
- import type { EmailTemplates } from "../emails/email-types.js";
6
- export interface EmailModule {
7
- render: <K extends keyof EmailTemplates>(name: K, props: EmailTemplates[K]) => {
8
- subject: string;
9
- html: string;
10
- text: string;
11
- };
12
- }
13
- export declare function loadEmail(): Promise<EmailModule>;
14
- export declare function loadDocs(): Promise<unknown>;
@@ -1,54 +0,0 @@
1
- /**
2
- * Loads the repo-local, never-published `@devdogsuga/*` packages devtools
3
- * needs at runtime: `open-graph`, `email`, `docs`. Unlike the
4
- * `peers.ts` set, these are `"private": true` in the target repo and never
5
- * reach npm — devtools resolves them straight out of the repo's own
6
- * `node_modules` (a pnpm workspace symlink) using the `devdogs-source`
7
- * export condition, picked by hand (see `resolve.ts`'s header and
8
- * FINDINGS.md experiment 4 for why this can't go through
9
- * `require.resolve`/tsx's `register({ conditions })`).
10
- *
11
- * `open-graph` and `email` both declare a `"devdogs-source"` entry in their
12
- * `exports["."]` map, pointing at TS source. `docs` does not (its `default`
13
- * points straight at a built `dist/index.js`, produced by
14
- * `docs-compiler`) — `resolveFromRepo` falls back to `.default` for it,
15
- * and routing the result through the same tsx-backed import as the other
16
- * two is harmless: tsx passes plain `.js` through unchanged.
17
- */
18
- import { findRepoRoot } from "./root.js";
19
- import { findDependent, resolveFromRepo } from "./resolve.js";
20
- import { importRepoTs } from "./tsx-loader.js";
21
- const CONDITION = "devdogs-source";
22
- const cache = new Map();
23
- function loadSource(specifier) {
24
- const cached = cache.get(specifier);
25
- if (cached)
26
- return cached;
27
- const promise = (async () => {
28
- const repoRoot = findRepoRoot();
29
- const resolutionBase = findDependent(repoRoot, specifier);
30
- if (!resolutionBase) {
31
- throw new Error(`Nothing in this repo depends on ${specifier} — expected an app or package under apps/*` +
32
- ` or packages/* to declare it.`);
33
- }
34
- const { resolvedPath } = resolveFromRepo(repoRoot, resolutionBase, specifier, {
35
- condition: CONDITION,
36
- });
37
- return importRepoTs(resolvedPath);
38
- })();
39
- cache.set(specifier, promise);
40
- return promise;
41
- }
42
- /** Test-only: clears the memoized source modules. */
43
- export function resetSourceCacheForTests() {
44
- cache.clear();
45
- }
46
- export function loadOpenGraph() {
47
- return loadSource("@devdogsuga/open-graph");
48
- }
49
- export function loadEmail() {
50
- return loadSource("@devdogsuga/email");
51
- }
52
- export function loadDocs() {
53
- return loadSource("@devdogsuga/docs");
54
- }
@@ -1,60 +0,0 @@
1
- /**
2
- * Reads `project_id` out of `<repoRoot>/supabase/config.toml`, or `null`
3
- * when the file is missing or unparsable.
4
- *
5
- * Regex, not a TOML parser: it is one line, the shape has been stable
6
- * across every CLI version this repo has seen, and a parser on a path some
7
- * callers pay before their first real subprocess is a cost that stays
8
- * invisible until it is why the tool feels slow.
9
- */
10
- export declare function readProjectId(repoRoot: string): string | null;
11
- /**
12
- * The Supabase CLI's container name prefix for a project id, or the bare
13
- * `supabase_db_` fallback when the id could not be read.
14
- *
15
- * Falling back to the bare prefix means a machine whose `config.toml`
16
- * cannot be read still detects *a* stack, at the cost of over-matching a
17
- * differently-named project — deliberate, and unchanged from this
18
- * function's original home in `environment.ts`: over-matching offers
19
- * `stop`/a foreign-stack hint for a stack that turns out to be this
20
- * project's own, which is harmless to see and decline, while
21
- * under-matching hides a real signal entirely.
22
- */
23
- export declare function containerPrefix(projectId: string | null): string;
24
- /**
25
- * The local stack's API port, published by its Kong container. Mirrors
26
- * `@devdogsuga/env/load`'s `LOCAL_STACK_PORT`, which this module cannot import
27
- * statically (that package is an optional peer, loaded on demand).
28
- */
29
- export declare const STACK_API_PORT = 54321;
30
- /**
31
- * `docker ps --format '{{.Names}}'`, split into trimmed, non-empty names —
32
- * or `null` when Docker could not be read at all (no daemon, not
33
- * installed, timed out). With `publish`, only the containers publishing that
34
- * host port. `execute` is injectable for tests, mirroring `environment.ts`'s
35
- * own probes.
36
- */
37
- export declare function listContainerNames(publish?: number, execute?: (file: string, args: string[]) => string | null): string[] | null;
38
- /**
39
- * Finds the `supabase_kong_<id>` container among `names` whose id differs
40
- * from `projectId` — the signature of a stack started from a DIFFERENT
41
- * Supabase project (this same repo before/after a rename, or another
42
- * project entirely) holding the shared ports. Kong is the container that
43
- * publishes the API port, so callers pass the names `listContainerNames`
44
- * returns for `STACK_API_PORT`: that names the stack actually on 54321,
45
- * not just any Supabase stack on the machine.
46
- *
47
- * Returns that foreign id, or `null` when every matching container belongs
48
- * to this project, none match at all, or `projectId` itself could not be
49
- * read — with no known id of our own, there is nothing to compare against,
50
- * and guessing would risk telling a contributor their OWN stack is
51
- * foreign.
52
- */
53
- export declare function foreignStackProjectId(names: readonly string[], projectId: string | null): string | null;
54
- /**
55
- * The actionable message for a detected foreign stack — shared by
56
- * `db/generated-env.ts` (a failed `supabase status -o env`) and `stack.ts`
57
- * (a failed `supabase start`), so both name the same fix in the same
58
- * words.
59
- */
60
- export declare function foreignStackMessage(foreignProjectId: string): string;