@fairgarden/monolith 0.1.0-0.canary.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 (54) hide show
  1. package/Readme.md +84 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +160 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/compat.d.ts +4 -0
  7. package/dist/compat.d.ts.map +1 -0
  8. package/dist/compat.js +174 -0
  9. package/dist/compat.js.map +1 -0
  10. package/dist/eslint.d.ts +62 -0
  11. package/dist/eslint.d.ts.map +1 -0
  12. package/dist/eslint.js +198 -0
  13. package/dist/eslint.js.map +1 -0
  14. package/dist/index.d.ts +28 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +84 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/link.d.ts +24 -0
  19. package/dist/link.d.ts.map +1 -0
  20. package/dist/link.js +473 -0
  21. package/dist/link.js.map +1 -0
  22. package/dist/mounts.d.ts +37 -0
  23. package/dist/mounts.d.ts.map +1 -0
  24. package/dist/mounts.js +58 -0
  25. package/dist/mounts.js.map +1 -0
  26. package/dist/package-json.d.ts +38 -0
  27. package/dist/package-json.d.ts.map +1 -0
  28. package/dist/package-json.js +156 -0
  29. package/dist/package-json.js.map +1 -0
  30. package/dist/portability.d.ts +41 -0
  31. package/dist/portability.d.ts.map +1 -0
  32. package/dist/portability.js +171 -0
  33. package/dist/portability.js.map +1 -0
  34. package/dist/portable-link.d.ts +22 -0
  35. package/dist/portable-link.d.ts.map +1 -0
  36. package/dist/portable-link.js +24 -0
  37. package/dist/portable-link.js.map +1 -0
  38. package/dist/proxies.d.ts +33 -0
  39. package/dist/proxies.d.ts.map +1 -0
  40. package/dist/proxies.js +177 -0
  41. package/dist/proxies.js.map +1 -0
  42. package/dist/resolve.d.ts +5 -0
  43. package/dist/resolve.d.ts.map +1 -0
  44. package/dist/resolve.js +181 -0
  45. package/dist/resolve.js.map +1 -0
  46. package/dist/routes.d.ts +23 -0
  47. package/dist/routes.d.ts.map +1 -0
  48. package/dist/routes.js +102 -0
  49. package/dist/routes.js.map +1 -0
  50. package/dist/types.d.ts +111 -0
  51. package/dist/types.d.ts.map +1 -0
  52. package/dist/types.js +2 -0
  53. package/dist/types.js.map +1 -0
  54. package/package.json +77 -0
package/dist/link.js ADDED
@@ -0,0 +1,473 @@
1
+ import { readdirSync, realpathSync, statSync, watch, } from 'node:fs';
2
+ import { lstat, writeFile, mkdir, readdir, readlink, realpath, rm, stat, symlink, unlink, } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { async as syncDirectoryAsync, sync as syncDirectorySync, } from 'sync-directory';
5
+ /**
6
+ * Dropped into a derived tree so a later run knows it built it.
7
+ *
8
+ * Without it there is no way to tell a tree this created from one the monolith
9
+ * keeps its own routes in — and the difference decides whether clearing it is
10
+ * routine or destroys someone's work. A dotfile is not a route.
11
+ */
12
+ const MARKER = '.fg-monolith';
13
+ const markDerived = async (target) => {
14
+ await mkdir(target, { recursive: true });
15
+ await writeFile(path.join(target, MARKER), 'Built by withMonolith from the committed tree. Safe to delete; do not edit.\n');
16
+ };
17
+ const isDerived = async (target) => (await lstat(path.join(target, MARKER)).catch(() => undefined)) !== undefined;
18
+ /** Directories that are never part of an app's routes. */
19
+ const IGNORED = new Set(['node_modules', '.next', '.turbo', '.git']);
20
+ /**
21
+ * Remove whatever currently occupies a mount point.
22
+ *
23
+ * Only ever called for paths generated inside the monolith, and refuses
24
+ * anything else — deleting the wrong directory here would take an app's real
25
+ * source with it.
26
+ */
27
+ const clear = async (target, monolithRoot) => {
28
+ const relative = path.relative(monolithRoot, target);
29
+ if (relative.startsWith('..') || path.isAbsolute(relative)) {
30
+ throw new Error(`Refusing to replace ${target}, which is outside ${monolithRoot}.`);
31
+ }
32
+ let stats;
33
+ try {
34
+ // lstat, not stat: a symlink must be unlinked rather than followed.
35
+ stats = await lstat(target);
36
+ }
37
+ catch {
38
+ return;
39
+ }
40
+ if (stats.isSymbolicLink() || stats.isFile()) {
41
+ await unlink(target);
42
+ return;
43
+ }
44
+ await rm(target, { recursive: true, force: true });
45
+ };
46
+ const pointsAt = async (link, expected) => {
47
+ const current = await readlink(link).catch(() => undefined);
48
+ return (current !== undefined && path.resolve(path.dirname(link), current) === expected);
49
+ };
50
+ /**
51
+ * Point a committed symlink at an app's directory.
52
+ *
53
+ * These are the readable view of the composition: they live in git, and GitHub
54
+ * renders them as links you can follow. Writing them is idempotent so a repeat
55
+ * run leaves no diff.
56
+ */
57
+ const linkSource = async (source, target, monolithRoot) => {
58
+ const existing = await lstat(target).catch(() => undefined);
59
+ if (existing?.isSymbolicLink() && (await pointsAt(target, source)))
60
+ return;
61
+ await mkdir(path.dirname(target), { recursive: true });
62
+ await clear(target, monolithRoot);
63
+ // Relative so the tree stays valid if the repo is moved or mounted elsewhere.
64
+ await symlink(path.relative(path.dirname(target), source), target, 'dir');
65
+ };
66
+ /**
67
+ * Recreate `source`'s directory tree under `target`, symlinking each file.
68
+ *
69
+ * Real directories are what `next dev` needs to walk; symlinked files keep the
70
+ * content resolving back to the app, so edits never go stale.
71
+ */
72
+ const mirrorTree = async (source, target, preserve = new Set()) => {
73
+ await mkdir(target, { recursive: true });
74
+ // A missing source is an empty one: every app may be package-sourced, in
75
+ // which case nothing was ever linked into the committed tree.
76
+ const entries = await readdir(source, { withFileTypes: true }).catch(() => []);
77
+ const expected = new Set();
78
+ for (const entry of entries) {
79
+ if (IGNORED.has(entry.name))
80
+ continue;
81
+ expected.add(entry.name);
82
+ const from = path.join(source, entry.name);
83
+ const to = path.join(target, entry.name);
84
+ // Follow symlinks, so an app linked into the source tree is walked too.
85
+ const stats = await stat(from).catch(() => undefined);
86
+ if (!stats)
87
+ continue;
88
+ // Never mirror something that resolves into node_modules. Turbopack will
89
+ // not process a route whose real path is there, and such an entry is
90
+ // either stale or a link that should never have been committed.
91
+ const real = await realpath(from).catch(() => from);
92
+ if (real.split(path.sep).includes('node_modules'))
93
+ continue;
94
+ if (stats.isDirectory()) {
95
+ const existing = await lstat(to).catch(() => undefined);
96
+ if (existing && !existing.isDirectory())
97
+ await rm(to, { force: true });
98
+ await mirrorTree(from, to);
99
+ continue;
100
+ }
101
+ const existing = await lstat(to).catch(() => undefined);
102
+ if (existing) {
103
+ if (existing.isSymbolicLink() && (await pointsAt(to, from)))
104
+ continue;
105
+ await rm(to, { recursive: true, force: true });
106
+ }
107
+ await symlink(path.relative(path.dirname(to), from), to, 'file');
108
+ }
109
+ // Drop anything the source no longer has, so deleted routes stop being
110
+ // served — except mounts that are copied in rather than derived from here.
111
+ for (const entry of await readdir(target, { withFileTypes: true })) {
112
+ if (entry.name === MARKER)
113
+ continue;
114
+ if (!expected.has(entry.name) && !preserve.has(entry.name)) {
115
+ await rm(path.join(target, entry.name), { recursive: true, force: true });
116
+ }
117
+ }
118
+ };
119
+ const duplicate = async (source, target, type, shouldWatch) => {
120
+ await mkdir(path.dirname(target), { recursive: true });
121
+ const options = {
122
+ type,
123
+ deleteOrphaned: true,
124
+ // sync-directory knows `staySymlink`, not `supportSymlink`; the latter was
125
+ // silently ignored. Symlinks in the source are followed and their contents
126
+ // copied, which is what a derived tree wants.
127
+ staySymlink: false,
128
+ exclude: [...IGNORED].map((name) => new RegExp(`(^|[/\\\\])${name}([/\\\\]|$)`)),
129
+ };
130
+ if (shouldWatch) {
131
+ await syncDirectoryAsync(source, target, { ...options, watch: true });
132
+ return;
133
+ }
134
+ syncDirectorySync(source, target, options);
135
+ };
136
+ /** Held so the watchers are not collected while the dev server runs. */
137
+ const watchers = new Set();
138
+ /**
139
+ * Re-mirror when files are added or removed.
140
+ *
141
+ * Content changes need no watcher — the symlinks already resolve to the app —
142
+ * so this only has to catch the tree changing shape.
143
+ */
144
+ const watchMirror = (source, target, preserve) => {
145
+ let pending;
146
+ const rebuild = () => {
147
+ clearTimeout(pending);
148
+ pending = setTimeout(() => {
149
+ void mirrorTree(source, target, preserve).catch(() => { });
150
+ }, 50);
151
+ };
152
+ const add = (dir) => {
153
+ try {
154
+ const watcher = watch(dir, { recursive: true }, rebuild);
155
+ watcher.unref();
156
+ watchers.add(watcher);
157
+ }
158
+ catch {
159
+ // A directory that cannot be watched is not worth failing dev over.
160
+ }
161
+ };
162
+ add(source);
163
+ // On Linux a recursive watch does not follow directory symlinks, and every
164
+ // app in the committed tree is one — so routes added inside an app would go
165
+ // unnoticed until a restart. Watch each mount's real directory as well.
166
+ for (const entry of readdirSync(source, { withFileTypes: true })) {
167
+ if (IGNORED.has(entry.name))
168
+ continue;
169
+ const full = path.join(source, entry.name);
170
+ const real = realpathSync(full);
171
+ if (real !== full && statSync(real).isDirectory())
172
+ add(real);
173
+ }
174
+ };
175
+ /**
176
+ * Make an app resolvable by its own package name from inside its own tree.
177
+ *
178
+ * Apps import their own modules by package name, because relative imports stop
179
+ * working once the routes are mounted elsewhere. Turbopack resolves a mounted
180
+ * file from its real location, so the monolith's `node_modules` is not on the
181
+ * lookup path and the app has to be able to find itself.
182
+ *
183
+ * Leaves a real installed package alone, and only replaces a symlink it would
184
+ * have created itself.
185
+ */
186
+ export const linkSelfReference = async (app) => {
187
+ if (!app.packageName)
188
+ return;
189
+ const target = path.join(app.root, 'node_modules', app.packageName);
190
+ const existing = await lstat(target).catch(() => undefined);
191
+ if (existing) {
192
+ if (!existing.isSymbolicLink())
193
+ return;
194
+ if (await pointsAt(target, app.root))
195
+ return;
196
+ await unlink(target);
197
+ }
198
+ await mkdir(path.dirname(target), { recursive: true });
199
+ await symlink(path.relative(path.dirname(target), app.root), target, 'dir');
200
+ };
201
+ /** Everything each app would put into the monolith, before anything is written. */
202
+ const claimsOf = async (monolithRoot, apps, options) => {
203
+ const claims = [];
204
+ const entries = async (from) => (await readdir(from, { withFileTypes: true }).catch(() => []))
205
+ .filter((entry) => !IGNORED.has(entry.name))
206
+ .map((entry) => entry.name);
207
+ for (const app of apps) {
208
+ const places = [
209
+ [app.appDir, options.sourceDir, 'routes'],
210
+ [app.publicDir, path.join(monolithRoot, 'public'), 'assets'],
211
+ [app.pagesApiDir, path.join(options.sourcePagesDir, 'api'), 'api routes'],
212
+ ];
213
+ for (const [from, into, what] of places) {
214
+ if (!from)
215
+ continue;
216
+ // At the root an app claims each of its entries; anywhere else it claims
217
+ // one directory named after the mount.
218
+ if (app.prefix === '') {
219
+ for (const entry of await entries(from)) {
220
+ claims.push({
221
+ target: path.join(into, entry),
222
+ source: path.join(from, entry),
223
+ app: app.name,
224
+ what,
225
+ });
226
+ }
227
+ }
228
+ else {
229
+ claims.push({
230
+ target: path.join(into, app.name),
231
+ source: from,
232
+ app: app.name,
233
+ what,
234
+ });
235
+ }
236
+ }
237
+ }
238
+ return claims;
239
+ };
240
+ /**
241
+ * Apps that cannot be served together from one deployment.
242
+ *
243
+ * Two apps claiming the same path, or an app claiming one the monolith already
244
+ * serves, is not something a monolith can resolve — the path can only belong to
245
+ * one of them. Most distributions never collide; the ones that do have to be
246
+ * deployed separately, a subdomain each.
247
+ */
248
+ const findCollisions = async (monolithRoot, claims) => {
249
+ const problems = [];
250
+ const byTarget = new Map();
251
+ for (const claim of claims) {
252
+ byTarget.set(claim.target, [...(byTarget.get(claim.target) ?? []), claim]);
253
+ }
254
+ for (const [target, claimants] of byTarget) {
255
+ const where = path.relative(monolithRoot, target);
256
+ if (claimants.length > 1) {
257
+ const names = [...new Set(claimants.map((c) => `"${c.app}"`))];
258
+ problems.push(`${names.join(' and ')} both serve ${where} (${claimants[0].what}).`);
259
+ continue;
260
+ }
261
+ const [claim] = claimants;
262
+ const existing = await lstat(target).catch(() => undefined);
263
+ if (!existing)
264
+ continue;
265
+ // A symlink pointing where this app would point is a previous run's.
266
+ if (existing.isSymbolicLink() && (await pointsAt(target, claim.source)))
267
+ continue;
268
+ if (existing.isSymbolicLink())
269
+ continue;
270
+ problems.push(`"${claim.app}" serves ${where} (${claim.what}), which the monolith ` +
271
+ 'already has.');
272
+ }
273
+ return problems;
274
+ };
275
+ /**
276
+ * Mount an app at the site root, entry by entry.
277
+ *
278
+ * An app served at `/` has no directory of its own — its `about/` becomes the
279
+ * monolith's `about/`. So each entry is linked individually. Whether any of
280
+ * them clash with the monolith's own files, or another app's, is settled by
281
+ * the collision check before anything here runs.
282
+ */
283
+ const linkAtRoot = async (from, into, monolithRoot) => {
284
+ const linked = [];
285
+ await mkdir(into, { recursive: true });
286
+ for (const entry of await readdir(from, { withFileTypes: true })) {
287
+ if (IGNORED.has(entry.name))
288
+ continue;
289
+ const source = path.join(from, entry.name);
290
+ const target = path.join(into, entry.name);
291
+ await linkSource(source, target, monolithRoot);
292
+ linked.push(target);
293
+ }
294
+ return linked;
295
+ };
296
+ /**
297
+ * Mount an app's Pages Router routes.
298
+ *
299
+ * `pages/api` gets its own mount at `pages/api/<name>`, because Next only
300
+ * treats files directly under `pages/api/` as API routes — nesting it under
301
+ * `pages/<name>/api` would turn the handlers into pages. Anything else is
302
+ * linked entry by entry so that split stays possible.
303
+ */
304
+ const linkPages = async (app, sourcePagesDir, monolithRoot) => {
305
+ if (!app.pagesDir)
306
+ return [];
307
+ const mounted = [];
308
+ if (app.pagesApiDir) {
309
+ // At the site root its api routes are the monolith's: /api/x, not /api/www/x.
310
+ const target = app.prefix === ''
311
+ ? path.join(sourcePagesDir, 'api')
312
+ : path.join(sourcePagesDir, 'api', app.name);
313
+ if (app.prefix === '') {
314
+ mounted.push(...(await linkAtRoot(app.pagesApiDir, target, monolithRoot)));
315
+ }
316
+ else {
317
+ await linkSource(app.pagesApiDir, target, monolithRoot);
318
+ mounted.push(target);
319
+ }
320
+ }
321
+ for (const entry of await readdir(app.pagesDir, { withFileTypes: true })) {
322
+ if (entry.name === 'api' || IGNORED.has(entry.name))
323
+ continue;
324
+ const target = path.join(sourcePagesDir, app.name, entry.name);
325
+ await linkSource(path.join(app.pagesDir, entry.name), target, monolithRoot);
326
+ mounted.push(target);
327
+ }
328
+ return mounted;
329
+ };
330
+ /**
331
+ * Point the committed symlinks at each app, then produce whatever Next reads.
332
+ *
333
+ * `public/<name>` is served straight through its symlink — only route
334
+ * discovery needs the derived tree.
335
+ */
336
+ /**
337
+ * Refuse a layout where the derived tree would be written over the monolith's
338
+ * own routes.
339
+ *
340
+ * `app/` and `pages/` are rebuilt and cleared on every run, so they cannot also
341
+ * be where the monolith keeps its source. A conventional Next app puts them
342
+ * exactly there, and deriving over it would delete the lot.
343
+ *
344
+ * Checked before anything is written, since mounting creates the committed tree
345
+ * and would otherwise make this look like a layout that was always derived.
346
+ */
347
+ const assertDerivable = async (monolithRoot, options) => {
348
+ for (const [source, name] of [
349
+ [options.sourceDir, 'app'],
350
+ [options.sourcePagesDir, 'pages'],
351
+ ]) {
352
+ const target = path.join(monolithRoot, name);
353
+ const targetExists = (await lstat(target).catch(() => undefined)) !== undefined;
354
+ const sourceExists = (await lstat(source).catch(() => undefined)) !== undefined;
355
+ // A tree this built before is ours to rebuild, however it looks now.
356
+ const ours = targetExists && (await isDerived(target));
357
+ if (path.resolve(source) === path.resolve(target) ||
358
+ (targetExists && !sourceExists && !ours)) {
359
+ throw new Error(`The monolith keeps its routes in ${name}/, which is where the mounted ` +
360
+ `tree is built and cleared. Move them to ${path.relative(monolithRoot, source)}/ ` +
361
+ `— that is the tree that is committed, and ${name}/ is derived from it.`);
362
+ }
363
+ }
364
+ };
365
+ export const linkApps = async (monolithRoot, apps, options) => {
366
+ await assertDerivable(monolithRoot, options);
367
+ const mounted = [];
368
+ // An app resolved from node_modules cannot be linked into the committed
369
+ // tree: the path is machine-specific, and Turbopack will not process a route
370
+ // whose real path is inside node_modules. Its files are copied instead.
371
+ const fromPackage = apps.filter((app) => app.source === 'package');
372
+ const fromPath = apps.filter((app) => app.source !== 'package');
373
+ // Only one app can be served at the site root.
374
+ const atRoot = apps.filter((app) => app.prefix === '');
375
+ if (atRoot.length > 1) {
376
+ throw new Error(`Only one app can be served at the site root; ${atRoot
377
+ .map((app) => `"${app.name}"`)
378
+ .join(' and ')} both are.`);
379
+ }
380
+ const collisions = await findCollisions(monolithRoot, await claimsOf(monolithRoot, apps, options));
381
+ if (collisions.length > 0) {
382
+ throw new Error([
383
+ 'These apps cannot be served from one deployment:',
384
+ ...collisions.map((problem) => ` - ${problem}`),
385
+ 'A path can only belong to one of them. Rename a mount, or deploy the ' +
386
+ 'apps separately — a subdomain each — rather than as a monolith.',
387
+ ].join('\n'));
388
+ }
389
+ for (const app of fromPath) {
390
+ if (options.selfReference !== false)
391
+ await linkSelfReference(app);
392
+ if (app.prefix === '') {
393
+ mounted.push(...(await linkAtRoot(app.appDir, options.sourceDir, monolithRoot)));
394
+ if (app.publicDir) {
395
+ mounted.push(...(await linkAtRoot(app.publicDir, path.join(monolithRoot, 'public'), monolithRoot)));
396
+ }
397
+ mounted.push(...(await linkPages(app, options.sourcePagesDir, monolithRoot)));
398
+ continue;
399
+ }
400
+ const routes = path.join(options.sourceDir, app.name);
401
+ await linkSource(app.appDir, routes, monolithRoot);
402
+ mounted.push(routes);
403
+ if (app.publicDir) {
404
+ const assets = path.join(monolithRoot, 'public', app.name);
405
+ await linkSource(app.publicDir, assets, monolithRoot);
406
+ mounted.push(assets);
407
+ }
408
+ mounted.push(...(await linkPages(app, options.sourcePagesDir, monolithRoot)));
409
+ }
410
+ const appTarget = path.join(monolithRoot, 'app');
411
+ const pagesTarget = path.join(monolithRoot, 'pages');
412
+ // Only path-sourced apps write into the committed pages tree; a
413
+ // package-sourced one is copied straight into `pages/` further down, so
414
+ // counting it here would sync from a source that was never created.
415
+ const hasPages = fromPath.some((app) => app.pagesDir !== undefined);
416
+ // Next refuses to start when `app` and `pages` live in different folders, so
417
+ // once the Pages Router forces a derived tree the App Router needs one too.
418
+ // A package-sourced app forces one as well, having nothing in the committed
419
+ // tree to be read from.
420
+ const strategy = options.strategy === 'source' && (hasPages || fromPackage.length > 0)
421
+ ? 'mirror'
422
+ : options.strategy;
423
+ if (strategy === 'source') {
424
+ // Next falls through to the committed tree only when these are absent, so
425
+ // leftovers from a dev session must not be allowed to shadow it.
426
+ await clear(appTarget, monolithRoot);
427
+ await clear(pagesTarget, monolithRoot);
428
+ return mounted;
429
+ }
430
+ const stale = await lstat(appTarget).catch(() => undefined);
431
+ if (stale?.isSymbolicLink())
432
+ await clear(appTarget, monolithRoot);
433
+ // Names copied in below, which deriving the tree must not treat as orphans.
434
+ const copied = new Set(fromPackage.map((app) => app.name));
435
+ if (strategy === 'mirror') {
436
+ await mirrorTree(options.sourceDir, appTarget, copied);
437
+ if (options.watch)
438
+ watchMirror(options.sourceDir, appTarget, copied);
439
+ }
440
+ else {
441
+ await duplicate(options.sourceDir, appTarget, strategy, options.watch);
442
+ }
443
+ await markDerived(appTarget);
444
+ mounted.push(appTarget);
445
+ const materialise = strategy === 'copy' ? 'copy' : 'hardlink';
446
+ if (hasPages) {
447
+ await duplicate(options.sourcePagesDir, pagesTarget, materialise, options.watch);
448
+ await markDerived(pagesTarget);
449
+ mounted.push(pagesTarget);
450
+ }
451
+ else if (fromPackage.every((app) => app.pagesApiDir === undefined)) {
452
+ await clear(pagesTarget, monolithRoot);
453
+ }
454
+ // After each tree exists, so deriving it cannot delete these again.
455
+ for (const app of fromPackage) {
456
+ const routes = path.join(appTarget, app.name);
457
+ await duplicate(app.appDir, routes, materialise, options.watch);
458
+ mounted.push(routes);
459
+ if (app.publicDir) {
460
+ const assets = path.join(monolithRoot, 'public', app.name);
461
+ await duplicate(app.publicDir, assets, materialise, false);
462
+ mounted.push(assets);
463
+ }
464
+ if (app.pagesApiDir) {
465
+ const api = path.join(pagesTarget, 'api', app.name);
466
+ await duplicate(app.pagesApiDir, api, materialise, options.watch);
467
+ await markDerived(pagesTarget);
468
+ mounted.push(api);
469
+ }
470
+ }
471
+ return mounted;
472
+ };
473
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,KAAK,GAEN,MAAM,S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CAAA;QAEpB,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;YAC1D,MAAM,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAA;YAC1D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACtB,CAAC;QAED,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;YACnD,MAAM,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;YACjE,MAAM,WAAW,CAAC,WAAW,CAAC,CAAA;YAC9B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Environment variable carrying where each app is mounted, as a JSON object
3
+ * keyed by package name.
4
+ *
5
+ * `basePath` is not used, so nothing prefixes an app's own URLs for it. An app
6
+ * that generates absolute paths — an OIDC discovery document, a link back to
7
+ * itself — reads its mount from here and prefixes them itself. Unset when the
8
+ * app runs standalone, which is the same as being mounted at the root.
9
+ */
10
+ export declare const MOUNTS_ENV = "MONOLITH_MOUNTS";
11
+ /**
12
+ * The shape of a `next/link` href, without depending on Next to say so.
13
+ *
14
+ * `pathname` is nullable because Next's own `UrlObject` allows it.
15
+ */
16
+ export type Href = string | {
17
+ pathname?: string | null | undefined;
18
+ };
19
+ /**
20
+ * Where this app is mounted, or `''` when it is running on its own.
21
+ *
22
+ * `process.env.MONOLITH_MOUNTS` is written out in full because bundlers only
23
+ * substitute a literal member access — a computed `process.env[NAME]` survives
24
+ * into the bundle and reads as undefined in the browser.
25
+ */
26
+ export declare const mountPrefix: (packageName: string) => string;
27
+ /**
28
+ * Move an app-relative href into the app's mount point.
29
+ *
30
+ * Only paths rooted at `/` belong to the app. Absolute URLs, protocol-relative
31
+ * URLs, fragments and relative paths are left alone, as is a path that already
32
+ * carries the prefix.
33
+ */
34
+ export declare const prefixHref: <T extends Href>(href: T, prefix: string) => T;
35
+ /** Build an app-relative path, for `router.push` and friends. */
36
+ export declare const createHref: (packageName: string) => (path: string) => string;
37
+ //# sourceMappingURL=mounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mounts.d.ts","sourceRoot":"","sources":["../src/mounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,oBAAoB,CAAA;AAE3C;;;;GAIG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,CAAA;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,aAAa,MAAM,KAAG,MAUjD,CAAA;AAMD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,IAAI,EAAE,MAAM,CAAC,EAAE,QAAQ,MAAM,KAAG,CAmBpE,CAAA;AAED,iEAAiE;AACjE,eAAO,MAAM,UAAU,GACpB,aAAa,MAAM,MACnB,MAAM,MAAM,KAAG,MAC4B,CAAA"}
package/dist/mounts.js ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Environment variable carrying where each app is mounted, as a JSON object
3
+ * keyed by package name.
4
+ *
5
+ * `basePath` is not used, so nothing prefixes an app's own URLs for it. An app
6
+ * that generates absolute paths — an OIDC discovery document, a link back to
7
+ * itself — reads its mount from here and prefixes them itself. Unset when the
8
+ * app runs standalone, which is the same as being mounted at the root.
9
+ */
10
+ export const MOUNTS_ENV = 'MONOLITH_MOUNTS';
11
+ /**
12
+ * Where this app is mounted, or `''` when it is running on its own.
13
+ *
14
+ * `process.env.MONOLITH_MOUNTS` is written out in full because bundlers only
15
+ * substitute a literal member access — a computed `process.env[NAME]` survives
16
+ * into the bundle and reads as undefined in the browser.
17
+ */
18
+ export const mountPrefix = (packageName) => {
19
+ try {
20
+ const mounts = JSON.parse(process.env.MONOLITH_MOUNTS ?? '{}');
21
+ return mounts[packageName] ?? '';
22
+ }
23
+ catch {
24
+ return '';
25
+ }
26
+ };
27
+ /** Whether `path` is the mount itself or something under it, query and fragment included. */
28
+ const isUnder = (path, prefix) => path.startsWith(prefix) && ['', '/', '?', '#'].includes(path.charAt(prefix.length));
29
+ /**
30
+ * Move an app-relative href into the app's mount point.
31
+ *
32
+ * Only paths rooted at `/` belong to the app. Absolute URLs, protocol-relative
33
+ * URLs, fragments and relative paths are left alone, as is a path that already
34
+ * carries the prefix.
35
+ */
36
+ export const prefixHref = (href, prefix) => {
37
+ if (!prefix)
38
+ return href;
39
+ if (typeof href === 'string') {
40
+ if (!href.startsWith('/') || href.startsWith('//'))
41
+ return href;
42
+ if (isUnder(href, prefix))
43
+ return href;
44
+ // The app's root is the mount itself, as it is under Next's basePath:
45
+ // `/id`, not `/id/`, which is a redirect away.
46
+ if (href === '/' || href.startsWith('/?') || href.startsWith('/#')) {
47
+ return `${prefix}${href.slice(1)}`;
48
+ }
49
+ return `${prefix}${href}`;
50
+ }
51
+ if (href && typeof href === 'object' && typeof href.pathname === 'string') {
52
+ return { ...href, pathname: prefixHref(href.pathname, prefix) };
53
+ }
54
+ return href;
55
+ };
56
+ /** Build an app-relative path, for `router.push` and friends. */
57
+ export const createHref = (packageName) => (path) => prefixHref(path, mountPrefix(packageName));
58
+ //# sourceMappingURL=mounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mounts.js","sourceRoot":"","sources":["../src/mounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,G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CAAC;QACD,OAAO,GAAG,MAAM,GAAG,IAAI,EAAO,CAAA;IAChC,CAAC;IAED,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1E,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAO,CAAA;IACtE,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,UAAU,GACrB,CAAC,WAAmB,EAAE,EAAE,CACxB,CAAC,IAAY,EAAU,EAAE,CACvB,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA"}
@@ -0,0 +1,38 @@
1
+ import type { ResolvedApp } from './types.ts';
2
+ type PackageJson = Record<string, unknown>;
3
+ /**
4
+ * Packages the app's route files import directly.
5
+ *
6
+ * Both route trees need these from the monolith, for different reasons. Pages
7
+ * Router files are copied, so their real path is inside the monolith and the
8
+ * app's `node_modules` is no longer above them. App Router files are only
9
+ * symlinked, and Turbopack does resolve those against the app — but TypeScript
10
+ * resolves from where the file sits in the monolith, so it needs them too.
11
+ *
12
+ * Only *direct* imports matter. Anything an app reaches through its own package
13
+ * name resolves via the monolith's link to the app and carries on from there.
14
+ */
15
+ export declare const routeImports: (app: ResolvedApp) => Promise<Set<string>>;
16
+ export interface MergeOptions {
17
+ /**
18
+ * Take every dependency rather than only what the route trees import.
19
+ * Use when something outside the route trees is resolved from the monolith.
20
+ */
21
+ all?: boolean;
22
+ }
23
+ export interface MergeResult {
24
+ packageJson: PackageJson;
25
+ changed: boolean;
26
+ /** What was taken from each app, for reporting. */
27
+ taken: Map<string, string[]>;
28
+ }
29
+ /**
30
+ * Fold what each app needs from the monolith into its package.json.
31
+ *
32
+ * Uses a three-way merge against an empty base so conflicting ranges are
33
+ * resolved by semver rather than by whichever app happens to be last.
34
+ */
35
+ export declare const mergeAppDependencies: (monolithPackageJsonPath: string, apps: ResolvedApp[], options?: MergeOptions) => Promise<MergeResult>;
36
+ export declare const writePackageJson: (file: string, packageJson: PackageJson) => Promise<void>;
37
+ export {};
38
+ //# sourceMappingURL=package-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../src/package-json.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAS7C,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAwC1C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAU,KAAK,WAAW,KAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAkBxE,CAAA;AA4CD,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,WAAW,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,mDAAmD;IACnD,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CAC7B;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,yBAAyB,MAAM,EAC/B,MAAM,WAAW,EAAE,EACnB,UAAS,YAAiB,KACzB,OAAO,CAAC,WAAW,CAoCrB,CAAA;AAWD,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,EACZ,aAAa,WAAW,KACvB,OAAO,CAAC,IAAI,CAEd,CAAA"}