@payloadcms/figma 0.1.0-alpha.1 → 0.1.0-alpha.10
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.
- package/LICENSE.md +1 -1
- package/dist/{utils → adapters}/asset-collection.d.ts +17 -3
- package/dist/adapters/asset-collection.js +242 -0
- package/dist/{utils → adapters}/build-lambda-zip.d.ts +8 -7
- package/dist/adapters/build-lambda-zip.js +111 -0
- package/dist/adapters/configureNextjsCache.d.ts +8 -0
- package/dist/adapters/configureNextjsCache.js +55 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.d.ts +12 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.js +28 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.d.ts +9 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.js +13 -0
- package/dist/adapters/deploy-output/isFile.d.ts +1 -0
- package/dist/adapters/deploy-output/isFile.js +4 -0
- package/dist/adapters/deploy-output/readJson.d.ts +1 -0
- package/dist/adapters/deploy-output/readJson.js +9 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.js +16 -0
- package/dist/adapters/deploy-output/resolveOutputPath.d.ts +2 -0
- package/dist/adapters/deploy-output/resolveOutputPath.js +9 -0
- package/dist/adapters/deploy-output/resolveWithin.d.ts +1 -0
- package/dist/adapters/deploy-output/resolveWithin.js +12 -0
- package/dist/adapters/fs-utils.d.ts +39 -0
- package/dist/adapters/fs-utils.js +135 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.d.ts +40 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.js +174 -0
- package/dist/adapters/nextjs.d.ts +12 -0
- package/dist/adapters/nextjs.js +67 -0
- package/dist/adapters/nitro.d.ts +8 -0
- package/dist/adapters/nitro.js +193 -0
- package/dist/adapters/secret-files.d.ts +25 -0
- package/dist/adapters/secret-files.js +50 -0
- package/dist/adapters/types.d.ts +42 -0
- package/dist/adapters/types.js +1 -0
- package/dist/{utils/adapters → adapters}/vite.d.ts +2 -2
- package/dist/adapters/vite.js +33 -0
- package/dist/api/check-project-subdomain-availability.d.ts +12 -0
- package/dist/api/check-project-subdomain-availability.js +32 -0
- package/dist/api/control-plane-error.d.ts +6 -0
- package/dist/api/control-plane-error.js +8 -0
- package/dist/api/control-plane-fetch.d.ts +7 -0
- package/dist/api/control-plane-fetch.js +37 -0
- package/dist/api/control-plane.d.ts +1 -9
- package/dist/api/control-plane.js +2 -48
- package/dist/api/create-project.d.ts +18 -0
- package/dist/api/create-project.js +37 -0
- package/dist/api/list-project-workspaces.d.ts +8 -0
- package/dist/api/list-project-workspaces.js +28 -0
- package/dist/api/project-resource-type.d.ts +1 -0
- package/dist/api/project-resource-type.js +1 -0
- package/dist/auth/headless-oauth-flow.d.ts +23 -0
- package/dist/auth/headless-oauth-flow.js +69 -0
- package/dist/auth/oauth-flow.d.ts +2 -0
- package/dist/auth/oauth-flow.js +13 -8
- package/dist/auth/token-store.d.ts +4 -1
- package/dist/auth/token-store.js +14 -0
- package/dist/auth/types.d.ts +12 -0
- package/dist/cli.d.ts +39 -0
- package/dist/cli.js +71 -36
- package/dist/commands/bootstrap.js +2 -1
- package/dist/commands/build-lambda-zip.js +1 -1
- package/dist/commands/deploy.d.ts +12 -0
- package/dist/commands/deploy.js +63 -25
- package/dist/commands/detect-project-resource-type.d.ts +3 -0
- package/dist/commands/detect-project-resource-type.js +28 -0
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +164 -79
- package/dist/commands/login.d.ts +11 -1
- package/dist/commands/login.js +66 -4
- package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
- package/dist/commands/prompt-to-create-project.d.ts +24 -0
- package/dist/commands/prompt-to-create-project.js +69 -0
- package/dist/commands/setup-agent.d.ts +12 -0
- package/dist/commands/setup-agent.js +123 -0
- package/dist/commands/write-project-configuration.d.ts +12 -0
- package/dist/commands/write-project-configuration.js +16 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +6 -2
- package/dist/db-content-api/index.d.ts +1 -1
- package/dist/db-content-api/index.js +121 -72
- package/dist/db-content-api/utilities/data/index.js +2 -2
- package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
- package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +3 -11
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
- package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
- package/dist/db-content-api/utilities/isRecord.js +19 -0
- package/dist/db-content-api/utilities/joins.js +5 -1
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.js +95 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.js +112 -0
- package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
- package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
- package/dist/db-content-api/utilities/where.d.ts +2 -6
- package/dist/db-content-api/utilities/where.js +20 -9
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.js +2 -0
- package/dist/exports/views.d.ts +1 -0
- package/dist/exports/views.js +1 -0
- package/dist/imageSizeOptions.d.ts +23 -0
- package/dist/imageSizeOptions.js +26 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/write-agent-config.d.ts +12 -0
- package/dist/lib/write-agent-config.js +52 -0
- package/dist/next/image-loader.d.ts +6 -0
- package/dist/next/image-loader.js +14 -0
- package/dist/oauth/components/LoginButton/index.js +66 -19
- package/dist/oauth/components/LoginButton/index.scss +121 -15
- package/dist/oauth/defaults.js +4 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +5 -2
- package/dist/oauth/index.js +8 -7
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +1 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +1 -0
- package/dist/oauth/utilities/getAuthorizeURL.js +5 -1
- package/dist/plugin/build-config.d.ts +4 -2
- package/dist/plugin/build-config.js +95 -31
- package/dist/plugin/cache-revalidation-hooks.d.ts +6 -0
- package/dist/plugin/cache-revalidation-hooks.js +69 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +8 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.js +66 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +56 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +110 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.css +14 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.js +52 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +7 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +1 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.js +27 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +2 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
- package/dist/plugin/cloud-limits/routes.d.ts +2 -0
- package/dist/plugin/cloud-limits/routes.js +4 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.d.ts +9 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.js +28 -0
- package/dist/plugin/cloud-limits/shared.d.ts +10 -0
- package/dist/plugin/cloud-limits/shared.js +52 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.d.ts +2 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.js +134 -0
- package/dist/plugin/cloud-limits/utilities/toasts.d.ts +4 -0
- package/dist/plugin/cloud-limits/utilities/toasts.js +19 -0
- package/dist/plugin/make-permission-access/make-permission-access.d.ts +8 -0
- package/dist/plugin/make-permission-access/make-permission-access.js +24 -0
- package/dist/plugin/sandbox-upload-fetch.d.ts +32 -0
- package/dist/plugin/sandbox-upload-fetch.js +53 -0
- package/dist/skills/deploy-to-figma/SKILL.md +234 -0
- package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
- package/dist/storage-content-api/client-uploads/generate.js +2 -1
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.d.ts +11 -0
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.js +27 -0
- package/dist/storage-content-api/index.js +1 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.d.ts +5 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.js +13 -0
- package/dist/storage-content-api/staticHandler.js +2 -1
- package/dist/storage-content-api/types.d.ts +4 -1
- package/dist/translations/ar.d.ts +12 -0
- package/dist/translations/ar.js +12 -0
- package/dist/translations/az.d.ts +12 -0
- package/dist/translations/az.js +12 -0
- package/dist/translations/bg.d.ts +12 -0
- package/dist/translations/bg.js +12 -0
- package/dist/translations/bnBd.d.ts +12 -0
- package/dist/translations/bnBd.js +12 -0
- package/dist/translations/bnIn.d.ts +12 -0
- package/dist/translations/bnIn.js +12 -0
- package/dist/translations/ca.d.ts +12 -0
- package/dist/translations/ca.js +12 -0
- package/dist/translations/cs.d.ts +12 -0
- package/dist/translations/cs.js +12 -0
- package/dist/translations/da.d.ts +12 -0
- package/dist/translations/da.js +12 -0
- package/dist/translations/de.d.ts +12 -0
- package/dist/translations/de.js +12 -0
- package/dist/translations/en.d.ts +12 -0
- package/dist/translations/en.js +12 -0
- package/dist/translations/es.d.ts +12 -0
- package/dist/translations/es.js +12 -0
- package/dist/translations/et.d.ts +12 -0
- package/dist/translations/et.js +12 -0
- package/dist/translations/fa.d.ts +12 -0
- package/dist/translations/fa.js +12 -0
- package/dist/translations/fr.d.ts +12 -0
- package/dist/translations/fr.js +12 -0
- package/dist/translations/he.d.ts +12 -0
- package/dist/translations/he.js +12 -0
- package/dist/translations/hr.d.ts +12 -0
- package/dist/translations/hr.js +12 -0
- package/dist/translations/hu.d.ts +12 -0
- package/dist/translations/hu.js +12 -0
- package/dist/translations/hy.d.ts +12 -0
- package/dist/translations/hy.js +12 -0
- package/dist/translations/id.d.ts +12 -0
- package/dist/translations/id.js +12 -0
- package/dist/translations/index.d.ts +533 -0
- package/dist/translations/index.js +90 -0
- package/dist/translations/is.d.ts +12 -0
- package/dist/translations/is.js +12 -0
- package/dist/translations/it.d.ts +12 -0
- package/dist/translations/it.js +12 -0
- package/dist/translations/ja.d.ts +12 -0
- package/dist/translations/ja.js +12 -0
- package/dist/translations/ko.d.ts +12 -0
- package/dist/translations/ko.js +12 -0
- package/dist/translations/lt.d.ts +12 -0
- package/dist/translations/lt.js +12 -0
- package/dist/translations/lv.d.ts +12 -0
- package/dist/translations/lv.js +12 -0
- package/dist/translations/my.d.ts +12 -0
- package/dist/translations/my.js +12 -0
- package/dist/translations/nb.d.ts +12 -0
- package/dist/translations/nb.js +12 -0
- package/dist/translations/nl.d.ts +12 -0
- package/dist/translations/nl.js +12 -0
- package/dist/translations/pl.d.ts +12 -0
- package/dist/translations/pl.js +12 -0
- package/dist/translations/pt.d.ts +12 -0
- package/dist/translations/pt.js +12 -0
- package/dist/translations/ro.d.ts +12 -0
- package/dist/translations/ro.js +12 -0
- package/dist/translations/rs.d.ts +12 -0
- package/dist/translations/rs.js +12 -0
- package/dist/translations/rsLatin.d.ts +12 -0
- package/dist/translations/rsLatin.js +12 -0
- package/dist/translations/ru.d.ts +12 -0
- package/dist/translations/ru.js +12 -0
- package/dist/translations/sk.d.ts +12 -0
- package/dist/translations/sk.js +12 -0
- package/dist/translations/sl.d.ts +12 -0
- package/dist/translations/sl.js +12 -0
- package/dist/translations/sv.d.ts +12 -0
- package/dist/translations/sv.js +12 -0
- package/dist/translations/ta.d.ts +12 -0
- package/dist/translations/ta.js +12 -0
- package/dist/translations/th.d.ts +12 -0
- package/dist/translations/th.js +12 -0
- package/dist/translations/tr.d.ts +12 -0
- package/dist/translations/tr.js +12 -0
- package/dist/translations/uk.d.ts +12 -0
- package/dist/translations/uk.js +12 -0
- package/dist/translations/vi.d.ts +12 -0
- package/dist/translations/vi.js +12 -0
- package/dist/translations/zh.d.ts +12 -0
- package/dist/translations/zh.js +12 -0
- package/dist/translations/zhTw.d.ts +12 -0
- package/dist/translations/zhTw.js +12 -0
- package/dist/types.d.ts +11 -0
- package/dist/utils/assert-never.d.ts +1 -0
- package/dist/utils/assert-never.js +3 -0
- package/dist/utils/build-detection.d.ts +6 -1
- package/dist/utils/build-detection.js +68 -89
- package/dist/utils/deploy-adapter.d.ts +3 -35
- package/dist/utils/deploy-adapter.js +25 -14
- package/dist/utils/lambda-config.js +18 -23
- package/dist/utils/messages.js +24 -3
- package/dist/utils/next-image-loader-config.d.ts +2 -0
- package/dist/utils/next-image-loader-config.js +63 -0
- package/dist/utils/next-image-loader-file.d.ts +2 -0
- package/dist/utils/next-image-loader-file.js +11 -0
- package/dist/utils/payload-generate.d.ts +10 -0
- package/dist/utils/payload-generate.js +59 -0
- package/dist/utils/pnpm-builds.d.ts +14 -0
- package/dist/utils/pnpm-builds.js +125 -0
- package/dist/utils/s3-upload.js +4 -1
- package/package.json +31 -7
- package/dist/lib/download-skill.d.ts +0 -12
- package/dist/lib/download-skill.js +0 -77
- package/dist/utils/adapters/nextjs.d.ts +0 -8
- package/dist/utils/adapters/nextjs.js +0 -61
- package/dist/utils/adapters/nitro.d.ts +0 -8
- package/dist/utils/adapters/nitro.js +0 -172
- package/dist/utils/adapters/vite.js +0 -31
- package/dist/utils/asset-collection.js +0 -144
- package/dist/utils/build-lambda-zip.js +0 -90
- package/dist/utils/fs-utils.d.ts +0 -12
- package/dist/utils/fs-utils.js +0 -55
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { buildLambdaZip } from './build-lambda-zip.js';
|
|
4
|
-
import * as log from './log.js';
|
|
5
|
-
// Maximum file size for static assets (S3 limitation)
|
|
6
|
-
const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
|
|
7
|
-
;
|
|
8
|
-
/**
|
|
9
|
-
* Get file size in bytes
|
|
10
|
-
*
|
|
11
|
-
* @param filePath - Absolute path to file
|
|
12
|
-
* @returns File size in bytes
|
|
13
|
-
*/ export async function getFileSize(filePath) {
|
|
14
|
-
const stats = await fs.stat(filePath);
|
|
15
|
-
return stats.size;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Recursively collect files from a directory
|
|
19
|
-
*
|
|
20
|
-
* Excludes files larger than 50MB (S3 limitation).
|
|
21
|
-
* Warns user when files are excluded due to size.
|
|
22
|
-
*
|
|
23
|
-
* @param dir - Directory to scan
|
|
24
|
-
* @param baseDir - Base directory for relative paths
|
|
25
|
-
* @returns Array of relative file paths
|
|
26
|
-
*/ async function collectFiles(dir, baseDir) {
|
|
27
|
-
const files = [];
|
|
28
|
-
try {
|
|
29
|
-
const entries = await fs.readdir(dir, {
|
|
30
|
-
withFileTypes: true
|
|
31
|
-
});
|
|
32
|
-
for (const entry of entries){
|
|
33
|
-
const fullPath = path.join(dir, entry.name);
|
|
34
|
-
if (entry.isDirectory()) {
|
|
35
|
-
// Recursively collect from subdirectories
|
|
36
|
-
const subFiles = await collectFiles(fullPath, baseDir);
|
|
37
|
-
files.push(...subFiles);
|
|
38
|
-
} else if (entry.isFile()) {
|
|
39
|
-
// Check file size before adding
|
|
40
|
-
const stats = await fs.stat(fullPath);
|
|
41
|
-
if (stats.size <= MAX_ASSET_SIZE) {
|
|
42
|
-
// Add relative path from base directory
|
|
43
|
-
const relativePath = path.relative(baseDir, fullPath);
|
|
44
|
-
files.push(relativePath);
|
|
45
|
-
} else {
|
|
46
|
-
// Warn user about skipped files
|
|
47
|
-
const sizeMB = (stats.size / (1024 * 1024)).toFixed(2);
|
|
48
|
-
const relativePath = path.relative(baseDir, fullPath);
|
|
49
|
-
log.warning(`Skipping large asset: ${relativePath} (${sizeMB}MB exceeds 50MB limit)`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
} catch {
|
|
54
|
-
// Directory doesn't exist or not accessible
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
return files;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Collect all static asset paths from .next/static
|
|
61
|
-
*
|
|
62
|
-
* Returns paths relative to project root, formatted for S3:
|
|
63
|
-
* - `.next/static/chunks/main.js` → `_next/static/chunks/main.js`
|
|
64
|
-
*
|
|
65
|
-
* @param projectPath - Path to project root
|
|
66
|
-
* @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
|
-
}
|
|
75
|
-
const files = await collectFiles(staticDir, projectPath);
|
|
76
|
-
// Normalize paths to forward slashes (cross-platform) and convert prefix
|
|
77
|
-
return files.map((file)=>{
|
|
78
|
-
const normalized = file.split(path.sep).join('/');
|
|
79
|
-
return normalized.replace(/^\.next\//, '_next/');
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Collect SSG asset paths by parsing .next/prerender-manifest.json
|
|
84
|
-
*
|
|
85
|
-
* For each route in the manifest's `routes` object, collects three files:
|
|
86
|
-
* - {route}.html (full HTML)
|
|
87
|
-
* - {route}.rsc (React Server Components payload)
|
|
88
|
-
* - {route}.meta (response headers JSON)
|
|
89
|
-
*
|
|
90
|
-
* S3 keys use the route path without leading slash.
|
|
91
|
-
* Filesystem paths point to .next/server/app/{route}.{ext}
|
|
92
|
-
*
|
|
93
|
-
* @param projectPath - Path to project root
|
|
94
|
-
* @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');
|
|
97
|
-
let manifest;
|
|
98
|
-
try {
|
|
99
|
-
const raw = await fs.readFile(manifestPath, 'utf-8');
|
|
100
|
-
manifest = JSON.parse(raw);
|
|
101
|
-
} catch {
|
|
102
|
-
return {
|
|
103
|
-
keys: [],
|
|
104
|
-
pathMap: {}
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
if (!manifest.routes || typeof manifest.routes !== 'object') {
|
|
108
|
-
return {
|
|
109
|
-
keys: [],
|
|
110
|
-
pathMap: {}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
const keys = [];
|
|
114
|
-
const pathMap = {};
|
|
115
|
-
const extensions = [
|
|
116
|
-
'.html',
|
|
117
|
-
'.rsc',
|
|
118
|
-
'.meta'
|
|
119
|
-
];
|
|
120
|
-
for (const routeKey of Object.keys(manifest.routes)){
|
|
121
|
-
// Strip leading slash for S3 key; handle root "/" → "index"
|
|
122
|
-
const stripped = routeKey === '/' ? 'index' : routeKey.replace(/^\//, '');
|
|
123
|
-
for (const ext of extensions){
|
|
124
|
-
const s3Key = `${stripped}${ext}`;
|
|
125
|
-
const fsPath = path.join('.next', 'server', 'app', `${stripped}${ext}`);
|
|
126
|
-
keys.push(s3Key);
|
|
127
|
-
pathMap[s3Key] = fsPath;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
keys,
|
|
132
|
-
pathMap
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Create Lambda deployment zip
|
|
137
|
-
*
|
|
138
|
-
* Uses cross-platform Node.js implementation instead of shell script.
|
|
139
|
-
*
|
|
140
|
-
* @param projectPath - Path to project root
|
|
141
|
-
* @throws Error if build missing or zip creation fails
|
|
142
|
-
*/ export async function createLambdaZip(projectPath) {
|
|
143
|
-
await buildLambdaZip(projectPath);
|
|
144
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import archiver from 'archiver';
|
|
2
|
-
import { createWriteStream } from 'fs';
|
|
3
|
-
import fs from 'fs/promises';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { getDirectorySize } from './fs-utils.js';
|
|
6
|
-
/**
|
|
7
|
-
* AWS Lambda's hard limit on unzipped deployment code size (250 MB). The unzipped
|
|
8
|
-
* total must be strictly less than this value, so a bundle exactly equal to it is
|
|
9
|
-
* rejected. The server enforces this too and now returns a clear message, so a
|
|
10
|
-
* client-side check against this value is an early-exit convenience, not the
|
|
11
|
-
* source of truth.
|
|
12
|
-
*/ export const LAMBDA_MAX_UNZIPPED_BYTES = 250 * 1024 * 1024;
|
|
13
|
-
/**
|
|
14
|
-
* Build Lambda deployment zip using pure Node.js
|
|
15
|
-
*
|
|
16
|
-
* Cross-platform replacement for build_for_lambda.sh:
|
|
17
|
-
* 1. Copies .next/static to .next/standalone/.next/static
|
|
18
|
-
* 2. Copies run.sh to .next/standalone/run.sh
|
|
19
|
-
* 3. Creates lambda.zip from .next/standalone/
|
|
20
|
-
*
|
|
21
|
-
* Note: public/ is NOT included in the zip — those files are uploaded
|
|
22
|
-
* as static assets and served via CDN, not from the Lambda function.
|
|
23
|
-
*
|
|
24
|
-
* @param projectPath - Path to project root
|
|
25
|
-
* @returns The built bundle: its unzipped byte size and the absolute zip path.
|
|
26
|
-
* @throws Error if standalone directory missing or zip creation fails
|
|
27
|
-
*/ export async function buildLambdaZip(projectPath) {
|
|
28
|
-
const standalonePath = path.join(projectPath, '.next', 'standalone');
|
|
29
|
-
const staticPath = path.join(projectPath, '.next', 'static');
|
|
30
|
-
const runShPath = path.join(projectPath, 'run.sh');
|
|
31
|
-
const zipPath = path.join(projectPath, 'lambda.zip');
|
|
32
|
-
if (!await isDirectory(standalonePath)) {
|
|
33
|
-
throw new Error('Standalone build not found at .next/standalone. ' + 'Ensure next.config has output: "standalone" and run build first.');
|
|
34
|
-
}
|
|
35
|
-
if (await isDirectory(staticPath)) {
|
|
36
|
-
const destStatic = path.join(standalonePath, '.next', 'static');
|
|
37
|
-
await copyDirectory(staticPath, destStatic);
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
await fs.copyFile(runShPath, path.join(standalonePath, 'run.sh'));
|
|
41
|
-
} catch {
|
|
42
|
-
// run.sh may not exist in all setups
|
|
43
|
-
}
|
|
44
|
-
const unzippedBytes = await getDirectorySize(standalonePath);
|
|
45
|
-
await createZip(standalonePath, zipPath);
|
|
46
|
-
return {
|
|
47
|
-
unzippedBytes,
|
|
48
|
-
zipPath
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
async function isDirectory(dirPath) {
|
|
52
|
-
try {
|
|
53
|
-
const stats = await fs.stat(dirPath);
|
|
54
|
-
return stats.isDirectory();
|
|
55
|
-
} catch {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async function copyDirectory(src, dest) {
|
|
60
|
-
await fs.mkdir(dest, {
|
|
61
|
-
recursive: true
|
|
62
|
-
});
|
|
63
|
-
const entries = await fs.readdir(src, {
|
|
64
|
-
withFileTypes: true
|
|
65
|
-
});
|
|
66
|
-
for (const entry of entries){
|
|
67
|
-
const srcPath = path.join(src, entry.name);
|
|
68
|
-
const destPath = path.join(dest, entry.name);
|
|
69
|
-
if (entry.isDirectory()) {
|
|
70
|
-
await copyDirectory(srcPath, destPath);
|
|
71
|
-
} else {
|
|
72
|
-
await fs.copyFile(srcPath, destPath);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function createZip(sourceDir, zipPath) {
|
|
77
|
-
return new Promise((resolve, reject)=>{
|
|
78
|
-
const output = createWriteStream(zipPath);
|
|
79
|
-
const archive = archiver('zip', {
|
|
80
|
-
zlib: {
|
|
81
|
-
level: 9
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
output.on('close', ()=>resolve());
|
|
85
|
-
archive.on('error', (err)=>reject(err));
|
|
86
|
-
archive.pipe(output);
|
|
87
|
-
archive.directory(sourceDir, false);
|
|
88
|
-
void archive.finalize();
|
|
89
|
-
});
|
|
90
|
-
}
|
package/dist/utils/fs-utils.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recursively collect all file paths under a directory,
|
|
3
|
-
* returned as forward-slash-separated paths relative to baseDir.
|
|
4
|
-
*/
|
|
5
|
-
export declare function collectFilesRecursive(dir: string, baseDir: string): Promise<string[]>;
|
|
6
|
-
/**
|
|
7
|
-
* Recursively sum the byte size of all files under a directory.
|
|
8
|
-
* Returns 0 for a missing or unreadable directory. Symlinks are not
|
|
9
|
-
* followed. Files that disappear or become unreadable between readdir
|
|
10
|
-
* and stat are skipped (treated as 0 bytes).
|
|
11
|
-
*/
|
|
12
|
-
export declare function getDirectorySize(dir: string): Promise<number>;
|
package/dist/utils/fs-utils.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
/**
|
|
4
|
-
* Recursively collect all file paths under a directory,
|
|
5
|
-
* returned as forward-slash-separated paths relative to baseDir.
|
|
6
|
-
*/ export async function collectFilesRecursive(dir, baseDir) {
|
|
7
|
-
const files = [];
|
|
8
|
-
try {
|
|
9
|
-
const entries = await fs.readdir(dir, {
|
|
10
|
-
withFileTypes: true
|
|
11
|
-
});
|
|
12
|
-
for (const entry of entries){
|
|
13
|
-
const fullPath = path.join(dir, entry.name);
|
|
14
|
-
if (entry.isDirectory()) {
|
|
15
|
-
const subFiles = await collectFilesRecursive(fullPath, baseDir);
|
|
16
|
-
files.push(...subFiles);
|
|
17
|
-
} else if (entry.isFile()) {
|
|
18
|
-
files.push(path.relative(baseDir, fullPath).split(path.sep).join('/'));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
} catch {
|
|
22
|
-
// Not accessible
|
|
23
|
-
}
|
|
24
|
-
return files;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Recursively sum the byte size of all files under a directory.
|
|
28
|
-
* Returns 0 for a missing or unreadable directory. Symlinks are not
|
|
29
|
-
* followed. Files that disappear or become unreadable between readdir
|
|
30
|
-
* and stat are skipped (treated as 0 bytes).
|
|
31
|
-
*/ export async function getDirectorySize(dir) {
|
|
32
|
-
let entries;
|
|
33
|
-
try {
|
|
34
|
-
entries = await fs.readdir(dir, {
|
|
35
|
-
withFileTypes: true
|
|
36
|
-
});
|
|
37
|
-
} catch {
|
|
38
|
-
return 0;
|
|
39
|
-
}
|
|
40
|
-
let total = 0;
|
|
41
|
-
for (const entry of entries){
|
|
42
|
-
const fullPath = path.join(dir, entry.name);
|
|
43
|
-
if (entry.isDirectory()) {
|
|
44
|
-
total += await getDirectorySize(fullPath);
|
|
45
|
-
} else if (entry.isFile()) {
|
|
46
|
-
try {
|
|
47
|
-
const stats = await fs.stat(fullPath);
|
|
48
|
-
total += stats.size;
|
|
49
|
-
} catch {
|
|
50
|
-
// File vanished or is unreadable between readdir and stat — skip it.
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return total;
|
|
55
|
-
}
|