@payloadcms/figma 0.0.1-alpha.44 → 0.0.1-alpha.46
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/api/control-plane.d.ts.map +1 -1
- package/dist/api/control-plane.js +90 -54
- package/dist/api/control-plane.js.map +1 -1
- package/dist/api/figma-api.d.ts +20 -0
- package/dist/api/figma-api.d.ts.map +1 -1
- package/dist/api/figma-api.js +34 -0
- package/dist/api/figma-api.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/debug.d.ts +8 -0
- package/dist/commands/debug.d.ts.map +1 -0
- package/dist/commands/debug.js +156 -0
- package/dist/commands/debug.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +17 -14
- package/dist/commands/init.js.map +1 -1
- package/dist/db-content-api/index.d.ts.map +1 -1
- package/dist/db-content-api/index.js +26 -7
- package/dist/db-content-api/index.js.map +1 -1
- package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
- package/dist/db-content-api/temp-utilities/types.d.ts.map +1 -0
- package/dist/db-content-api/temp-utilities/types.js +15 -0
- package/dist/db-content-api/temp-utilities/types.js.map +1 -0
- package/dist/db-content-api/utilities/data/index.d.ts +14 -4
- package/dist/db-content-api/utilities/data/index.d.ts.map +1 -1
- package/dist/db-content-api/utilities/data/index.js +15 -8
- package/dist/db-content-api/utilities/data/index.js.map +1 -1
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts.map +1 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js.map +1 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts.map +1 -1
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js.map +1 -1
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +17 -2
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts.map +1 -1
- package/dist/db-content-api/utilities/meta/buildMeta.js +4 -1
- package/dist/db-content-api/utilities/meta/buildMeta.js.map +1 -1
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +8 -2
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts.map +1 -1
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +41 -11
- package/dist/db-content-api/utilities/meta/buildPathTypes.js.map +1 -1
- package/dist/db-content-api/utilities/where.d.ts +8 -0
- package/dist/db-content-api/utilities/where.d.ts.map +1 -1
- package/dist/db-content-api/utilities/where.js +6 -0
- package/dist/db-content-api/utilities/where.js.map +1 -1
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +2 -0
- package/dist/exports/client.js.map +1 -1
- package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts.map +1 -0
- package/dist/oauth/components/FigmaAvatar/index.js +27 -0
- package/dist/oauth/components/FigmaAvatar/index.js.map +1 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts.map +1 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js.map +1 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts.map +1 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js.map +1 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/defaults.d.ts.map +1 -1
- package/dist/oauth/defaults.js +38 -5
- package/dist/oauth/defaults.js.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +49 -14
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
- package/dist/plugin/build-config.d.ts.map +1 -1
- package/dist/plugin/build-config.js +44 -2
- package/dist/plugin/build-config.js.map +1 -1
- package/dist/templates/README.md +1 -1
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +0 -2
- package/dist/types/config.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/lambda-config.d.ts +1 -1
- package/dist/utils/lambda-config.d.ts.map +1 -1
- package/dist/utils/lambda-config.js +2 -2
- package/dist/utils/lambda-config.js.map +1 -1
- package/dist/utils/messages.d.ts +1 -1
- package/dist/utils/messages.d.ts.map +1 -1
- package/dist/utils/messages.js +1 -0
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.d.ts.map +1 -1
- package/dist/utils/package-manager.js +53 -0
- package/dist/utils/package-manager.js.map +1 -1
- package/dist/utils/payload-config-modifier.d.ts +1 -1
- package/dist/utils/payload-config-modifier.d.ts.map +1 -1
- package/dist/utils/payload-config-modifier.js +4 -3
- package/dist/utils/payload-config-modifier.js.map +1 -1
- package/dist/utils/project.d.ts +3 -2
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +4 -2
- package/dist/utils/project.js.map +1 -1
- package/package.json +1 -1
- package/dist/db-content-api/utilities/meta/index.d.ts +0 -5
- package/dist/db-content-api/utilities/meta/index.d.ts.map +0 -1
- package/dist/db-content-api/utilities/meta/index.js +0 -5
- package/dist/db-content-api/utilities/meta/index.js.map +0 -1
|
@@ -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 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;I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"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 'npm')\n */\nexport async function applyLambdaModifications(\n projectPath: string,\n packageManager: PackageManager = 'npm',\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,KAAK;IAEtC,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,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HANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PackageManager } from '
|
|
1
|
+
import type { PackageManager } from './package-manager.js';
|
|
2
2
|
export declare function helpMessage(): void;
|
|
3
3
|
export declare function successMessage(projectDir: string, packageManager: PackageManager): string;
|
|
4
4
|
export declare function successfulNextInit(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/utils/messages.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/utils/messages.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAI1D,wBAAgB,WAAW,IAAI,IAAI,CA4ClC;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
|
@@ -14,6 +14,7 @@ export function helpMessage() {
|
|
|
14
14
|
${pc.cyan('logout')} Clear all stored tokens
|
|
15
15
|
${pc.cyan('list-tokens')} Show stored token information
|
|
16
16
|
${pc.cyan('init')} Initialize a Figma CMS project
|
|
17
|
+
${pc.cyan('debug')} Show debug info for troubleshooting
|
|
17
18
|
${pc.cyan('deploy')} Deploy your project to Figma
|
|
18
19
|
${pc.cyan('build-lambda-zip')} Build Lambda deployment zip
|
|
19
20
|
|
|
@@ -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 '
|
|
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 './package-manager.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('debug')} Show debug info for troubleshooting\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,OA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package manager, defaults to npm
|
|
10
10
|
*/
|
|
11
11
|
export declare function getPackageManager(projectDir: string): Promise<PackageManager>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve package manager for a project directory.
|
|
14
|
+
* Checks lockfiles first, falls back to environment detection.
|
|
15
|
+
*
|
|
16
|
+
* @param projectDir - Project directory to check
|
|
17
|
+
* @returns Resolved package manager
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolvePackageManager(projectDir: string): Promise<PackageManager>;
|
|
20
|
+
/**
|
|
21
|
+
* Detect package manager from npm_config_user_agent environment variable.
|
|
22
|
+
* Set automatically by npm/pnpm/yarn when running via npx/pnpm dlx/yarn dlx.
|
|
23
|
+
*
|
|
24
|
+
* @returns Detected package manager, defaults to npm
|
|
25
|
+
*/
|
|
26
|
+
export declare function detectPackageManagerFromEnvironment(): PackageManager;
|
|
27
|
+
/**
|
|
28
|
+
* Get the run command prefix for a package manager.
|
|
29
|
+
* npm needs "npm run", pnpm/yarn can run scripts directly.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getRunCommand(packageManager: PackageManager): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get the add/install command for a package manager.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getAddCommand(packageManager: PackageManager): string;
|
|
12
36
|
//# sourceMappingURL=package-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/utils/package-manager.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAEpD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAoBnF"}
|
|
1
|
+
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/utils/package-manager.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAEpD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAoBnF;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAcvF;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,IAAI,cAAc,CAcpE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,MAAM,CAEpE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,MAAM,CAQpE"}
|
|
@@ -23,6 +23,59 @@ import path from 'path';
|
|
|
23
23
|
return 'npm';
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolve package manager for a project directory.
|
|
28
|
+
* Checks lockfiles first, falls back to environment detection.
|
|
29
|
+
*
|
|
30
|
+
* @param projectDir - Project directory to check
|
|
31
|
+
* @returns Resolved package manager
|
|
32
|
+
*/ export async function resolvePackageManager(projectDir) {
|
|
33
|
+
const fromLockfile = await getPackageManager(projectDir);
|
|
34
|
+
if (fromLockfile !== 'npm') {
|
|
35
|
+
return fromLockfile;
|
|
36
|
+
}
|
|
37
|
+
// Check if there's actually a package-lock.json (explicit npm choice)
|
|
38
|
+
if (await fileExists(path.join(projectDir, 'package-lock.json'))) {
|
|
39
|
+
return 'npm';
|
|
40
|
+
}
|
|
41
|
+
// No lockfile found — check environment
|
|
42
|
+
return detectPackageManagerFromEnvironment();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Detect package manager from npm_config_user_agent environment variable.
|
|
46
|
+
* Set automatically by npm/pnpm/yarn when running via npx/pnpm dlx/yarn dlx.
|
|
47
|
+
*
|
|
48
|
+
* @returns Detected package manager, defaults to npm
|
|
49
|
+
*/ export function detectPackageManagerFromEnvironment() {
|
|
50
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
51
|
+
if (!userAgent) {
|
|
52
|
+
return 'npm';
|
|
53
|
+
}
|
|
54
|
+
if (userAgent.startsWith('pnpm/')) {
|
|
55
|
+
return 'pnpm';
|
|
56
|
+
}
|
|
57
|
+
if (userAgent.startsWith('yarn/')) {
|
|
58
|
+
return 'yarn';
|
|
59
|
+
}
|
|
60
|
+
return 'npm';
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the run command prefix for a package manager.
|
|
64
|
+
* npm needs "npm run", pnpm/yarn can run scripts directly.
|
|
65
|
+
*/ export function getRunCommand(packageManager) {
|
|
66
|
+
return packageManager === 'npm' ? 'npm run' : packageManager;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the add/install command for a package manager.
|
|
70
|
+
*/ export function getAddCommand(packageManager) {
|
|
71
|
+
if (packageManager === 'npm') {
|
|
72
|
+
return 'npm install';
|
|
73
|
+
}
|
|
74
|
+
if (packageManager === 'pnpm') {
|
|
75
|
+
return 'pnpm add';
|
|
76
|
+
}
|
|
77
|
+
return 'yarn add';
|
|
78
|
+
}
|
|
26
79
|
/**
|
|
27
80
|
* Check if file exists
|
|
28
81
|
*/ async function fileExists(filePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/package-manager.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\n/**\n * Supported package managers\n */\nexport type PackageManager = 'npm' | 'pnpm' | 'yarn'\n\n/**\n * Detect package manager from lockfiles\n *\n * @param projectDir - Project directory to check\n * @returns Detected package manager, defaults to npm\n */\nexport async function getPackageManager(projectDir: string): Promise<PackageManager> {\n try {\n // Check for lockfiles in order of preference\n if (await fileExists(path.join(projectDir, 'pnpm-lock.yaml'))) {\n return 'pnpm'\n }\n\n if (await fileExists(path.join(projectDir, 'yarn.lock'))) {\n return 'yarn'\n }\n\n if (await fileExists(path.join(projectDir, 'package-lock.json'))) {\n return 'npm'\n }\n\n // Default to npm if no lockfile found\n return 'npm'\n } catch {\n return 'npm'\n }\n}\n\n/**\n * Check if file exists\n */\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await fs.stat(filePath)\n return true\n } catch {\n return false\n }\n}\n"],"names":["fs","path","getPackageManager","projectDir","fileExists","join","filePath","stat"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAOvB;;;;;CAKC,GACD,OAAO,eAAeC,kBAAkBC,UAAkB;IACxD,IAAI;QACF,6CAA6C;QAC7C,IAAI,MAAMC,WAAWH,KAAKI,IAAI,CAACF,YAAY,oBAAoB;YAC7D,OAAO;QACT;QAEA,IAAI,MAAMC,WAAWH,KAAKI,IAAI,CAACF,YAAY,eAAe;YACxD,OAAO;QACT;QAEA,IAAI,MAAMC,WAAWH,KAAKI,IAAI,CAACF,YAAY,uBAAuB;YAChE,OAAO;QACT;QAEA,sCAAsC;QACtC,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;CAEC,GACD,
|
|
1
|
+
{"version":3,"sources":["../../src/utils/package-manager.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\n/**\n * Supported package managers\n */\nexport type PackageManager = 'npm' | 'pnpm' | 'yarn'\n\n/**\n * Detect package manager from lockfiles\n *\n * @param projectDir - Project directory to check\n * @returns Detected package manager, defaults to npm\n */\nexport async function getPackageManager(projectDir: string): Promise<PackageManager> {\n try {\n // Check for lockfiles in order of preference\n if (await fileExists(path.join(projectDir, 'pnpm-lock.yaml'))) {\n return 'pnpm'\n }\n\n if (await fileExists(path.join(projectDir, 'yarn.lock'))) {\n return 'yarn'\n }\n\n if (await fileExists(path.join(projectDir, 'package-lock.json'))) {\n return 'npm'\n }\n\n // Default to npm if no lockfile found\n return 'npm'\n } catch {\n return 'npm'\n }\n}\n\n/**\n * Resolve package manager for a project directory.\n * Checks lockfiles first, falls back to environment detection.\n *\n * @param projectDir - Project directory to check\n * @returns Resolved package manager\n */\nexport async function resolvePackageManager(projectDir: string): Promise<PackageManager> {\n const fromLockfile = await getPackageManager(projectDir)\n\n if (fromLockfile !== 'npm') {\n return fromLockfile\n }\n\n // Check if there's actually a package-lock.json (explicit npm choice)\n if (await fileExists(path.join(projectDir, 'package-lock.json'))) {\n return 'npm'\n }\n\n // No lockfile found — check environment\n return detectPackageManagerFromEnvironment()\n}\n\n/**\n * Detect package manager from npm_config_user_agent environment variable.\n * Set automatically by npm/pnpm/yarn when running via npx/pnpm dlx/yarn dlx.\n *\n * @returns Detected package manager, defaults to npm\n */\nexport function detectPackageManagerFromEnvironment(): PackageManager {\n const userAgent = process.env.npm_config_user_agent\n if (!userAgent) {\n return 'npm'\n }\n\n if (userAgent.startsWith('pnpm/')) {\n return 'pnpm'\n }\n if (userAgent.startsWith('yarn/')) {\n return 'yarn'\n }\n\n return 'npm'\n}\n\n/**\n * Get the run command prefix for a package manager.\n * npm needs \"npm run\", pnpm/yarn can run scripts directly.\n */\nexport function getRunCommand(packageManager: PackageManager): string {\n return packageManager === 'npm' ? 'npm run' : packageManager\n}\n\n/**\n * Get the add/install command for a package manager.\n */\nexport function getAddCommand(packageManager: PackageManager): string {\n if (packageManager === 'npm') {\n return 'npm install'\n }\n if (packageManager === 'pnpm') {\n return 'pnpm add'\n }\n return 'yarn add'\n}\n\n/**\n * Check if file exists\n */\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await fs.stat(filePath)\n return true\n } catch {\n return false\n }\n}\n"],"names":["fs","path","getPackageManager","projectDir","fileExists","join","resolvePackageManager","fromLockfile","detectPackageManagerFromEnvironment","userAgent","process","env","npm_config_user_agent","startsWith","getRunCommand","packageManager","getAddCommand","filePath","stat"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAOvB;;;;;CAKC,GACD,OAAO,eAAeC,kBAAkBC,UAAkB;IACxD,IAAI;QACF,6CAA6C;QAC7C,IAAI,MAAMC,WAAWH,KAAKI,IAAI,CAACF,YAAY,oBAAoB;YAC7D,OAAO;QACT;QAEA,IAAI,MAAMC,WAAWH,KAAKI,IAAI,CAACF,YAAY,eAAe;YACxD,OAAO;QACT;QAEA,IAAI,MAAMC,WAAWH,KAAKI,IAAI,CAACF,YAAY,uBAAuB;YAChE,OAAO;QACT;QAEA,sCAAsC;QACtC,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;;;;;CAMC,GACD,OAAO,eAAeG,sBAAsBH,UAAkB;IAC5D,MAAMI,eAAe,MAAML,kBAAkBC;IAE7C,IAAII,iBAAiB,OAAO;QAC1B,OAAOA;IACT;IAEA,sEAAsE;IACtE,IAAI,MAAMH,WAAWH,KAAKI,IAAI,CAACF,YAAY,uBAAuB;QAChE,OAAO;IACT;IAEA,wCAAwC;IACxC,OAAOK;AACT;AAEA;;;;;CAKC,GACD,OAAO,SAASA;IACd,MAAMC,YAAYC,QAAQC,GAAG,CAACC,qBAAqB;IACnD,IAAI,CAACH,WAAW;QACd,OAAO;IACT;IAEA,IAAIA,UAAUI,UAAU,CAAC,UAAU;QACjC,OAAO;IACT;IACA,IAAIJ,UAAUI,UAAU,CAAC,UAAU;QACjC,OAAO;IACT;IAEA,OAAO;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,cAAcC,cAA8B;IAC1D,OAAOA,mBAAmB,QAAQ,YAAYA;AAChD;AAEA;;CAEC,GACD,OAAO,SAASC,cAAcD,cAA8B;IAC1D,IAAIA,mBAAmB,OAAO;QAC5B,OAAO;IACT;IACA,IAAIA,mBAAmB,QAAQ;QAC7B,OAAO;IACT;IACA,OAAO;AACT;AAEA;;CAEC,GACD,eAAeX,WAAWa,QAAgB;IACxC,IAAI;QACF,MAAMjB,GAAGkB,IAAI,CAACD;QACd,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
|
@@ -15,5 +15,5 @@ export declare function ensurePayloadFigmaConfig(projectPath: string, packageMan
|
|
|
15
15
|
/**
|
|
16
16
|
* Display manual configuration instructions
|
|
17
17
|
*/
|
|
18
|
-
export declare function displayManualInstructions(reason: string): void;
|
|
18
|
+
export declare function displayManualInstructions(reason: string, packageManager?: PackageManager): void;
|
|
19
19
|
//# sourceMappingURL=payload-config-modifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload-config-modifier.d.ts","sourceRoot":"","sources":["../../src/utils/payload-config-modifier.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"payload-config-modifier.d.ts","sourceRoot":"","sources":["../../src/utils/payload-config-modifier.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAK1D,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAA;AAUhC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,cAAc,EAC9B,WAAW,CAAC,EAAE,mBAAmB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAoQ7B;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,cAAc,GAAE,cAAsB,GACrC,IAAI,CAwCN"}
|
|
@@ -2,6 +2,7 @@ import pc from 'picocolors';
|
|
|
2
2
|
import { Project } from 'ts-morph';
|
|
3
3
|
import { formatFile } from './formatter.js';
|
|
4
4
|
import * as log from './log.js';
|
|
5
|
+
import { getAddCommand, getRunCommand } from './package-manager.js';
|
|
5
6
|
import { addFigmaProperty, applyModifications, detectRequiredChanges } from './payload-config-ast.js';
|
|
6
7
|
import { findPayloadConfig } from './payload-config-finder.js';
|
|
7
8
|
import { checkPackageInstalled, getPayloadVersion, installPackage, uninstallPackage } from './payload-package-check.js';
|
|
@@ -183,7 +184,7 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
183
184
|
log.debug('Running TypeScript validation...');
|
|
184
185
|
const tsResult = await runTypeScriptCheck(projectPath, packageManager);
|
|
185
186
|
if (!tsResult.success && tsResult.errors.length > 0) {
|
|
186
|
-
warnings.push(
|
|
187
|
+
warnings.push(`TypeScript validation found issues - run '${getRunCommand(packageManager)} build' for details`);
|
|
187
188
|
log.debug(`TypeScript validation found ${tsResult.errors.length} issues`);
|
|
188
189
|
}
|
|
189
190
|
} else {
|
|
@@ -211,7 +212,7 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
211
212
|
}
|
|
212
213
|
/**
|
|
213
214
|
* Display manual configuration instructions
|
|
214
|
-
*/ export function displayManualInstructions(reason) {
|
|
215
|
+
*/ export function displayManualInstructions(reason, packageManager = 'npm') {
|
|
215
216
|
const leftLineWrap = (message)=>{
|
|
216
217
|
// Add '┌ ' prefix to first line, '│ ' to subsequent lines, and '└ ' to last line
|
|
217
218
|
return message.split(/\r?\n/).map((line, index, arr)=>{
|
|
@@ -241,7 +242,7 @@ ${pc.bold('Required changes:')}
|
|
|
241
242
|
• editor (if using default lexicalEditor())
|
|
242
243
|
|
|
243
244
|
3. Install package:
|
|
244
|
-
${pc.cyan(
|
|
245
|
+
${pc.cyan(`${getAddCommand(packageManager)} @payloadcms/figma`)}
|
|
245
246
|
|
|
246
247
|
Then run: ${pc.cyan('npx @payloadcms/figma init')}`);
|
|
247
248
|
// eslint-disable-next-line no-console
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/payload-config-modifier.ts"],"sourcesContent":["import pc from 'picocolors'\nimport { Project } from 'ts-morph'\n\nimport type { PackageManager } from './package-manager.js'\n\nimport { formatFile } from './formatter.js'\nimport * as log from './log.js'\nimport {\n addFigmaProperty,\n applyModifications,\n detectRequiredChanges,\n type FigmaPropertyConfig,\n} from './payload-config-ast.js'\nimport { findPayloadConfig } from './payload-config-finder.js'\nimport {\n checkPackageInstalled,\n getPayloadVersion,\n installPackage,\n uninstallPackage,\n} from './payload-package-check.js'\nimport { runTypeScriptCheck } from './typescript-validator.js'\n\nexport type ModificationResult = {\n changes: string[]\n error?: string\n modified: boolean\n success: boolean\n warnings?: string[]\n}\n\n/**\n * Main orchestrator for payload config modification\n * Checks package, detects needed changes, applies modifications\n */\nexport async function ensurePayloadFigmaConfig(\n projectPath: string,\n packageManager: PackageManager,\n figmaConfig?: FigmaPropertyConfig,\n): Promise<ModificationResult> {\n const changes: string[] = []\n const warnings: string[] = []\n let modified = false\n\n try {\n log.debug(`Starting payload config modification for: ${projectPath}`)\n\n // 1. Find config file\n const configPath = await findPayloadConfig(projectPath)\n if (!configPath) {\n log.debug(`Config file not found in: ${projectPath}`)\n return {\n changes: [],\n error: 'payload.config.ts not found in project',\n modified: false,\n success: false,\n }\n }\n\n log.debug(`Found config file: ${configPath}`)\n\n // Get payload version to pin @payloadcms/* dependencies\n const payloadVersion = await getPayloadVersion(projectPath)\n log.debug(`Detected payload version: ${payloadVersion || 'unknown'}`)\n\n // 2. Check/install @payloadcms/figma package\n const isInstalled = await checkPackageInstalled(projectPath, '@payloadcms/figma')\n if (!isInstalled) {\n log.debug('@payloadcms/figma not installed, attempting installation...')\n try {\n await installPackage(projectPath, '@payloadcms/figma', packageManager)\n changes.push('Installed @payloadcms/figma')\n modified = true\n log.debug('@payloadcms/figma installed successfully')\n } catch (error) {\n log.debug(\n `Failed to install @payloadcms/figma: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n return {\n changes: [],\n error: 'Failed to install @payloadcms/figma',\n modified: false,\n success: false,\n }\n }\n } else {\n log.debug('@payloadcms/figma already installed')\n }\n\n // 3. Parse config with ts-morph\n log.debug('Parsing config file with ts-morph...')\n const project = new Project({\n skipAddingFilesFromTsConfig: true,\n })\n const sourceFile = project.addSourceFileAtPath(configPath)\n\n // 4. Detect required changes\n log.debug('Detecting required changes...')\n const detection = detectRequiredChanges(sourceFile)\n\n log.debug(\n `Detection results: needsImportChange=${detection.needsImportChange}, hasAlias=${detection.hasAlias}, hasBuildConfig=${detection.hasBuildConfig}`,\n )\n\n // Handle failure modes\n if (detection.hasAlias) {\n log.debug('Config uses import alias (e.g., buildConfig as X)')\n return {\n changes,\n error: 'Config uses import alias - manual modification required',\n modified,\n success: false,\n }\n }\n\n if (detection.hasBuildConfig === false) {\n log.debug('No buildConfig call found in config file')\n return {\n changes,\n error: 'Config structure not recognized (no buildConfig call found)',\n modified,\n success: false,\n }\n }\n\n // 5. Apply modifications\n log.debug('Applying modifications...')\n const modResult = applyModifications(sourceFile, detection)\n if (modResult.modified) {\n changes.push(...modResult.changes)\n modified = true\n\n log.debug(`Applied ${modResult.changes.length} modifications`)\n }\n\n // 6. Add figma property if config provided and doesn't exist\n if (figmaConfig && !detection.figmaObjectExists) {\n log.debug('Adding figma property to buildConfig...')\n const figmaResult = addFigmaProperty(sourceFile, figmaConfig)\n if (figmaResult.modified) {\n changes.push(...figmaResult.changes)\n modified = true\n log.debug(`Added figma property`)\n } else {\n log.debug('Figma property not added (may already exist)')\n }\n } else if (detection.figmaObjectExists) {\n log.debug('Figma property already exists, skipping')\n }\n\n // Save file if any modifications were made\n if (modified) {\n await sourceFile.save()\n log.debug('Config file saved')\n\n // 7. Handle package management\n const packagesToUninstall: string[] = []\n\n // Uninstall db adapter (buildFigmaConfig provides its own)\n if (detection.dbProperty) {\n packagesToUninstall.push(detection.dbProperty.importSource)\n }\n\n // Uninstall sharp (Figma infrastructure handles image processing)\n if (detection.sharpProperty) {\n packagesToUninstall.push('sharp')\n }\n\n // Ensure lexical is installed if user doesn't have a custom editor\n // (buildFigmaConfig uses lexicalEditor() as default)\n if (!detection.editorProperty) {\n log.debug(\n 'No editor property detected - will ensure lexical is installed for default editor',\n )\n } else if (detection.editorProperty.isDefault) {\n log.debug('Default lexicalEditor() detected - will ensure lexical is installed')\n } else {\n log.debug(\n `Custom editor detected (${detection.editorProperty.importSource}) - skipping lexical installation`,\n )\n }\n\n if (!detection.editorProperty || detection.editorProperty.isDefault) {\n log.debug('Checking if @payloadcms/richtext-lexical is installed...')\n const hasLexical = await checkPackageInstalled(projectPath, '@payloadcms/richtext-lexical')\n if (!hasLexical) {\n log.debug('@payloadcms/richtext-lexical not found, installing...')\n try {\n await installPackage(\n projectPath,\n '@payloadcms/richtext-lexical',\n packageManager,\n payloadVersion,\n )\n changes.push('Installed @payloadcms/richtext-lexical (default editor)')\n log.debug('Successfully installed @payloadcms/richtext-lexical')\n } catch (error) {\n log.debug(\n `Failed to install @payloadcms/richtext-lexical: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n // Don't fail on install error - user can install manually if needed\n warnings.push(\n 'Could not install @payloadcms/richtext-lexical - you may need to install it manually',\n )\n }\n } else {\n log.debug('@payloadcms/richtext-lexical already installed, skipping')\n }\n }\n\n // Ensure cloud-storage is installed (required peer dependency for buildFigmaConfig)\n log.debug('Checking if @payloadcms/plugin-cloud-storage is installed...')\n const hasCloudStorage = await checkPackageInstalled(\n projectPath,\n '@payloadcms/plugin-cloud-storage',\n )\n if (!hasCloudStorage) {\n log.debug('@payloadcms/plugin-cloud-storage not found, installing...')\n try {\n await installPackage(\n projectPath,\n '@payloadcms/plugin-cloud-storage',\n packageManager,\n payloadVersion,\n )\n changes.push('Installed @payloadcms/plugin-cloud-storage')\n log.debug('Successfully installed @payloadcms/plugin-cloud-storage')\n } catch (error) {\n log.debug(\n `Failed to install @payloadcms/plugin-cloud-storage: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n warnings.push(\n 'Could not install @payloadcms/plugin-cloud-storage - you may need to install it manually',\n )\n }\n } else {\n log.debug('@payloadcms/plugin-cloud-storage already installed, skipping')\n }\n\n if (packagesToUninstall.length > 0) {\n log.debug(`Uninstalling ${packagesToUninstall.length} orphaned packages...`)\n }\n\n for (const pkg of packagesToUninstall) {\n try {\n await uninstallPackage(projectPath, pkg, packageManager)\n changes.push(`Uninstalled ${pkg}`)\n log.debug(`Uninstalled ${pkg}`)\n } catch (error) {\n log.debug(\n `Failed to uninstall ${pkg}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n // Don't fail on uninstall errors - orphaned package is better than broken config\n }\n }\n\n // 8. Format file\n log.debug('Formatting config file...')\n const formatResult = await formatFile(configPath, packageManager)\n if (!formatResult.success && formatResult.warning) {\n warnings.push(formatResult.warning)\n log.debug(`Formatting warning: ${formatResult.warning}`)\n }\n\n // 9. Run TypeScript validation\n log.debug('Running TypeScript validation...')\n const tsResult = await runTypeScriptCheck(projectPath, packageManager)\n if (!tsResult.success && tsResult.errors.length > 0) {\n warnings.push(\"TypeScript validation found issues - run 'pnpm build' for details\")\n log.debug(`TypeScript validation found ${tsResult.errors.length} issues`)\n }\n } else {\n log.debug('No modifications needed - config already correct')\n }\n\n log.debug('Payload config modification completed successfully')\n\n return {\n changes,\n modified,\n success: true,\n warnings: warnings.length > 0 ? warnings : undefined,\n }\n } catch (error) {\n log.debug(\n `Unexpected error in ensurePayloadFigmaConfig: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n if (error instanceof Error && error.stack) {\n log.debug(`Stack trace: ${error.stack}`)\n }\n return {\n changes,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n modified,\n success: false,\n }\n }\n}\n\n/**\n * Display manual configuration instructions\n */\nexport function displayManualInstructions(reason: string): void {\n const leftLineWrap = (message: string): string => {\n // Add '┌ ' prefix to first line, '│ ' to subsequent lines, and '└ ' to last line\n return message\n .split(/\\r?\\n/)\n .map((line, index, arr) => {\n if (index === 0) {\n return `${pc.dim('┌ ')}${line}`\n } else if (index === arr.length - 1) {\n return `${pc.dim('└ ')}${line}`\n } else {\n return `${pc.dim('│ ')}${line}`\n }\n })\n .join('\\n')\n }\n\n const message = leftLineWrap(`${pc.cyan(pc.bold('Manual Configuration Required'))}\n\nUnable to automatically modify payload.config.ts\nReason: ${pc.yellow(reason)}\n\n${pc.bold('Required changes:')}\n\n1. Replace buildConfig import:\n ${pc.dim('- FROM: ')}${pc.cyan(\"import { buildConfig } from 'payload'\")}\n ${pc.dim('- TO: ')}${pc.cyan(\"import { buildFigmaConfig } from '@payloadcms/figma'\")}\n\n2. Remove these properties from buildConfig():\n • db\n • secret\n • editor (if using default lexicalEditor())\n\n3. Install package:\n ${pc.cyan('pnpm add @payloadcms/figma')}\n\nThen run: ${pc.cyan('npx @payloadcms/figma init')}`)\n\n // eslint-disable-next-line no-console\n console.log(message)\n}\n"],"names":["pc","Project","formatFile","log","addFigmaProperty","applyModifications","detectRequiredChanges","findPayloadConfig","checkPackageInstalled","getPayloadVersion","installPackage","uninstallPackage","runTypeScriptCheck","ensurePayloadFigmaConfig","projectPath","packageManager","figmaConfig","changes","warnings","modified","debug","configPath","error","success","payloadVersion","isInstalled","push","Error","message","project","skipAddingFilesFromTsConfig","sourceFile","addSourceFileAtPath","detection","needsImportChange","hasAlias","hasBuildConfig","modResult","length","figmaObjectExists","figmaResult","save","packagesToUninstall","dbProperty","importSource","sharpProperty","editorProperty","isDefault","hasLexical","hasCloudStorage","pkg","formatResult","warning","tsResult","errors","undefined","stack","displayManualInstructions","reason","leftLineWrap","split","map","line","index","arr","dim","join","cyan","bold","yellow","console"],"mappings":"AAAA,OAAOA,QAAQ,aAAY;AAC3B,SAASC,OAAO,QAAQ,WAAU;AAIlC,SAASC,UAAU,QAAQ,iBAAgB;AAC3C,YAAYC,SAAS,WAAU;AAC/B,SACEC,gBAAgB,EAChBC,kBAAkB,EAClBC,qBAAqB,QAEhB,0BAAyB;AAChC,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,cAAc,EACdC,gBAAgB,QACX,6BAA4B;AACnC,SA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AAEpE,GAAGqE,MAAM,CAACX,QAAQ;;AAE5B,EAAE1D,GAAGoE,IAAI,CAAC,qBAAqB;;;GAG5B,EAAEpE,GAAGiE,GAAG,CAAC,cAAcjE,GAAGmE,IAAI,CAAC,yCAAyC;GACxE,EAAEnE,GAAGiE,GAAG,CAAC,cAAcjE,GAAGmE,IAAI,CAAC,wDAAwD;;;;;;;;GAQvF,EAAEnE,GAAGmE,IAAI,CAAC,8BAA8B;;UAEjC,EAAEnE,GAAGmE,IAAI,CAAC,+BAA+B;IAEjD,sCAAsC;IACtCG,QAAQnE,GAAG,CAACyB;AACd"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/payload-config-modifier.ts"],"sourcesContent":["import pc from 'picocolors'\nimport { Project } from 'ts-morph'\n\nimport type { PackageManager } from './package-manager.js'\n\nimport { formatFile } from './formatter.js'\nimport * as log from './log.js'\nimport { getAddCommand, getRunCommand } from './package-manager.js'\nimport {\n addFigmaProperty,\n applyModifications,\n detectRequiredChanges,\n type FigmaPropertyConfig,\n} from './payload-config-ast.js'\nimport { findPayloadConfig } from './payload-config-finder.js'\nimport {\n checkPackageInstalled,\n getPayloadVersion,\n installPackage,\n uninstallPackage,\n} from './payload-package-check.js'\nimport { runTypeScriptCheck } from './typescript-validator.js'\n\nexport type ModificationResult = {\n changes: string[]\n error?: string\n modified: boolean\n success: boolean\n warnings?: string[]\n}\n\n/**\n * Main orchestrator for payload config modification\n * Checks package, detects needed changes, applies modifications\n */\nexport async function ensurePayloadFigmaConfig(\n projectPath: string,\n packageManager: PackageManager,\n figmaConfig?: FigmaPropertyConfig,\n): Promise<ModificationResult> {\n const changes: string[] = []\n const warnings: string[] = []\n let modified = false\n\n try {\n log.debug(`Starting payload config modification for: ${projectPath}`)\n\n // 1. Find config file\n const configPath = await findPayloadConfig(projectPath)\n if (!configPath) {\n log.debug(`Config file not found in: ${projectPath}`)\n return {\n changes: [],\n error: 'payload.config.ts not found in project',\n modified: false,\n success: false,\n }\n }\n\n log.debug(`Found config file: ${configPath}`)\n\n // Get payload version to pin @payloadcms/* dependencies\n const payloadVersion = await getPayloadVersion(projectPath)\n log.debug(`Detected payload version: ${payloadVersion || 'unknown'}`)\n\n // 2. Check/install @payloadcms/figma package\n const isInstalled = await checkPackageInstalled(projectPath, '@payloadcms/figma')\n if (!isInstalled) {\n log.debug('@payloadcms/figma not installed, attempting installation...')\n try {\n await installPackage(projectPath, '@payloadcms/figma', packageManager)\n changes.push('Installed @payloadcms/figma')\n modified = true\n log.debug('@payloadcms/figma installed successfully')\n } catch (error) {\n log.debug(\n `Failed to install @payloadcms/figma: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n return {\n changes: [],\n error: 'Failed to install @payloadcms/figma',\n modified: false,\n success: false,\n }\n }\n } else {\n log.debug('@payloadcms/figma already installed')\n }\n\n // 3. Parse config with ts-morph\n log.debug('Parsing config file with ts-morph...')\n const project = new Project({\n skipAddingFilesFromTsConfig: true,\n })\n const sourceFile = project.addSourceFileAtPath(configPath)\n\n // 4. Detect required changes\n log.debug('Detecting required changes...')\n const detection = detectRequiredChanges(sourceFile)\n\n log.debug(\n `Detection results: needsImportChange=${detection.needsImportChange}, hasAlias=${detection.hasAlias}, hasBuildConfig=${detection.hasBuildConfig}`,\n )\n\n // Handle failure modes\n if (detection.hasAlias) {\n log.debug('Config uses import alias (e.g., buildConfig as X)')\n return {\n changes,\n error: 'Config uses import alias - manual modification required',\n modified,\n success: false,\n }\n }\n\n if (detection.hasBuildConfig === false) {\n log.debug('No buildConfig call found in config file')\n return {\n changes,\n error: 'Config structure not recognized (no buildConfig call found)',\n modified,\n success: false,\n }\n }\n\n // 5. Apply modifications\n log.debug('Applying modifications...')\n const modResult = applyModifications(sourceFile, detection)\n if (modResult.modified) {\n changes.push(...modResult.changes)\n modified = true\n\n log.debug(`Applied ${modResult.changes.length} modifications`)\n }\n\n // 6. Add figma property if config provided and doesn't exist\n if (figmaConfig && !detection.figmaObjectExists) {\n log.debug('Adding figma property to buildConfig...')\n const figmaResult = addFigmaProperty(sourceFile, figmaConfig)\n if (figmaResult.modified) {\n changes.push(...figmaResult.changes)\n modified = true\n log.debug(`Added figma property`)\n } else {\n log.debug('Figma property not added (may already exist)')\n }\n } else if (detection.figmaObjectExists) {\n log.debug('Figma property already exists, skipping')\n }\n\n // Save file if any modifications were made\n if (modified) {\n await sourceFile.save()\n log.debug('Config file saved')\n\n // 7. Handle package management\n const packagesToUninstall: string[] = []\n\n // Uninstall db adapter (buildFigmaConfig provides its own)\n if (detection.dbProperty) {\n packagesToUninstall.push(detection.dbProperty.importSource)\n }\n\n // Uninstall sharp (Figma infrastructure handles image processing)\n if (detection.sharpProperty) {\n packagesToUninstall.push('sharp')\n }\n\n // Ensure lexical is installed if user doesn't have a custom editor\n // (buildFigmaConfig uses lexicalEditor() as default)\n if (!detection.editorProperty) {\n log.debug(\n 'No editor property detected - will ensure lexical is installed for default editor',\n )\n } else if (detection.editorProperty.isDefault) {\n log.debug('Default lexicalEditor() detected - will ensure lexical is installed')\n } else {\n log.debug(\n `Custom editor detected (${detection.editorProperty.importSource}) - skipping lexical installation`,\n )\n }\n\n if (!detection.editorProperty || detection.editorProperty.isDefault) {\n log.debug('Checking if @payloadcms/richtext-lexical is installed...')\n const hasLexical = await checkPackageInstalled(projectPath, '@payloadcms/richtext-lexical')\n if (!hasLexical) {\n log.debug('@payloadcms/richtext-lexical not found, installing...')\n try {\n await installPackage(\n projectPath,\n '@payloadcms/richtext-lexical',\n packageManager,\n payloadVersion,\n )\n changes.push('Installed @payloadcms/richtext-lexical (default editor)')\n log.debug('Successfully installed @payloadcms/richtext-lexical')\n } catch (error) {\n log.debug(\n `Failed to install @payloadcms/richtext-lexical: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n // Don't fail on install error - user can install manually if needed\n warnings.push(\n 'Could not install @payloadcms/richtext-lexical - you may need to install it manually',\n )\n }\n } else {\n log.debug('@payloadcms/richtext-lexical already installed, skipping')\n }\n }\n\n // Ensure cloud-storage is installed (required peer dependency for buildFigmaConfig)\n log.debug('Checking if @payloadcms/plugin-cloud-storage is installed...')\n const hasCloudStorage = await checkPackageInstalled(\n projectPath,\n '@payloadcms/plugin-cloud-storage',\n )\n if (!hasCloudStorage) {\n log.debug('@payloadcms/plugin-cloud-storage not found, installing...')\n try {\n await installPackage(\n projectPath,\n '@payloadcms/plugin-cloud-storage',\n packageManager,\n payloadVersion,\n )\n changes.push('Installed @payloadcms/plugin-cloud-storage')\n log.debug('Successfully installed @payloadcms/plugin-cloud-storage')\n } catch (error) {\n log.debug(\n `Failed to install @payloadcms/plugin-cloud-storage: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n warnings.push(\n 'Could not install @payloadcms/plugin-cloud-storage - you may need to install it manually',\n )\n }\n } else {\n log.debug('@payloadcms/plugin-cloud-storage already installed, skipping')\n }\n\n if (packagesToUninstall.length > 0) {\n log.debug(`Uninstalling ${packagesToUninstall.length} orphaned packages...`)\n }\n\n for (const pkg of packagesToUninstall) {\n try {\n await uninstallPackage(projectPath, pkg, packageManager)\n changes.push(`Uninstalled ${pkg}`)\n log.debug(`Uninstalled ${pkg}`)\n } catch (error) {\n log.debug(\n `Failed to uninstall ${pkg}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n // Don't fail on uninstall errors - orphaned package is better than broken config\n }\n }\n\n // 8. Format file\n log.debug('Formatting config file...')\n const formatResult = await formatFile(configPath, packageManager)\n if (!formatResult.success && formatResult.warning) {\n warnings.push(formatResult.warning)\n log.debug(`Formatting warning: ${formatResult.warning}`)\n }\n\n // 9. Run TypeScript validation\n log.debug('Running TypeScript validation...')\n const tsResult = await runTypeScriptCheck(projectPath, packageManager)\n if (!tsResult.success && tsResult.errors.length > 0) {\n warnings.push(\n `TypeScript validation found issues - run '${getRunCommand(packageManager)} build' for details`,\n )\n log.debug(`TypeScript validation found ${tsResult.errors.length} issues`)\n }\n } else {\n log.debug('No modifications needed - config already correct')\n }\n\n log.debug('Payload config modification completed successfully')\n\n return {\n changes,\n modified,\n success: true,\n warnings: warnings.length > 0 ? warnings : undefined,\n }\n } catch (error) {\n log.debug(\n `Unexpected error in ensurePayloadFigmaConfig: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n if (error instanceof Error && error.stack) {\n log.debug(`Stack trace: ${error.stack}`)\n }\n return {\n changes,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n modified,\n success: false,\n }\n }\n}\n\n/**\n * Display manual configuration instructions\n */\nexport function displayManualInstructions(\n reason: string,\n packageManager: PackageManager = 'npm',\n): void {\n const leftLineWrap = (message: string): string => {\n // Add '┌ ' prefix to first line, '│ ' to subsequent lines, and '└ ' to last line\n return message\n .split(/\\r?\\n/)\n .map((line, index, arr) => {\n if (index === 0) {\n return `${pc.dim('┌ ')}${line}`\n } else if (index === arr.length - 1) {\n return `${pc.dim('└ ')}${line}`\n } else {\n return `${pc.dim('│ ')}${line}`\n }\n })\n .join('\\n')\n }\n\n const message = leftLineWrap(`${pc.cyan(pc.bold('Manual Configuration Required'))}\n\nUnable to automatically modify payload.config.ts\nReason: ${pc.yellow(reason)}\n\n${pc.bold('Required changes:')}\n\n1. Replace buildConfig import:\n ${pc.dim('- FROM: ')}${pc.cyan(\"import { buildConfig } from 'payload'\")}\n ${pc.dim('- TO: ')}${pc.cyan(\"import { buildFigmaConfig } from '@payloadcms/figma'\")}\n\n2. Remove these properties from buildConfig():\n • db\n • secret\n • editor (if using default lexicalEditor())\n\n3. Install package:\n ${pc.cyan(`${getAddCommand(packageManager)} @payloadcms/figma`)}\n\nThen run: ${pc.cyan('npx @payloadcms/figma init')}`)\n\n // eslint-disable-next-line no-console\n console.log(message)\n}\n"],"names":["pc","Project","formatFile","log","getAddCommand","getRunCommand","addFigmaProperty","applyModifications","detectRequiredChanges","findPayloadConfig","checkPackageInstalled","getPayloadVersion","installPackage","uninstallPackage","runTypeScriptCheck","ensurePayloadFigmaConfig","projectPath","packageManager","figmaConfig","changes","warnings","modified","debug","configPath","error","success","payloadVersion","isInstalled","push","Error","message","project","skipAddingFilesFromTsConfig","sourceFile","addSourceFileAtPath","detection","needsImportChange","hasAlias","hasBuildConfig","modResult","length","figmaObjectExists","figmaResult","save","packagesToUninstall","dbProperty","importSource","sharpProperty","editorProperty","isDefault","hasLexical","hasCloudStorage","pkg","formatResult","warning","tsResult","errors","undefined","stack","displayManualInstructions","reason","leftLineWrap","split","map","line","index","arr","dim","join","cyan","bold","yellow","console"],"mappings":"AAAA,OAAOA,QAAQ,aAAY;AAC3B,SAASC,OAAO,QAAQ,WAAU;AAIlC,SAASC,UAAU,QAAQ,iBAAgB;AAC3C,YAAYC,SAAS,WAAU;AAC/B,SAASC,aAAa,EAAEC,aAAa,QAAQ,uBAAsB;AACnE,SACEC,gBAAgB,EAChBC,kBAAkB,EAClBC,qBAAqB,QAEhB,0BAAyB;AAChC,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,cAAc,EACdC,gBAAgB,QACX,6BAA4B;AACnC,SAASC,kBAAkB,QAAQ,4BAA2B;AAU9D;;;CAGC,GACD,OAAO,eAAeC,yBACpBC,WAAmB,EACnBC,cAA8B,EAC9BC,WAAiC;IAEjC,MAAMC,UAAoB,EAAE;IAC5B,MAAMC,WAAqB,EAAE;IAC7B,IAAIC,WAAW;IAEf,IAAI;QACFlB,IAAImB,KAAK,CAAC,CAAC,0CAA0C,EAAEN,aAAa;QAEpE,sBAAsB;QACtB,MAAMO,aAAa,MAAMd,kBAAkBO;QAC3C,IAAI,CAACO,YAAY;YACfpB,IAAImB,KAAK,CAAC,CAAC,0BAA0B,EAAEN,aAAa;YACpD,OAAO;gBACLG,SAAS,EAAE;gBACXK,OAAO;gBACPH,UAAU;gBACVI,SAAS;YACX;QACF;QAEAtB,IAAImB,KAAK,CAAC,CAAC,mBAAmB,EAAEC,YAAY;QAE5C,wDAAwD;QACxD,MAAMG,iBAAiB,MAAMf,kBAAkBK;QAC/Cb,IAAImB,KAAK,CAAC,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AAO;YACLvC;YACAK,OAAOA,iBAAiBK,QAAQL,MAAMM,OAAO,GAAG;YAChDT;YACAI,SAAS;QACX;IACF;AACF;AAEA;;CAEC,GACD,OAAO,SAASkC,0BACdC,MAAc,EACd3C,iBAAiC,KAAK;IAEtC,MAAM4C,eAAe,CAAC/B;QACpB,oFAAoF;QACpF,OAAOA,QACJgC,KAAK,CAAC,SACNC,GAAG,CAAC,CAACC,MAAMC,OAAOC;YACjB,IAAID,UAAU,GAAG;gBACf,OAAO,GAAGjE,GAAGmE,GAAG,CAAC,SAASH,MAAM;YAClC,OAAO,IAAIC,UAAUC,IAAI1B,MAAM,GAAG,GAAG;gBACnC,OAAO,GAAGxC,GAAGmE,GAAG,CAAC,SAASH,MAAM;YAClC,OAAO;gBACL,OAAO,GAAGhE,GAAGmE,GAAG,CAAC,SAASH,MAAM;YAClC;QACF,GACCI,IAAI,CAAC;IACV;IAEA,MAAMtC,UAAU+B,aAAa,GAAG7D,GAAGqE,IAAI,CAACrE,GAAGsE,IAAI,CAAC,kCAAkC;;;QAG5E,EAAEtE,GAAGuE,MAAM,CAACX,QAAQ;;AAE5B,EAAE5D,GAAGsE,IAAI,CAAC,qBAAqB;;;GAG5B,EAAEtE,GAAGmE,GAAG,CAAC,cAAcnE,GAAGqE,IAAI,CAAC,yCAAyC;GACxE,EAAErE,GAAGmE,GAAG,CAAC,cAAcnE,GAAGqE,IAAI,CAAC,wDAAwD;;;;;;;;GAQvF,EAAErE,GAAGqE,IAAI,CAAC,GAAGjE,cAAca,gBAAgB,kBAAkB,CAAC,EAAE;;UAEzD,EAAEjB,GAAGqE,IAAI,CAAC,+BAA+B;IAEjD,sCAAsC;IACtCG,QAAQrE,GAAG,CAAC2B;AACd"}
|
package/dist/utils/project.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Project detection and scaffolding utilities
|
|
3
3
|
*/
|
|
4
4
|
import type { ProjectInfo } from '../types/config.js';
|
|
5
|
+
import type { PackageManager } from './package-manager.js';
|
|
5
6
|
/**
|
|
6
7
|
* Detect if current directory has a Payload project
|
|
7
8
|
*
|
|
@@ -22,7 +23,7 @@ export declare function validatePayloadVersion(version: string): boolean;
|
|
|
22
23
|
* @param projectPath - Path where to create the project
|
|
23
24
|
* @param projectName - Name for the project
|
|
24
25
|
*/
|
|
25
|
-
export declare function scaffoldProject(projectPath: string, projectName: string): Promise<void>;
|
|
26
|
+
export declare function scaffoldProject(projectPath: string, projectName: string, packageManager?: PackageManager): Promise<void>;
|
|
26
27
|
/**
|
|
27
28
|
* Initialize git repository after all setup is complete
|
|
28
29
|
*
|
|
@@ -38,7 +39,7 @@ export declare function initializeGitRepo(projectPath: string): void;
|
|
|
38
39
|
* @param packageManager - Package manager to use
|
|
39
40
|
* @returns Promise that resolves when installation completes
|
|
40
41
|
*/
|
|
41
|
-
export declare function installDependencies(projectPath: string, packageManager?:
|
|
42
|
+
export declare function installDependencies(projectPath: string, packageManager?: PackageManager): Promise<void>;
|
|
42
43
|
/**
|
|
43
44
|
* Check if required dependencies are installed
|
|
44
45
|
*
|
|
@@ -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;
|
|
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;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAQ1D;;;;;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,CACnC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,cAAsB,GACrC,OAAO,CAAC,IAAI,CAAC,CAqDf;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAE3D;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,cAAsB,GACrC,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
|
@@ -8,6 +8,7 @@ import { ensureGitignore } from './config.js';
|
|
|
8
8
|
import { downloadTemplateFromGitHub } from './download-template.js';
|
|
9
9
|
import { tryInitRepoAndCommit } from './git.js';
|
|
10
10
|
import { applyLambdaModifications } from './lambda-config.js';
|
|
11
|
+
import { getRunCommand } from './package-manager.js';
|
|
11
12
|
/**
|
|
12
13
|
* Detect if current directory has a Payload project
|
|
13
14
|
*
|
|
@@ -116,7 +117,7 @@ import { applyLambdaModifications } from './lambda-config.js';
|
|
|
116
117
|
*
|
|
117
118
|
* @param projectPath - Path where to create the project
|
|
118
119
|
* @param projectName - Name for the project
|
|
119
|
-
*/ export async function scaffoldProject(projectPath, projectName) {
|
|
120
|
+
*/ export async function scaffoldProject(projectPath, projectName, packageManager = 'npm') {
|
|
120
121
|
// Create project directory if it doesn't exist
|
|
121
122
|
await fs.mkdir(projectPath, {
|
|
122
123
|
recursive: true
|
|
@@ -125,7 +126,7 @@ import { applyLambdaModifications } from './lambda-config.js';
|
|
|
125
126
|
await downloadTemplateFromGitHub(projectPath);
|
|
126
127
|
// Apply Lambda modifications BEFORE updating package.json
|
|
127
128
|
// This ensures we don't overwrite version replacements
|
|
128
|
-
await applyLambdaModifications(projectPath);
|
|
129
|
+
await applyLambdaModifications(projectPath, packageManager);
|
|
129
130
|
// Get latest Payload version from npm
|
|
130
131
|
const latestVersion = await getLatestPackageVersion('payload');
|
|
131
132
|
// Delete any existing lock files from template (they reference workspace:* versions)
|
|
@@ -162,6 +163,7 @@ import { applyLambdaModifications } from './lambda-config.js';
|
|
|
162
163
|
const readmeTemplatePath = fileURLToPath(new URL('../templates/README.md', import.meta.url));
|
|
163
164
|
let readmeContent = await fs.readFile(readmeTemplatePath, 'utf-8');
|
|
164
165
|
readmeContent = readmeContent.replace(/\{\{PROJECT_NAME\}\}/g, projectName);
|
|
166
|
+
readmeContent = readmeContent.replace(/\{\{RUN_COMMAND\}\}/g, getRunCommand(packageManager));
|
|
165
167
|
await fs.writeFile(path.join(projectPath, 'README.md'), readmeContent, 'utf-8');
|
|
166
168
|
// Copy .env.example template
|
|
167
169
|
const envExampleTemplatePath = fileURLToPath(new URL('../templates/.env.example', import.meta.url));
|
|
@@ -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 // 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,Q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AAMG,kBAAkBV,KAAKW,IAAI,CAACJ,aAAa;IAE/C,IAAI;QACF,MAAMK,UAAU,MAAMb,GAAGc,QAAQ,CAACH,iBAAiB;QACnD,MAAMI,cAAcC,KAAKC,KAAK,CAACJ;QAE/B,gCAAgC;QAChC,MAAMW,aAAaT,YAAYI,YAAY,EAAEC,WAAWL,YAAYM,eAAe,EAAED;QACrF,MAAMmE,UAAUxE,YAAYI,YAAY,EAAEqE,QAAQzE,YAAYM,eAAe,EAAEmE;QAE/E,OAAO,CAAC,CAAEhE,CAAAA,cAAc+D,OAAM;IAChC,EAAE,OAAM;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"}
|
|
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'\nimport type { PackageManager } from './package-manager.js'\n\nimport { ensureGitignore } from './config.js'\nimport { downloadTemplateFromGitHub } from './download-template.js'\nimport { tryInitRepoAndCommit } from './git.js'\nimport { applyLambdaModifications } from './lambda-config.js'\nimport { getRunCommand } from './package-manager.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: PackageManager = '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(\n projectPath: string,\n projectName: string,\n packageManager: PackageManager = 'npm',\n): 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, packageManager)\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 readmeContent = readmeContent.replace(/\\{\\{RUN_COMMAND\\}\\}/g, getRunCommand(packageManager))\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: PackageManager = '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","getRunCommand","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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AI/C,MAAM,CAAC,cAAc,EAAEN,eAAe,UAAU,EAAEI,MAAMG,OAAO,EAAE;QAC9E;IACF;AACF;AAEA;;;;;CAKC,GACD,OAAO,eAAeyD,wBAAwB9E,WAAmB;IAC/D,MAAMG,kBAAkBX,KAAKY,IAAI,CAACJ,aAAa;IAE/C,IAAI;QACF,MAAMK,UAAU,MAAMd,GAAGe,QAAQ,CAACH,iBAAiB;QACnD,MAAMI,cAAcC,KAAKC,KAAK,CAACJ;QAE/B,gCAAgC;QAChC,MAAMW,aAAaT,YAAYI,YAAY,EAAEC,WAAWL,YAAYM,eAAe,EAAED;QACrF,MAAMmE,UAAUxE,YAAYI,YAAY,EAAEqE,QAAQzE,YAAYM,eAAe,EAAEmE;QAE/E,OAAO,CAAC,CAAEhE,CAAAA,cAAc+D,OAAM;IAChC,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeE,qBAAqBjF,cAAsBC,QAAQC,GAAG,EAAE;IAC5E,IAAI;QACF,yBAAyB;QACzB,MAAMX,GAAGwB,MAAM,CAACvB,KAAKY,IAAI,CAACJ,aAAa;QACvC,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { buildLocalizedPaths } from './buildLocalizedPaths.js';
|
|
2
|
-
export { buildMeta } from './buildMeta.js';
|
|
3
|
-
export type { BuildMetaOptions, ContentAPIMeta } from './buildMeta.js';
|
|
4
|
-
export { buildPathTypes } from './buildPathTypes.js';
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/meta/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/db-content-api/utilities/meta/index.ts"],"sourcesContent":["export { buildLocalizedPaths } from './buildLocalizedPaths.js'\nexport { buildMeta } from './buildMeta.js'\nexport type { BuildMetaOptions, ContentAPIMeta } from './buildMeta.js'\nexport { buildPathTypes } from './buildPathTypes.js'\n"],"names":["buildLocalizedPaths","buildMeta","buildPathTypes"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,SAAS,QAAQ,iBAAgB;AAE1C,SAASC,cAAc,QAAQ,sBAAqB"}
|