@payloadcms/figma 0.0.1-alpha.41 → 0.0.1-alpha.43
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/dist/auth/oauth-flow.d.ts.map +1 -1
- package/dist/auth/oauth-flow.js +6 -3
- package/dist/auth/oauth-flow.js.map +1 -1
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js +11 -3
- package/dist/auth/refresh.js.map +1 -1
- package/dist/auth/token-store.d.ts +6 -4
- package/dist/auth/token-store.d.ts.map +1 -1
- package/dist/auth/token-store.js +17 -14
- package/dist/auth/token-store.js.map +1 -1
- package/dist/auth/types.d.ts +7 -4
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/cli.js +8 -6
- package/dist/cli.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +2 -1
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +12 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.d.ts.map +1 -1
- package/dist/commands/list-tokens.js +20 -8
- package/dist/commands/list-tokens.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +12 -4
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/logout.js +55 -12
- package/dist/commands/logout.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +19 -4
- package/dist/constants.js.map +1 -1
- package/dist/db-content-api/generated/content-api-types.d.ts +166 -277
- package/dist/db-content-api/generated/content-api-types.d.ts.map +1 -1
- package/dist/db-content-api/generated/content-api-types.js.map +1 -1
- package/dist/db-content-api/index.d.ts.map +1 -1
- package/dist/db-content-api/index.js +116 -64
- package/dist/db-content-api/index.js.map +1 -1
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +31 -1
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts.map +1 -1
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +24 -24
- package/dist/db-content-api/temp-utilities/unwrapDocument.js.map +1 -1
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts.map +1 -1
- package/dist/db-content-api/utilities/data/castFieldValue.js +4 -1
- package/dist/db-content-api/utilities/data/castFieldValue.js.map +1 -1
- package/dist/db-content-api/utilities/data/index.d.ts +2 -0
- package/dist/db-content-api/utilities/data/index.d.ts.map +1 -1
- package/dist/db-content-api/utilities/data/index.js +23 -2
- package/dist/db-content-api/utilities/data/index.js.map +1 -1
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts.map +1 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +55 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js.map +1 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +22 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts.map +1 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +30 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js.map +1 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +7 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts.map +1 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +151 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js.map +1 -0
- package/dist/db-content-api/utilities/meta/index.d.ts +5 -0
- package/dist/db-content-api/utilities/meta/index.d.ts.map +1 -0
- package/dist/db-content-api/utilities/meta/index.js +5 -0
- package/dist/db-content-api/utilities/meta/index.js.map +1 -0
- package/dist/db-content-api/utilities/where.d.ts.map +1 -1
- package/dist/db-content-api/utilities/where.js +17 -3
- package/dist/db-content-api/utilities/where.js.map +1 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
- package/dist/oauth/components/LogoutButton/index.js +5 -3
- package/dist/oauth/components/LogoutButton/index.js.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +17 -7
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +1 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +1 -1
- package/dist/plugin/build-config.js +3 -3
- package/dist/plugin/build-config.js.map +1 -1
- package/dist/storage-content-api/api-types.d.ts +8 -1
- package/dist/storage-content-api/api-types.d.ts.map +1 -1
- package/dist/storage-content-api/api-types.js.map +1 -1
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts.map +1 -1
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +3 -3
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js.map +1 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts.map +1 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +9 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.js.map +1 -1
- package/dist/storage-content-api/generateURL.d.ts.map +1 -1
- package/dist/storage-content-api/generateURL.js +3 -2
- package/dist/storage-content-api/generateURL.js.map +1 -1
- package/dist/storage-content-api/handleDelete.d.ts.map +1 -1
- package/dist/storage-content-api/handleDelete.js +4 -2
- package/dist/storage-content-api/handleDelete.js.map +1 -1
- package/dist/storage-content-api/handleUpload.d.ts +1 -1
- package/dist/storage-content-api/handleUpload.d.ts.map +1 -1
- package/dist/storage-content-api/handleUpload.js +11 -3
- package/dist/storage-content-api/handleUpload.js.map +1 -1
- package/dist/storage-content-api/staticHandler.js +1 -0
- package/dist/storage-content-api/staticHandler.js.map +1 -1
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts.map +1 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js.map +1 -0
- package/dist/storage-content-api/utilities/index.d.ts +2 -0
- package/dist/storage-content-api/utilities/index.d.ts.map +1 -0
- package/dist/storage-content-api/utilities/index.js +3 -0
- package/dist/storage-content-api/utilities/index.js.map +1 -0
- package/dist/templates/.env.example +11 -0
- package/dist/utils/env-management.d.ts +9 -1
- package/dist/utils/env-management.d.ts.map +1 -1
- package/dist/utils/env-management.js +39 -17
- package/dist/utils/env-management.js.map +1 -1
- package/dist/utils/format-env-suffix.d.ts +12 -0
- package/dist/utils/format-env-suffix.d.ts.map +1 -0
- package/dist/utils/format-env-suffix.js +13 -0
- package/dist/utils/format-env-suffix.js.map +1 -0
- package/dist/utils/lambda-config.js +26 -12
- package/dist/utils/lambda-config.js.map +1 -1
- package/dist/utils/messages.d.ts.map +1 -1
- package/dist/utils/messages.js +1 -2
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +3 -0
- package/dist/utils/project.js.map +1 -1
- package/package.json +2 -2
- package/dist/db-content-api/temp-utilities/pagination.d.ts +0 -13
- package/dist/db-content-api/temp-utilities/pagination.d.ts.map +0 -1
- package/dist/db-content-api/temp-utilities/pagination.js +0 -45
- package/dist/db-content-api/temp-utilities/pagination.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format environment suffix for user-facing messages.
|
|
3
|
+
* Returns empty string for production (default), suffix for other environments.
|
|
4
|
+
*
|
|
5
|
+
* @param env - The environment
|
|
6
|
+
* @param prefix - Prefix before environment name (default: ' to ')
|
|
7
|
+
* @param suffix - Suffix after environment name (default: '')
|
|
8
|
+
* @returns Formatted string or empty string for production
|
|
9
|
+
*/ export function formatEnvSuffix(env, prefix = ' to ', suffix = '') {
|
|
10
|
+
return env !== 'production' ? `${prefix}${env}${suffix}` : '';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=format-env-suffix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/format-env-suffix.ts"],"sourcesContent":["import type { Environment } from '../constants.js'\n\n/**\n * Format environment suffix for user-facing messages.\n * Returns empty string for production (default), suffix for other environments.\n *\n * @param env - The environment\n * @param prefix - Prefix before environment name (default: ' to ')\n * @param suffix - Suffix after environment name (default: '')\n * @returns Formatted string or empty string for production\n */\nexport function formatEnvSuffix(env: Environment, prefix = ' to ', suffix = ''): string {\n return env !== 'production' ? `${prefix}${env}${suffix}` : ''\n}\n"],"names":["formatEnvSuffix","env","prefix","suffix"],"mappings":"AAEA;;;;;;;;CAQC,GACD,OAAO,SAASA,gBAAgBC,GAAgB,EAAEC,SAAS,MAAM,EAAEC,SAAS,EAAE;IAC5E,OAAOF,QAAQ,eAAe,GAAGC,SAASD,MAAME,QAAQ,GAAG;AAC7D"}
|
|
@@ -17,8 +17,8 @@ NODE_ENV=production exec node server.js
|
|
|
17
17
|
const runShPath = path.join(projectPath, 'run.sh');
|
|
18
18
|
await fs.writeFile(runShPath, RUN_SH_CONTENT, 'utf-8');
|
|
19
19
|
await fs.chmod(runShPath, 0o755);
|
|
20
|
-
// 2. Modify next config to add standalone output
|
|
21
|
-
await
|
|
20
|
+
// 2. Modify next config to add standalone output and eslint ignore
|
|
21
|
+
await addNextConfigProperties(projectPath);
|
|
22
22
|
// 3. Create/update .npmrc
|
|
23
23
|
const npmrcPath = path.join(projectPath, '.npmrc');
|
|
24
24
|
let npmrcContent = '';
|
|
@@ -56,13 +56,18 @@ NODE_ENV=production exec node server.js
|
|
|
56
56
|
throw new Error('Could not find next.config.js or next.config.mjs');
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Add
|
|
60
|
-
|
|
59
|
+
* Add required Next.js config properties using AST parsing
|
|
60
|
+
* - output: 'standalone' (for Lambda deployment)
|
|
61
|
+
* - eslint: { ignoreDuringBuilds: true } (allow builds with lint errors)
|
|
62
|
+
*/ async function addNextConfigProperties(projectPath) {
|
|
61
63
|
const nextConfigPath = await findNextConfigPath(projectPath);
|
|
62
64
|
const content = await fs.readFile(nextConfigPath, 'utf-8');
|
|
63
|
-
// Check
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
// Check which properties already exist
|
|
66
|
+
const hasOutput = content.includes('output:');
|
|
67
|
+
const hasEslint = content.includes('eslint:');
|
|
68
|
+
// Early exit if both already configured
|
|
69
|
+
if (hasOutput && hasEslint) {
|
|
70
|
+
return;
|
|
66
71
|
}
|
|
67
72
|
const ast = parseModule(content, {
|
|
68
73
|
loc: true
|
|
@@ -104,16 +109,25 @@ NODE_ENV=production exec node server.js
|
|
|
104
109
|
}
|
|
105
110
|
const { loc } = targetObjectExpression;
|
|
106
111
|
const lines = content.split(/\r?\n/);
|
|
107
|
-
//
|
|
112
|
+
// Build insertion string based on what's missing
|
|
113
|
+
const parts = [];
|
|
114
|
+
if (!hasOutput) {
|
|
115
|
+
parts.push("output: 'standalone',");
|
|
116
|
+
}
|
|
117
|
+
if (!hasEslint) {
|
|
118
|
+
parts.push(`eslint: {
|
|
119
|
+
ignoreDuringBuilds: true,
|
|
120
|
+
},`);
|
|
121
|
+
}
|
|
122
|
+
const insertString = '\n ' + parts.join('\n ');
|
|
123
|
+
// Insert after opening brace
|
|
108
124
|
const insertLine = loc.start.line - 1;
|
|
109
|
-
const insertColumn = loc.start.column + 1
|
|
110
|
-
;
|
|
111
|
-
// Find the content of the line with the opening brace
|
|
125
|
+
const insertColumn = loc.start.column + 1;
|
|
112
126
|
const targetLine = lines[insertLine];
|
|
113
127
|
if (!targetLine) {
|
|
114
128
|
throw new Error(`Could not find target line in ${path.basename(nextConfigPath)}`);
|
|
115
129
|
}
|
|
116
|
-
lines[insertLine] = targetLine.slice(0, insertColumn) +
|
|
130
|
+
lines[insertLine] = targetLine.slice(0, insertColumn) + insertString + targetLine.slice(insertColumn);
|
|
117
131
|
const modifiedContent = lines.join('\n');
|
|
118
132
|
await fs.writeFile(nextConfigPath, modifiedContent, 'utf-8');
|
|
119
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/lambda-config.ts"],"sourcesContent":["import { parseModule, Syntax } from 'esprima-next'\nimport fs from 'fs/promises'\nimport path from 'path'\n\nimport type { PackageManager } from './package-manager.js'\n\nconst RUN_SH_CONTENT = `#!/bin/bash -x\n\n[ ! -d '/tmp/cache' ] && mkdir -p /tmp/cache\n\nNODE_ENV=production exec node server.js\n`\n\n/**\n * Apply Lambda-specific modifications to a Payload project\n *\n * @param projectPath - Path to project directory\n * @param packageManager - Package manager to use in scripts (defaults to 'pnpm')\n */\nexport async function applyLambdaModifications(\n projectPath: string,\n packageManager: PackageManager = 'pnpm',\n): Promise<void> {\n // 1. Create run.sh\n const runShPath = path.join(projectPath, 'run.sh')\n await fs.writeFile(runShPath, RUN_SH_CONTENT, 'utf-8')\n await fs.chmod(runShPath, 0o755)\n\n // 2. Modify next config to add standalone output\n await addStandaloneToNextConfig(projectPath)\n\n // 3. Create/update .npmrc\n const npmrcPath = path.join(projectPath, '.npmrc')\n let npmrcContent = ''\n\n try {\n npmrcContent = await fs.readFile(npmrcPath, 'utf-8')\n } catch {\n // File doesn't exist, start fresh\n }\n\n if (!npmrcContent.includes('node-linker=hoisted')) {\n npmrcContent += npmrcContent && !npmrcContent.endsWith('\\n') ? '\\n' : ''\n npmrcContent += 'node-linker=hoisted\\n'\n await fs.writeFile(npmrcPath, npmrcContent, 'utf-8')\n }\n\n // 4. Add lambda:buildzip script to package.json\n await addLambdaBuildScript(projectPath, packageManager)\n}\n\n/**\n * Find the Next.js config file (next.config.js or next.config.mjs)\n *\n * @todo Support TypeScript config files in future\n */\nasync function findNextConfigPath(projectPath: string): Promise<string> {\n const configFiles = ['next.config.js', 'next.config.mjs']\n\n for (const configFile of configFiles) {\n const configPath = path.join(projectPath, configFile)\n try {\n await fs.access(configPath)\n return configPath\n } catch {\n // File doesn't exist, try next one\n }\n }\n\n throw new Error('Could not find next.config.js or next.config.mjs')\n}\n\n/**\n * Add standalone output to Next.js config using AST parsing\n */\nasync function addStandaloneToNextConfig(projectPath: string): Promise<void> {\n const nextConfigPath = await findNextConfigPath(projectPath)\n const content = await fs.readFile(nextConfigPath, 'utf-8')\n\n // Check if output already configured (quick check before parsing)\n if (content.includes('output:')) {\n return // Already configured\n }\n\n const ast = parseModule(content, { loc: true })\n\n // Find export default declaration\n const exportDefaultDeclaration = ast.body.find(\n (p) => p.type === Syntax.ExportDefaultDeclaration,\n ) as ExportDefaultDeclaration | undefined\n\n if (!exportDefaultDeclaration?.declaration?.loc) {\n throw new Error(`Could not find export default declaration in ${path.basename(nextConfigPath)}`)\n }\n\n // Find the object expression to modify\n let targetObjectExpression: ObjectExpressionNode | undefined\n\n if (exportDefaultDeclaration.declaration.type === 'ObjectExpression') {\n // Direct export: export default { ... }\n targetObjectExpression = exportDefaultDeclaration.declaration as ObjectExpressionNode\n } else if (exportDefaultDeclaration.declaration.type === 'CallExpression') {\n // Wrapped export: export default withPayload(nextConfig, ...)\n const callExpr = exportDefaultDeclaration.declaration as CallExpressionNode\n const firstArg = callExpr.arguments?.[0]\n\n if (firstArg?.type === 'Identifier') {\n // Find the variable declaration for this identifier\n const configVarName = (firstArg as IdentifierNode).name\n const varDeclaration = ast.body.find((node) => {\n if (node.type === Syntax.VariableDeclaration) {\n const varNode = node as VariableDeclarationNode\n return varNode.declarations?.some(\n (decl) =>\n decl.id?.type === 'Identifier' &&\n (decl.id as IdentifierNode).name === configVarName &&\n decl.init?.type === 'ObjectExpression',\n )\n }\n return false\n }) as undefined | VariableDeclarationNode\n\n if (varDeclaration) {\n const declarator = varDeclaration.declarations?.find(\n (decl) =>\n decl.id?.type === 'Identifier' && (decl.id as IdentifierNode).name === configVarName,\n )\n if (declarator?.init?.type === 'ObjectExpression') {\n targetObjectExpression = declarator.init as ObjectExpressionNode\n }\n }\n }\n }\n\n if (!targetObjectExpression?.loc) {\n throw new Error(\n `Could not find Next.js config object in ${path.basename(nextConfigPath)}. ` +\n `Expected either 'export default { ... }' or 'export default wrapper(configVar, ...)'`,\n )\n }\n\n const { loc } = targetObjectExpression\n const lines = content.split(/\\r?\\n/)\n\n // Insert output: 'standalone' as first property\n const insertLine = loc.start.line - 1\n const insertColumn = loc.start.column + 1 // After opening brace\n\n // Find the content of the line with the opening brace\n const targetLine = lines[insertLine]\n if (!targetLine) {\n throw new Error(`Could not find target line in ${path.basename(nextConfigPath)}`)\n }\n\n lines[insertLine] =\n targetLine.slice(0, insertColumn) + \"\\n output: 'standalone',\" + targetLine.slice(insertColumn)\n\n const modifiedContent = lines.join('\\n')\n await fs.writeFile(nextConfigPath, modifiedContent, 'utf-8')\n}\n\ntype ExportDefaultDeclaration = {\n declaration: {\n arguments?: unknown[]\n loc: {\n end: { column: number; line: number }\n start: { column: number; line: number }\n }\n type: string\n }\n type: string\n}\n\ntype ObjectExpressionNode = {\n loc: {\n end: { column: number; line: number }\n start: { column: number; line: number }\n }\n type: 'ObjectExpression'\n}\n\ntype IdentifierNode = {\n name: string\n type: 'Identifier'\n}\n\ntype CallExpressionNode = {\n arguments?: Array<{ type: string }>\n type: 'CallExpression'\n}\n\ntype VariableDeclarationNode = {\n declarations?: Array<{\n id?: { name?: string; type: string }\n init?: { loc?: ObjectExpressionNode['loc']; type: string }\n }>\n type: 'VariableDeclaration'\n}\n\n/**\n * Add lambda:buildzip script to package.json\n */\nasync function addLambdaBuildScript(\n projectPath: string,\n packageManager: PackageManager,\n): Promise<void> {\n const packageJsonPath = path.join(projectPath, 'package.json')\n const content = await fs.readFile(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(content)\n\n if (!packageJson.scripts) {\n packageJson.scripts = {}\n }\n\n // Use package manager's run and exec commands\n const runCmd = packageManager === 'npm' ? 'npm run' : packageManager\n const execCmd = packageManager === 'npm' ? 'npx' : `${packageManager} exec`\n\n packageJson.scripts['lambda:buildzip'] =\n `${runCmd} build && ${execCmd} payloadcms-figma build-lambda-zip`\n\n await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\\n', 'utf-8')\n}\n"],"names":["parseModule","Syntax","fs","path","RUN_SH_CONTENT","applyLambdaModifications","projectPath","packageManager","runShPath","join","writeFile","chmod","addStandaloneToNextConfig","npmrcPath","npmrcContent","readFile","includes","endsWith","addLambdaBuildScript","findNextConfigPath","configFiles","configFile","configPath","access","Error","nextConfigPath","content","ast","loc","exportDefaultDeclaration","body","find","p","type","ExportDefaultDeclaration","declaration","basename","targetObjectExpression","callExpr","firstArg","arguments","configVarName","name","varDeclaration","node","VariableDeclaration","varNode","declarations","some","decl","id","init","declarator","lines","split","insertLine","start","line","insertColumn","column","targetLine","slice","modifiedContent","packageJsonPath","packageJson","JSON","parse","scripts","runCmd","execCmd","stringify"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,eAAc;AAClD,OAAOC,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAIvB,MAAMC,iBAAiB,CAAC;;;;;AAKxB,CAAC;AAED;;;;;CAKC,GACD,OAAO,eAAeC,yBACpBC,WAAmB,EACnBC,iBAAiC,MAAM;IAEvC,mBAAmB;IACnB,MAAMC,YAAYL,KAAKM,IAAI,CAACH,aAAa;IACzC,MAAMJ,GAAGQ,SAAS,CAACF,WAAWJ,gBAAgB;IAC9C,MAAMF,GAAGS,KAAK,CAACH,WAAW;IAE1B,iDAAiD;IACjD,MAAMI,0BAA0BN;IAEhC,0BAA0B;IAC1B,MAAMO,YAAYV,KAAKM,IAAI,CAACH,aAAa;IACzC,IAAI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;IACpC,MAAMC,eAAe9B,IAAI4B,KAAK,CAACG,MAAM,GAAG,EAAE,sBAAsB;;IAEhE,sDAAsD;IACtD,MAAMC,aAAaP,KAAK,CAACE,WAAW;IACpC,IAAI,CAACK,YAAY;QACf,MAAM,IAAIpC,MAAM,CAAC,8BAA8B,EAAErB,KAAKiC,QAAQ,CAACX,iBAAiB;IAClF;IAEA4B,KAAK,CAACE,WAAW,GACfK,WAAWC,KAAK,CAAC,GAAGH,gBAAgB,8BAA8BE,WAAWC,KAAK,CAACH;IAErF,MAAMI,kBAAkBT,MAAM5C,IAAI,CAAC;IACnC,MAAMP,GAAGQ,SAAS,CAACe,gBAAgBqC,iBAAiB;AACtD;AAwCA;;CAEC,GACD,eAAe5C,qBACbZ,WAAmB,EACnBC,cAA8B;IAE9B,MAAMwD,kBAAkB5D,KAAKM,IAAI,CAACH,aAAa;IAC/C,MAAMoB,UAAU,MAAMxB,GAAGa,QAAQ,CAACgD,iBAAiB;IACnD,MAAMC,cAAcC,KAAKC,KAAK,CAACxC;IAE/B,IAAI,CAACsC,YAAYG,OAAO,EAAE;QACxBH,YAAYG,OAAO,GAAG,CAAC;IACzB;IAEA,8CAA8C;IAC9C,MAAMC,SAAS7D,mBAAmB,QAAQ,YAAYA;IACtD,MAAM8D,UAAU9D,mBAAmB,QAAQ,QAAQ,GAAGA,eAAe,KAAK,CAAC;IAE3EyD,YAAYG,OAAO,CAAC,kBAAkB,GACpC,GAAGC,OAAO,UAAU,EAAEC,QAAQ,kCAAkC,CAAC;IAEnE,MAAMnE,GAAGQ,SAAS,CAACqD,iBAAiBE,KAAKK,SAAS,CAACN,aAAa,MAAM,KAAK,MAAM;AACnF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/lambda-config.ts"],"sourcesContent":["import { parseModule, Syntax } from 'esprima-next'\nimport fs from 'fs/promises'\nimport path from 'path'\n\nimport type { PackageManager } from './package-manager.js'\n\nconst RUN_SH_CONTENT = `#!/bin/bash -x\n\n[ ! -d '/tmp/cache' ] && mkdir -p /tmp/cache\n\nNODE_ENV=production exec node server.js\n`\n\n/**\n * Apply Lambda-specific modifications to a Payload project\n *\n * @param projectPath - Path to project directory\n * @param packageManager - Package manager to use in scripts (defaults to 'pnpm')\n */\nexport async function applyLambdaModifications(\n projectPath: string,\n packageManager: PackageManager = 'pnpm',\n): Promise<void> {\n // 1. Create run.sh\n const runShPath = path.join(projectPath, 'run.sh')\n await fs.writeFile(runShPath, RUN_SH_CONTENT, 'utf-8')\n await fs.chmod(runShPath, 0o755)\n\n // 2. Modify next config to add standalone output and eslint ignore\n await addNextConfigProperties(projectPath)\n\n // 3. Create/update .npmrc\n const npmrcPath = path.join(projectPath, '.npmrc')\n let npmrcContent = ''\n\n try {\n npmrcContent = await fs.readFile(npmrcPath, 'utf-8')\n } catch {\n // File doesn't exist, start fresh\n }\n\n if (!npmrcContent.includes('node-linker=hoisted')) {\n npmrcContent += npmrcContent && !npmrcContent.endsWith('\\n') ? '\\n' : ''\n npmrcContent += 'node-linker=hoisted\\n'\n await fs.writeFile(npmrcPath, npmrcContent, 'utf-8')\n }\n\n // 4. Add lambda:buildzip script to package.json\n await addLambdaBuildScript(projectPath, packageManager)\n}\n\n/**\n * Find the Next.js config file (next.config.js or next.config.mjs)\n *\n * @todo Support TypeScript config files in future\n */\nasync function findNextConfigPath(projectPath: string): Promise<string> {\n const configFiles = ['next.config.js', 'next.config.mjs']\n\n for (const configFile of configFiles) {\n const configPath = path.join(projectPath, configFile)\n try {\n await fs.access(configPath)\n return configPath\n } catch {\n // File doesn't exist, try next one\n }\n }\n\n throw new Error('Could not find next.config.js or next.config.mjs')\n}\n\n/**\n * Add required Next.js config properties using AST parsing\n * - output: 'standalone' (for Lambda deployment)\n * - eslint: { ignoreDuringBuilds: true } (allow builds with lint errors)\n */\nasync function addNextConfigProperties(projectPath: string): Promise<void> {\n const nextConfigPath = await findNextConfigPath(projectPath)\n const content = await fs.readFile(nextConfigPath, 'utf-8')\n\n // Check which properties already exist\n const hasOutput = content.includes('output:')\n const hasEslint = content.includes('eslint:')\n\n // Early exit if both already configured\n if (hasOutput && hasEslint) {\n return\n }\n\n const ast = parseModule(content, { loc: true })\n\n // Find export default declaration\n const exportDefaultDeclaration = ast.body.find(\n (p) => p.type === Syntax.ExportDefaultDeclaration,\n ) as ExportDefaultDeclaration | undefined\n\n if (!exportDefaultDeclaration?.declaration?.loc) {\n throw new Error(`Could not find export default declaration in ${path.basename(nextConfigPath)}`)\n }\n\n // Find the object expression to modify\n let targetObjectExpression: ObjectExpressionNode | undefined\n\n if (exportDefaultDeclaration.declaration.type === 'ObjectExpression') {\n // Direct export: export default { ... }\n targetObjectExpression = exportDefaultDeclaration.declaration as ObjectExpressionNode\n } else if (exportDefaultDeclaration.declaration.type === 'CallExpression') {\n // Wrapped export: export default withPayload(nextConfig, ...)\n const callExpr = exportDefaultDeclaration.declaration as CallExpressionNode\n const firstArg = callExpr.arguments?.[0]\n\n if (firstArg?.type === 'Identifier') {\n // Find the variable declaration for this identifier\n const configVarName = (firstArg as IdentifierNode).name\n const varDeclaration = ast.body.find((node) => {\n if (node.type === Syntax.VariableDeclaration) {\n const varNode = node as VariableDeclarationNode\n return varNode.declarations?.some(\n (decl) =>\n decl.id?.type === 'Identifier' &&\n (decl.id as IdentifierNode).name === configVarName &&\n decl.init?.type === 'ObjectExpression',\n )\n }\n return false\n }) as undefined | VariableDeclarationNode\n\n if (varDeclaration) {\n const declarator = varDeclaration.declarations?.find(\n (decl) =>\n decl.id?.type === 'Identifier' && (decl.id as IdentifierNode).name === configVarName,\n )\n if (declarator?.init?.type === 'ObjectExpression') {\n targetObjectExpression = declarator.init as ObjectExpressionNode\n }\n }\n }\n }\n\n if (!targetObjectExpression?.loc) {\n throw new Error(\n `Could not find Next.js config object in ${path.basename(nextConfigPath)}. ` +\n `Expected either 'export default { ... }' or 'export default wrapper(configVar, ...)'`,\n )\n }\n\n const { loc } = targetObjectExpression\n const lines = content.split(/\\r?\\n/)\n\n // Build insertion string based on what's missing\n const parts: string[] = []\n if (!hasOutput) {\n parts.push(\"output: 'standalone',\")\n }\n if (!hasEslint) {\n parts.push(`eslint: {\n ignoreDuringBuilds: true,\n },`)\n }\n\n const insertString = '\\n ' + parts.join('\\n ')\n\n // Insert after opening brace\n const insertLine = loc.start.line - 1\n const insertColumn = loc.start.column + 1\n\n const targetLine = lines[insertLine]\n if (!targetLine) {\n throw new Error(`Could not find target line in ${path.basename(nextConfigPath)}`)\n }\n\n lines[insertLine] =\n targetLine.slice(0, insertColumn) + insertString + targetLine.slice(insertColumn)\n\n const modifiedContent = lines.join('\\n')\n await fs.writeFile(nextConfigPath, modifiedContent, 'utf-8')\n}\n\ntype ExportDefaultDeclaration = {\n declaration: {\n arguments?: unknown[]\n loc: {\n end: { column: number; line: number }\n start: { column: number; line: number }\n }\n type: string\n }\n type: string\n}\n\ntype ObjectExpressionNode = {\n loc: {\n end: { column: number; line: number }\n start: { column: number; line: number }\n }\n type: 'ObjectExpression'\n}\n\ntype IdentifierNode = {\n name: string\n type: 'Identifier'\n}\n\ntype CallExpressionNode = {\n arguments?: Array<{ type: string }>\n type: 'CallExpression'\n}\n\ntype VariableDeclarationNode = {\n declarations?: Array<{\n id?: { name?: string; type: string }\n init?: { loc?: ObjectExpressionNode['loc']; type: string }\n }>\n type: 'VariableDeclaration'\n}\n\n/**\n * Add lambda:buildzip script to package.json\n */\nasync function addLambdaBuildScript(\n projectPath: string,\n packageManager: PackageManager,\n): Promise<void> {\n const packageJsonPath = path.join(projectPath, 'package.json')\n const content = await fs.readFile(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(content)\n\n if (!packageJson.scripts) {\n packageJson.scripts = {}\n }\n\n // Use package manager's run and exec commands\n const runCmd = packageManager === 'npm' ? 'npm run' : packageManager\n const execCmd = packageManager === 'npm' ? 'npx' : `${packageManager} exec`\n\n packageJson.scripts['lambda:buildzip'] =\n `${runCmd} build && ${execCmd} payloadcms-figma build-lambda-zip`\n\n await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\\n', 'utf-8')\n}\n"],"names":["parseModule","Syntax","fs","path","RUN_SH_CONTENT","applyLambdaModifications","projectPath","packageManager","runShPath","join","writeFile","chmod","addNextConfigProperties","npmrcPath","npmrcContent","readFile","includes","endsWith","addLambdaBuildScript","findNextConfigPath","configFiles","configFile","configPath","access","Error","nextConfigPath","content","hasOutput","hasEslint","ast","loc","exportDefaultDeclaration","body","find","p","type","ExportDefaultDeclaration","declaration","basename","targetObjectExpression","callExpr","firstArg","arguments","configVarName","name","varDeclaration","node","VariableDeclaration","varNode","declarations","some","decl","id","init","declarator","lines","split","parts","push","insertString","insertLine","start","line","insertColumn","column","targetLine","slice","modifiedContent","packageJsonPath","packageJson","JSON","parse","scripts","runCmd","execCmd","stringify"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,eAAc;AAClD,OAAOC,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAIvB,MAAMC,iBAAiB,CAAC;;;;;AAKxB,CAAC;AAED;;;;;CAKC,GACD,OAAO,eAAeC,yBACpBC,WAAmB,EACnBC,iBAAiC,MAAM;IAEvC,mBAAmB;IACnB,MAAMC,YAAYL,KAAKM,IAAI,CAACH,aAAa;IACzC,MAAMJ,GAAGQ,SAAS,CAACF,WAAWJ,gBAAgB;IAC9C,MAAMF,GAAGS,KAAK,CAACH,WAAW;IAE1B,mEAAmE;IACnE,MAAMI,wBAAwBN;IAE9B,0BAA0B;IAC1B,MAAMO,YAAYV,KAAKM,IAAI,CAACH,aAAa;IACzC,IAAIQ,eAAe;IAEnB,IAAI;QACFA,eAAe,MAAMZ,GAAGa,QAAQ,CAACF,WAAW;IAC9C,EAAE,OAAM;IACN,kCAAkC;IACpC;IAEA,IAAI,CAACC,aAAaE,QAAQ,CAAC,wBAAwB;QACjDF,gBAAgBA,gBAAgB,CAACA,aAAaG,QAAQ,CAAC,QAAQ,OAAO;QACtEH,gBAAgB;QAChB,MAAMZ,GAAGQ,SA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|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/utils/messages.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAgB,WAAW,IAAI,IAAI,CA2ClC;AASD,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,CAiBzF;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAO3C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAgBpF;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
package/dist/utils/messages.js
CHANGED
|
@@ -22,12 +22,11 @@ export function helpMessage() {
|
|
|
22
22
|
${pc.dim('-h, --help Show help')}
|
|
23
23
|
${pc.dim('-v, --version Show CLI version')}
|
|
24
24
|
${pc.dim('--debug Enable debug logging')}
|
|
25
|
-
${pc.dim('--env <env> Set environment: prod or staging')}
|
|
26
25
|
|
|
27
26
|
${pc.bold('AUTHENTICATION')}
|
|
28
27
|
|
|
29
28
|
${pc.cyan('@payloadcms/figma login')} Authenticate with Figma
|
|
30
|
-
${pc.cyan('@payloadcms/figma logout')} Clear
|
|
29
|
+
${pc.cyan('@payloadcms/figma logout')} Clear tokens for current environment
|
|
31
30
|
${pc.cyan('@payloadcms/figma list-tokens')} Display stored OAuth and project tokens
|
|
32
31
|
|
|
33
32
|
${pc.bold('INIT COMMAND')}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/messages.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport path from 'path'\nimport pc from 'picocolors'\nimport terminalLink from 'terminal-link'\n\nimport type { PackageManager } from '../types.js'\n\nconst header = (message: string): string => pc.bold(message)\n\nexport function helpMessage(): void {\n console.log(`\n ${pc.bold('USAGE')}\n\n ${pc.dim('@payloadcms/figma <command> [options]')}\n\n ${pc.bold('COMMANDS')}\n\n ${pc.cyan('login')} Authenticate with Figma OAuth2\n ${pc.cyan('logout')} Clear all stored tokens\n ${pc.cyan('list-tokens')} Show stored token information\n ${pc.cyan('init')} Initialize a Figma CMS project\n ${pc.cyan('deploy')} Deploy your project to Figma\n ${pc.cyan('build-lambda-zip')} Build Lambda deployment zip\n\n ${pc.bold('OPTIONS')}\n\n ${pc.dim('-h, --help Show help')}\n ${pc.dim('-v, --version Show CLI version')}\n ${pc.dim('--debug Enable debug logging')}\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/messages.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport path from 'path'\nimport pc from 'picocolors'\nimport terminalLink from 'terminal-link'\n\nimport type { PackageManager } from '../types.js'\n\nconst header = (message: string): string => pc.bold(message)\n\nexport function helpMessage(): void {\n console.log(`\n ${pc.bold('USAGE')}\n\n ${pc.dim('@payloadcms/figma <command> [options]')}\n\n ${pc.bold('COMMANDS')}\n\n ${pc.cyan('login')} Authenticate with Figma OAuth2\n ${pc.cyan('logout')} Clear all stored tokens\n ${pc.cyan('list-tokens')} Show stored token information\n ${pc.cyan('init')} Initialize a Figma CMS project\n ${pc.cyan('deploy')} Deploy your project to Figma\n ${pc.cyan('build-lambda-zip')} Build Lambda deployment zip\n\n ${pc.bold('OPTIONS')}\n\n ${pc.dim('-h, --help Show help')}\n ${pc.dim('-v, --version Show CLI version')}\n ${pc.dim('--debug Enable debug logging')}\n\n ${pc.bold('AUTHENTICATION')}\n\n ${pc.cyan('@payloadcms/figma login')} Authenticate with Figma\n ${pc.cyan('@payloadcms/figma logout')} Clear tokens for current environment\n ${pc.cyan('@payloadcms/figma list-tokens')} Display stored OAuth and project tokens\n\n ${pc.bold('INIT COMMAND')}\n\n ${pc.cyan('@payloadcms/figma init --id <content-system-id>')} Initialize project with Content System ID\n ${pc.cyan('@payloadcms/figma init --force')} Force reconfiguration of existing project\n\n ${pc.bold('DEPLOY COMMAND')}\n\n ${pc.cyan('@payloadcms/figma deploy')} Deploy your project to Figma\n ${pc.dim('--yes, -y')} Skip confirmation prompts\n ${pc.dim('--skip-build')} Skip building and use existing build\n\n ${pc.bold('DOCUMENTATION')}\n\n ${createTerminalLink('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload')}\n ${createTerminalLink('Figma CMS Docs', 'https://www.figma.com/developers/api')}\n`)\n}\n\n// Create terminalLink with fallback for unsupported terminals\nfunction createTerminalLink(text: string, url: string) {\n return terminalLink(text, url, {\n fallback: (text, url) => `${text}: ${url}`,\n })\n}\n\nexport function successMessage(projectDir: string, packageManager: PackageManager): string {\n const relativePath = path.relative(process.cwd(), projectDir)\n return `\n${header('Launch Application:')}\n\n - cd ./${relativePath}\n - ${packageManager === 'npm' ? 'npm run' : packageManager} dev or follow directions in README.md\n\n${header('Documentation:')}\n\n - ${createTerminalLink(\n 'Getting Started',\n 'https://payloadcms.com/docs/getting-started/what-is-payload',\n )}\n - ${createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview')}\n\n`\n}\n\nexport function successfulNextInit(): string {\n return `- ${createTerminalLink(\n 'Getting Started',\n 'https://payloadcms.com/docs/getting-started/what-is-payload',\n )}\n- ${createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview')}\n`\n}\n\nexport function moveMessage(args: { nextAppDir: string; projectDir: string }): string {\n const relativeAppDir = path.relative(process.cwd(), args.nextAppDir)\n return `\n${header('Next Steps:')}\n\nPayload does not support a top-level layout.tsx file in the app directory.\n\n${pc.bold('To continue:')}\n\n- Create a new directory in ./${relativeAppDir} such as ./${relativeAppDir}/${pc.bold('(app)')}\n- Move all files from ./${relativeAppDir} into that directory\n\nIt is recommended to do this from your IDE if your app has existing file references.\n\nOnce moved, rerun the @payloadcms/figma command again.\n`\n}\n\nexport function feedbackOutro(): string {\n return `${pc.bgCyan(pc.black(' Have feedback? '))} Visit us on ${createTerminalLink('GitHub', 'https://github.com/payloadcms/payload')}.`\n}\n"],"names":["path","pc","terminalLink","header","message","bold","helpMessage","console","log","dim","cyan","createTerminalLink","text","url","fallback","successMessage","projectDir","packageManager","relativePath","relative","process","cwd","successfulNextInit","moveMessage","args","relativeAppDir","nextAppDir","feedbackOutro","bgCyan","black"],"mappings":"AAAA,6BAA6B,GAC7B,OAAOA,UAAU,OAAM;AACvB,OAAOC,QAAQ,aAAY;AAC3B,OAAOC,kBAAkB,gBAAe;AAIxC,MAAMC,SAAS,CAACC,UAA4BH,GAAGI,IAAI,CAACD;AAEpD,OAAO,SAASE;IACdC,QAAQC,GAAG,CAAC,CAAC;EACb,EAAEP,GAAGI,IAAI,CAAC,SAAS;;MAEf,EAAEJ,GAAGQ,GAAG,CAAC,yCAAyC;;EAEtD,EAAER,GAAGI,IAAI,CAAC,YAAY;;MAElB,EAAEJ,GAAGS,IAAI,CAAC,SAAS;MACnB,EAAET,GAAGS,IAAI,CAAC,UAAU;MACpB,EAAET,GAAGS,IAAI,CAAC,eAAe;MACzB,EAAET,GAAGS,IAAI,CAAC,QAAQ;MAClB,EAAET,GAAGS,IAAI,CAAC,UAAU;MACpB,EAAET,GAAGS,IAAI,CAAC,oBAAoB;;EAElC,EAAET,GAAGI,IAAI,CAAC,WAAW;;MAEjB,EAAEJ,GAAGQ,GAAG,CAAC,iCAAiC;MAC1C,EAAER,GAAGQ,GAAG,CAAC,wCAAwC;MACjD,EAAER,GAAGQ,GAAG,CAAC,4CAA4C;;EAEzD,EAAER,GAAGI,IAAI,CAAC,kBAAkB;;MAExB,EAAEJ,GAAGS,IAAI,CAAC,2BAA2B;MACrC,EAAET,GAAGS,IAAI,CAAC,4BAA4B;MACtC,EAAET,GAAGS,IAAI,CAAC,iCAAiC;;EAE/C,EAAET,GAAGI,IAAI,CAAC,gBAAgB;;MAEtB,EAAEJ,GAAGS,IAAI,CAAC,mDAAmD;MAC7D,EAAET,GAAGS,IAAI,CAAC,kCAAkC;;EAEhD,EAAET,GAAGI,IAAI,CAAC,kBAAkB;;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ASE;IACd,OAAO,GAAG1B,GAAG2B,MAAM,CAAC3B,GAAG4B,KAAK,CAAC,qBAAqB,aAAa,EAAElB,mBAAmB,UAAU,yCAAyC,CAAC,CAAC;AAC3I"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAOrD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,GAAE,MAAsB,GAClC,OAAO,CAAC,WAAW,CAAC,CAwCtB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAS/D;AAiED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAOrD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,GAAE,MAAsB,GAClC,OAAO,CAAC,WAAW,CAAC,CAwCtB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAS/D;AAiED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoD7F;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAE3D;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,KAAK,GAAG,MAAM,GAAG,MAAc,GAC9C,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAenF;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,WAAW,GAAE,MAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAQhG"}
|
package/dist/utils/project.js
CHANGED
|
@@ -163,6 +163,9 @@ import { applyLambdaModifications } from './lambda-config.js';
|
|
|
163
163
|
let readmeContent = await fs.readFile(readmeTemplatePath, 'utf-8');
|
|
164
164
|
readmeContent = readmeContent.replace(/\{\{PROJECT_NAME\}\}/g, projectName);
|
|
165
165
|
await fs.writeFile(path.join(projectPath, 'README.md'), readmeContent, 'utf-8');
|
|
166
|
+
// Copy .env.example template
|
|
167
|
+
const envExampleTemplatePath = fileURLToPath(new URL('../templates/.env.example', import.meta.url));
|
|
168
|
+
await fs.copyFile(envExampleTemplatePath, path.join(projectPath, '.env.example'));
|
|
166
169
|
}
|
|
167
170
|
/**
|
|
168
171
|
* Initialize git repository after all setup is complete
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/project.ts"],"sourcesContent":["/**\n * Project detection and scaffolding utilities\n */\n\nimport spawn from 'cross-spawn'\nimport fs from 'fs/promises'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\n\nimport type { ProjectInfo } from '../types/config.js'\n\nimport { ensureGitignore } from './config.js'\nimport { downloadTemplateFromGitHub } from './download-template.js'\nimport { tryInitRepoAndCommit } from './git.js'\nimport { applyLambdaModifications } from './lambda-config.js'\n\n/**\n * Detect if current directory has a Payload project\n *\n * @param projectPath - Path to check (defaults to cwd)\n * @returns Project information\n */\nexport async function detectPayloadProject(\n projectPath: string = process.cwd(),\n): Promise<ProjectInfo> {\n const packageJsonPath = path.join(projectPath, 'package.json')\n\n try {\n const content = await fs.readFile(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(content)\n\n // Check for payload in dependencies or devDependencies\n const payloadVersion = packageJson.dependencies?.payload || packageJson.devDependencies?.payload\n\n // Detect package manager\n let packageManager: 'npm' | 'pnpm' | 'yarn' = 'npm'\n try {\n await fs.access(path.join(projectPath, 'pnpm-lock.yaml'))\n packageManager = 'pnpm'\n } catch {\n try {\n await fs.access(path.join(projectPath, 'yarn.lock'))\n packageManager = 'yarn'\n } catch {\n packageManager = 'npm'\n }\n }\n\n return {\n hasPayload: !!payloadVersion,\n packageManager,\n path: projectPath,\n payloadVersion: payloadVersion || undefined,\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n // No package.json found\n return {\n hasPayload: false,\n path: projectPath,\n }\n }\n throw new Error(`Failed to read package.json: ${(error as Error).message}`)\n }\n}\n\n/**\n * Validate Payload version (must be 3.x)\n *\n * @param version - Version string from package.json\n * @returns True if version is valid\n */\nexport function validatePayloadVersion(version: string): boolean {\n // Extract major version (handle ^3.0.0, ~3.0.0, 3.0.0, etc.)\n const match = version.match(/(\\d+)/)\n if (!match) {\n return false\n }\n\n const majorVersion = parseInt(match[1], 10)\n return majorVersion === 3\n}\n\n/**\n * Fetch the latest version of a package from npm registry\n *\n * @param packageName - Package name to fetch version for\n * @returns Latest version string\n */\nasync function getLatestPackageVersion(packageName: string): Promise<string> {\n const response = await fetch(`https://registry.npmjs.org/-/package/${packageName}/dist-tags`)\n\n if (!response.ok) {\n throw new Error(`Failed to fetch version for ${packageName}: ${response.statusText}`)\n }\n\n const data = (await response.json()) as Record<string, unknown>\n\n if (typeof data.latest !== 'string') {\n throw new Error(`Invalid version data received for ${packageName}`)\n }\n\n return data.latest\n}\n\n/**\n * Replace workspace versions in package.json with actual versions\n *\n * @param packageJson - Package JSON object to update\n * @param latestVersion - Latest Payload version to use\n */\nfunction replaceWorkspaceVersions(\n packageJson: Record<string, unknown>,\n latestVersion: string,\n): void {\n const deps = packageJson.dependencies as Record<string, string> | undefined\n if (!deps) {\n return\n }\n\n for (const [key, value] of Object.entries(deps)) {\n // Replace workspace:* or workspace:^ with actual version\n if (typeof value === 'string' && value.startsWith('workspace:')) {\n deps[key] = latestVersion\n }\n // Ensure all payload packages use the same version\n else if (key === 'payload' || key.startsWith('@payloadcms/')) {\n deps[key] = latestVersion\n }\n }\n\n // Also handle devDependencies if present\n const devDeps = packageJson.devDependencies as Record<string, string> | undefined\n if (!devDeps) {\n return\n }\n\n for (const [key, value] of Object.entries(devDeps)) {\n if (typeof value === 'string' && value.startsWith('workspace:')) {\n devDeps[key] = latestVersion\n } else if (key === 'payload' || key.startsWith('@payloadcms/')) {\n devDeps[key] = latestVersion\n }\n }\n}\n\n/**\n * Scaffold a new Payload project from GitHub template\n *\n * @param projectPath - Path where to create the project\n * @param projectName - Name for the project\n */\nexport async function scaffoldProject(projectPath: string, projectName: string): Promise<void> {\n // Create project directory if it doesn't exist\n await fs.mkdir(projectPath, { recursive: true })\n\n // Download template from GitHub\n await downloadTemplateFromGitHub(projectPath)\n\n // Apply Lambda modifications BEFORE updating package.json\n // This ensures we don't overwrite version replacements\n await applyLambdaModifications(projectPath)\n\n // Get latest Payload version from npm\n const latestVersion = await getLatestPackageVersion('payload')\n\n // Delete any existing lock files from template (they reference workspace:* versions)\n // This ensures pnpm install creates a fresh lock file with actual versions\n const lockFiles = ['pnpm-lock.yaml', 'yarn.lock', 'package-lock.json']\n for (const lockFile of lockFiles) {\n try {\n await fs.unlink(path.join(projectPath, lockFile))\n } catch {\n // File doesn't exist, ignore\n }\n }\n\n // Update package.json: set name, replace workspace versions\n // This must come AFTER applyLambdaModifications to ensure we have final versions\n const packageJsonPath = path.join(projectPath, 'package.json')\n const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(packageJsonContent) as Record<string, unknown>\n packageJson.name = projectName\n\n // Replace workspace:* versions with actual versions\n replaceWorkspaceVersions(packageJson, latestVersion)\n\n await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\\n', 'utf-8')\n\n // Ensure .gitignore has required entries\n // Note: .env file is created by init command with FIGMA_CONTENT_SYSTEM_ID\n await ensureGitignore(projectPath, ['.env', '.env.local', 'lambda.zip'])\n\n // Replace README with Figma-specific version\n const readmeTemplatePath = fileURLToPath(new URL('../templates/README.md', import.meta.url))\n let readmeContent = await fs.readFile(readmeTemplatePath, 'utf-8')\n readmeContent = readmeContent.replace(/\\{\\{PROJECT_NAME\\}\\}/g, projectName)\n await fs.writeFile(path.join(projectPath, 'README.md'), readmeContent, 'utf-8')\n}\n\n/**\n * Initialize git repository after all setup is complete\n *\n * This should be called AFTER installDependencies so that lock files are included\n *\n * @param projectPath - Path to project directory\n */\nexport function initializeGitRepo(projectPath: string): void {\n tryInitRepoAndCommit(projectPath)\n}\n\n/**\n * Install dependencies using the detected package manager\n *\n * @param projectPath - Path to project\n * @param packageManager - Package manager to use\n * @returns Promise that resolves when installation completes\n */\nexport async function installDependencies(\n projectPath: string,\n packageManager: 'npm' | 'pnpm' | 'yarn' = 'npm',\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const child = spawn(packageManager, ['install'], {\n cwd: projectPath,\n stdio: 'pipe',\n })\n\n let stdout = ''\n let stderr = ''\n\n // Capture stdout\n child.stdout?.on('data', (data) => {\n stdout += data.toString()\n })\n\n // Capture stderr\n child.stderr?.on('data', (data) => {\n stderr += data.toString()\n })\n\n child.on('close', (code) => {\n if (code === 0) {\n resolve()\n } else {\n // Show captured output on error\n const output = [stdout, stderr].filter(Boolean).join('\\n\\n')\n const errorMessage = output\n ? `${packageManager} install failed with code ${code}\\n\\nOutput:\\n${output}`\n : `${packageManager} install failed with code ${code}`\n reject(new Error(errorMessage))\n }\n })\n\n child.on('error', (error) => {\n reject(new Error(`Failed to run ${packageManager} install: ${error.message}`))\n })\n })\n}\n\n/**\n * Check if required dependencies are installed\n *\n * @param projectPath - Path to project\n * @returns True if all required dependencies exist\n */\nexport async function hasRequiredDependencies(projectPath: string): Promise<boolean> {\n const packageJsonPath = path.join(projectPath, 'package.json')\n\n try {\n const content = await fs.readFile(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(content)\n\n // Check for Payload and Next.js\n const hasPayload = packageJson.dependencies?.payload || packageJson.devDependencies?.payload\n const hasNext = packageJson.dependencies?.next || packageJson.devDependencies?.next\n\n return !!(hasPayload && hasNext)\n } catch {\n return false\n }\n}\n\n/**\n * Check if current directory is a project directory\n *\n * A project directory has package.json\n *\n * @param projectPath - Path to check (defaults to cwd)\n * @returns True if in project directory\n */\nexport async function isInProjectDirectory(projectPath: string = process.cwd()): Promise<boolean> {\n try {\n // Check for package.json\n await fs.access(path.join(projectPath, 'package.json'))\n return true\n } catch {\n return false\n }\n}\n"],"names":["spawn","fs","path","fileURLToPath","ensureGitignore","downloadTemplateFromGitHub","tryInitRepoAndCommit","applyLambdaModifications","detectPayloadProject","projectPath","process","cwd","packageJsonPath","join","content","readFile","packageJson","JSON","parse","payloadVersion","dependencies","payload","devDependencies","packageManager","access","hasPayload","undefined","error","code","Error","message","validatePayloadVersion","version","match","majorVersion","parseInt","getLatestPackageVersion","packageName","response","fetch","ok","statusText","data","json","latest","replaceWorkspaceVersions","latestVersion","deps","key","value","Object","entries","startsWith","devDeps","scaffoldProject","projectName","mkdir","recursive","lockFiles","lockFile","unlink","packageJsonContent","name","writeFile","stringify","readmeTemplatePath","URL","url","readmeContent","replace","initializeGitRepo","installDependencies","Promise","resolve","reject","child","stdio","stdout","stderr","on","toString","output","filter","Boolean","errorMessage","hasRequiredDependencies","hasNext","next","isInProjectDirectory"],"mappings":"AAAA;;CAEC,GAED,OAAOA,WAAW,cAAa;AAC/B,OAAOC,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AAInC,SAASC,eAAe,QAAQ,cAAa;AAC7C,SAASC,0BAA0B,QAAQ,yBAAwB;AACnE,SAASC,oBAAoB,QAAQ,WAAU;AAC/C,SAASC,wBAAwB,QAAQ,qBAAo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E,QAAQvE,YAAYM,eAAe,EAAEiE;QAE/E,OAAO,CAAC,CAAE9D,CAAAA,cAAc6D,OAAM;IAChC,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeE,qBAAqB/E,cAAsBC,QAAQC,GAAG,EAAE;IAC5E,IAAI;QACF,yBAAyB;QACzB,MAAMV,GAAGuB,MAAM,CAACtB,KAAKW,IAAI,CAACJ,aAAa;QACvC,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/project.ts"],"sourcesContent":["/**\n * Project detection and scaffolding utilities\n */\n\nimport spawn from 'cross-spawn'\nimport fs from 'fs/promises'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\n\nimport type { ProjectInfo } from '../types/config.js'\n\nimport { ensureGitignore } from './config.js'\nimport { downloadTemplateFromGitHub } from './download-template.js'\nimport { tryInitRepoAndCommit } from './git.js'\nimport { applyLambdaModifications } from './lambda-config.js'\n\n/**\n * Detect if current directory has a Payload project\n *\n * @param projectPath - Path to check (defaults to cwd)\n * @returns Project information\n */\nexport async function detectPayloadProject(\n projectPath: string = process.cwd(),\n): Promise<ProjectInfo> {\n const packageJsonPath = path.join(projectPath, 'package.json')\n\n try {\n const content = await fs.readFile(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(content)\n\n // Check for payload in dependencies or devDependencies\n const payloadVersion = packageJson.dependencies?.payload || packageJson.devDependencies?.payload\n\n // Detect package manager\n let packageManager: 'npm' | 'pnpm' | 'yarn' = 'npm'\n try {\n await fs.access(path.join(projectPath, 'pnpm-lock.yaml'))\n packageManager = 'pnpm'\n } catch {\n try {\n await fs.access(path.join(projectPath, 'yarn.lock'))\n packageManager = 'yarn'\n } catch {\n packageManager = 'npm'\n }\n }\n\n return {\n hasPayload: !!payloadVersion,\n packageManager,\n path: projectPath,\n payloadVersion: payloadVersion || undefined,\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n // No package.json found\n return {\n hasPayload: false,\n path: projectPath,\n }\n }\n throw new Error(`Failed to read package.json: ${(error as Error).message}`)\n }\n}\n\n/**\n * Validate Payload version (must be 3.x)\n *\n * @param version - Version string from package.json\n * @returns True if version is valid\n */\nexport function validatePayloadVersion(version: string): boolean {\n // Extract major version (handle ^3.0.0, ~3.0.0, 3.0.0, etc.)\n const match = version.match(/(\\d+)/)\n if (!match) {\n return false\n }\n\n const majorVersion = parseInt(match[1], 10)\n return majorVersion === 3\n}\n\n/**\n * Fetch the latest version of a package from npm registry\n *\n * @param packageName - Package name to fetch version for\n * @returns Latest version string\n */\nasync function getLatestPackageVersion(packageName: string): Promise<string> {\n const response = await fetch(`https://registry.npmjs.org/-/package/${packageName}/dist-tags`)\n\n if (!response.ok) {\n throw new Error(`Failed to fetch version for ${packageName}: ${response.statusText}`)\n }\n\n const data = (await response.json()) as Record<string, unknown>\n\n if (typeof data.latest !== 'string') {\n throw new Error(`Invalid version data received for ${packageName}`)\n }\n\n return data.latest\n}\n\n/**\n * Replace workspace versions in package.json with actual versions\n *\n * @param packageJson - Package JSON object to update\n * @param latestVersion - Latest Payload version to use\n */\nfunction replaceWorkspaceVersions(\n packageJson: Record<string, unknown>,\n latestVersion: string,\n): void {\n const deps = packageJson.dependencies as Record<string, string> | undefined\n if (!deps) {\n return\n }\n\n for (const [key, value] of Object.entries(deps)) {\n // Replace workspace:* or workspace:^ with actual version\n if (typeof value === 'string' && value.startsWith('workspace:')) {\n deps[key] = latestVersion\n }\n // Ensure all payload packages use the same version\n else if (key === 'payload' || key.startsWith('@payloadcms/')) {\n deps[key] = latestVersion\n }\n }\n\n // Also handle devDependencies if present\n const devDeps = packageJson.devDependencies as Record<string, string> | undefined\n if (!devDeps) {\n return\n }\n\n for (const [key, value] of Object.entries(devDeps)) {\n if (typeof value === 'string' && value.startsWith('workspace:')) {\n devDeps[key] = latestVersion\n } else if (key === 'payload' || key.startsWith('@payloadcms/')) {\n devDeps[key] = latestVersion\n }\n }\n}\n\n/**\n * Scaffold a new Payload project from GitHub template\n *\n * @param projectPath - Path where to create the project\n * @param projectName - Name for the project\n */\nexport async function scaffoldProject(projectPath: string, projectName: string): Promise<void> {\n // Create project directory if it doesn't exist\n await fs.mkdir(projectPath, { recursive: true })\n\n // Download template from GitHub\n await downloadTemplateFromGitHub(projectPath)\n\n // Apply Lambda modifications BEFORE updating package.json\n // This ensures we don't overwrite version replacements\n await applyLambdaModifications(projectPath)\n\n // Get latest Payload version from npm\n const latestVersion = await getLatestPackageVersion('payload')\n\n // Delete any existing lock files from template (they reference workspace:* versions)\n // This ensures pnpm install creates a fresh lock file with actual versions\n const lockFiles = ['pnpm-lock.yaml', 'yarn.lock', 'package-lock.json']\n for (const lockFile of lockFiles) {\n try {\n await fs.unlink(path.join(projectPath, lockFile))\n } catch {\n // File doesn't exist, ignore\n }\n }\n\n // Update package.json: set name, replace workspace versions\n // This must come AFTER applyLambdaModifications to ensure we have final versions\n const packageJsonPath = path.join(projectPath, 'package.json')\n const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(packageJsonContent) as Record<string, unknown>\n packageJson.name = projectName\n\n // Replace workspace:* versions with actual versions\n replaceWorkspaceVersions(packageJson, latestVersion)\n\n await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\\n', 'utf-8')\n\n // Ensure .gitignore has required entries\n // Note: .env file is created by init command with FIGMA_CONTENT_SYSTEM_ID\n await ensureGitignore(projectPath, ['.env', '.env.local', 'lambda.zip'])\n\n // Replace README with Figma-specific version\n const readmeTemplatePath = fileURLToPath(new URL('../templates/README.md', import.meta.url))\n let readmeContent = await fs.readFile(readmeTemplatePath, 'utf-8')\n readmeContent = readmeContent.replace(/\\{\\{PROJECT_NAME\\}\\}/g, projectName)\n await fs.writeFile(path.join(projectPath, 'README.md'), readmeContent, 'utf-8')\n\n // Copy .env.example template\n const envExampleTemplatePath = fileURLToPath(\n new URL('../templates/.env.example', import.meta.url),\n )\n await fs.copyFile(envExampleTemplatePath, path.join(projectPath, '.env.example'))\n}\n\n/**\n * Initialize git repository after all setup is complete\n *\n * This should be called AFTER installDependencies so that lock files are included\n *\n * @param projectPath - Path to project directory\n */\nexport function initializeGitRepo(projectPath: string): void {\n tryInitRepoAndCommit(projectPath)\n}\n\n/**\n * Install dependencies using the detected package manager\n *\n * @param projectPath - Path to project\n * @param packageManager - Package manager to use\n * @returns Promise that resolves when installation completes\n */\nexport async function installDependencies(\n projectPath: string,\n packageManager: 'npm' | 'pnpm' | 'yarn' = 'npm',\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const child = spawn(packageManager, ['install'], {\n cwd: projectPath,\n stdio: 'pipe',\n })\n\n let stdout = ''\n let stderr = ''\n\n // Capture stdout\n child.stdout?.on('data', (data) => {\n stdout += data.toString()\n })\n\n // Capture stderr\n child.stderr?.on('data', (data) => {\n stderr += data.toString()\n })\n\n child.on('close', (code) => {\n if (code === 0) {\n resolve()\n } else {\n // Show captured output on error\n const output = [stdout, stderr].filter(Boolean).join('\\n\\n')\n const errorMessage = output\n ? `${packageManager} install failed with code ${code}\\n\\nOutput:\\n${output}`\n : `${packageManager} install failed with code ${code}`\n reject(new Error(errorMessage))\n }\n })\n\n child.on('error', (error) => {\n reject(new Error(`Failed to run ${packageManager} install: ${error.message}`))\n })\n })\n}\n\n/**\n * Check if required dependencies are installed\n *\n * @param projectPath - Path to project\n * @returns True if all required dependencies exist\n */\nexport async function hasRequiredDependencies(projectPath: string): Promise<boolean> {\n const packageJsonPath = path.join(projectPath, 'package.json')\n\n try {\n const content = await fs.readFile(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(content)\n\n // Check for Payload and Next.js\n const hasPayload = packageJson.dependencies?.payload || packageJson.devDependencies?.payload\n const hasNext = packageJson.dependencies?.next || packageJson.devDependencies?.next\n\n return !!(hasPayload && hasNext)\n } catch {\n return false\n }\n}\n\n/**\n * Check if current directory is a project directory\n *\n * A project directory has package.json\n *\n * @param projectPath - Path to check (defaults to cwd)\n * @returns True if in project directory\n */\nexport async function isInProjectDirectory(projectPath: string = process.cwd()): Promise<boolean> {\n try {\n // Check for package.json\n await fs.access(path.join(projectPath, 'package.json'))\n return true\n } catch {\n return false\n }\n}\n"],"names":["spawn","fs","path","fileURLToPath","ensureGitignore","downloadTemplateFromGitHub","tryInitRepoAndCommit","applyLambdaModifications","detectPayloadProject","projectPath","process","cwd","packageJsonPath","join","content","readFile","packageJson","JSON","parse","payloadVersion","dependencies","payload","devDependencies","packageManager","access","hasPayload","undefined","error","code","Error","message","validatePayloadVersion","version","match","majorVersion","parseInt","getLatestPackageVersion","packageName","response","fetch","ok","statusText","data","json","latest","replaceWorkspaceVersions","latestVersion","deps","key","value","Object","entries","startsWith","devDeps","scaffoldProject","projectName","mkdir","recursive","lockFiles","lockFile","unlink","packageJsonContent","name","writeFile","stringify","readmeTemplatePath","URL","url","readmeContent","replace","envExampleTemplatePath","copyFile","initializeGitRepo","installDependencies","Promise","resolve","reject","child","stdio","stdout","stderr","on","toString","output","filter","Boolean","errorMessage","hasRequiredDependencies","hasNext","next","isInProjectDirectory"],"mappings":"AAAA;;CAEC,GAED,OAAOA,WAAW,cAAa;AAC/B,OAAOC,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AAInC,SAASC,eAAe,QAAQ,cAAa;AAC7C,SAASC,0BAA0B,QAAQ,yBAAwB;AACnE,SAASC,oBAAoB,QAAQ,WAAU;AAC/C,SAASC,wBAAwB,QAAQ,qBAAoB;AAE7D;;;;;CAKC,GACD,OAAO,eAAeC,qBACpBC,cAAsBC,QAAQC,GAAG,EAAE;IAEnC,MAAMC,kBAAkBV,KAAKW,IAAI,CAACJ,aAAa;IAE/C,IAAI;QACF,MAAMK,UAAU,MAAMb,GAAGc,QAAQ,CAACH,iBAAiB;QACnD,MAAMI,cAAcC,KAAKC,KAAK,CAACJ;QAE/B,uDAAuD;QACvD,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M;QACN,OAAO;IACT;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeE,qBAAqBjF,cAAsBC,QAAQC,GAAG,EAAE;IAC5E,IAAI;QACF,yBAAyB;QACzB,MAAMV,GAAGuB,MAAM,CAACtB,KAAKW,IAAI,CAACJ,aAAa;QACvC,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/figma",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.43",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
76
76
|
"build:types": "tsc --project tsconfig.build.json",
|
|
77
77
|
"clean": "rimraf -g \"{dist,*.tsbuildinfo,package}\"",
|
|
78
|
-
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,md}\" dist/",
|
|
78
|
+
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,md}\" \"src/**/.env.example\" dist/",
|
|
79
79
|
"debug:clear-tokens": "tsx scripts/clear-tokens.ts",
|
|
80
80
|
"debug:expire-token": "tsx scripts/expire-token.ts",
|
|
81
81
|
"debug:get-project-token": "tsx scripts/get-project-token.ts",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { components } from '../generated/content-api-types.js';
|
|
2
|
-
export declare const getPaginationData: (contentAPIPagination: components["schemas"]["Pagination"], pagination?: boolean) => {
|
|
3
|
-
hasNextPage: boolean;
|
|
4
|
-
hasPrevPage: boolean;
|
|
5
|
-
limit: number;
|
|
6
|
-
nextPage: number | null;
|
|
7
|
-
page: number;
|
|
8
|
-
pagingCounter: number;
|
|
9
|
-
prevPage: number | null;
|
|
10
|
-
totalDocs: number;
|
|
11
|
-
totalPages: number;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/db-content-api/temp-utilities/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AA6BnE,eAAO,MAAM,iBAAiB,yBACN,UAAU,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,eAC5C,OAAO;;;;;;;;;;CAiBrB,CAAA"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Convert Content API pagination response to Payload's expected format
|
|
2
|
-
// Content API already calculates next/prev pages, we just need to transform the structure
|
|
3
|
-
//
|
|
4
|
-
// Content API format (nested):
|
|
5
|
-
// {
|
|
6
|
-
// data: [...],
|
|
7
|
-
// pagination: {
|
|
8
|
-
// total: 100,
|
|
9
|
-
// current: { limit: 10, page: 2 },
|
|
10
|
-
// next: { limit: 10, page: 3 },
|
|
11
|
-
// prev: { limit: 10, page: 1 }
|
|
12
|
-
// }
|
|
13
|
-
// }
|
|
14
|
-
//
|
|
15
|
-
// Payload format (flat):
|
|
16
|
-
// {
|
|
17
|
-
// docs: [...],
|
|
18
|
-
// hasNextPage: true,
|
|
19
|
-
// hasPrevPage: true,
|
|
20
|
-
// limit: 10,
|
|
21
|
-
// nextPage: 3,
|
|
22
|
-
// page: 2,
|
|
23
|
-
// pagingCounter: 11,
|
|
24
|
-
// prevPage: 1,
|
|
25
|
-
// totalDocs: 100,
|
|
26
|
-
// totalPages: 10
|
|
27
|
-
// }
|
|
28
|
-
export const getPaginationData = (contentAPIPagination, pagination)=>{
|
|
29
|
-
const { current, next, prev, total } = contentAPIPagination;
|
|
30
|
-
const hasNextPage = pagination !== false && next !== undefined;
|
|
31
|
-
const hasPrevPage = pagination !== false && prev !== undefined;
|
|
32
|
-
return {
|
|
33
|
-
hasNextPage,
|
|
34
|
-
hasPrevPage,
|
|
35
|
-
limit: current.limit,
|
|
36
|
-
nextPage: next?.page ?? null,
|
|
37
|
-
page: current.page,
|
|
38
|
-
pagingCounter: (current.page - 1) * current.limit + 1,
|
|
39
|
-
prevPage: prev?.page ?? null,
|
|
40
|
-
totalDocs: total,
|
|
41
|
-
totalPages: current.limit > 0 ? Math.ceil(total / current.limit) : 1
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=pagination.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/db-content-api/temp-utilities/pagination.ts"],"sourcesContent":["import type { components } from '../generated/content-api-types.js'\n\n// Convert Content API pagination response to Payload's expected format\n// Content API already calculates next/prev pages, we just need to transform the structure\n//\n// Content API format (nested):\n// {\n// data: [...],\n// pagination: {\n// total: 100,\n// current: { limit: 10, page: 2 },\n// next: { limit: 10, page: 3 },\n// prev: { limit: 10, page: 1 }\n// }\n// }\n//\n// Payload format (flat):\n// {\n// docs: [...],\n// hasNextPage: true,\n// hasPrevPage: true,\n// limit: 10,\n// nextPage: 3,\n// page: 2,\n// pagingCounter: 11,\n// prevPage: 1,\n// totalDocs: 100,\n// totalPages: 10\n// }\nexport const getPaginationData = (\n contentAPIPagination: components['schemas']['Pagination'],\n pagination?: boolean,\n) => {\n const { current, next, prev, total } = contentAPIPagination\n const hasNextPage = pagination !== false && next !== undefined\n const hasPrevPage = pagination !== false && prev !== undefined\n\n return {\n hasNextPage,\n hasPrevPage,\n limit: current.limit,\n nextPage: next?.page ?? null,\n page: current.page,\n pagingCounter: (current.page - 1) * current.limit + 1,\n prevPage: prev?.page ?? null,\n totalDocs: total,\n totalPages: current.limit > 0 ? Math.ceil(total / current.limit) : 1,\n }\n}\n"],"names":["getPaginationData","contentAPIPagination","pagination","current","next","prev","total","hasNextPage","undefined","hasPrevPage","limit","nextPage","page","pagingCounter","prevPage","totalDocs","totalPages","Math","ceil"],"mappings":"AAEA,uEAAuE;AACvE,0FAA0F;AAC1F,EAAE;AACF,+BAA+B;AAC/B,IAAI;AACJ,iBAAiB;AACjB,kBAAkB;AAClB,kBAAkB;AAClB,uCAAuC;AACvC,oCAAoC;AACpC,mCAAmC;AACnC,MAAM;AACN,IAAI;AACJ,EAAE;AACF,yBAAyB;AACzB,IAAI;AACJ,iBAAiB;AACjB,uBAAuB;AACvB,uBAAuB;AACvB,eAAe;AACf,iBAAiB;AACjB,aAAa;AACb,uBAAuB;AACvB,iBAAiB;AACjB,oBAAoB;AACpB,mBAAmB;AACnB,IAAI;AACJ,OAAO,MAAMA,oBAAoB,CAC/BC,sBACAC;IAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGL;IACvC,MAAMM,cAAcL,eAAe,SAASE,SAASI;IACrD,MAAMC,cAAcP,eAAe,SAASG,SAASG;IAErD,OAAO;QACLD;QACAE;QACAC,OAAOP,QAAQO,KAAK;QACpBC,UAAUP,MAAMQ,QAAQ;QACxBA,MAAMT,QAAQS,IAAI;QAClBC,eAAe,AAACV,CAAAA,QAAQS,IAAI,GAAG,CAAA,IAAKT,QAAQO,KAAK,GAAG;QACpDI,UAAUT,MAAMO,QAAQ;QACxBG,WAAWT;QACXU,YAAYb,QAAQO,KAAK,GAAG,IAAIO,KAAKC,IAAI,CAACZ,QAAQH,QAAQO,KAAK,IAAI;IACrE;AACF,EAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ClientConfig, SanitizedConfig } from 'payload';
|
|
2
|
-
/**
|
|
3
|
-
* This is the path to the admin panel WITHOUT domain.
|
|
4
|
-
*
|
|
5
|
-
* This respects the `basePath` property in the Next config.
|
|
6
|
-
*/
|
|
7
|
-
export declare const getAdminPath: (config: ClientConfig | SanitizedConfig) => string;
|
|
8
|
-
//# sourceMappingURL=getAdminPath.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAdminPath.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/getAdminPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE5D;;;;GAIG;AACH,eAAO,MAAM,YAAY,WAAY,YAAY,GAAG,eAAe,WAElE,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the path to the admin panel WITHOUT domain.
|
|
3
|
-
*
|
|
4
|
-
* This respects the `basePath` property in the Next config.
|
|
5
|
-
*/ export const getAdminPath = (config)=>{
|
|
6
|
-
return `${process.env.NEXT_BASE_PATH ?? ''}${config.routes?.admin || '/admin'}`;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=getAdminPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/oauth/utilities/getAdminPath.ts"],"sourcesContent":["import type { ClientConfig, SanitizedConfig } from 'payload'\n\n/**\n * This is the path to the admin panel WITHOUT domain.\n *\n * This respects the `basePath` property in the Next config.\n */\nexport const getAdminPath = (config: ClientConfig | SanitizedConfig) => {\n return `${process.env.NEXT_BASE_PATH ?? ''}${config.routes?.admin || '/admin'}`\n}\n"],"names":["getAdminPath","config","process","env","NEXT_BASE_PATH","routes","admin"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,eAAe,CAACC;IAC3B,OAAO,GAAGC,QAAQC,GAAG,CAACC,cAAc,IAAI,KAAKH,OAAOI,MAAM,EAAEC,SAAS,UAAU;AACjF,EAAC"}
|