@payloadcms/figma 0.1.0-alpha.2 → 0.1.0-alpha.3

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 (151) hide show
  1. package/dist/api/control-plane.d.ts +1 -1
  2. package/dist/api/control-plane.js +1 -1
  3. package/dist/cli.d.ts +30 -0
  4. package/dist/cli.js +33 -33
  5. package/dist/commands/deploy.d.ts +2 -0
  6. package/dist/commands/deploy.js +22 -12
  7. package/dist/db-content-api/index.d.ts +1 -1
  8. package/dist/db-content-api/index.js +70 -40
  9. package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
  10. package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
  11. package/dist/exports/client.d.ts +2 -0
  12. package/dist/exports/client.js +2 -0
  13. package/dist/plugin/build-config.js +32 -3
  14. package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +9 -0
  15. package/dist/plugin/cloud-limits/CloudLimitModal/index.js +78 -0
  16. package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +51 -0
  17. package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +7 -0
  18. package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +169 -0
  19. package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +2 -0
  20. package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
  21. package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +9 -0
  22. package/dist/plugin/cloud-limits/SlugTracker/index.js +23 -0
  23. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +2 -0
  24. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
  25. package/dist/plugin/cloud-limits/shared.d.ts +10 -0
  26. package/dist/plugin/cloud-limits/shared.js +27 -0
  27. package/dist/translations/ar.d.ts +12 -0
  28. package/dist/translations/ar.js +12 -0
  29. package/dist/translations/az.d.ts +12 -0
  30. package/dist/translations/az.js +12 -0
  31. package/dist/translations/bg.d.ts +12 -0
  32. package/dist/translations/bg.js +12 -0
  33. package/dist/translations/bnBd.d.ts +12 -0
  34. package/dist/translations/bnBd.js +12 -0
  35. package/dist/translations/bnIn.d.ts +12 -0
  36. package/dist/translations/bnIn.js +12 -0
  37. package/dist/translations/ca.d.ts +12 -0
  38. package/dist/translations/ca.js +12 -0
  39. package/dist/translations/cs.d.ts +12 -0
  40. package/dist/translations/cs.js +12 -0
  41. package/dist/translations/da.d.ts +12 -0
  42. package/dist/translations/da.js +12 -0
  43. package/dist/translations/de.d.ts +12 -0
  44. package/dist/translations/de.js +12 -0
  45. package/dist/translations/en.d.ts +12 -0
  46. package/dist/translations/en.js +12 -0
  47. package/dist/translations/es.d.ts +12 -0
  48. package/dist/translations/es.js +12 -0
  49. package/dist/translations/et.d.ts +12 -0
  50. package/dist/translations/et.js +12 -0
  51. package/dist/translations/fa.d.ts +12 -0
  52. package/dist/translations/fa.js +12 -0
  53. package/dist/translations/fr.d.ts +12 -0
  54. package/dist/translations/fr.js +12 -0
  55. package/dist/translations/he.d.ts +12 -0
  56. package/dist/translations/he.js +12 -0
  57. package/dist/translations/hr.d.ts +12 -0
  58. package/dist/translations/hr.js +12 -0
  59. package/dist/translations/hu.d.ts +12 -0
  60. package/dist/translations/hu.js +12 -0
  61. package/dist/translations/hy.d.ts +12 -0
  62. package/dist/translations/hy.js +12 -0
  63. package/dist/translations/id.d.ts +12 -0
  64. package/dist/translations/id.js +12 -0
  65. package/dist/translations/index.d.ts +533 -0
  66. package/dist/translations/index.js +90 -0
  67. package/dist/translations/is.d.ts +12 -0
  68. package/dist/translations/is.js +12 -0
  69. package/dist/translations/it.d.ts +12 -0
  70. package/dist/translations/it.js +12 -0
  71. package/dist/translations/ja.d.ts +12 -0
  72. package/dist/translations/ja.js +12 -0
  73. package/dist/translations/ko.d.ts +12 -0
  74. package/dist/translations/ko.js +12 -0
  75. package/dist/translations/lt.d.ts +12 -0
  76. package/dist/translations/lt.js +12 -0
  77. package/dist/translations/lv.d.ts +12 -0
  78. package/dist/translations/lv.js +12 -0
  79. package/dist/translations/my.d.ts +12 -0
  80. package/dist/translations/my.js +12 -0
  81. package/dist/translations/nb.d.ts +12 -0
  82. package/dist/translations/nb.js +12 -0
  83. package/dist/translations/nl.d.ts +12 -0
  84. package/dist/translations/nl.js +12 -0
  85. package/dist/translations/pl.d.ts +12 -0
  86. package/dist/translations/pl.js +12 -0
  87. package/dist/translations/pt.d.ts +12 -0
  88. package/dist/translations/pt.js +12 -0
  89. package/dist/translations/ro.d.ts +12 -0
  90. package/dist/translations/ro.js +12 -0
  91. package/dist/translations/rs.d.ts +12 -0
  92. package/dist/translations/rs.js +12 -0
  93. package/dist/translations/rsLatin.d.ts +12 -0
  94. package/dist/translations/rsLatin.js +12 -0
  95. package/dist/translations/ru.d.ts +12 -0
  96. package/dist/translations/ru.js +12 -0
  97. package/dist/translations/sk.d.ts +12 -0
  98. package/dist/translations/sk.js +12 -0
  99. package/dist/translations/sl.d.ts +12 -0
  100. package/dist/translations/sl.js +12 -0
  101. package/dist/translations/sv.d.ts +12 -0
  102. package/dist/translations/sv.js +12 -0
  103. package/dist/translations/ta.d.ts +12 -0
  104. package/dist/translations/ta.js +12 -0
  105. package/dist/translations/th.d.ts +12 -0
  106. package/dist/translations/th.js +12 -0
  107. package/dist/translations/tr.d.ts +12 -0
  108. package/dist/translations/tr.js +12 -0
  109. package/dist/translations/uk.d.ts +12 -0
  110. package/dist/translations/uk.js +12 -0
  111. package/dist/translations/vi.d.ts +12 -0
  112. package/dist/translations/vi.js +12 -0
  113. package/dist/translations/zh.d.ts +12 -0
  114. package/dist/translations/zh.js +12 -0
  115. package/dist/translations/zhTw.d.ts +12 -0
  116. package/dist/translations/zhTw.js +12 -0
  117. package/dist/types.d.ts +2 -0
  118. package/dist/utils/adapters/nextjs.d.ts +3 -3
  119. package/dist/utils/adapters/nextjs.js +9 -7
  120. package/dist/utils/adapters/nitro.d.ts +3 -3
  121. package/dist/utils/adapters/nitro.js +73 -77
  122. package/dist/utils/adapters/vite.d.ts +1 -1
  123. package/dist/utils/adapters/vite.js +8 -7
  124. package/dist/utils/assert-never.d.ts +1 -0
  125. package/dist/utils/assert-never.js +3 -0
  126. package/dist/utils/asset-collection.d.ts +2 -2
  127. package/dist/utils/asset-collection.js +10 -15
  128. package/dist/utils/build-detection.d.ts +6 -1
  129. package/dist/utils/build-detection.js +68 -89
  130. package/dist/utils/build-lambda-zip.d.ts +5 -6
  131. package/dist/utils/build-lambda-zip.js +31 -48
  132. package/dist/utils/deploy-adapter.d.ts +4 -4
  133. package/dist/utils/deploy-adapter.js +12 -8
  134. package/dist/utils/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
  135. package/dist/utils/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
  136. package/dist/utils/deploy-output/inspectNextjsOutput.d.ts +12 -0
  137. package/dist/utils/deploy-output/inspectNextjsOutput.js +28 -0
  138. package/dist/utils/deploy-output/inspectNitroOutput.d.ts +9 -0
  139. package/dist/utils/deploy-output/inspectNitroOutput.js +13 -0
  140. package/dist/utils/deploy-output/isFile.d.ts +1 -0
  141. package/dist/utils/deploy-output/isFile.js +4 -0
  142. package/dist/utils/deploy-output/readJson.d.ts +1 -0
  143. package/dist/utils/deploy-output/readJson.js +9 -0
  144. package/dist/utils/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
  145. package/dist/utils/deploy-output/resolveNitroOutputLayout.js +16 -0
  146. package/dist/utils/deploy-output/resolveOutputPath.d.ts +2 -0
  147. package/dist/utils/deploy-output/resolveOutputPath.js +9 -0
  148. package/dist/utils/deploy-output/resolveWithin.d.ts +1 -0
  149. package/dist/utils/deploy-output/resolveWithin.js +12 -0
  150. package/dist/utils/messages.js +2 -0
  151. package/package.json +5 -5
@@ -1,8 +1,8 @@
1
1
  import type { AssetCollection, DeployAdapter, LambdaBundle, PageCollection } from '../deploy-adapter.js';
2
2
  export declare class NextjsAdapter implements DeployAdapter {
3
3
  name: "nextjs";
4
- collectAssets(projectPath: string): Promise<AssetCollection>;
5
- collectPages(projectPath: string): Promise<PageCollection>;
6
- prepareLambdaBundle(projectPath: string): Promise<LambdaBundle>;
4
+ collectAssets(projectPath: string, output?: string): Promise<AssetCollection>;
5
+ collectPages(projectPath: string, output?: string): Promise<PageCollection>;
6
+ prepareLambdaBundle(projectPath: string, output?: string): Promise<LambdaBundle>;
7
7
  }
8
8
  export declare const nextjsAdapter: NextjsAdapter;
@@ -2,12 +2,14 @@ import fs from 'fs/promises';
2
2
  import path from 'path';
3
3
  import { collectSSGAssets, collectStaticAssets } from '../asset-collection.js';
4
4
  import { buildLambdaZip } from '../build-lambda-zip.js';
5
+ import { resolveOutputPath } from '../deploy-output/resolveOutputPath.js';
5
6
  import { collectFilesRecursive } from '../fs-utils.js';
6
7
  export class NextjsAdapter {
7
8
  name = 'nextjs';
8
- async collectAssets(projectPath) {
9
+ async collectAssets(projectPath, output) {
9
10
  // Bundle assets: .next/static/ → _next/static/
10
- const staticAssets = await collectStaticAssets(projectPath);
11
+ const staticAssets = await collectStaticAssets(projectPath, output);
12
+ const outputPath = resolveOutputPath(projectPath, 'nextjs', output);
11
13
  // Public assets: public/ directory
12
14
  const publicDir = path.join(projectPath, 'public');
13
15
  let publicAssets = [];
@@ -23,7 +25,7 @@ export class NextjsAdapter {
23
25
  ];
24
26
  const pathMap = {};
25
27
  for (const key of staticAssets){
26
- pathMap[key] = key.replace(/^_next\//, '.next/');
28
+ pathMap[key] = path.relative(projectPath, path.join(outputPath, key.replace(/^_next\//, '')));
27
29
  }
28
30
  for (const key of publicAssets){
29
31
  pathMap[key] = path.join('public', key);
@@ -34,8 +36,8 @@ export class NextjsAdapter {
34
36
  uploadKeys: allKeys
35
37
  };
36
38
  }
37
- async collectPages(projectPath) {
38
- const ssg = await collectSSGAssets(projectPath);
39
+ async collectPages(projectPath, output) {
40
+ const ssg = await collectSSGAssets(projectPath, output);
39
41
  // Build route → asset keys mapping and extract unique routes
40
42
  const routeAssetMap = {};
41
43
  for (const key of ssg.keys){
@@ -54,8 +56,8 @@ export class NextjsAdapter {
54
56
  uploadKeys: ssg.keys
55
57
  };
56
58
  }
57
- async prepareLambdaBundle(projectPath) {
58
- return buildLambdaZip(projectPath);
59
+ async prepareLambdaBundle(projectPath, output) {
60
+ return buildLambdaZip(projectPath, output);
59
61
  }
60
62
  }
61
63
  export const nextjsAdapter = new NextjsAdapter();
@@ -1,8 +1,8 @@
1
1
  import type { AssetCollection, DeployAdapter, LambdaBundle, PageCollection } from '../deploy-adapter.js';
2
2
  export declare class NitroAdapter implements DeployAdapter {
3
3
  name: "nitro";
4
- collectAssets(projectPath: string): Promise<AssetCollection>;
5
- collectPages(projectPath: string): Promise<PageCollection>;
6
- prepareLambdaBundle(projectPath: string): Promise<LambdaBundle>;
4
+ collectAssets(projectPath: string, output?: string): Promise<AssetCollection>;
5
+ collectPages(projectPath: string, output?: string): Promise<PageCollection>;
6
+ prepareLambdaBundle(projectPath: string, output?: string): Promise<LambdaBundle>;
7
7
  }
8
8
  export declare const nitroAdapter: NitroAdapter;
@@ -2,62 +2,39 @@ import archiver from 'archiver';
2
2
  import { createWriteStream, statSync } from 'fs';
3
3
  import fs from 'fs/promises';
4
4
  import path from 'path';
5
+ import { resolveNitroOutputLayout } from '../deploy-output/resolveNitroOutputLayout.js';
6
+ import { resolveOutputPath } from '../deploy-output/resolveOutputPath.js';
5
7
  import { collectFilesRecursive, getDirectorySize } from '../fs-utils.js';
6
- const RUN_SCRIPT = `#!/bin/bash -x
7
- [ ! -d '/tmp/cache' ] && mkdir -p /tmp/cache
8
- NODE_ENV=production exec node server/index.mjs
9
- `;
10
- /** Directories in .output/public/ that are NOT pre-rendered pages */ const NON_PAGE_DIRS = new Set([
11
- '_next',
8
+ /** Framework asset directories that are not pre-rendered pages. */ const NON_PAGE_DIRS = new Set([
9
+ '_build',
10
+ '_nuxt',
12
11
  'assets'
13
12
  ]);
14
13
  export class NitroAdapter {
15
14
  name = 'nitro';
16
- async collectAssets(projectPath) {
17
- const publicDir = path.join(projectPath, '.output', 'public');
18
- const assets = [];
19
- const pathMap = {};
20
- // Collect flat files in .output/public/ (public dir assets)
21
- try {
22
- const entries = await fs.readdir(publicDir, {
23
- withFileTypes: true
24
- });
25
- for (const entry of entries){
26
- if (entry.isFile()) {
27
- assets.push(entry.name);
28
- pathMap[entry.name] = path.join('.output', 'public', entry.name);
29
- }
30
- }
31
- } catch {
32
- // No public directory
33
- }
34
- // Collect bundle assets from .output/public/_next/static/
35
- const bundleDir = path.join(publicDir, '_next', 'static');
36
- try {
37
- const bundleFiles = await collectFilesRecursive(bundleDir, bundleDir);
38
- for (const file of bundleFiles){
39
- const key = `_next/static/${file}`;
40
- assets.push(key);
41
- pathMap[key] = path.join('.output', 'public', '_next', 'static', file);
42
- }
43
- } catch {
44
- // No bundle directory
45
- }
15
+ async collectAssets(projectPath, output) {
16
+ const { publicPath } = await getLayout(projectPath, output);
17
+ const pageKeys = new Set((await scanForPages(publicPath, publicPath)).map(toPageUploadKey));
18
+ const assets = (await collectFilesRecursive(publicPath, publicPath)).filter((file)=>!pageKeys.has(file));
19
+ const pathMap = Object.fromEntries(assets.map((file)=>[
20
+ file,
21
+ path.relative(projectPath, path.join(publicPath, file))
22
+ ]));
46
23
  return {
47
24
  pathMap,
48
25
  routes: assets.map((k)=>`/${k}`),
49
26
  uploadKeys: assets
50
27
  };
51
28
  }
52
- async collectPages(projectPath) {
53
- const publicDir = path.join(projectPath, '.output', 'public');
54
- const pages = await scanForPages(publicDir, publicDir);
29
+ async collectPages(projectPath, output) {
30
+ const { publicPath } = await getLayout(projectPath, output);
31
+ const pages = await scanForPages(publicPath, publicPath);
55
32
  const routes = pages.map((p)=>p === 'index' ? '/' : `/${p}`);
56
- const uploadKeys = pages.map((p)=>p === 'index' ? 'index.html' : `${p}/index.html`);
33
+ const uploadKeys = pages.map(toPageUploadKey);
57
34
  const pathMap = {};
58
35
  const routeAssetMap = {};
59
36
  for(let i = 0; i < uploadKeys.length; i++){
60
- pathMap[uploadKeys[i]] = path.join('.output', 'public', uploadKeys[i]);
37
+ pathMap[uploadKeys[i]] = path.relative(projectPath, path.join(publicPath, uploadKeys[i]));
61
38
  routeAssetMap[routes[i]] = [
62
39
  uploadKeys[i]
63
40
  ];
@@ -69,52 +46,68 @@ export class NitroAdapter {
69
46
  uploadKeys
70
47
  };
71
48
  }
72
- async prepareLambdaBundle(projectPath) {
73
- const zipPath = path.join(projectPath, 'lambda.zip');
74
- const serverDir = path.join(projectPath, '.output', 'server');
75
- const publicDir = path.join(projectPath, '.output', 'public');
76
- // Verify server directory exists
49
+ async prepareLambdaBundle(projectPath, output) {
50
+ const layout = await getLayout(projectPath, output);
77
51
  try {
78
- await fs.stat(serverDir);
52
+ const stat = await fs.stat(layout.serverEntryPath);
53
+ if (!stat.isFile()) {
54
+ throw new Error('not a file');
55
+ }
79
56
  } catch {
80
- throw new Error('Nitro server build not found at .output/server. Run build first.');
57
+ throw new Error(`Nitro server build not found at ${layout.outputPath}`);
81
58
  }
82
- // Write run.sh to a temp location
83
- const runShPath = path.join(projectPath, '.output', 'run.sh');
84
- await fs.writeFile(runShPath, RUN_SCRIPT, {
59
+ const serverDir = path.dirname(layout.serverEntryPath);
60
+ const serverPrefix = path.relative(layout.outputPath, serverDir).split(path.sep).join('/');
61
+ const publicPrefix = path.relative(layout.outputPath, layout.publicPath).split(path.sep).join('/');
62
+ const serverEntry = path.relative(layout.outputPath, layout.serverEntryPath).split(path.sep).join('/');
63
+ const runShPath = path.join(layout.outputPath, 'run.sh');
64
+ await fs.writeFile(runShPath, createRunScript(serverEntry), {
85
65
  mode: 0o755
86
66
  });
87
- // Create zip: server/ + public/ + run.sh
88
- await createZip(zipPath, [
89
- {
90
- prefix: 'server/',
91
- source: serverDir
92
- },
93
- {
94
- prefix: 'public/',
95
- source: publicDir
96
- },
97
- {
98
- prefix: '',
99
- source: runShPath
100
- }
101
- ]);
102
- const runShStat = await fs.stat(runShPath);
103
- const unzippedBytes = await getDirectorySize(serverDir) + await getDirectorySize(publicDir) + runShStat.size;
104
- // Clean up temp run.sh
105
- await fs.rm(runShPath, {
106
- force: true
107
- });
108
- return {
109
- unzippedBytes,
110
- zipPath
111
- };
67
+ const zipPath = path.join(projectPath, 'lambda.zip');
68
+ try {
69
+ await createZip(zipPath, [
70
+ {
71
+ prefix: `${serverPrefix}/`,
72
+ source: serverDir
73
+ },
74
+ {
75
+ prefix: `${publicPrefix}/`,
76
+ source: layout.publicPath
77
+ },
78
+ {
79
+ prefix: '',
80
+ source: runShPath
81
+ }
82
+ ]);
83
+ const runShStat = await fs.stat(runShPath);
84
+ const unzippedBytes = await getDirectorySize(serverDir) + await getDirectorySize(layout.publicPath) + runShStat.size;
85
+ return {
86
+ unzippedBytes,
87
+ zipPath
88
+ };
89
+ } finally{
90
+ await fs.rm(runShPath, {
91
+ force: true
92
+ });
93
+ }
112
94
  }
113
95
  }
114
96
  export const nitroAdapter = new NitroAdapter();
97
+ function getLayout(projectPath, output) {
98
+ const outputPath = resolveOutputPath(projectPath, 'nitro', output);
99
+ return resolveNitroOutputLayout(outputPath);
100
+ }
101
+ function createRunScript(serverEntry) {
102
+ const escapedEntry = serverEntry.replaceAll("'", "'\\''");
103
+ return `#!/bin/bash -x
104
+ [ ! -d '/tmp/cache' ] && mkdir -p /tmp/cache
105
+ NODE_ENV=production exec node '${escapedEntry}'
106
+ `;
107
+ }
115
108
  /**
116
109
  * Recursively scan for pre-rendered pages (directories containing index.html).
117
- * Skips known non-page directories (_next/, assets/).
110
+ * Skips known framework asset directories.
118
111
  */ async function scanForPages(dir, baseDir) {
119
112
  const pages = [];
120
113
  // Check if this directory has an index.html (it's a page)
@@ -142,6 +135,9 @@ export const nitroAdapter = new NitroAdapter();
142
135
  }
143
136
  return pages;
144
137
  }
138
+ function toPageUploadKey(page) {
139
+ return page === 'index' ? 'index.html' : `${page}/index.html`;
140
+ }
145
141
  async function createZip(zipPath, entries) {
146
142
  return new Promise((resolve, reject)=>{
147
143
  const output = createWriteStream(zipPath);
@@ -2,7 +2,7 @@ import type { AssetCollection, DeployAdapter, LambdaBundle, PageCollection } fro
2
2
  export declare class ViteAdapter implements DeployAdapter {
3
3
  fallback: string;
4
4
  name: "vite";
5
- collectAssets(projectPath: string): Promise<AssetCollection>;
5
+ collectAssets(projectPath: string, output?: string): Promise<AssetCollection>;
6
6
  collectPages(): Promise<PageCollection>;
7
7
  prepareLambdaBundle(): Promise<LambdaBundle | null>;
8
8
  }
@@ -1,15 +1,16 @@
1
1
  import path from 'path';
2
+ import { resolveOutputPath } from '../deploy-output/resolveOutputPath.js';
2
3
  import { collectFilesRecursive } from '../fs-utils.js';
3
4
  export class ViteAdapter {
4
5
  fallback = '/index.html';
5
6
  name = 'vite';
6
- async collectAssets(projectPath) {
7
- const distDir = path.join(projectPath, 'dist');
8
- const files = await collectFilesRecursive(distDir, distDir);
9
- const pathMap = {};
10
- for (const file of files){
11
- pathMap[file] = path.join('dist', file);
12
- }
7
+ async collectAssets(projectPath, output) {
8
+ const outputPath = resolveOutputPath(projectPath, 'vite', output);
9
+ const files = await collectFilesRecursive(outputPath, outputPath);
10
+ const pathMap = Object.fromEntries(files.map((file)=>[
11
+ file,
12
+ path.relative(projectPath, path.join(outputPath, file))
13
+ ]));
13
14
  return {
14
15
  pathMap,
15
16
  routes: files.map((k)=>`/${k}`),
@@ -0,0 +1 @@
1
+ export declare function assertNever(x: never): never;
@@ -0,0 +1,3 @@
1
+ export function assertNever(x) {
2
+ throw new Error('Unhandled case: ' + JSON.stringify(x));
3
+ }
@@ -14,7 +14,7 @@ export declare function getFileSize(filePath: string): Promise<number>;
14
14
  * @param projectPath - Path to project root
15
15
  * @returns Array of static asset paths (using _next prefix)
16
16
  */
17
- export declare function collectStaticAssets(projectPath: string): Promise<string[]>;
17
+ export declare function collectStaticAssets(projectPath: string, output?: string): Promise<string[]>;
18
18
  /**
19
19
  * Result from collecting SSG assets
20
20
  */
@@ -38,7 +38,7 @@ export type SSGAssets = {
38
38
  * @param projectPath - Path to project root
39
39
  * @returns SSG asset keys and a pathMap for filesystem resolution
40
40
  */
41
- export declare function collectSSGAssets(projectPath: string): Promise<SSGAssets>;
41
+ export declare function collectSSGAssets(projectPath: string, output?: string): Promise<SSGAssets>;
42
42
  /**
43
43
  * Create Lambda deployment zip
44
44
  *
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs/promises';
2
2
  import path from 'path';
3
3
  import { buildLambdaZip } from './build-lambda-zip.js';
4
+ import { resolveOutputPath } from './deploy-output/resolveOutputPath.js';
4
5
  import * as log from './log.js';
5
6
  // Maximum file size for static assets (S3 limitation)
6
7
  const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
@@ -64,19 +65,13 @@ const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
64
65
  *
65
66
  * @param projectPath - Path to project root
66
67
  * @returns Array of static asset paths (using _next prefix)
67
- */ export async function collectStaticAssets(projectPath) {
68
- const staticDir = path.join(projectPath, '.next', 'static');
69
- try {
70
- await fs.stat(staticDir);
71
- } catch {
72
- // No static directory
73
- return [];
74
- }
68
+ */ export async function collectStaticAssets(projectPath, output) {
69
+ const outputPath = resolveOutputPath(projectPath, 'nextjs', output);
70
+ const staticDir = path.join(outputPath, 'static');
75
71
  const files = await collectFiles(staticDir, projectPath);
76
- // Normalize paths to forward slashes (cross-platform) and convert prefix
77
72
  return files.map((file)=>{
78
- const normalized = file.split(path.sep).join('/');
79
- return normalized.replace(/^\.next\//, '_next/');
73
+ const relativeToStatic = path.relative(staticDir, path.resolve(projectPath, file));
74
+ return `_next/static/${relativeToStatic.split(path.sep).join('/')}`;
80
75
  });
81
76
  }
82
77
  /**
@@ -92,8 +87,9 @@ const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
92
87
  *
93
88
  * @param projectPath - Path to project root
94
89
  * @returns SSG asset keys and a pathMap for filesystem resolution
95
- */ export async function collectSSGAssets(projectPath) {
96
- const manifestPath = path.join(projectPath, '.next', 'prerender-manifest.json');
90
+ */ export async function collectSSGAssets(projectPath, output) {
91
+ const outputPath = resolveOutputPath(projectPath, 'nextjs', output);
92
+ const manifestPath = path.join(outputPath, 'prerender-manifest.json');
97
93
  let manifest;
98
94
  try {
99
95
  const raw = await fs.readFile(manifestPath, 'utf-8');
@@ -122,9 +118,8 @@ const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
122
118
  const stripped = routeKey === '/' ? 'index' : routeKey.replace(/^\//, '');
123
119
  for (const ext of extensions){
124
120
  const s3Key = `${stripped}${ext}`;
125
- const fsPath = path.join('.next', 'server', 'app', `${stripped}${ext}`);
126
121
  keys.push(s3Key);
127
- pathMap[s3Key] = fsPath;
122
+ pathMap[s3Key] = path.relative(projectPath, path.join(outputPath, 'server', 'app', `${stripped}${ext}`));
128
123
  }
129
124
  }
130
125
  return {
@@ -1,3 +1,4 @@
1
+ import type { AdapterName } from './deploy-adapter.js';
1
2
  /**
2
3
  * Information about a detected build
3
4
  */
@@ -11,11 +12,15 @@ export interface BuildInfo {
11
12
  /** Build timestamp */
12
13
  timestamp: Date;
13
14
  }
15
+ export interface DetectBuildOptions {
16
+ adapter?: AdapterName;
17
+ output?: string;
18
+ }
14
19
  /**
15
20
  * Detect a valid build across supported frameworks.
16
21
  * Tries NextJS, then Nitro, then Vite. Returns the first match.
17
22
  */
18
- export declare function detectBuild(projectPath: string): Promise<BuildInfo | null>;
23
+ export declare function detectBuild(projectPath: string, options: DetectBuildOptions): Promise<BuildInfo | null>;
19
24
  /**
20
25
  * Get the build command from package.json
21
26
  *
@@ -1,103 +1,82 @@
1
1
  import fs from 'fs/promises';
2
2
  import path from 'path';
3
+ import { assertNever } from './assert-never.js';
4
+ import { inspectNextjsOutput } from './deploy-output/inspectNextjsOutput.js';
5
+ import { inspectNitroOutput } from './deploy-output/inspectNitroOutput.js';
6
+ import { resolveOutputPath } from './deploy-output/resolveOutputPath.js';
3
7
  /**
4
8
  * Detect a valid build across supported frameworks.
5
9
  * Tries NextJS, then Nitro, then Vite. Returns the first match.
6
- */ export async function detectBuild(projectPath) {
7
- // Try NextJS first
8
- const nextjsBuild = await detectNextjsBuild(projectPath);
9
- if (nextjsBuild) {
10
- return nextjsBuild;
11
- }
12
- // Try Nitro
13
- const nitroBuild = await detectNitroBuild(projectPath);
14
- if (nitroBuild) {
15
- return nitroBuild;
16
- }
17
- // Try Vite
18
- const viteBuild = await detectViteBuild(projectPath);
19
- if (viteBuild) {
20
- return viteBuild;
21
- }
22
- return null;
23
- }
24
- /**
25
- * Detect NextJS standalone build (.next/standalone/server.js + .next/BUILD_ID)
26
- */ async function detectNextjsBuild(projectPath) {
27
- try {
28
- const serverPath = path.join(projectPath, '.next', 'standalone', 'server.js');
29
- const serverStat = await fs.stat(serverPath);
30
- const buildIdPath = path.join(projectPath, '.next', 'BUILD_ID');
31
- const buildId = (await fs.readFile(buildIdPath, 'utf-8')).trim();
32
- const lambdaZipPath = path.join(projectPath, 'lambda.zip');
33
- let hasLambdaZip = false;
34
- try {
35
- await fs.stat(lambdaZipPath);
36
- hasLambdaZip = true;
37
- } catch {
38
- hasLambdaZip = false;
10
+ */ export async function detectBuild(projectPath, options) {
11
+ const adapters = options.adapter ? [
12
+ options.adapter
13
+ ] : [
14
+ 'nextjs',
15
+ 'nitro',
16
+ 'vite'
17
+ ];
18
+ for (const adapter of adapters){
19
+ const outputPath = resolveOutputPath(projectPath, adapter, options.output);
20
+ const build = await detectAdapterBuild(projectPath, adapter, outputPath);
21
+ if (build) {
22
+ return build;
39
23
  }
40
- return {
41
- buildId,
42
- hasLambdaZip,
43
- path: '.next/standalone',
44
- timestamp: serverStat.mtime
45
- };
46
- } catch {
47
- return null;
48
24
  }
25
+ return null;
49
26
  }
50
- /**
51
- * Detect Nitro build (.output/server/index.mjs)
52
- * Build ID parsed from .output/nitro.json date field, or mtime of index.mjs
53
- */ async function detectNitroBuild(projectPath) {
54
- try {
55
- const indexPath = path.join(projectPath, '.output', 'server', 'index.mjs');
56
- const indexStat = await fs.stat(indexPath);
57
- let buildId = indexStat.mtime.toISOString();
58
- try {
59
- const nitroJsonPath = path.join(projectPath, '.output', 'nitro.json');
60
- const nitroJson = JSON.parse(await fs.readFile(nitroJsonPath, 'utf-8'));
61
- if (nitroJson.date) {
62
- buildId = nitroJson.date;
27
+ async function detectAdapterBuild(projectPath, adapter, outputPath) {
28
+ switch(adapter){
29
+ case 'nextjs':
30
+ {
31
+ const layout = await inspectNextjsOutput(outputPath);
32
+ if (!layout) {
33
+ return null;
34
+ }
35
+ const stat = await fs.stat(layout.serverEntryPath);
36
+ return {
37
+ buildId: layout.buildId,
38
+ hasLambdaZip: await hasLambdaZip(projectPath),
39
+ path: path.relative(projectPath, layout.standalonePath),
40
+ timestamp: stat.mtime
41
+ };
63
42
  }
64
- } catch {
65
- // nitro.json missing or unparseable — fall back to mtime
66
- }
67
- const lambdaZipPath = path.join(projectPath, 'lambda.zip');
68
- let hasLambdaZip = false;
69
- try {
70
- await fs.stat(lambdaZipPath);
71
- hasLambdaZip = true;
72
- } catch {
73
- hasLambdaZip = false;
74
- }
75
- return {
76
- buildId,
77
- hasLambdaZip,
78
- path: '.output',
79
- timestamp: indexStat.mtime
80
- };
81
- } catch {
82
- return null;
43
+ case 'nitro':
44
+ {
45
+ const layout = await inspectNitroOutput(outputPath);
46
+ if (!layout) {
47
+ return null;
48
+ }
49
+ const stat = await fs.stat(layout.serverEntryPath);
50
+ return {
51
+ buildId: layout.buildId ?? stat.mtime.toISOString(),
52
+ hasLambdaZip: await hasLambdaZip(projectPath),
53
+ path: path.relative(projectPath, outputPath),
54
+ timestamp: stat.mtime
55
+ };
56
+ }
57
+ case 'vite':
58
+ {
59
+ try {
60
+ const stat = await fs.stat(path.join(outputPath, 'index.html'));
61
+ if (!stat.isFile()) {
62
+ return null;
63
+ }
64
+ return {
65
+ buildId: stat.mtime.toISOString(),
66
+ hasLambdaZip: false,
67
+ path: path.relative(projectPath, outputPath),
68
+ timestamp: stat.mtime
69
+ };
70
+ } catch {
71
+ return null;
72
+ }
73
+ }
74
+ default:
75
+ assertNever(adapter);
83
76
  }
84
77
  }
85
- /**
86
- * Detect Vite build (dist/index.html)
87
- * Build ID is mtime of index.html as ISO string. No server, so hasLambdaZip is always false.
88
- */ async function detectViteBuild(projectPath) {
89
- try {
90
- const indexPath = path.join(projectPath, 'dist', 'index.html');
91
- const indexStat = await fs.stat(indexPath);
92
- return {
93
- buildId: indexStat.mtime.toISOString(),
94
- hasLambdaZip: false,
95
- path: 'dist',
96
- timestamp: indexStat.mtime
97
- };
98
- } catch {
99
- return null;
100
- }
78
+ async function hasLambdaZip(projectPath) {
79
+ return fs.stat(path.join(projectPath, 'lambda.zip')).then(()=>true).catch(()=>false);
101
80
  }
102
81
  /**
103
82
  * Get the build command from package.json
@@ -11,15 +11,14 @@ export declare const LAMBDA_MAX_UNZIPPED_BYTES: number;
11
11
  * Build Lambda deployment zip using pure Node.js
12
12
  *
13
13
  * Cross-platform replacement for build_for_lambda.sh:
14
- * 1. Copies .next/static to .next/standalone/.next/static
15
- * 2. Copies run.sh to .next/standalone/run.sh
16
- * 3. Creates lambda.zip from .next/standalone/
14
+ * 1. Adds a generated run.sh directly to the archive
15
+ * 2. Creates lambda.zip from the standalone output
17
16
  *
18
- * Note: public/ is NOT included in the zip those files are uploaded
19
- * as static assets and served via CDN, not from the Lambda function.
17
+ * The output's static/ and the project's public/ directories are not copied into the zip. Those
18
+ * files are uploaded separately and served by Gatekeeper, not the Lambda function.
20
19
  *
21
20
  * @param projectPath - Path to project root
22
21
  * @returns The built bundle: its unzipped byte size and the absolute zip path.
23
22
  * @throws Error if standalone directory missing or zip creation fails
24
23
  */
25
- export declare function buildLambdaZip(projectPath: string): Promise<LambdaBundle>;
24
+ export declare function buildLambdaZip(projectPath: string, output?: string): Promise<LambdaBundle>;