create-payload-app 3.85.0 → 4.0.0-internal.1f9ae9a

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.
@@ -107,7 +107,7 @@ export function detectPayloadConfigStructure(sourceFile) {
107
107
  },
108
108
  importSources: {
109
109
  dbAdapter: dbAdapterImportInfo,
110
- storageAdapters: storageAdapterImports.length > 0 ? storageAdapterImports : undefined
110
+ storage: storageAdapterImports.length > 0 ? storageAdapterImports : undefined
111
111
  },
112
112
  sourceFile,
113
113
  structures: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/ast/payload-config.ts"],"sourcesContent":["import { execSync } from 'child_process'\nimport path from 'path'\nimport { Project, QuoteKind, type SourceFile, SyntaxKind } from 'ts-morph'\n\nimport type {\n ConfigureOptions,\n DatabaseAdapter,\n DetectionResult,\n Modification,\n StorageAdapter,\n TransformationResult,\n WriteOptions,\n WriteResult,\n} from './types.js'\n\nimport { debug } from '../../utils/log.js'\nimport { DB_ADAPTER_CONFIG, STORAGE_ADAPTER_CONFIG } from './adapter-config.js'\nimport {\n addImportDeclaration,\n cleanupOrphanedImports,\n formatError,\n removeImportDeclaration,\n} from './utils.js'\n\nexport function detectPayloadConfigStructure(sourceFile: SourceFile): DetectionResult {\n debug(`[AST] Detecting payload config structure in ${sourceFile.getFilePath()}`)\n\n // First find the actual name being used (might be aliased)\n const payloadImport = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === 'payload')\n\n const buildConfigImportSpec = payloadImport\n ?.getNamedImports()\n .find((spec) => spec.getName() === 'buildConfig')\n\n const aliasNode = buildConfigImportSpec?.getAliasNode()\n const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n\n debug(`[AST] Looking for function call: ${buildConfigName}`)\n\n // Find buildConfig call expression (using actual name in code)\n const buildConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n if (!buildConfigCall) {\n debug(`[AST] ✗ ${buildConfigName} call not found`)\n return {\n error: formatError({\n actual: `No ${buildConfigName} call found in file`,\n context: 'buildConfig call',\n expected: `export default ${buildConfigName}({ ... })`,\n technicalDetails: `Could not find CallExpression with identifier \"${buildConfigName}\"`,\n }),\n success: false,\n }\n }\n\n debug(`[AST] ✓ ${buildConfigName} call found`)\n\n // Get import statements\n const importStatements = sourceFile.getImportDeclarations()\n debug(`[AST] Found ${importStatements.length} import statements`)\n\n // Find db property if it exists\n const configObject = buildConfigCall.getArguments()[0]\n let dbProperty\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n dbProperty = configObject\n .asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n .getProperty('db')\n ?.asKind(SyntaxKind.PropertyAssignment)\n }\n\n debug(`[AST] db property: ${dbProperty ? '✓ found' : '✗ not found'}`)\n\n // Find plugins array if it exists\n let pluginsArray\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const pluginsProperty = objLiteral.getProperty('plugins')\n\n // Handle PropertyAssignment (e.g., plugins: [...])\n const propertyAssignment = pluginsProperty?.asKind(SyntaxKind.PropertyAssignment)\n if (propertyAssignment) {\n const initializer = propertyAssignment.getInitializer()\n if (initializer?.getKind() === SyntaxKind.ArrayLiteralExpression) {\n pluginsArray = initializer.asKind(SyntaxKind.ArrayLiteralExpression)\n }\n }\n // For ShorthandPropertyAssignment (e.g., plugins), we can't get the array directly\n // but we'll detect it in addStorageAdapter\n }\n\n debug(`[AST] plugins array: ${pluginsArray ? '✓ found' : '✗ not found'}`)\n\n // Find all buildConfig calls for edge case detection (using actual name)\n const allBuildConfigCalls = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n const hasImportAlias = !!aliasNode\n\n // Check for other Payload imports\n const payloadImports = payloadImport?.getNamedImports() || []\n const hasOtherPayloadImports =\n payloadImports.length > 1 || payloadImports.some((imp) => imp.getName() !== 'buildConfig')\n\n // Track database adapter imports\n let dbAdapterImportInfo\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n dbAdapterImportInfo = {\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n }\n break\n }\n }\n\n // Track storage adapter imports\n const storageAdapterImports = []\n for (const [, config] of Object.entries(STORAGE_ADAPTER_CONFIG)) {\n if (!config.packageName || !config.adapterName) {\n continue\n }\n\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n storageAdapterImports.push({\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n })\n }\n }\n\n const needsManualIntervention = hasImportAlias || allBuildConfigCalls.length > 2\n\n debug(\n `[AST] Edge cases: alias=${hasImportAlias}, multiple=${allBuildConfigCalls.length > 1}, otherImports=${hasOtherPayloadImports}, manual=${needsManualIntervention}`,\n )\n\n return {\n edgeCases: {\n hasImportAlias,\n hasOtherPayloadImports,\n multipleBuildConfigCalls: allBuildConfigCalls.length > 1,\n needsManualIntervention,\n },\n importSources: {\n dbAdapter: dbAdapterImportInfo,\n storageAdapters: storageAdapterImports.length > 0 ? storageAdapterImports : undefined,\n },\n sourceFile,\n structures: {\n buildConfigCall,\n dbProperty,\n importStatements,\n pluginsArray,\n },\n success: true,\n }\n}\n\nexport function addDatabaseAdapter({\n adapter,\n envVarName = 'DATABASE_URL',\n sourceFile,\n}: {\n adapter: DatabaseAdapter\n envVarName?: string\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding database adapter: ${adapter} (envVar: ${envVarName})`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall, dbProperty } = detection.structures\n const config = DB_ADAPTER_CONFIG[adapter]\n\n // Remove old db adapter imports and track position for replacement\n const oldAdapters = Object.values(DB_ADAPTER_CONFIG)\n const removedAdapters: string[] = []\n let importInsertIndex: number | undefined\n oldAdapters.forEach((oldConfig) => {\n if (oldConfig.packageName !== config.packageName) {\n const { removedIndex } = removeImportDeclaration({\n moduleSpecifier: oldConfig.packageName,\n sourceFile,\n })\n if (removedIndex !== undefined) {\n // Use the first removed adapter's position\n if (importInsertIndex === undefined) {\n importInsertIndex = removedIndex\n }\n removedAdapters.push(oldConfig.packageName)\n modifications.push({\n type: 'import-removed',\n description: `Removed import from '${oldConfig.packageName}'`,\n })\n }\n }\n })\n\n if (removedAdapters.length > 0) {\n debug(`[AST] Removed old adapter imports: ${removedAdapters.join(', ')}`)\n }\n\n // Add new import at the position of the removed one (or default position)\n addImportDeclaration({\n insertIndex: importInsertIndex,\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n\n // Add special imports for specific adapters\n if (adapter === 'd1-sqlite') {\n debug('[AST] Adding special import: ./db/migrations')\n addImportDeclaration({\n defaultImport: 'migrations',\n moduleSpecifier: './db/migrations',\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: migrations from './db/migrations'`,\n })\n }\n\n // Get config object\n const configObject = buildConfigCall.getArguments()[0]\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'database adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n const newDbCode = `db: ${config.configTemplate(envVarName)}`\n\n if (dbProperty) {\n // Replace existing db property\n // NOTE: Using replaceWithText() instead of remove() + insertPropertyAssignment()\n // to avoid double comma issues. When remove() is called, ts-morph doesn't always\n // clean up trailing commas correctly, which can result in syntax like \"},,\" when\n // inserting a new property at that position. replaceWithText() preserves the\n // surrounding punctuation correctly.\n debug(`[AST] Replacing existing db property`)\n dbProperty.replaceWithText(newDbCode)\n modifications.push({\n type: 'property-added',\n description: `Replaced db property with ${adapter} adapter`,\n })\n } else {\n // No existing db property - insert at end\n const insertIndex = objLiteral.getProperties().length\n debug(`[AST] Adding db property at index ${insertIndex}`)\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'db',\n initializer: config.configTemplate(envVarName),\n })\n modifications.push({\n type: 'property-added',\n description: `Added db property with ${adapter} adapter`,\n })\n }\n\n debug(`[AST] ✓ Database adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function addStorageAdapter({\n adapter,\n sourceFile,\n}: {\n adapter: StorageAdapter\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding storage adapter: ${adapter}`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const config = STORAGE_ADAPTER_CONFIG[adapter]\n\n // Local disk doesn't need any imports or plugins\n if (adapter === 'localDisk') {\n debug('[AST] localDisk storage adapter - no imports or plugins needed')\n return {\n modifications: [],\n modified: false,\n success: true,\n }\n }\n\n // Add import\n if (config.packageName && config.adapterName) {\n addImportDeclaration({\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'storage adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n // Find or create plugins array\n const pluginsPropertyRaw = objLiteral.getProperty('plugins')\n let pluginsProperty = pluginsPropertyRaw?.asKind(SyntaxKind.PropertyAssignment)\n\n // Check if it's a shorthand property (e.g., `plugins` referencing an imported variable)\n const shorthandProperty = pluginsPropertyRaw?.asKind(SyntaxKind.ShorthandPropertyAssignment)\n\n if (shorthandProperty) {\n debug('[AST] Found shorthand plugins property, converting to long form with spread')\n // Get the identifier name (usually 'plugins')\n const identifierName = shorthandProperty.getName()\n\n // Find insert position before removing\n const allProperties = objLiteral.getProperties()\n const insertIndex = allProperties.indexOf(shorthandProperty)\n\n // Remove the shorthand property\n shorthandProperty.remove()\n\n // Create new property with spread operator: plugins: [...plugins, newAdapter]\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'plugins',\n initializer: `[...${identifierName}]`,\n })\n\n pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Converted shorthand plugins property to array with spread syntax`,\n })\n } else if (!pluginsProperty) {\n debug('[AST] Creating new plugins array')\n // Create plugins array\n objLiteral.addPropertyAssignment({\n name: 'plugins',\n initializer: '[]',\n })\n pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Created plugins array`,\n })\n } else {\n debug('[AST] Reusing existing plugins array')\n }\n\n if (!pluginsProperty) {\n return {\n error: formatError({\n actual: 'Failed to create or find plugins property',\n context: 'storage adapter configuration',\n expected: 'plugins array property',\n technicalDetails: 'Could not create or access plugins property',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const initializer = pluginsProperty.getInitializer()\n if (!initializer || initializer.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return {\n error: formatError({\n actual: 'plugins property is not an array',\n context: 'storage adapter configuration',\n expected: 'plugins: [...]',\n technicalDetails: 'plugins property must be an array literal expression',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const pluginsArray = initializer.asKindOrThrow(SyntaxKind.ArrayLiteralExpression)\n\n // Add storage adapter call\n const configText = config.configTemplate()\n if (configText) {\n pluginsArray.addElement(configText)\n modifications.push({\n type: 'property-added',\n description: `Added ${adapter} to plugins array`,\n })\n }\n\n debug(`[AST] ✓ Storage adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function removeSharp(sourceFile: SourceFile): TransformationResult {\n debug('[AST] Removing sharp import and property')\n\n const modifications: Modification[] = []\n\n // Remove import\n const { removedIndex } = removeImportDeclaration({ moduleSpecifier: 'sharp', sourceFile })\n if (removedIndex !== undefined) {\n modifications.push({\n type: 'import-removed',\n description: `Removed import from 'sharp'`,\n })\n }\n\n // Find and remove sharp property from buildConfig\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n // If detection failed but we removed import, still count as partial success\n if (modifications.length > 0) {\n return {\n modifications,\n modified: true,\n success: true,\n warnings: ['Could not detect config structure to remove sharp property'],\n }\n }\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n warnings: ['buildConfig has no object literal argument - could not remove sharp property'],\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const sharpProperty = objLiteral.getProperty('sharp')\n\n if (sharpProperty) {\n sharpProperty.remove()\n modifications.push({\n type: 'property-removed',\n description: `Removed sharp property from config`,\n })\n debug('[AST] ✓ Sharp property removed from config')\n } else {\n debug('[AST] Sharp property not found (already absent)')\n }\n\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n }\n}\n\n/** This shouldn't be necessary once the templates are updated. Can't hurt to keep in, though */\nexport function removeCommentMarkers(sourceFile: SourceFile): SourceFile {\n // Get the full text and replace comment markers\n let text = sourceFile.getFullText()\n\n // Remove inline comment markers from imports\n text = text.replace(/\\s*\\/\\/\\s*database-adapter-import\\s*$/gm, '')\n text = text.replace(/\\s*\\/\\/\\s*storage-adapter-import-placeholder\\s*$/gm, '')\n\n // Remove standalone comment lines\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-start\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-end\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*storage-adapter-placeholder\\s*\\n/gm, '')\n\n // Also remove the placeholder line from template (storage-adapter-import-placeholder at top)\n text = text.replace(/^\\/\\/\\s*storage-adapter-import-placeholder\\s*\\n/gm, '')\n\n // Replace the entire source file content\n sourceFile.replaceWithText(text)\n\n return sourceFile\n}\n\n/**\n * Validates payload config structure has required elements after transformation.\n * Checks that buildConfig() call exists and has a db property configured.\n */\nexport function validateStructure(sourceFile: SourceFile): WriteResult {\n debug('[AST] Validating payload config structure')\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success) {\n debug('[AST] ✗ Validation failed: detection unsuccessful')\n return {\n error: detection.error,\n success: false,\n }\n }\n\n const { structures } = detection\n\n // Validate db property exists\n if (!structures?.dbProperty) {\n debug('[AST] ✗ Validation failed: db property missing')\n return {\n error: formatError({\n actual: 'No db property found',\n context: 'database configuration',\n expected: 'buildConfig must have a db property',\n technicalDetails: 'PropertyAssignment with name \"db\" not found in buildConfig object',\n }),\n success: false,\n }\n }\n\n debug('[AST] ✓ Validation passed')\n return { success: true }\n}\n\nexport async function writeTransformedFile(\n sourceFile: SourceFile,\n options: WriteOptions = {},\n): Promise<WriteResult> {\n const { formatWithPrettier = true, validateStructure: shouldValidate = true } = options\n\n debug(`[AST] Writing transformed file: ${sourceFile.getFilePath()}`)\n\n // Validate if requested\n if (shouldValidate) {\n const validation = validateStructure(sourceFile)\n if (!validation.success) {\n return validation\n }\n }\n\n // Get file path and save to disk\n const filePath = sourceFile.getFilePath()\n\n // Format with ts-morph before saving (fixes trailing commas, indentation)\n debug('[AST] Formatting with ts-morph')\n sourceFile.formatText()\n\n // Write file\n debug('[AST] Writing file to disk')\n await sourceFile.save()\n\n // Format with prettier if requested\n if (formatWithPrettier) {\n debug('[AST] Running prettier formatting via CLI')\n try {\n // Detect project directory (go up from file until we find package.json or use dirname)\n const projectDir = path.dirname(filePath)\n\n // Run prettier via CLI (avoids Jest/ESM compatibility issues)\n const prettierCmd = `npx prettier --write \"${filePath}\"`\n\n debug(`[AST] Executing: ${prettierCmd}`)\n execSync(prettierCmd, {\n cwd: projectDir,\n stdio: 'pipe', // Suppress output\n })\n debug('[AST] ✓ Prettier formatting successful')\n } catch (error) {\n // Log but don't fail if prettier fails (might not be installed)\n debug(\n `[AST] ⚠ Prettier formatting failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n debug('[AST] Continuing with unformatted output')\n }\n } else {\n debug('[AST] Skipping prettier formatting (disabled)')\n }\n\n debug('[AST] ✓ File written successfully')\n\n return { success: true }\n}\n\nexport async function configurePayloadConfig(\n filePath: string,\n options: ConfigureOptions = {},\n): Promise<WriteResult> {\n debug(`[AST] Configuring payload config: ${filePath}`)\n debug(\n `[AST] Options: db=${options.db?.type}, storage=${options.storage}, removeSharp=${options.removeSharp}`,\n )\n\n const allModifications: Modification[] = []\n const allWarnings: string[] = []\n\n try {\n // Create Project and load source file with proper settings\n const project = new Project({\n manipulationSettings: {\n quoteKind: QuoteKind.Single,\n },\n })\n let sourceFile = project.addSourceFileAtPath(filePath)\n\n // Run detection\n const detection = detectPayloadConfigStructure(sourceFile)\n if (!detection.success) {\n return detection\n }\n\n // Apply transformations based on options\n if (options.db) {\n debug('[AST] Applying database adapter transformation')\n const result = addDatabaseAdapter({\n adapter: options.db.type,\n envVarName: options.db.envVarName,\n sourceFile,\n })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.storage) {\n debug('[AST] Applying storage adapter transformation')\n const result = addStorageAdapter({ adapter: options.storage, sourceFile })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.removeSharp) {\n debug('[AST] Applying sharp removal')\n const result = removeSharp(sourceFile)\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n // Remove comment markers from template\n sourceFile = removeCommentMarkers(sourceFile)\n\n // Cleanup orphaned imports after all transformations\n debug('[AST] Cleaning up orphaned imports')\n\n // Cleanup database adapter imports if db was removed\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n if (options.db && config.packageName !== DB_ADAPTER_CONFIG[options.db.type].packageName) {\n const cleanup = cleanupOrphanedImports({\n importNames: [config.adapterName],\n moduleSpecifier: config.packageName,\n sourceFile,\n })\n if (cleanup.removed.length > 0) {\n cleanup.removed.forEach((importName) => {\n allModifications.push({\n type: 'import-removed',\n description: `Cleaned up unused import '${importName}' from '${config.packageName}'`,\n })\n })\n }\n }\n }\n\n // Log summary of modifications\n if (allModifications.length > 0) {\n debug(`[AST] Applied ${allModifications.length} modification(s):`)\n allModifications.forEach((mod) => {\n debug(`[AST] - ${mod.type}: ${mod.description}`)\n })\n }\n\n if (allWarnings.length > 0) {\n debug(`[AST] ${allWarnings.length} warning(s):`)\n allWarnings.forEach((warning) => {\n debug(`[AST] - ${warning}`)\n })\n }\n\n // Write transformed file with validation and formatting\n return await writeTransformedFile(sourceFile, {\n formatWithPrettier: options.formatWithPrettier,\n validateStructure: options.validateStructure ?? true,\n })\n } catch (error) {\n debug(`[AST] ✗ Configuration failed: ${error instanceof Error ? error.message : String(error)}`)\n return {\n error: formatError({\n actual: error instanceof Error ? error.message : String(error),\n context: 'configurePayloadConfig',\n expected: 'Successful file transformation',\n technicalDetails: error instanceof Error ? error.stack || error.message : String(error),\n }),\n success: false,\n }\n }\n}\n"],"names":["execSync","path","Project","QuoteKind","SyntaxKind","debug","DB_ADAPTER_CONFIG","STORAGE_ADAPTER_CONFIG","addImportDeclaration","cleanupOrphanedImports","formatError","removeImportDeclaration","detectPayloadConfigStructure","sourceFile","getFilePath","payloadImport","getImportDeclarations","find","imp","getModuleSpecifierValue","buildConfigImportSpec","getNamedImports","spec","getName","aliasNode","getAliasNode","buildConfigName","getText","buildConfigCall","getDescendantsOfKind","CallExpression","call","expression","getExpression","error","actual","context","expected","technicalDetails","success","importStatements","length","configObject","getArguments","dbProperty","getKind","ObjectLiteralExpression","asKindOrThrow","getProperty","asKind","PropertyAssignment","pluginsArray","objLiteral","pluginsProperty","propertyAssignment","initializer","getInitializer","ArrayLiteralExpression","allBuildConfigCalls","filter","hasImportAlias","payloadImports","hasOtherPayloadImports","some","dbAdapterImportInfo","config","Object","entries","importDecl","packageName","namedImports","hasOtherImports","importDeclaration","storageAdapterImports","adapterName","push","needsManualIntervention","edgeCases","multipleBuildConfigCalls","importSources","dbAdapter","storageAdapters","undefined","structures","addDatabaseAdapter","adapter","envVarName","modifications","detection","modified","oldAdapters","values","removedAdapters","importInsertIndex","forEach","oldConfig","removedIndex","moduleSpecifier","type","description","join","insertIndex","defaultImport","newDbCode","configTemplate","replaceWithText","getProperties","insertPropertyAssignment","name","addStorageAdapter","pluginsPropertyRaw","shorthandProperty","ShorthandPropertyAssignment","identifierName","allProperties","indexOf","remove","addPropertyAssignment","configText","addElement","removeSharp","warnings","sharpProperty","removeCommentMarkers","text","getFullText","replace","validateStructure","writeTransformedFile","options","formatWithPrettier","shouldValidate","validation","filePath","formatText","save","projectDir","dirname","prettierCmd","cwd","stdio","Error","message","configurePayloadConfig","db","storage","allModifications","allWarnings","project","manipulationSettings","quoteKind","Single","addSourceFileAtPath","result","cleanup","importNames","removed","importName","mod","warning","String","stack"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAe;AACxC,OAAOC,UAAU,OAAM;AACvB,SAASC,OAAO,EAAEC,SAAS,EAAmBC,UAAU,QAAQ,WAAU;AAa1E,SAASC,KAAK,QAAQ,qBAAoB;AAC1C,SAASC,iBAAiB,EAAEC,sBAAsB,QAAQ,sBAAqB;AAC/E,SACEC,oBAAoB,EACpBC,sBAAsB,EACtBC,WAAW,EACXC,uBAAuB,QAClB,aAAY;AAEnB,OAAO,SAASC,6BAA6BC,UAAsB;IACjER,MAAM,CAAC,4CAA4C,EAAEQ,WAAWC,WAAW,IAAI;IAE/E,2DAA2D;IAC3D,MAAMC,gBAAgBF,WACnBG,qBAAqB,GACrBC,IAAI,CAAC,CAACC,MAAQA,IAAIC,uBAAuB,OAAO;IAEnD,MAAMC,wBAAwBL,eAC1BM,kBACDJ,KAAK,CAACK,OAASA,KAAKC,OAAO,OAAO;IAErC,MAAMC,YAAYJ,uBAAuBK;IACzC,MAAMC,kBAAkBF,YAAYA,UAAUG,OAAO,KAAK;IAE1DtB,MAAM,CAAC,iCAAiC,EAAEqB,iBAAiB;IAE3D,+DAA+D;IAC/D,MAAME,kBAAkBf,WACrBgB,oBAAoB,CAACzB,WAAW0B,cAAc,EAC9Cb,IAAI,CAAC,CAACc;QACL,MAAMC,aAAaD,KAAKE,aAAa;QACrC,OAAOD,WAAWL,OAAO,OAAOD;IAClC;IAEF,IAAI,CAACE,iBAAiB;QACpBvB,M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4D,IAAI3D,WAAW,EAAE;YACnD;QACF;QAEA,IAAIgD,YAAY1G,MAAM,GAAG,GAAG;YAC1BpC,MAAM,CAAC,MAAM,EAAE8I,YAAY1G,MAAM,CAAC,YAAY,CAAC;YAC/C0G,YAAYrD,OAAO,CAAC,CAACiE;gBACnB1J,MAAM,CAAC,UAAU,EAAE0J,SAAS;YAC9B;QACF;QAEA,wDAAwD;QACxD,OAAO,MAAM/B,qBAAqBnH,YAAY;YAC5CqH,oBAAoBD,QAAQC,kBAAkB;YAC9CH,mBAAmBE,QAAQF,iBAAiB,IAAI;QAClD;IACF,EAAE,OAAO7F,OAAO;QACd7B,MAAM,CAAC,8BAA8B,EAAE6B,iBAAiB2G,QAAQ3G,MAAM4G,OAAO,GAAGkB,OAAO9H,QAAQ;QAC/F,OAAO;YACLA,OAAOxB,YAAY;gBACjByB,QAAQD,iBAAiB2G,QAAQ3G,MAAM4G,OAAO,GAAGkB,OAAO9H;gBACxDE,SAAS;gBACTC,UAAU;gBACVC,kBAAkBJ,iBAAiB2G,QAAQ3G,MAAM+H,KAAK,IAAI/H,MAAM4G,OAAO,GAAGkB,OAAO9H;YACnF;YACAK,SAAS;QACX;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/lib/ast/payload-config.ts"],"sourcesContent":["import { execSync } from 'child_process'\nimport path from 'path'\nimport { Project, QuoteKind, type SourceFile, SyntaxKind } from 'ts-morph'\n\nimport type {\n ConfigureOptions,\n DatabaseAdapter,\n DetectionResult,\n Modification,\n StorageAdapter,\n TransformationResult,\n WriteOptions,\n WriteResult,\n} from './types.js'\n\nimport { debug } from '../../utils/log.js'\nimport { DB_ADAPTER_CONFIG, STORAGE_ADAPTER_CONFIG } from './adapter-config.js'\nimport {\n addImportDeclaration,\n cleanupOrphanedImports,\n formatError,\n removeImportDeclaration,\n} from './utils.js'\n\nexport function detectPayloadConfigStructure(sourceFile: SourceFile): DetectionResult {\n debug(`[AST] Detecting payload config structure in ${sourceFile.getFilePath()}`)\n\n // First find the actual name being used (might be aliased)\n const payloadImport = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === 'payload')\n\n const buildConfigImportSpec = payloadImport\n ?.getNamedImports()\n .find((spec) => spec.getName() === 'buildConfig')\n\n const aliasNode = buildConfigImportSpec?.getAliasNode()\n const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n\n debug(`[AST] Looking for function call: ${buildConfigName}`)\n\n // Find buildConfig call expression (using actual name in code)\n const buildConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n if (!buildConfigCall) {\n debug(`[AST] ✗ ${buildConfigName} call not found`)\n return {\n error: formatError({\n actual: `No ${buildConfigName} call found in file`,\n context: 'buildConfig call',\n expected: `export default ${buildConfigName}({ ... })`,\n technicalDetails: `Could not find CallExpression with identifier \"${buildConfigName}\"`,\n }),\n success: false,\n }\n }\n\n debug(`[AST] ✓ ${buildConfigName} call found`)\n\n // Get import statements\n const importStatements = sourceFile.getImportDeclarations()\n debug(`[AST] Found ${importStatements.length} import statements`)\n\n // Find db property if it exists\n const configObject = buildConfigCall.getArguments()[0]\n let dbProperty\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n dbProperty = configObject\n .asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n .getProperty('db')\n ?.asKind(SyntaxKind.PropertyAssignment)\n }\n\n debug(`[AST] db property: ${dbProperty ? '✓ found' : '✗ not found'}`)\n\n // Find plugins array if it exists\n let pluginsArray\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const pluginsProperty = objLiteral.getProperty('plugins')\n\n // Handle PropertyAssignment (e.g., plugins: [...])\n const propertyAssignment = pluginsProperty?.asKind(SyntaxKind.PropertyAssignment)\n if (propertyAssignment) {\n const initializer = propertyAssignment.getInitializer()\n if (initializer?.getKind() === SyntaxKind.ArrayLiteralExpression) {\n pluginsArray = initializer.asKind(SyntaxKind.ArrayLiteralExpression)\n }\n }\n // For ShorthandPropertyAssignment (e.g., plugins), we can't get the array directly\n // but we'll detect it in addStorageAdapter\n }\n\n debug(`[AST] plugins array: ${pluginsArray ? '✓ found' : '✗ not found'}`)\n\n // Find all buildConfig calls for edge case detection (using actual name)\n const allBuildConfigCalls = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n const hasImportAlias = !!aliasNode\n\n // Check for other Payload imports\n const payloadImports = payloadImport?.getNamedImports() || []\n const hasOtherPayloadImports =\n payloadImports.length > 1 || payloadImports.some((imp) => imp.getName() !== 'buildConfig')\n\n // Track database adapter imports\n let dbAdapterImportInfo\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n dbAdapterImportInfo = {\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n }\n break\n }\n }\n\n // Track storage adapter imports\n const storageAdapterImports = []\n for (const [, config] of Object.entries(STORAGE_ADAPTER_CONFIG)) {\n if (!config.packageName || !config.adapterName) {\n continue\n }\n\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n storageAdapterImports.push({\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n })\n }\n }\n\n const needsManualIntervention = hasImportAlias || allBuildConfigCalls.length > 2\n\n debug(\n `[AST] Edge cases: alias=${hasImportAlias}, multiple=${allBuildConfigCalls.length > 1}, otherImports=${hasOtherPayloadImports}, manual=${needsManualIntervention}`,\n )\n\n return {\n edgeCases: {\n hasImportAlias,\n hasOtherPayloadImports,\n multipleBuildConfigCalls: allBuildConfigCalls.length > 1,\n needsManualIntervention,\n },\n importSources: {\n dbAdapter: dbAdapterImportInfo,\n storage: storageAdapterImports.length > 0 ? storageAdapterImports : undefined,\n },\n sourceFile,\n structures: {\n buildConfigCall,\n dbProperty,\n importStatements,\n pluginsArray,\n },\n success: true,\n }\n}\n\nexport function addDatabaseAdapter({\n adapter,\n envVarName = 'DATABASE_URL',\n sourceFile,\n}: {\n adapter: DatabaseAdapter\n envVarName?: string\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding database adapter: ${adapter} (envVar: ${envVarName})`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall, dbProperty } = detection.structures\n const config = DB_ADAPTER_CONFIG[adapter]\n\n // Remove old db adapter imports and track position for replacement\n const oldAdapters = Object.values(DB_ADAPTER_CONFIG)\n const removedAdapters: string[] = []\n let importInsertIndex: number | undefined\n oldAdapters.forEach((oldConfig) => {\n if (oldConfig.packageName !== config.packageName) {\n const { removedIndex } = removeImportDeclaration({\n moduleSpecifier: oldConfig.packageName,\n sourceFile,\n })\n if (removedIndex !== undefined) {\n // Use the first removed adapter's position\n if (importInsertIndex === undefined) {\n importInsertIndex = removedIndex\n }\n removedAdapters.push(oldConfig.packageName)\n modifications.push({\n type: 'import-removed',\n description: `Removed import from '${oldConfig.packageName}'`,\n })\n }\n }\n })\n\n if (removedAdapters.length > 0) {\n debug(`[AST] Removed old adapter imports: ${removedAdapters.join(', ')}`)\n }\n\n // Add new import at the position of the removed one (or default position)\n addImportDeclaration({\n insertIndex: importInsertIndex,\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n\n // Add special imports for specific adapters\n if (adapter === 'd1-sqlite') {\n debug('[AST] Adding special import: ./db/migrations')\n addImportDeclaration({\n defaultImport: 'migrations',\n moduleSpecifier: './db/migrations',\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: migrations from './db/migrations'`,\n })\n }\n\n // Get config object\n const configObject = buildConfigCall.getArguments()[0]\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'database adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n const newDbCode = `db: ${config.configTemplate(envVarName)}`\n\n if (dbProperty) {\n // Replace existing db property\n // NOTE: Using replaceWithText() instead of remove() + insertPropertyAssignment()\n // to avoid double comma issues. When remove() is called, ts-morph doesn't always\n // clean up trailing commas correctly, which can result in syntax like \"},,\" when\n // inserting a new property at that position. replaceWithText() preserves the\n // surrounding punctuation correctly.\n debug(`[AST] Replacing existing db property`)\n dbProperty.replaceWithText(newDbCode)\n modifications.push({\n type: 'property-added',\n description: `Replaced db property with ${adapter} adapter`,\n })\n } else {\n // No existing db property - insert at end\n const insertIndex = objLiteral.getProperties().length\n debug(`[AST] Adding db property at index ${insertIndex}`)\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'db',\n initializer: config.configTemplate(envVarName),\n })\n modifications.push({\n type: 'property-added',\n description: `Added db property with ${adapter} adapter`,\n })\n }\n\n debug(`[AST] ✓ Database adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function addStorageAdapter({\n adapter,\n sourceFile,\n}: {\n adapter: StorageAdapter\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding storage adapter: ${adapter}`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const config = STORAGE_ADAPTER_CONFIG[adapter]\n\n // Local disk doesn't need any imports or plugins\n if (adapter === 'localDisk') {\n debug('[AST] localDisk storage adapter - no imports or plugins needed')\n return {\n modifications: [],\n modified: false,\n success: true,\n }\n }\n\n // Add import\n if (config.packageName && config.adapterName) {\n addImportDeclaration({\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'storage adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n // Find or create plugins array\n const pluginsPropertyRaw = objLiteral.getProperty('plugins')\n let pluginsProperty = pluginsPropertyRaw?.asKind(SyntaxKind.PropertyAssignment)\n\n // Check if it's a shorthand property (e.g., `plugins` referencing an imported variable)\n const shorthandProperty = pluginsPropertyRaw?.asKind(SyntaxKind.ShorthandPropertyAssignment)\n\n if (shorthandProperty) {\n debug('[AST] Found shorthand plugins property, converting to long form with spread')\n // Get the identifier name (usually 'plugins')\n const identifierName = shorthandProperty.getName()\n\n // Find insert position before removing\n const allProperties = objLiteral.getProperties()\n const insertIndex = allProperties.indexOf(shorthandProperty)\n\n // Remove the shorthand property\n shorthandProperty.remove()\n\n // Create new property with spread operator: plugins: [...plugins, newAdapter]\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'plugins',\n initializer: `[...${identifierName}]`,\n })\n\n pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Converted shorthand plugins property to array with spread syntax`,\n })\n } else if (!pluginsProperty) {\n debug('[AST] Creating new plugins array')\n // Create plugins array\n objLiteral.addPropertyAssignment({\n name: 'plugins',\n initializer: '[]',\n })\n pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Created plugins array`,\n })\n } else {\n debug('[AST] Reusing existing plugins array')\n }\n\n if (!pluginsProperty) {\n return {\n error: formatError({\n actual: 'Failed to create or find plugins property',\n context: 'storage adapter configuration',\n expected: 'plugins array property',\n technicalDetails: 'Could not create or access plugins property',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const initializer = pluginsProperty.getInitializer()\n if (!initializer || initializer.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return {\n error: formatError({\n actual: 'plugins property is not an array',\n context: 'storage adapter configuration',\n expected: 'plugins: [...]',\n technicalDetails: 'plugins property must be an array literal expression',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const pluginsArray = initializer.asKindOrThrow(SyntaxKind.ArrayLiteralExpression)\n\n // Add storage adapter call\n const configText = config.configTemplate()\n if (configText) {\n pluginsArray.addElement(configText)\n modifications.push({\n type: 'property-added',\n description: `Added ${adapter} to plugins array`,\n })\n }\n\n debug(`[AST] ✓ Storage adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function removeSharp(sourceFile: SourceFile): TransformationResult {\n debug('[AST] Removing sharp import and property')\n\n const modifications: Modification[] = []\n\n // Remove import\n const { removedIndex } = removeImportDeclaration({ moduleSpecifier: 'sharp', sourceFile })\n if (removedIndex !== undefined) {\n modifications.push({\n type: 'import-removed',\n description: `Removed import from 'sharp'`,\n })\n }\n\n // Find and remove sharp property from buildConfig\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n // If detection failed but we removed import, still count as partial success\n if (modifications.length > 0) {\n return {\n modifications,\n modified: true,\n success: true,\n warnings: ['Could not detect config structure to remove sharp property'],\n }\n }\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n warnings: ['buildConfig has no object literal argument - could not remove sharp property'],\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const sharpProperty = objLiteral.getProperty('sharp')\n\n if (sharpProperty) {\n sharpProperty.remove()\n modifications.push({\n type: 'property-removed',\n description: `Removed sharp property from config`,\n })\n debug('[AST] ✓ Sharp property removed from config')\n } else {\n debug('[AST] Sharp property not found (already absent)')\n }\n\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n }\n}\n\n/** This shouldn't be necessary once the templates are updated. Can't hurt to keep in, though */\nexport function removeCommentMarkers(sourceFile: SourceFile): SourceFile {\n // Get the full text and replace comment markers\n let text = sourceFile.getFullText()\n\n // Remove inline comment markers from imports\n text = text.replace(/\\s*\\/\\/\\s*database-adapter-import\\s*$/gm, '')\n text = text.replace(/\\s*\\/\\/\\s*storage-adapter-import-placeholder\\s*$/gm, '')\n\n // Remove standalone comment lines\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-start\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-end\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*storage-adapter-placeholder\\s*\\n/gm, '')\n\n // Also remove the placeholder line from template (storage-adapter-import-placeholder at top)\n text = text.replace(/^\\/\\/\\s*storage-adapter-import-placeholder\\s*\\n/gm, '')\n\n // Replace the entire source file content\n sourceFile.replaceWithText(text)\n\n return sourceFile\n}\n\n/**\n * Validates payload config structure has required elements after transformation.\n * Checks that buildConfig() call exists and has a db property configured.\n */\nexport function validateStructure(sourceFile: SourceFile): WriteResult {\n debug('[AST] Validating payload config structure')\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success) {\n debug('[AST] ✗ Validation failed: detection unsuccessful')\n return {\n error: detection.error,\n success: false,\n }\n }\n\n const { structures } = detection\n\n // Validate db property exists\n if (!structures?.dbProperty) {\n debug('[AST] ✗ Validation failed: db property missing')\n return {\n error: formatError({\n actual: 'No db property found',\n context: 'database configuration',\n expected: 'buildConfig must have a db property',\n technicalDetails: 'PropertyAssignment with name \"db\" not found in buildConfig object',\n }),\n success: false,\n }\n }\n\n debug('[AST] ✓ Validation passed')\n return { success: true }\n}\n\nexport async function writeTransformedFile(\n sourceFile: SourceFile,\n options: WriteOptions = {},\n): Promise<WriteResult> {\n const { formatWithPrettier = true, validateStructure: shouldValidate = true } = options\n\n debug(`[AST] Writing transformed file: ${sourceFile.getFilePath()}`)\n\n // Validate if requested\n if (shouldValidate) {\n const validation = validateStructure(sourceFile)\n if (!validation.success) {\n return validation\n }\n }\n\n // Get file path and save to disk\n const filePath = sourceFile.getFilePath()\n\n // Format with ts-morph before saving (fixes trailing commas, indentation)\n debug('[AST] Formatting with ts-morph')\n sourceFile.formatText()\n\n // Write file\n debug('[AST] Writing file to disk')\n await sourceFile.save()\n\n // Format with prettier if requested\n if (formatWithPrettier) {\n debug('[AST] Running prettier formatting via CLI')\n try {\n // Detect project directory (go up from file until we find package.json or use dirname)\n const projectDir = path.dirname(filePath)\n\n // Run prettier via CLI (avoids Jest/ESM compatibility issues)\n const prettierCmd = `npx prettier --write \"${filePath}\"`\n\n debug(`[AST] Executing: ${prettierCmd}`)\n execSync(prettierCmd, {\n cwd: projectDir,\n stdio: 'pipe', // Suppress output\n })\n debug('[AST] ✓ Prettier formatting successful')\n } catch (error) {\n // Log but don't fail if prettier fails (might not be installed)\n debug(\n `[AST] ⚠ Prettier formatting failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n debug('[AST] Continuing with unformatted output')\n }\n } else {\n debug('[AST] Skipping prettier formatting (disabled)')\n }\n\n debug('[AST] ✓ File written successfully')\n\n return { success: true }\n}\n\nexport async function configurePayloadConfig(\n filePath: string,\n options: ConfigureOptions = {},\n): Promise<WriteResult> {\n debug(`[AST] Configuring payload config: ${filePath}`)\n debug(\n `[AST] Options: db=${options.db?.type}, storage=${options.storage}, removeSharp=${options.removeSharp}`,\n )\n\n const allModifications: Modification[] = []\n const allWarnings: string[] = []\n\n try {\n // Create Project and load source file with proper settings\n const project = new Project({\n manipulationSettings: {\n quoteKind: QuoteKind.Single,\n },\n })\n let sourceFile = project.addSourceFileAtPath(filePath)\n\n // Run detection\n const detection = detectPayloadConfigStructure(sourceFile)\n if (!detection.success) {\n return detection\n }\n\n // Apply transformations based on options\n if (options.db) {\n debug('[AST] Applying database adapter transformation')\n const result = addDatabaseAdapter({\n adapter: options.db.type,\n envVarName: options.db.envVarName,\n sourceFile,\n })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.storage) {\n debug('[AST] Applying storage adapter transformation')\n const result = addStorageAdapter({ adapter: options.storage, sourceFile })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.removeSharp) {\n debug('[AST] Applying sharp removal')\n const result = removeSharp(sourceFile)\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n // Remove comment markers from template\n sourceFile = removeCommentMarkers(sourceFile)\n\n // Cleanup orphaned imports after all transformations\n debug('[AST] Cleaning up orphaned imports')\n\n // Cleanup database adapter imports if db was removed\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n if (options.db && config.packageName !== DB_ADAPTER_CONFIG[options.db.type].packageName) {\n const cleanup = cleanupOrphanedImports({\n importNames: [config.adapterName],\n moduleSpecifier: config.packageName,\n sourceFile,\n })\n if (cleanup.removed.length > 0) {\n cleanup.removed.forEach((importName) => {\n allModifications.push({\n type: 'import-removed',\n description: `Cleaned up unused import '${importName}' from '${config.packageName}'`,\n })\n })\n }\n }\n }\n\n // Log summary of modifications\n if (allModifications.length > 0) {\n debug(`[AST] Applied ${allModifications.length} modification(s):`)\n allModifications.forEach((mod) => {\n debug(`[AST] - ${mod.type}: ${mod.description}`)\n })\n }\n\n if (allWarnings.length > 0) {\n debug(`[AST] ${allWarnings.length} warning(s):`)\n allWarnings.forEach((warning) => {\n debug(`[AST] - ${warning}`)\n })\n }\n\n // Write transformed file with validation and formatting\n return await writeTransformedFile(sourceFile, {\n formatWithPrettier: options.formatWithPrettier,\n validateStructure: options.validateStructure ?? true,\n })\n } catch (error) {\n debug(`[AST] ✗ Configuration failed: ${error instanceof Error ? error.message : String(error)}`)\n return {\n error: formatError({\n actual: error instanceof Error ? error.message : String(error),\n context: 'configurePayloadConfig',\n expected: 'Successful file transformation',\n technicalDetails: error instanceof Error ? error.stack || error.message : String(error),\n }),\n success: false,\n }\n }\n}\n"],"names":["execSync","path","Project","QuoteKind","SyntaxKind","debug","DB_ADAPTER_CONFIG","STORAGE_ADAPTER_CONFIG","addImportDeclaration","cleanupOrphanedImports","formatError","removeImportDeclaration","detectPayloadConfigStructure","sourceFile","getFilePath","payloadImport","getImportDeclarations","find","imp","getModuleSpecifierValue","buildConfigImportSpec","getNamedImports","spec","getName","aliasNode","getAliasNode","buildConfigName","getText","buildConfigCall","getDescendantsOfKind","CallExpression","call","expression","getExpression","error","actual","context","expected","technicalDetails","success","importStatements","length","configObject","getArguments","dbProperty","getKind","ObjectLiteralExpression","asKindOrThrow","getProperty","asKind","PropertyAssignment","pluginsArray","objLiteral","pluginsProperty","propertyAssignment","initializer","getInitializer","ArrayLiteralExpression","allBuildConfigCalls","filter","hasImportAlias","payloadImports","hasOtherPayloadImports","some","dbAdapterImportInfo","config","Object","entries","importDecl","packageName","namedImports","hasOtherImports","importDeclaration","storageAdapterImports","adapterName","push","needsManualIntervention","edgeCases","multipleBuildConfigCalls","importSources","dbAdapter","storage","undefined","structures","addDatabaseAdapter","adapter","envVarName","modifications","detection","modified","oldAdapters","values","removedAdapters","importInsertIndex","forEach","oldConfig","removedIndex","moduleSpecifier","type","description","join","insertIndex","defaultImport","newDbCode","configTemplate","replaceWithText","getProperties","insertPropertyAssignment","name","addStorageAdapter","pluginsPropertyRaw","shorthandProperty","ShorthandPropertyAssignment","identifierName","allProperties","indexOf","remove","addPropertyAssignment","configText","addElement","removeSharp","warnings","sharpProperty","removeCommentMarkers","text","getFullText","replace","validateStructure","writeTransformedFile","options","formatWithPrettier","shouldValidate","validation","filePath","formatText","save","projectDir","dirname","prettierCmd","cwd","stdio","Error","message","configurePayloadConfig","db","allModifications","allWarnings","project","manipulationSettings","quoteKind","Single","addSourceFileAtPath","result","cleanup","importNames","removed","importName","mod","warning","String","stack"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAe;AACxC,OAAOC,UAAU,OAAM;AACvB,SAASC,OAAO,EAAEC,SAAS,EAAmBC,UAAU,QAAQ,WAAU;AAa1E,SAASC,KAAK,QAAQ,qBAAoB;AAC1C,SAASC,iBAAiB,EAAEC,sBAAsB,QAAQ,sBAAqB;AAC/E,SACEC,oBAAoB,EACpBC,sBAAsB,EACtBC,WAAW,EACXC,uBAAuB,QAClB,aAAY;AAEnB,OAAO,SAASC,6BAA6BC,UAAsB;IACjER,MAAM,CAAC,4CAA4C,EAAEQ,WAAWC,WAAW,IAAI;IAE/E,2DAA2D;IAC3D,MAAMC,gBAAgBF,WACnBG,qBAAqB,GACrBC,IAAI,CAAC,CAACC,MAAQA,IAAIC,uBAAuB,OAAO;IAEnD,MAAMC,wBAAwBL,eAC1BM,kBACDJ,KAAK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AAM;4BACNC,aAAa,CAAC,0BAA0B,EAAEyD,WAAW,QAAQ,EAAE3F,OAAOI,WAAW,CAAC,CAAC,CAAC;wBACtF;oBACF;gBACF;YACF;QACF;QAEA,+BAA+B;QAC/B,IAAI4E,iBAAiBxG,MAAM,GAAG,GAAG;YAC/BpC,MAAM,CAAC,cAAc,EAAE4I,iBAAiBxG,MAAM,CAAC,iBAAiB,CAAC;YACjEwG,iBAAiBnD,OAAO,CAAC,CAAC+D;gBACxBxJ,MAAM,CAAC,UAAU,EAAEwJ,IAAI3D,IAAI,CAAC,EAAE,EAAE2D,IAAI1D,WAAW,EAAE;YACnD;QACF;QAEA,IAAI+C,YAAYzG,MAAM,GAAG,GAAG;YAC1BpC,MAAM,CAAC,MAAM,EAAE6I,YAAYzG,MAAM,CAAC,YAAY,CAAC;YAC/CyG,YAAYpD,OAAO,CAAC,CAACgE;gBACnBzJ,MAAM,CAAC,UAAU,EAAEyJ,SAAS;YAC9B;QACF;QAEA,wDAAwD;QACxD,OAAO,MAAM9B,qBAAqBnH,YAAY;YAC5CqH,oBAAoBD,QAAQC,kBAAkB;YAC9CH,mBAAmBE,QAAQF,iBAAiB,IAAI;QAClD;IACF,EAAE,OAAO7F,OAAO;QACd7B,MAAM,CAAC,8BAA8B,EAAE6B,iBAAiB2G,QAAQ3G,MAAM4G,OAAO,GAAGiB,OAAO7H,QAAQ;QAC/F,OAAO;YACLA,OAAOxB,YAAY;gBACjByB,QAAQD,iBAAiB2G,QAAQ3G,MAAM4G,OAAO,GAAGiB,OAAO7H;gBACxDE,SAAS;gBACTC,UAAU;gBACVC,kBAAkBJ,iBAAiB2G,QAAQ3G,MAAM8H,KAAK,IAAI9H,MAAM4G,OAAO,GAAGiB,OAAO7H;YACnF;YACAK,SAAS;QACX;IACF;AACF"}
@@ -49,7 +49,7 @@ export type DetectionResult = {
49
49
  packageName: string;
50
50
  };
51
51
  /** Current storage adapter import info */
52
- storageAdapters?: Array<{
52
+ storage?: Array<{
53
53
  hasOtherImports: boolean;
54
54
  importDeclaration: ImportDeclaration;
55
55
  packageName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACX,MAAM,UAAU,CAAA;AAGjB,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,eAAe,EAAE,cAAc,CAAA;IAC/B,UAAU,CAAC,EAAE,kBAAkB,CAAA;IAC/B,gBAAgB,EAAE,iBAAiB,EAAE,CAAA;IACrC,YAAY,CAAC,EAAE,sBAAsB,CAAA;CACtC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,sBAAsB;IACtB,SAAS,CAAC,EAAE;QACV,gEAAgE;QAChE,cAAc,EAAE,OAAO,CAAA;QACvB,2DAA2D;QAC3D,sBAAsB,EAAE,OAAO,CAAA;QAC/B,+CAA+C;QAC/C,wBAAwB,EAAE,OAAO,CAAA;QACj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,CAAC,CAAA;AAEpE,eAAO,MAAM,qBAAqB,4EAMxB,CAAA;AAEV,eAAO,MAAM,oBAAoB,2HAQvB,CAAA;AAEV,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,CAAC,EAAE;QAChB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,IAAI,EAAE,eAAe,CAAA;KACtB,CAAA;IACD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,cAAc,CAAC,EAAE;QACf,IAAI,EAAE,cAAc,CAAA;KACrB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,CAAC,EAAE;QACH,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,IAAI,EAAE,eAAe,CAAA;KACtB,CAAA;IACD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,OAAO,CAAC,EAAE,cAAc,CAAA;CACzB,GAAG,YAAY,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/ast/types.ts"],"sourcesContent":["import type {\n ArrayLiteralExpression,\n CallExpression,\n ImportDeclaration,\n PropertyAssignment,\n SourceFile,\n} from 'ts-morph'\n\n// Result types for import utility functions\nexport type ImportRemovalResult = {\n removedIndex?: number\n sourceFile: SourceFile\n}\n\nexport type NamedImportRemovalResult = {\n fullyRemoved: boolean\n index?: number\n sourceFile: SourceFile\n}\n\nexport type ImportCleanupResult = {\n kept: string[]\n removed: string[]\n sourceFile: SourceFile\n}\n\nexport type DetectionError = {\n debugInfo?: Record<string, unknown>\n technicalDetails: string\n userMessage: string\n}\n\nexport type PayloadConfigStructures = {\n buildConfigCall: CallExpression\n dbProperty?: PropertyAssignment\n importStatements: ImportDeclaration[]\n pluginsArray?: ArrayLiteralExpression\n}\n\n/**\n * Detection result with edge case tracking and import source information\n */\nexport type DetectionResult = {\n /** Edge case flags */\n edgeCases?: {\n /** Import uses an alias (e.g., import { buildConfig as bc }) */\n hasImportAlias: boolean\n /** Other Payload imports exist (e.g., CollectionConfig) */\n hasOtherPayloadImports: boolean\n /** Multiple buildConfig calls found in file */\n multipleBuildConfigCalls: boolean\n /** Needs manual intervention (can't be automatically handled) */\n needsManualIntervention: boolean\n }\n error?: DetectionError\n /** Import source tracking */\n importSources?: {\n /** Current database adapter import info */\n dbAdapter?: {\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }\n /** Current storage adapter import info */\n storageAdapters?: Array<{\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }>\n }\n /** Source file reference */\n sourceFile?: SourceFile\n /** Detected structures */\n structures?: PayloadConfigStructures\n success: boolean\n}\n\n/**\n * Tracks a single modification made to the AST\n */\nexport type Modification = {\n description: string\n location?: {\n column: number\n line: number\n }\n type:\n | 'function-renamed'\n | 'import-added'\n | 'import-modified'\n | 'import-removed'\n | 'property-added'\n | 'property-removed'\n}\n\n/**\n * Result of transformation operations\n */\nexport type TransformationResult = {\n error?: DetectionError\n modifications: Modification[]\n modified: boolean\n success: boolean\n warnings?: string[]\n}\n\n/**\n * Final result after writing to disk\n */\nexport type ModificationResult = {\n error?: DetectionError\n filePath: string\n formatted?: boolean\n modifications: Modification[]\n success: boolean\n warnings?: string[]\n}\nexport type DatabaseAdapter = (typeof ALL_DATABASE_ADAPTERS)[number]\n\nexport const ALL_DATABASE_ADAPTERS = [\n 'mongodb',\n 'postgres',\n 'sqlite',\n 'vercel-postgres',\n 'd1-sqlite',\n] as const\n\nexport const ALL_STORAGE_ADAPTERS = [\n 'azureStorage',\n 'gcsStorage',\n 'localDisk',\n 'r2Storage',\n 's3Storage',\n 'uploadthingStorage',\n 'vercelBlobStorage',\n] as const\n\nexport type StorageAdapter = (typeof ALL_STORAGE_ADAPTERS)[number]\n\nexport type TransformOptions = {\n databaseAdapter?: {\n envVarName?: string\n type: DatabaseAdapter\n }\n removeSharp?: boolean\n storageAdapter?: {\n type: StorageAdapter\n }\n}\n\nexport type WriteOptions = {\n formatWithPrettier?: boolean\n validateStructure?: boolean\n}\n\nexport type WriteResult = {\n error?: DetectionError\n success: boolean\n}\n\nexport type ConfigureOptions = {\n db?: {\n envVarName?: string\n type: DatabaseAdapter\n }\n removeSharp?: boolean\n storage?: StorageAdapter\n} & WriteOptions\n"],"names":["ALL_DATABASE_ADAPTERS","ALL_STORAGE_ADAPTERS"],"mappings":"AAuHA,OAAO,MAAMA,wBAAwB;IACnC;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV,OAAO,MAAMC,uBAAuB;IAClC;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS"}
1
+ {"version":3,"sources":["../../../src/lib/ast/types.ts"],"sourcesContent":["import type {\n ArrayLiteralExpression,\n CallExpression,\n ImportDeclaration,\n PropertyAssignment,\n SourceFile,\n} from 'ts-morph'\n\n// Result types for import utility functions\nexport type ImportRemovalResult = {\n removedIndex?: number\n sourceFile: SourceFile\n}\n\nexport type NamedImportRemovalResult = {\n fullyRemoved: boolean\n index?: number\n sourceFile: SourceFile\n}\n\nexport type ImportCleanupResult = {\n kept: string[]\n removed: string[]\n sourceFile: SourceFile\n}\n\nexport type DetectionError = {\n debugInfo?: Record<string, unknown>\n technicalDetails: string\n userMessage: string\n}\n\nexport type PayloadConfigStructures = {\n buildConfigCall: CallExpression\n dbProperty?: PropertyAssignment\n importStatements: ImportDeclaration[]\n pluginsArray?: ArrayLiteralExpression\n}\n\n/**\n * Detection result with edge case tracking and import source information\n */\nexport type DetectionResult = {\n /** Edge case flags */\n edgeCases?: {\n /** Import uses an alias (e.g., import { buildConfig as bc }) */\n hasImportAlias: boolean\n /** Other Payload imports exist (e.g., CollectionConfig) */\n hasOtherPayloadImports: boolean\n /** Multiple buildConfig calls found in file */\n multipleBuildConfigCalls: boolean\n /** Needs manual intervention (can't be automatically handled) */\n needsManualIntervention: boolean\n }\n error?: DetectionError\n /** Import source tracking */\n importSources?: {\n /** Current database adapter import info */\n dbAdapter?: {\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }\n /** Current storage adapter import info */\n storage?: Array<{\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }>\n }\n /** Source file reference */\n sourceFile?: SourceFile\n /** Detected structures */\n structures?: PayloadConfigStructures\n success: boolean\n}\n\n/**\n * Tracks a single modification made to the AST\n */\nexport type Modification = {\n description: string\n location?: {\n column: number\n line: number\n }\n type:\n | 'function-renamed'\n | 'import-added'\n | 'import-modified'\n | 'import-removed'\n | 'property-added'\n | 'property-removed'\n}\n\n/**\n * Result of transformation operations\n */\nexport type TransformationResult = {\n error?: DetectionError\n modifications: Modification[]\n modified: boolean\n success: boolean\n warnings?: string[]\n}\n\n/**\n * Final result after writing to disk\n */\nexport type ModificationResult = {\n error?: DetectionError\n filePath: string\n formatted?: boolean\n modifications: Modification[]\n success: boolean\n warnings?: string[]\n}\nexport type DatabaseAdapter = (typeof ALL_DATABASE_ADAPTERS)[number]\n\nexport const ALL_DATABASE_ADAPTERS = [\n 'mongodb',\n 'postgres',\n 'sqlite',\n 'vercel-postgres',\n 'd1-sqlite',\n] as const\n\nexport const ALL_STORAGE_ADAPTERS = [\n 'azureStorage',\n 'gcsStorage',\n 'localDisk',\n 'r2Storage',\n 's3Storage',\n 'uploadthingStorage',\n 'vercelBlobStorage',\n] as const\n\nexport type StorageAdapter = (typeof ALL_STORAGE_ADAPTERS)[number]\n\nexport type TransformOptions = {\n databaseAdapter?: {\n envVarName?: string\n type: DatabaseAdapter\n }\n removeSharp?: boolean\n storageAdapter?: {\n type: StorageAdapter\n }\n}\n\nexport type WriteOptions = {\n formatWithPrettier?: boolean\n validateStructure?: boolean\n}\n\nexport type WriteResult = {\n error?: DetectionError\n success: boolean\n}\n\nexport type ConfigureOptions = {\n db?: {\n envVarName?: string\n type: DatabaseAdapter\n }\n removeSharp?: boolean\n storage?: StorageAdapter\n} & WriteOptions\n"],"names":["ALL_DATABASE_ADAPTERS","ALL_STORAGE_ADAPTERS"],"mappings":"AAuHA,OAAO,MAAMA,wBAAwB;IACnC;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV,OAAO,MAAMC,uBAAuB;IAClC;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"configure-plugin-project.d.ts","sourceRoot":"","sources":["../../src/lib/configure-plugin-project.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,sBAAsB,qCAGhC;IACD,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;CACpB,SAmCA,CAAA"}
1
+ {"version":3,"file":"configure-plugin-project.d.ts","sourceRoot":"","sources":["../../src/lib/configure-plugin-project.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,kCAGpC;IACD,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;CACpB,SAmCA,CAAA"}
@@ -83,7 +83,7 @@ describe('createProject', ()=>{
83
83
  const projectName = 'custom-server-example';
84
84
  const example = {
85
85
  name: 'custom-server',
86
- url: 'https://github.com/payloadcms/payload/examples/custom-server#3.x'
86
+ url: 'https://github.com/payloadcms/payload/examples/custom-server#main'
87
87
  };
88
88
  await createProject({
89
89
  cliArgs: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/create-project.spec.ts"],"sourcesContent":["import fs from 'fs'\nimport fse from 'fs-extra'\nimport globby from 'globby'\nimport * as os from 'node:os'\nimport path from 'path'\nimport { afterEach, beforeAll, beforeEach, describe, expect, it, vitest } from 'vitest'\nimport type { CliArgs, DbType, ProjectExample, ProjectTemplate } from '../types.js'\n\nimport { createProject, updatePackageJSONDependencies } from './create-project.js'\nimport { getValidTemplates } from './templates.js'\n\ndescribe('createProject', () => {\n let projectDir: string\n\n beforeAll(() => {\n // eslint-disable-next-line no-console\n console.log = vitest.fn()\n })\n\n beforeEach(() => {\n const tempDirectory = fs.realpathSync(os.tmpdir())\n projectDir = `${tempDirectory}/${Math.random().toString(36).substring(7)}`\n })\n\n afterEach(() => {\n if (fse.existsSync(projectDir)) {\n fse.rmSync(projectDir, { recursive: true })\n }\n })\n\n describe('#createProject', () => {\n const args = {\n _: ['project-name'],\n '--db': 'mongodb',\n '--local-template': 'blank',\n '--no-deps': true,\n } as CliArgs\n const packageManager = 'yarn'\n\n it('creates plugin template', async () => {\n const projectName = 'plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin',\n }\n\n await createProject({\n cliArgs: { ...args, '--local-template': 'plugin' } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toStrictEqual(projectName)\n })\n\n it('updates project name in plugin template importMap file', async () => {\n const projectName = 'my-custom-plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin',\n }\n\n await createProject({\n cliArgs: { ...args, '--local-template': 'plugin' } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n const importMapPath = path.resolve(projectDir, './dev/app/(payload)/admin/importMap.js')\n const importMapFile = fse.readFileSync(importMapPath, 'utf-8')\n\n expect(importMapFile).not.toContain('plugin-package-name-placeholder')\n expect(importMapFile).toContain('my-custom-plugin')\n })\n\n it('creates example', async () => {\n const projectName = 'custom-server-example'\n const example: ProjectExample = {\n name: 'custom-server',\n url: 'https://github.com/payloadcms/payload/examples/custom-server#3.x',\n }\n\n await createProject({\n cliArgs: {\n ...args,\n '--local-template': undefined,\n '--local-example': 'custom-server',\n } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n example,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toStrictEqual(projectName)\n }, 90_000)\n\n describe('creates project from template', () => {\n const templates = getValidTemplates()\n\n it.each([\n ['blank', 'mongodb'],\n ['blank', 'postgres'],\n\n // TODO: Re-enable these once 3.0 is stable and templates updated\n // ['website', 'mongodb'],\n // ['website', 'postgres'],\n // ['ecommerce', 'mongodb'],\n // ['ecommerce', 'postgres'],\n ])('update config and deps: %s, %s', async (templateName, db) => {\n const projectName = 'starter-project'\n\n const template = templates.find((t) => t.name === templateName)\n\n const cliArgs = {\n ...args,\n '--db': db,\n '--local-template': templateName,\n } as CliArgs\n\n await createProject({\n cliArgs,\n dbDetails: {\n type: db as DbType,\n dbUri: `${db}://localhost:27017/create-project-test`,\n },\n packageManager,\n projectDir,\n projectName,\n template: template as ProjectTemplate,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Verify git was initialized\n expect(fse.existsSync(path.resolve(projectDir, '.git'))).toBe(true)\n\n // Should only have one db adapter\n expect(\n Object.keys(packageJson.dependencies).filter((n) => n.startsWith('@payloadcms/db-')),\n ).toHaveLength(1)\n\n const payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: projectDir,\n })\n )?.[0]\n\n const content = fse.readFileSync(payloadConfigPath, 'utf-8')\n\n // Check payload.config.ts doesn't have placeholder comments\n expect(content).not.toContain('// database-adapter-import')\n expect(content).not.toContain('// database-adapter-config-start')\n expect(content).not.toContain('// database-adapter-config-end')\n\n // Verify correct adapter import and usage based on db type\n if (db === 'mongodb') {\n expect(content).toContain(\"import { mongooseAdapter } from '@payloadcms/db-mongodb'\")\n expect(content).toContain('mongooseAdapter')\n } else if (db === 'postgres') {\n expect(content).toContain(\"import { postgresAdapter } from '@payloadcms/db-postgres'\")\n expect(content).toContain('postgresAdapter')\n }\n })\n })\n\n describe('updates package.json', () => {\n it('updates package name and bumps workspace versions', async () => {\n const latestVersion = '3.0.0'\n const initialJSON = {\n name: 'test-project',\n version: '1.0.0',\n dependencies: {\n '@payloadcms/db-mongodb': 'workspace:*',\n payload: 'workspace:*',\n '@payloadcms/ui': 'workspace:*',\n },\n }\n\n const correctlyModifiedJSON = {\n name: 'test-project',\n version: '1.0.0',\n dependencies: {\n '@payloadcms/db-mongodb': `${latestVersion}`,\n payload: `${latestVersion}`,\n '@payloadcms/ui': `${latestVersion}`,\n },\n }\n\n updatePackageJSONDependencies({\n latestVersion,\n packageJson: initialJSON,\n })\n\n expect(initialJSON).toEqual(correctlyModifiedJSON)\n })\n })\n })\n})\n"],"names":["fs","fse","globby","os","path","afterEach","beforeAll","beforeEach","describe","expect","it","vitest","createProject","updatePackageJSONDependencies","getValidTemplates","projectDir","console","log","fn","tempDirectory","realpathSync","tmpdir","Math","random","toString","substring","existsSync","rmSync","recursive","args","_","packageManager","projectName","template","name","type","description","url","cliArgs","packageJsonPath","resolve","packageJson","readJsonSync","toStrictEqual","importMapPath","importMapFile","readFileSync","not","toContain","example","undefined","templates","each","templateName","db","find","t","dbDetails","dbUri","toBe","Object","keys","dependencies","filter","n","startsWith","toHaveLength","payloadConfigPath","absolute","cwd","content","latestVersion","initialJSON","version","payload","correctlyModifiedJSON","toEqual"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,YAAYC,QAAQ,UAAS;AAC7B,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,EAA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kB,GAAGA,eAAe;oBACtC;gBACF;gBAEA1D,8BAA8B;oBAC5B0D;oBACA9B,aAAa+B;gBACf;gBAEA/D,OAAO+D,aAAaI,OAAO,CAACD;YAC9B;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/lib/create-project.spec.ts"],"sourcesContent":["import fs from 'fs'\nimport fse from 'fs-extra'\nimport globby from 'globby'\nimport * as os from 'node:os'\nimport path from 'path'\nimport { afterEach, beforeAll, beforeEach, describe, expect, it, vitest } from 'vitest'\nimport type { CliArgs, DbType, ProjectExample, ProjectTemplate } from '../types.js'\n\nimport { createProject, updatePackageJSONDependencies } from './create-project.js'\nimport { getValidTemplates } from './templates.js'\n\ndescribe('createProject', () => {\n let projectDir: string\n\n beforeAll(() => {\n // eslint-disable-next-line no-console\n console.log = vitest.fn()\n })\n\n beforeEach(() => {\n const tempDirectory = fs.realpathSync(os.tmpdir())\n projectDir = `${tempDirectory}/${Math.random().toString(36).substring(7)}`\n })\n\n afterEach(() => {\n if (fse.existsSync(projectDir)) {\n fse.rmSync(projectDir, { recursive: true })\n }\n })\n\n describe('#createProject', () => {\n const args = {\n _: ['project-name'],\n '--db': 'mongodb',\n '--local-template': 'blank',\n '--no-deps': true,\n } as CliArgs\n const packageManager = 'yarn'\n\n it('creates plugin template', async () => {\n const projectName = 'plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin',\n }\n\n await createProject({\n cliArgs: { ...args, '--local-template': 'plugin' } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toStrictEqual(projectName)\n })\n\n it('updates project name in plugin template importMap file', async () => {\n const projectName = 'my-custom-plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin',\n }\n\n await createProject({\n cliArgs: { ...args, '--local-template': 'plugin' } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n const importMapPath = path.resolve(projectDir, './dev/app/(payload)/admin/importMap.js')\n const importMapFile = fse.readFileSync(importMapPath, 'utf-8')\n\n expect(importMapFile).not.toContain('plugin-package-name-placeholder')\n expect(importMapFile).toContain('my-custom-plugin')\n })\n\n it('creates example', async () => {\n const projectName = 'custom-server-example'\n const example: ProjectExample = {\n name: 'custom-server',\n url: 'https://github.com/payloadcms/payload/examples/custom-server#main',\n }\n\n await createProject({\n cliArgs: {\n ...args,\n '--local-template': undefined,\n '--local-example': 'custom-server',\n } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n example,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toStrictEqual(projectName)\n }, 90_000)\n\n describe('creates project from template', () => {\n const templates = getValidTemplates()\n\n it.each([\n ['blank', 'mongodb'],\n ['blank', 'postgres'],\n\n // TODO: Re-enable these once 3.0 is stable and templates updated\n // ['website', 'mongodb'],\n // ['website', 'postgres'],\n // ['ecommerce', 'mongodb'],\n // ['ecommerce', 'postgres'],\n ])('update config and deps: %s, %s', async (templateName, db) => {\n const projectName = 'starter-project'\n\n const template = templates.find((t) => t.name === templateName)\n\n const cliArgs = {\n ...args,\n '--db': db,\n '--local-template': templateName,\n } as CliArgs\n\n await createProject({\n cliArgs,\n dbDetails: {\n type: db as DbType,\n dbUri: `${db}://localhost:27017/create-project-test`,\n },\n packageManager,\n projectDir,\n projectName,\n template: template as ProjectTemplate,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Verify git was initialized\n expect(fse.existsSync(path.resolve(projectDir, '.git'))).toBe(true)\n\n // Should only have one db adapter\n expect(\n Object.keys(packageJson.dependencies).filter((n) => n.startsWith('@payloadcms/db-')),\n ).toHaveLength(1)\n\n const payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: projectDir,\n })\n )?.[0]\n\n const content = fse.readFileSync(payloadConfigPath, 'utf-8')\n\n // Check payload.config.ts doesn't have placeholder comments\n expect(content).not.toContain('// database-adapter-import')\n expect(content).not.toContain('// database-adapter-config-start')\n expect(content).not.toContain('// database-adapter-config-end')\n\n // Verify correct adapter import and usage based on db type\n if (db === 'mongodb') {\n expect(content).toContain(\"import { mongooseAdapter } from '@payloadcms/db-mongodb'\")\n expect(content).toContain('mongooseAdapter')\n } else if (db === 'postgres') {\n expect(content).toContain(\"import { postgresAdapter } from '@payloadcms/db-postgres'\")\n expect(content).toContain('postgresAdapter')\n }\n })\n })\n\n describe('updates package.json', () => {\n it('updates package name and bumps workspace versions', async () => {\n const latestVersion = '3.0.0'\n const initialJSON = {\n name: 'test-project',\n version: '1.0.0',\n dependencies: {\n '@payloadcms/db-mongodb': 'workspace:*',\n payload: 'workspace:*',\n '@payloadcms/ui': 'workspace:*',\n },\n }\n\n const correctlyModifiedJSON = {\n name: 'test-project',\n version: '1.0.0',\n dependencies: {\n '@payloadcms/db-mongodb': `${latestVersion}`,\n payload: `${latestVersion}`,\n '@payloadcms/ui': `${latestVersion}`,\n },\n }\n\n updatePackageJSONDependencies({\n latestVersion,\n packageJson: initialJSON,\n })\n\n expect(initialJSON).toEqual(correctlyModifiedJSON)\n })\n })\n })\n})\n"],"names":["fs","fse","globby","os","path","afterEach","beforeAll","beforeEach","describe","expect","it","vitest","createProject","updatePackageJSONDependencies","getValidTemplates","projectDir","console","log","fn","tempDirectory","realpathSync","tmpdir","Math","random","toString","substring","existsSync","rmSync","recursive","args","_","packageManager","projectName","template","name","type","description","url","cliArgs","packageJsonPath","resolve","packageJson","readJsonSync","toStrictEqual","importMapPath","importMapFile","readFileSync","not","toContain","example","undefined","templates","each","templateName","db","find","t","dbDetails","dbUri","toBe","Object","keys","dependencies","filter","n","startsWith","toHaveLength","payloadConfigPath","absolute","cwd","content","latestVersion","initialJSON","version","payload","correctlyModifiedJSON","toEqual"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,YAAYC,QAAQ,UAAS;AAC7B,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAGvF,SAASC,aAAa,EAAEC,6BAA6B,QAAQ,sBAAqB;AAClF,SAASC,iBAAiB,QAAQ,iBAAgB;AAElDN,SAAS,iBAAiB;IACxB,IAAIO;IAEJT,UAAU;QACR,sCAAsC;QACtCU,QAAQC,GAAG,GAAGN,OAAOO,EAAE;IACzB;IAEAX,WAAW;QACT,MAAMY,gBAAgBnB,GAAGoB,YAAY,CAACjB,GAAGkB,MAAM;QAC/CN,aAAa,GAAGI,cAAc,CAAC,EAAEG,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,IAAI;IAC5E;IAEApB,UAAU;QACR,IAAIJ,IAAIyB,UAAU,CAACX,aAAa;YAC9Bd,IAAI0B,MAAM,CAACZ,YAAY;gBAAEa,WAAW;YAAK;QAC3C;IACF;IAEApB,SAAS,kBAAkB;QACzB,MAAMqB,OAAO;YACXC,GAAG;gBAAC;aAAe;YACnB,QAAQ;YACR,oBAAoB;YACpB,aAAa;QACf;QACA,MAAMC,iBAAiB;QAEvBrB,GAAG,2BAA2B;YAC5B,MAAMsB,cAAc;YACpB,MAAMC,WAA4B;gBAChCC,MAAM;gBACNC,MAAM;gBACNC,aAAa;gBACbC,KAAK;YACP;YAEA,MAAMzB,cAAc;gBAClB0B,SAAS;oBAAE,GAAGT,IAAI;oBAAE,oBAAoB;gBAAS;gBACjDE;gBACAhB;gBACAiB;gBACAC;YACF;YAEA,MAAMM,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BACtD,MAAM6D,gBAAgB;gBACtB,MAAMC,cAAc;oBAClBtC,MAAM;oBACNuC,SAAS;oBACTX,cAAc;wBACZ,0BAA0B;wBAC1BY,SAAS;wBACT,kBAAkB;oBACpB;gBACF;gBAEA,MAAMC,wBAAwB;oBAC5BzC,MAAM;oBACNuC,SAAS;oBACTX,cAAc;wBACZ,0BAA0B,GAAGS,eAAe;wBAC5CG,SAAS,GAAGH,eAAe;wBAC3B,kBAAkB,GAAGA,eAAe;oBACtC;gBACF;gBAEA1D,8BAA8B;oBAC5B0D;oBACA9B,aAAa+B;gBACf;gBAEA/D,OAAO+D,aAAaI,OAAO,CAACD;YAC9B;QACF;IACF;AACF"}
@@ -6,7 +6,7 @@ import { x } from 'tar';
6
6
  import { debug as debugLog } from '../utils/log.js';
7
7
  import { getSkillsDir } from './select-agent.js';
8
8
  export async function downloadSkill(args) {
9
- const { agentType, branch = '3.x', debug, projectDir } = args;
9
+ const { agentType, branch = 'main', debug, projectDir } = args;
10
10
  const skillsDir = getSkillsDir(agentType);
11
11
  const destDir = path.join(projectDir, skillsDir, 'payload');
12
12
  await fse.mkdirp(destDir);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/download-skill.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport path from 'path'\nimport { x } from 'tar'\n\nimport type { AgentType } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\nimport { getSkillsDir } from './select-agent.js'\n\nexport async function downloadSkill(args: {\n agentType: AgentType\n branch?: string\n debug?: boolean\n projectDir: string\n}): Promise<void> {\n const { agentType, branch = '3.x', debug, projectDir } = args\n\n const skillsDir = getSkillsDir(agentType)\n const destDir = path.join(projectDir, skillsDir, 'payload')\n\n await fse.mkdirp(destDir)\n\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branch}`\n const filter = `payload-${branch.replace(/^v/, '').replaceAll('/', '-')}/tools/claude-plugin/skills/payload/`\n\n if (debug) {\n debugLog(`Downloading skill for agent: ${agentType}`)\n debugLog(`Skill codeload url: ${url}`)\n debugLog(`Skill filter: ${filter}`)\n debugLog(`Skill destination: ${destDir}`)\n }\n\n const res = await fetch(url)\n\n if (!res.ok) {\n throw new Error(`Failed to download skill: ${res.status} ${res.statusText} from ${url}`)\n }\n\n if (!res.body) {\n throw new Error(`Failed to download skill: empty response from ${url}`)\n }\n\n await pipeline(\n Readable.from(res.body as unknown as NodeJS.ReadableStream),\n x({\n cwd: destDir,\n filter: (p) => p.includes(filter),\n strip: filter.split('/').length - 1,\n }),\n )\n}\n"],"names":["fse","Readable","pipeline","path","x","debug","debugLog","getSkillsDir","downloadSkill","args","agentType","branch","projectDir","skillsDir","destDir","join","mkdirp","url","filter","replace","replaceAll","res","fetch","ok","Error","status","statusText","body","from","cwd","p","includes","strip","split","length"],"mappings":"AAAA,OAAOA,SAAS,WAAU;AAC1B,SAASC,QAAQ,QAAQ,cAAa;AACtC,SAASC,QAAQ,QAAQ,uBAAsB;AAC/C,OAAOC,UAAU,OAAM;AACvB,SAASC,CAAC,QAAQ,MAAK;AAIvB,SAASC,SAASC,QAAQ,QAAQ,kBAAiB;AACnD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,OAAO,eAAeC,cAAcC,IAKnC;IACC,MAAM,EAAEC,SAAS,EAAEC,SAAS,KAAK,EAAEN,KAAK,EAAEO,UAAU,EAAE,GAAGH;IAEzD,MAAMI,YAAYN,aAAaG;IAC/B,MAAMI,UAAUX,KAAKY,IAAI,CAACH,YAAYC,WAAW;IAEjD,MAAMb,IAAIgB,MAAM,CAACF;IAEjB,MAAMG,MAAM,CAAC,sDAAsD,EAAEN,QAAQ;IAC7E,MAAMO,SAAS,CAAC,QAAQ,EAAEP,OAAOQ,OAAO,CAAC,MAAM,IAAIC,UAAU,CAAC,KAAK,KAAK,oCAAoC,CAAC;IAE7G,IAAIf,OAAO;QACTC,SAAS,CAAC,6BAA6B,EAAEI,WAAW;QACpDJ,SAAS,CAAC,oBAAoB,EAAEW,KAAK;QACrCX,SAAS,CAAC,cAAc,EAAEY,QAAQ;QAClCZ,SAAS,CAAC,mBAAmB,EAAEQ,SAAS;IAC1C;IAEA,MAAMO,MAAM,MAAMC,MAAML;IAExB,IAAI,CAACI,IAAIE,EAAE,EAAE;QACX,MAAM,IAAIC,MAAM,CAAC,0BAA0B,EAAEH,IAAII,MAAM,CAAC,CAAC,EAAEJ,IAAIK,UAAU,CAAC,MAAM,EAAET,KAAK;IACzF;IAEA,IAAI,CAACI,IAAIM,IAAI,EAAE;QACb,MAAM,IAAIH,MAAM,CAAC,8CAA8C,EAAEP,KAAK;IACxE;IAEA,MAAMf,SACJD,SAAS2B,IAAI,CAACP,IAAIM,IAAI,GACtBvB,EAAE;QACAyB,KAAKf;QACLI,QAAQ,CAACY,IAAMA,EAAEC,QAAQ,CAACb;QAC1Bc,OAAOd,OAAOe,KAAK,CAAC,KAAKC,MAAM,GAAG;IACpC;AAEJ"}
1
+ {"version":3,"sources":["../../src/lib/download-skill.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport path from 'path'\nimport { x } from 'tar'\n\nimport type { AgentType } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\nimport { getSkillsDir } from './select-agent.js'\n\nexport async function downloadSkill(args: {\n agentType: AgentType\n branch?: string\n debug?: boolean\n projectDir: string\n}): Promise<void> {\n const { agentType, branch = 'main', debug, projectDir } = args\n\n const skillsDir = getSkillsDir(agentType)\n const destDir = path.join(projectDir, skillsDir, 'payload')\n\n await fse.mkdirp(destDir)\n\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branch}`\n const filter = `payload-${branch.replace(/^v/, '').replaceAll('/', '-')}/tools/claude-plugin/skills/payload/`\n\n if (debug) {\n debugLog(`Downloading skill for agent: ${agentType}`)\n debugLog(`Skill codeload url: ${url}`)\n debugLog(`Skill filter: ${filter}`)\n debugLog(`Skill destination: ${destDir}`)\n }\n\n const res = await fetch(url)\n\n if (!res.ok) {\n throw new Error(`Failed to download skill: ${res.status} ${res.statusText} from ${url}`)\n }\n\n if (!res.body) {\n throw new Error(`Failed to download skill: empty response from ${url}`)\n }\n\n await pipeline(\n Readable.from(res.body as unknown as NodeJS.ReadableStream),\n x({\n cwd: destDir,\n filter: (p) => p.includes(filter),\n strip: filter.split('/').length - 1,\n }),\n )\n}\n"],"names":["fse","Readable","pipeline","path","x","debug","debugLog","getSkillsDir","downloadSkill","args","agentType","branch","projectDir","skillsDir","destDir","join","mkdirp","url","filter","replace","replaceAll","res","fetch","ok","Error","status","statusText","body","from","cwd","p","includes","strip","split","length"],"mappings":"AAAA,OAAOA,SAAS,WAAU;AAC1B,SAASC,QAAQ,QAAQ,cAAa;AACtC,SAASC,QAAQ,QAAQ,uBAAsB;AAC/C,OAAOC,UAAU,OAAM;AACvB,SAASC,CAAC,QAAQ,MAAK;AAIvB,SAASC,SAASC,QAAQ,QAAQ,kBAAiB;AACnD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,OAAO,eAAeC,cAAcC,IAKnC;IACC,MAAM,EAAEC,SAAS,EAAEC,SAAS,MAAM,EAAEN,KAAK,EAAEO,UAAU,EAAE,GAAGH;IAE1D,MAAMI,YAAYN,aAAaG;IAC/B,MAAMI,UAAUX,KAAKY,IAAI,CAACH,YAAYC,WAAW;IAEjD,MAAMb,IAAIgB,MAAM,CAACF;IAEjB,MAAMG,MAAM,CAAC,sDAAsD,EAAEN,QAAQ;IAC7E,MAAMO,SAAS,CAAC,QAAQ,EAAEP,OAAOQ,OAAO,CAAC,MAAM,IAAIC,UAAU,CAAC,KAAK,KAAK,oCAAoC,CAAC;IAE7G,IAAIf,OAAO;QACTC,SAAS,CAAC,6BAA6B,EAAEI,WAAW;QACpDJ,SAAS,CAAC,oBAAoB,EAAEW,KAAK;QACrCX,SAAS,CAAC,cAAc,EAAEY,QAAQ;QAClCZ,SAAS,CAAC,mBAAmB,EAAEQ,SAAS;IAC1C;IAEA,MAAMO,MAAM,MAAMC,MAAML;IAExB,IAAI,CAACI,IAAIE,EAAE,EAAE;QACX,MAAM,IAAIC,MAAM,CAAC,0BAA0B,EAAEH,IAAII,MAAM,CAAC,CAAC,EAAEJ,IAAIK,UAAU,CAAC,MAAM,EAAET,KAAK;IACzF;IAEA,IAAI,CAACI,IAAIM,IAAI,EAAE;QACb,MAAM,IAAIH,MAAM,CAAC,8CAA8C,EAAEP,KAAK;IACxE;IAEA,MAAMf,SACJD,SAAS2B,IAAI,CAACP,IAAIM,IAAI,GACtBvB,EAAE;QACAyB,KAAKf;QACLI,QAAQ,CAACY,IAAMA,EAAEC,QAAQ,CAACb;QAC1Bc,OAAOd,OAAOe,KAAK,CAAC,KAAKC,MAAM,GAAG;IACpC;AAEJ"}
@@ -15,32 +15,32 @@ export function getValidTemplates() {
15
15
  name: 'blank',
16
16
  type: 'starter',
17
17
  description: 'Blank 3.0 Template',
18
- url: `https://github.com/payloadcms/payload/templates/blank#3.x`
18
+ url: `https://github.com/payloadcms/payload/templates/blank#main`
19
19
  },
20
20
  {
21
21
  name: 'website',
22
22
  type: 'starter',
23
23
  description: 'Website Template',
24
- url: `https://github.com/payloadcms/payload/templates/website#3.x`
24
+ url: `https://github.com/payloadcms/payload/templates/website#main`
25
25
  },
26
26
  {
27
27
  name: 'ecommerce',
28
28
  type: 'starter',
29
29
  description: 'Ecommerce template',
30
- url: 'https://github.com/payloadcms/payload/templates/ecommerce#3.x'
30
+ url: 'https://github.com/payloadcms/payload/templates/ecommerce#main'
31
31
  },
32
32
  {
33
33
  name: 'with-cloudflare-d1',
34
34
  type: 'starter',
35
35
  dbType: 'd1-sqlite',
36
36
  description: 'Blank template with Cloudflare D1 and Workers integration',
37
- url: 'https://github.com/payloadcms/payload/templates/with-cloudflare-d1#3.x'
37
+ url: 'https://github.com/payloadcms/payload/templates/with-cloudflare-d1#main'
38
38
  },
39
39
  {
40
40
  name: 'plugin',
41
41
  type: 'plugin',
42
42
  description: 'Template for creating a Payload plugin',
43
- url: 'https://github.com/payloadcms/payload/templates/plugin#3.x'
43
+ url: 'https://github.com/payloadcms/payload/templates/plugin#main'
44
44
  }
45
45
  ];
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/templates.ts"],"sourcesContent":["import type { ProjectTemplate } from '../types.js'\n\nimport { error, info } from '../utils/log.js'\n\nexport function validateTemplate({ templateName }: { templateName: string }): boolean {\n const validTemplates = getValidTemplates()\n if (!validTemplates.map((t) => t.name).includes(templateName)) {\n error(`'${templateName}' is not a valid template.`)\n info(`Valid templates: ${validTemplates.map((t) => t.name).join(', ')}`)\n return false\n }\n return true\n}\n\nexport function getValidTemplates(): ProjectTemplate[] {\n // Starters _must_ be a valid template name from the templates/ directory\n return [\n {\n name: 'blank',\n type: 'starter',\n description: 'Blank 3.0 Template',\n url: `https://github.com/payloadcms/payload/templates/blank#3.x`,\n },\n {\n name: 'website',\n type: 'starter',\n description: 'Website Template',\n url: `https://github.com/payloadcms/payload/templates/website#3.x`,\n },\n {\n name: 'ecommerce',\n type: 'starter',\n description: 'Ecommerce template',\n url: 'https://github.com/payloadcms/payload/templates/ecommerce#3.x',\n },\n {\n name: 'with-cloudflare-d1',\n type: 'starter',\n dbType: 'd1-sqlite',\n description: 'Blank template with Cloudflare D1 and Workers integration',\n url: 'https://github.com/payloadcms/payload/templates/with-cloudflare-d1#3.x',\n },\n {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin#3.x',\n },\n ]\n}\n"],"names":["error","info","validateTemplate","templateName","validTemplates","getValidTemplates","map","t","name","includes","join","type","description","url","dbType"],"mappings":"AAEA,SAASA,KAAK,EAAEC,IAAI,QAAQ,kBAAiB;AAE7C,OAAO,SAASC,iBAAiB,EAAEC,YAAY,EAA4B;IACzE,MAAMC,iBAAiBC;IACvB,IAAI,CAACD,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEC,QAAQ,CAACN,eAAe;QAC7DH,MAAM,CAAC,CAAC,EAAEG,aAAa,0BAA0B,CAAC;QAClDF,KAAK,CAAC,iBAAiB,EAAEG,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEE,IAAI,CAAC,OAAO;QACvE,OAAO;IACT;IACA,OAAO;AACT;AAEA,OAAO,SAASL;IACd,yEAAyE;IACzE,OAAO;QACL;YACEG,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK,CAAC,yDAAyD,CAAC;QAClE;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK,CAAC,2DAA2D,CAAC;QACpE;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEL,MAAM;YACNG,MAAM;YACNG,QAAQ;YACRF,aAAa;YACbC,KAAK;QACP;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;KACD;AACH"}
1
+ {"version":3,"sources":["../../src/lib/templates.ts"],"sourcesContent":["import type { ProjectTemplate } from '../types.js'\n\nimport { error, info } from '../utils/log.js'\n\nexport function validateTemplate({ templateName }: { templateName: string }): boolean {\n const validTemplates = getValidTemplates()\n if (!validTemplates.map((t) => t.name).includes(templateName)) {\n error(`'${templateName}' is not a valid template.`)\n info(`Valid templates: ${validTemplates.map((t) => t.name).join(', ')}`)\n return false\n }\n return true\n}\n\nexport function getValidTemplates(): ProjectTemplate[] {\n // Starters _must_ be a valid template name from the templates/ directory\n return [\n {\n name: 'blank',\n type: 'starter',\n description: 'Blank 3.0 Template',\n url: `https://github.com/payloadcms/payload/templates/blank#main`,\n },\n {\n name: 'website',\n type: 'starter',\n description: 'Website Template',\n url: `https://github.com/payloadcms/payload/templates/website#main`,\n },\n {\n name: 'ecommerce',\n type: 'starter',\n description: 'Ecommerce template',\n url: 'https://github.com/payloadcms/payload/templates/ecommerce#main',\n },\n {\n name: 'with-cloudflare-d1',\n type: 'starter',\n dbType: 'd1-sqlite',\n description: 'Blank template with Cloudflare D1 and Workers integration',\n url: 'https://github.com/payloadcms/payload/templates/with-cloudflare-d1#main',\n },\n {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin#main',\n },\n ]\n}\n"],"names":["error","info","validateTemplate","templateName","validTemplates","getValidTemplates","map","t","name","includes","join","type","description","url","dbType"],"mappings":"AAEA,SAASA,KAAK,EAAEC,IAAI,QAAQ,kBAAiB;AAE7C,OAAO,SAASC,iBAAiB,EAAEC,YAAY,EAA4B;IACzE,MAAMC,iBAAiBC;IACvB,IAAI,CAACD,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEC,QAAQ,CAACN,eAAe;QAC7DH,MAAM,CAAC,CAAC,EAAEG,aAAa,0BAA0B,CAAC;QAClDF,KAAK,CAAC,iBAAiB,EAAEG,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEE,IAAI,CAAC,OAAO;QACvE,OAAO;IACT;IACA,OAAO;AACT;AAEA,OAAO,SAASL;IACd,yEAAyE;IACzE,OAAO;QACL;YACEG,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK,CAAC,0DAA0D,CAAC;QACnE;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK,CAAC,4DAA4D,CAAC;QACrE;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEL,MAAM;YACNG,MAAM;YACNG,QAAQ;YACRF,aAAa;YACbC,KAAK;QACP;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;KACD;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-next-config.d.ts","sourceRoot":"","sources":["../../src/lib/wrap-next-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAA;AAED,eAAO,MAAM,cAAc,SAAgB;IACzC,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,cAAc,CAAA;CAC/B,kBAaA,CAAA;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,cAAc,GACzB,OAAO,CAAC;IAAE,qBAAqB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA4H9D"}
1
+ {"version":3,"file":"wrap-next-config.d.ts","sourceRoot":"","sources":["../../src/lib/wrap-next-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,MAAM;IACzC,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,cAAc,CAAA;CAC/B,kBAaA,CAAA;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,cAAc,GACzB,OAAO,CAAC;IAAE,qBAAqB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA4H9D"}
package/dist/main.js CHANGED
@@ -181,7 +181,7 @@ export class Main {
181
181
  if (exampleArg) {
182
182
  const example = await parseExample({
183
183
  name: exampleArg,
184
- branch: this.args['--branch'] ?? '3.x'
184
+ branch: this.args['--branch'] ?? 'main'
185
185
  });
186
186
  if (!example) {
187
187
  helpMessage();
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\nimport arg from 'arg'\nimport chalk from 'chalk'\nimport figures from 'figures'\nimport path from 'path'\n\nimport type { CliArgs } from './types.js'\n\nimport { configurePayloadConfig } from './lib/configure-payload-config.js'\nimport { createProject } from './lib/create-project.js'\nimport { parseExample } from './lib/examples.js'\nimport { generateSecret } from './lib/generate-secret.js'\nimport { getPackageManager } from './lib/get-package-manager.js'\nimport { getNextAppDetails, initNext } from './lib/init-next.js'\nimport { manageEnvFiles } from './lib/manage-env-files.js'\nimport { parseProjectName } from './lib/parse-project-name.js'\nimport { parseTemplate } from './lib/parse-template.js'\nimport { selectAgent } from './lib/select-agent.js'\nimport { selectDb } from './lib/select-db.js'\nimport { getValidTemplates, validateTemplate } from './lib/templates.js'\nimport { updatePayloadInProject } from './lib/update-payload-in-project.js'\nimport { getLatestPackageVersion } from './utils/getLatestPackageVersion.js'\nimport { debug, error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successfulNextInit,\n successMessage,\n} from './utils/messages.js'\n\nexport class Main {\n args: CliArgs\n\n constructor() {\n // @ts-expect-error bad typings\n this.args = arg(\n {\n '--agent': String,\n '--branch': String,\n '--db': String,\n '--db-accept-recommended': Boolean,\n '--db-connection-string': String,\n '--example': String,\n '--help': Boolean,\n '--local-template': String,\n '--name': String,\n '--secret': String,\n '--template': String,\n '--version': String, // Allows overriding the installed Payload version instead of installing the latest\n\n // Next.js\n '--init-next': Boolean, // TODO: Is this needed if we detect if inside Next.js project?\n\n // Agent\n '--no-agent': Boolean,\n\n // Package manager\n '--no-deps': Boolean,\n '--use-bun': Boolean,\n '--use-npm': Boolean,\n '--use-pnpm': Boolean,\n '--use-yarn': Boolean,\n\n // Other\n '--no-git': Boolean,\n\n // Flags\n '--beta': Boolean,\n '--debug': Boolean,\n '--dry-run': Boolean,\n\n // Aliases\n '-a': '--agent',\n '-d': '--db',\n '-e': '--example',\n '-h': '--help',\n '-n': '--name',\n '-t': '--template',\n },\n { permissive: true },\n )\n }\n\n async init(): Promise<void> {\n try {\n const debugFlag = this.args['--debug']\n\n // Set DEBUG env var for logger utility\n if (debugFlag) {\n process.env.DEBUG = 'true'\n }\n\n const LATEST_VERSION = await getLatestPackageVersion({\n debug: debugFlag,\n packageName: 'payload',\n })\n\n if (this.args['--help']) {\n helpMessage()\n process.exit(0)\n }\n\n // eslint-disable-next-line no-console\n console.log('\\n')\n p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')))\n p.note(\"Welcome to Payload. Let's create a project!\")\n\n // Detect if inside Next.js project\n const nextAppDetails = await getNextAppDetails(process.cwd())\n const {\n hasTopLevelLayout,\n isPayloadInstalled,\n isSupportedNextVersion,\n nextAppDir,\n nextConfigPath,\n nextVersion,\n } = nextAppDetails\n\n if (nextConfigPath && !isSupportedNextVersion) {\n p.log.warn(\n `Next.js v${nextVersion} is unsupported. Next.js >= 15 is required to use Payload.`,\n )\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Upgrade Payload in existing project\n if (isPayloadInstalled && nextConfigPath) {\n p.log.warn(`Payload installation detected in current project.`)\n const shouldUpdate = await p.confirm({\n initialValue: false,\n message: chalk.bold(`Upgrade Payload in this project?`),\n })\n\n if (!p.isCancel(shouldUpdate) && shouldUpdate) {\n const { message, success: updateSuccess } = await updatePayloadInProject(nextAppDetails)\n if (updateSuccess) {\n info(message)\n } else {\n error(message)\n }\n }\n\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n if (nextConfigPath) {\n this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath)))\n }\n\n const projectName = await parseProjectName(this.args)\n const projectDir = nextConfigPath\n ? path.dirname(nextConfigPath)\n : path.resolve(process.cwd(), slugify(projectName))\n\n const packageManager = await getPackageManager({ cliArgs: this.args, projectDir })\n\n if (nextConfigPath) {\n p.log.step(\n chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`),\n )\n\n const proceed = await p.confirm({\n initialValue: true,\n message: chalk.bold(`Install ${chalk.green('Payload')} in this project?`),\n })\n if (p.isCancel(proceed) || !proceed) {\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Check for top-level layout.tsx\n if (nextAppDir && hasTopLevelLayout) {\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const dbDetails = await selectDb(this.args, projectName)\n\n const result = await initNext({\n ...this.args,\n dbType: dbDetails.type,\n nextAppDetails,\n packageManager,\n projectDir,\n })\n\n if (result.success === false) {\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n await configurePayloadConfig({\n dbType: dbDetails?.type,\n projectDirOrConfigPath: {\n payloadConfigPath: result.payloadConfigPath,\n },\n })\n\n await manageEnvFiles({\n cliArgs: this.args,\n databaseType: dbDetails.type,\n databaseUri: dbDetails.dbUri,\n payloadSecret: generateSecret(),\n projectDir,\n })\n\n info('Payload project successfully initialized!')\n p.note(successfulNextInit(), chalk.bgGreen(chalk.black(' Documentation ')))\n p.outro(feedbackOutro())\n return\n }\n\n const templateArg = this.args['--template']\n if (templateArg) {\n const valid = validateTemplate({ templateName: templateArg })\n if (!valid) {\n helpMessage()\n process.exit(1)\n }\n }\n\n const exampleArg = this.args['--example']\n\n if (exampleArg) {\n const example = await parseExample({\n name: exampleArg,\n branch: this.args['--branch'] ?? '3.x',\n })\n\n if (!example) {\n helpMessage()\n process.exit(1)\n }\n\n const agentType = await selectAgent({ cliArgs: this.args })\n\n await createProject({\n agentType,\n cliArgs: this.args,\n example,\n packageManager,\n projectDir,\n projectName,\n })\n }\n\n if (debugFlag) {\n debug(`Using ${exampleArg ? 'examples' : 'templates'} from git tag: v${LATEST_VERSION}`)\n }\n\n if (!exampleArg) {\n const validTemplates = getValidTemplates()\n const template = await parseTemplate(this.args, validTemplates)\n if (!template) {\n p.log.error('Invalid template given')\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n switch (template.type) {\n case 'plugin': {\n const agentType = await selectAgent({ cliArgs: this.args })\n await createProject({\n agentType,\n cliArgs: this.args,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n break\n }\n case 'starter': {\n const dbDetails = await selectDb(this.args, projectName, template)\n const agentType = await selectAgent({ cliArgs: this.args })\n\n await createProject({\n agentType,\n cliArgs: this.args,\n dbDetails,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n break\n }\n }\n }\n\n info('Payload project successfully created!')\n p.log.step(chalk.bgGreen(chalk.black(' Next Steps ')))\n p.log.message(successMessage(projectDir, packageManager))\n p.outro(feedbackOutro())\n } catch (err: unknown) {\n error(err instanceof Error ? err.message : 'An error occurred')\n }\n }\n}\n"],"names":["p","slugify","arg","chalk","figures","path","configurePayloadConfig","createProject","parseExample","generateSecret","getPackageManager","getNextAppDetails","initNext","manageEnvFiles","parseProjectName","parseTemplate","selectAgent","selectDb","getValidTemplates","validateTemplate","updatePayloadInProject","getLatestPackageVersion","debug","error","info","feedbackOutro","helpMessage","moveMessage","successfulNextInit","successMessage","Main","args","String","Boolean","permissive","init","debugFlag","process","env","DEBUG","LATEST_VERSION","packageName","exit","console","log","intro","bgCyan","black","note","nextAppDetails","cwd","hasTopLevelLayout","isPayloadInstalled","isSupportedNextVersion","nextAppDir","nextConfigPath","nextVersion","warn","outro","shouldUpdate","confirm","initialValue","message","bold","isCancel","success","updateSuccess","basename","dirname","projectName","projectDir","resolve","packageManager","cliArgs","step","bgBlack","triangleUp","proceed","green","dbDetails","result","dbType","type","projectDirOrConfigPath","payloadConfigPath","databaseType","databaseUri","dbUri","payloadSecret","bgGreen","templateArg","valid","templateName","exampleArg","example","name","branch","agentType","validTemplates","template","err","Error"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,SAAS,MAAK;AACrB,OAAOC,WAAW,QAAO;AACzB,OAAOC,aAAa,UAAS;AAC7B,OAAOC,UAAU,OAAM;AAIvB,SAASC,sBAAsB,QAAQ,oCAAmC;AAC1E,SAASC,aAAa,QAAQ,0BAAyB;AACvD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,iBAAiB,QA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,IAAI,CAACqD,YAAY;gBACf,MAAMK,iBAAiBhF;gBACvB,MAAMiF,WAAW,MAAMpF,cAAc,IAAI,CAACgB,IAAI,EAAEmE;gBAChD,IAAI,CAACC,UAAU;oBACbnG,EAAE4C,GAAG,CAACrB,KAAK,CAAC;oBACZvB,EAAE0D,KAAK,CAACjC;oBACRY,QAAQK,IAAI,CAAC;gBACf;gBAEA,OAAQyD,SAASjB,IAAI;oBACnB,KAAK;wBAAU;4BACb,MAAMe,YAAY,MAAMjF,YAAY;gCAAEyD,SAAS,IAAI,CAAC1C,IAAI;4BAAC;4BACzD,MAAMxB,cAAc;gCAClB0F;gCACAxB,SAAS,IAAI,CAAC1C,IAAI;gCAClByC;gCACAF;gCACAD;gCACA8B;4BACF;4BACA;wBACF;oBACA,KAAK;wBAAW;4BACd,MAAMpB,YAAY,MAAM9D,SAAS,IAAI,CAACc,IAAI,EAAEsC,aAAa8B;4BACzD,MAAMF,YAAY,MAAMjF,YAAY;gCAAEyD,SAAS,IAAI,CAAC1C,IAAI;4BAAC;4BAEzD,MAAMxB,cAAc;gCAClB0F;gCACAxB,SAAS,IAAI,CAAC1C,IAAI;gCAClBgD;gCACAP;gCACAF;gCACAD;gCACA8B;4BACF;4BAEA;wBACF;gBACF;YACF;YAEA3E,KAAK;YACLxB,EAAE4C,GAAG,CAAC8B,IAAI,CAACvE,MAAMsF,OAAO,CAACtF,MAAM4C,KAAK,CAAC;YACrC/C,EAAE4C,GAAG,CAACkB,OAAO,CAACjC,eAAeyC,YAAYE;YACzCxE,EAAE0D,KAAK,CAACjC;QACV,EAAE,OAAO2E,KAAc;YACrB7E,MAAM6E,eAAeC,QAAQD,IAAItC,OAAO,GAAG;QAC7C;IACF;AACF"}
1
+ {"version":3,"sources":["../src/main.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\nimport arg from 'arg'\nimport chalk from 'chalk'\nimport figures from 'figures'\nimport path from 'path'\n\nimport type { CliArgs } from './types.js'\n\nimport { configurePayloadConfig } from './lib/configure-payload-config.js'\nimport { createProject } from './lib/create-project.js'\nimport { parseExample } from './lib/examples.js'\nimport { generateSecret } from './lib/generate-secret.js'\nimport { getPackageManager } from './lib/get-package-manager.js'\nimport { getNextAppDetails, initNext } from './lib/init-next.js'\nimport { manageEnvFiles } from './lib/manage-env-files.js'\nimport { parseProjectName } from './lib/parse-project-name.js'\nimport { parseTemplate } from './lib/parse-template.js'\nimport { selectAgent } from './lib/select-agent.js'\nimport { selectDb } from './lib/select-db.js'\nimport { getValidTemplates, validateTemplate } from './lib/templates.js'\nimport { updatePayloadInProject } from './lib/update-payload-in-project.js'\nimport { getLatestPackageVersion } from './utils/getLatestPackageVersion.js'\nimport { debug, error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successfulNextInit,\n successMessage,\n} from './utils/messages.js'\n\nexport class Main {\n args: CliArgs\n\n constructor() {\n // @ts-expect-error bad typings\n this.args = arg(\n {\n '--agent': String,\n '--branch': String,\n '--db': String,\n '--db-accept-recommended': Boolean,\n '--db-connection-string': String,\n '--example': String,\n '--help': Boolean,\n '--local-template': String,\n '--name': String,\n '--secret': String,\n '--template': String,\n '--version': String, // Allows overriding the installed Payload version instead of installing the latest\n\n // Next.js\n '--init-next': Boolean, // TODO: Is this needed if we detect if inside Next.js project?\n\n // Agent\n '--no-agent': Boolean,\n\n // Package manager\n '--no-deps': Boolean,\n '--use-bun': Boolean,\n '--use-npm': Boolean,\n '--use-pnpm': Boolean,\n '--use-yarn': Boolean,\n\n // Other\n '--no-git': Boolean,\n\n // Flags\n '--beta': Boolean,\n '--debug': Boolean,\n '--dry-run': Boolean,\n\n // Aliases\n '-a': '--agent',\n '-d': '--db',\n '-e': '--example',\n '-h': '--help',\n '-n': '--name',\n '-t': '--template',\n },\n { permissive: true },\n )\n }\n\n async init(): Promise<void> {\n try {\n const debugFlag = this.args['--debug']\n\n // Set DEBUG env var for logger utility\n if (debugFlag) {\n process.env.DEBUG = 'true'\n }\n\n const LATEST_VERSION = await getLatestPackageVersion({\n debug: debugFlag,\n packageName: 'payload',\n })\n\n if (this.args['--help']) {\n helpMessage()\n process.exit(0)\n }\n\n // eslint-disable-next-line no-console\n console.log('\\n')\n p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')))\n p.note(\"Welcome to Payload. Let's create a project!\")\n\n // Detect if inside Next.js project\n const nextAppDetails = await getNextAppDetails(process.cwd())\n const {\n hasTopLevelLayout,\n isPayloadInstalled,\n isSupportedNextVersion,\n nextAppDir,\n nextConfigPath,\n nextVersion,\n } = nextAppDetails\n\n if (nextConfigPath && !isSupportedNextVersion) {\n p.log.warn(\n `Next.js v${nextVersion} is unsupported. Next.js >= 15 is required to use Payload.`,\n )\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Upgrade Payload in existing project\n if (isPayloadInstalled && nextConfigPath) {\n p.log.warn(`Payload installation detected in current project.`)\n const shouldUpdate = await p.confirm({\n initialValue: false,\n message: chalk.bold(`Upgrade Payload in this project?`),\n })\n\n if (!p.isCancel(shouldUpdate) && shouldUpdate) {\n const { message, success: updateSuccess } = await updatePayloadInProject(nextAppDetails)\n if (updateSuccess) {\n info(message)\n } else {\n error(message)\n }\n }\n\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n if (nextConfigPath) {\n this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath)))\n }\n\n const projectName = await parseProjectName(this.args)\n const projectDir = nextConfigPath\n ? path.dirname(nextConfigPath)\n : path.resolve(process.cwd(), slugify(projectName))\n\n const packageManager = await getPackageManager({ cliArgs: this.args, projectDir })\n\n if (nextConfigPath) {\n p.log.step(\n chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`),\n )\n\n const proceed = await p.confirm({\n initialValue: true,\n message: chalk.bold(`Install ${chalk.green('Payload')} in this project?`),\n })\n if (p.isCancel(proceed) || !proceed) {\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Check for top-level layout.tsx\n if (nextAppDir && hasTopLevelLayout) {\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const dbDetails = await selectDb(this.args, projectName)\n\n const result = await initNext({\n ...this.args,\n dbType: dbDetails.type,\n nextAppDetails,\n packageManager,\n projectDir,\n })\n\n if (result.success === false) {\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n await configurePayloadConfig({\n dbType: dbDetails?.type,\n projectDirOrConfigPath: {\n payloadConfigPath: result.payloadConfigPath,\n },\n })\n\n await manageEnvFiles({\n cliArgs: this.args,\n databaseType: dbDetails.type,\n databaseUri: dbDetails.dbUri,\n payloadSecret: generateSecret(),\n projectDir,\n })\n\n info('Payload project successfully initialized!')\n p.note(successfulNextInit(), chalk.bgGreen(chalk.black(' Documentation ')))\n p.outro(feedbackOutro())\n return\n }\n\n const templateArg = this.args['--template']\n if (templateArg) {\n const valid = validateTemplate({ templateName: templateArg })\n if (!valid) {\n helpMessage()\n process.exit(1)\n }\n }\n\n const exampleArg = this.args['--example']\n\n if (exampleArg) {\n const example = await parseExample({\n name: exampleArg,\n branch: this.args['--branch'] ?? 'main',\n })\n\n if (!example) {\n helpMessage()\n process.exit(1)\n }\n\n const agentType = await selectAgent({ cliArgs: this.args })\n\n await createProject({\n agentType,\n cliArgs: this.args,\n example,\n packageManager,\n projectDir,\n projectName,\n })\n }\n\n if (debugFlag) {\n debug(`Using ${exampleArg ? 'examples' : 'templates'} from git tag: v${LATEST_VERSION}`)\n }\n\n if (!exampleArg) {\n const validTemplates = getValidTemplates()\n const template = await parseTemplate(this.args, validTemplates)\n if (!template) {\n p.log.error('Invalid template given')\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n switch (template.type) {\n case 'plugin': {\n const agentType = await selectAgent({ cliArgs: this.args })\n await createProject({\n agentType,\n cliArgs: this.args,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n break\n }\n case 'starter': {\n const dbDetails = await selectDb(this.args, projectName, template)\n const agentType = await selectAgent({ cliArgs: this.args })\n\n await createProject({\n agentType,\n cliArgs: this.args,\n dbDetails,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n break\n }\n }\n }\n\n info('Payload project successfully created!')\n p.log.step(chalk.bgGreen(chalk.black(' Next Steps ')))\n p.log.message(successMessage(projectDir, packageManager))\n p.outro(feedbackOutro())\n } catch (err: unknown) {\n error(err instanceof Error ? err.message : 'An error occurred')\n }\n }\n}\n"],"names":["p","slugify","arg","chalk","figures","path","configurePayloadConfig","createProject","parseExample","generateSecret","getPackageManager","getNextAppDetails","initNext","manageEnvFiles","parseProjectName","parseTemplate","selectAgent","selectDb","getValidTemplates","validateTemplate","updatePayloadInProject","getLatestPackageVersion","debug","error","info","feedbackOutro","helpMessage","moveMessage","successfulNextInit","successMessage","Main","args","String","Boolean","permissive","init","debugFlag","process","env","DEBUG","LATEST_VERSION","packageName","exit","console","log","intro","bgCyan","black","note","nextAppDetails","cwd","hasTopLevelLayout","isPayloadInstalled","isSupportedNextVersion","nextAppDir","nextConfigPath","nextVersion","warn","outro","shouldUpdate","confirm","initialValue","message","bold","isCancel","success","updateSuccess","basename","dirname","projectName","projectDir","resolve","packageManager","cliArgs","step","bgBlack","triangleUp","proceed","green","dbDetails","result","dbType","type","projectDirOrConfigPath","payloadConfigPath","databaseType","databaseUri","dbUri","payloadSecret","bgGreen","templateArg","valid","templateName","exampleArg","example","name","branch","agentType","validTemplates","template","err","Error"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,SAAS,MAAK;AACrB,OAAOC,WAAW,QAAO;AACzB,OAAOC,aAAa,UAAS;AAC7B,OAAOC,UAAU,OAAM;AAIvB,SAASC,sBAAsB,QAAQ,oCAAmC;AAC1E,SAASC,aAAa,QAAQ,0BAAyB;AACvD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,iBAAiB,QAAQ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AAI,CAACqD,YAAY;gBACf,MAAMK,iBAAiBhF;gBACvB,MAAMiF,WAAW,MAAMpF,cAAc,IAAI,CAACgB,IAAI,EAAEmE;gBAChD,IAAI,CAACC,UAAU;oBACbnG,EAAE4C,GAAG,CAACrB,KAAK,CAAC;oBACZvB,EAAE0D,KAAK,CAACjC;oBACRY,QAAQK,IAAI,CAAC;gBACf;gBAEA,OAAQyD,SAASjB,IAAI;oBACnB,KAAK;wBAAU;4BACb,MAAMe,YAAY,MAAMjF,YAAY;gCAAEyD,SAAS,IAAI,CAAC1C,IAAI;4BAAC;4BACzD,MAAMxB,cAAc;gCAClB0F;gCACAxB,SAAS,IAAI,CAAC1C,IAAI;gCAClByC;gCACAF;gCACAD;gCACA8B;4BACF;4BACA;wBACF;oBACA,KAAK;wBAAW;4BACd,MAAMpB,YAAY,MAAM9D,SAAS,IAAI,CAACc,IAAI,EAAEsC,aAAa8B;4BACzD,MAAMF,YAAY,MAAMjF,YAAY;gCAAEyD,SAAS,IAAI,CAAC1C,IAAI;4BAAC;4BAEzD,MAAMxB,cAAc;gCAClB0F;gCACAxB,SAAS,IAAI,CAAC1C,IAAI;gCAClBgD;gCACAP;gCACAF;gCACAD;gCACA8B;4BACF;4BAEA;wBACF;gBACF;YACF;YAEA3E,KAAK;YACLxB,EAAE4C,GAAG,CAAC8B,IAAI,CAACvE,MAAMsF,OAAO,CAACtF,MAAM4C,KAAK,CAAC;YACrC/C,EAAE4C,GAAG,CAACkB,OAAO,CAACjC,eAAeyC,YAAYE;YACzCxE,EAAE0D,KAAK,CAACjC;QACV,EAAE,OAAO2E,KAAc;YACrB7E,MAAM6E,eAAeC,QAAQD,IAAItC,OAAO,GAAG;QAC7C;IACF;AACF"}
@@ -19,11 +19,11 @@ export default async function HomePage() {
19
19
  <div className="home">
20
20
  <div className="content">
21
21
  <picture>
22
- <source srcSet="https://raw.githubusercontent.com/payloadcms/payload/3.x/packages/ui/src/assets/payload-favicon.svg" />
22
+ <source srcSet="https://raw.githubusercontent.com/payloadcms/payload/main/packages/ui/src/assets/payload-favicon.svg" />
23
23
  <Image
24
24
  alt="Payload Logo"
25
25
  height={65}
26
- src="https://raw.githubusercontent.com/payloadcms/payload/3.x/packages/ui/src/assets/payload-favicon.svg"
26
+ src="https://raw.githubusercontent.com/payloadcms/payload/main/packages/ui/src/assets/payload-favicon.svg"
27
27
  width={65}
28
28
  />
29
29
  </picture>
package/dist/types.d.ts CHANGED
@@ -64,7 +64,6 @@ export type DbDetails = {
64
64
  dbUri?: string;
65
65
  type: DbType;
66
66
  };
67
- export type EditorType = 'lexical' | 'slate';
68
67
  export type NextAppDetails = {
69
68
  hasTopLevelLayout: boolean;
70
69
  isPayloadInstalled?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAE1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAErF,MAAM,WAAW,IAAK,SAAQ,GAAG,CAAC,IAAI;IACpC,SAAS,EAAE,iBAAiB,CAAA;IAC5B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,UAAU,EAAE,iBAAiB,CAAA;IAC7B,MAAM,EAAE,iBAAiB,CAAA;IACzB,yBAAyB,EAAE,kBAAkB,CAAA;IAC7C,wBAAwB,EAAE,iBAAiB,CAAA;IAC3C,SAAS,EAAE,kBAAkB,CAAA;IAC7B,WAAW,EAAE,kBAAkB,CAAA;IAE/B,WAAW,EAAE,iBAAiB,CAAA;IAC9B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,aAAa,EAAE,kBAAkB,CAAA;IACjC,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,kBAAkB,EAAE,iBAAiB,CAAA;IACrC,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,YAAY,EAAE,kBAAkB,CAAA;IAChC,WAAW,EAAE,kBAAkB,CAAA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CAAC,CAAA;CAC9B;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAE5D,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3D,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,iBAAiB,EAAE,OAAO,CAAA;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,EAAE,OAAO,CAAA;IACjB,sBAAsB,EAAE,OAAO,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,WAAW,EAAE,IAAI,GAAG,MAAM,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,CAAA;AAEjD,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type arg from 'arg'\n\nimport type { ALL_DATABASE_ADAPTERS, ALL_STORAGE_ADAPTERS } from './lib/ast/types.js'\n\nexport interface Args extends arg.Spec {\n '--agent': StringConstructor\n '--beta': BooleanConstructor\n '--branch': StringConstructor\n '--db': StringConstructor\n '--db-accept-recommended': BooleanConstructor\n '--db-connection-string': StringConstructor\n '--debug': BooleanConstructor\n '--dry-run': BooleanConstructor\n\n '--example': StringConstructor\n '--help': BooleanConstructor\n '--init-next': BooleanConstructor\n '--local-example': StringConstructor\n '--local-template': StringConstructor\n '--name': StringConstructor\n '--no-agent': BooleanConstructor\n '--no-deps': BooleanConstructor\n '--no-git': BooleanConstructor\n '--secret': StringConstructor\n '--template': StringConstructor\n '--use-bun': BooleanConstructor\n '--use-npm': BooleanConstructor\n '--use-pnpm': BooleanConstructor\n '--use-yarn': BooleanConstructor\n\n // Aliases\n\n '-a': string\n '-e': string\n '-h': string\n '-n': string\n '-t': string\n}\n\nexport type CliArgs = arg.Result<Args>\n\nexport type ProjectTemplate = GitTemplate | PluginTemplate\n\nexport type ProjectExample = {\n name: string\n url: string\n}\n\n/**\n * Template that is cloned verbatim from a git repo\n * Performs .env manipulation based upon input\n */\nexport interface GitTemplate extends Template {\n type: 'starter'\n url: string\n}\n\n/**\n * Type specifically for the plugin template\n * No .env manipulation is done\n */\nexport interface PluginTemplate extends Template {\n type: 'plugin'\n url: string\n}\n\ninterface Template {\n dbType?: DbType\n description?: string\n name: string\n type: ProjectTemplate['type']\n}\n\nexport type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn'\n\nexport type DbType = (typeof ALL_DATABASE_ADAPTERS)[number]\n\nexport type DbDetails = {\n dbUri?: string\n type: DbType\n}\n\nexport type EditorType = 'lexical' | 'slate'\n\nexport type NextAppDetails = {\n hasTopLevelLayout: boolean\n isPayloadInstalled?: boolean\n isSrcDir: boolean\n isSupportedNextVersion: boolean\n nextAppDir?: string\n nextConfigPath?: string\n nextConfigType?: NextConfigType\n nextVersion: null | string\n}\n\nexport type NextConfigType = 'cjs' | 'esm' | 'ts'\n\nexport type StorageAdapterType = (typeof ALL_STORAGE_ADAPTERS)[number]\n\nexport type AgentType = 'claude' | 'codex' | 'cursor'\n"],"names":[],"mappings":"AAmGA,WAAqD"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type arg from 'arg'\n\nimport type { ALL_DATABASE_ADAPTERS, ALL_STORAGE_ADAPTERS } from './lib/ast/types.js'\n\nexport interface Args extends arg.Spec {\n '--agent': StringConstructor\n '--beta': BooleanConstructor\n '--branch': StringConstructor\n '--db': StringConstructor\n '--db-accept-recommended': BooleanConstructor\n '--db-connection-string': StringConstructor\n '--debug': BooleanConstructor\n '--dry-run': BooleanConstructor\n\n '--example': StringConstructor\n '--help': BooleanConstructor\n '--init-next': BooleanConstructor\n '--local-example': StringConstructor\n '--local-template': StringConstructor\n '--name': StringConstructor\n '--no-agent': BooleanConstructor\n '--no-deps': BooleanConstructor\n '--no-git': BooleanConstructor\n '--secret': StringConstructor\n '--template': StringConstructor\n '--use-bun': BooleanConstructor\n '--use-npm': BooleanConstructor\n '--use-pnpm': BooleanConstructor\n '--use-yarn': BooleanConstructor\n\n // Aliases\n\n '-a': string\n '-e': string\n '-h': string\n '-n': string\n '-t': string\n}\n\nexport type CliArgs = arg.Result<Args>\n\nexport type ProjectTemplate = GitTemplate | PluginTemplate\n\nexport type ProjectExample = {\n name: string\n url: string\n}\n\n/**\n * Template that is cloned verbatim from a git repo\n * Performs .env manipulation based upon input\n */\nexport interface GitTemplate extends Template {\n type: 'starter'\n url: string\n}\n\n/**\n * Type specifically for the plugin template\n * No .env manipulation is done\n */\nexport interface PluginTemplate extends Template {\n type: 'plugin'\n url: string\n}\n\ninterface Template {\n dbType?: DbType\n description?: string\n name: string\n type: ProjectTemplate['type']\n}\n\nexport type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn'\n\nexport type DbType = (typeof ALL_DATABASE_ADAPTERS)[number]\n\nexport type DbDetails = {\n dbUri?: string\n type: DbType\n}\n\nexport type NextAppDetails = {\n hasTopLevelLayout: boolean\n isPayloadInstalled?: boolean\n isSrcDir: boolean\n isSupportedNextVersion: boolean\n nextAppDir?: string\n nextConfigPath?: string\n nextConfigType?: NextConfigType\n nextVersion: null | string\n}\n\nexport type NextConfigType = 'cjs' | 'esm' | 'ts'\n\nexport type StorageAdapterType = (typeof ALL_STORAGE_ADAPTERS)[number]\n\nexport type AgentType = 'claude' | 'codex' | 'cursor'\n"],"names":[],"mappings":"AAiGA,WAAqD"}
@@ -1 +1 @@
1
- {"version":3,"file":"casing.d.ts","sourceRoot":"","sources":["../../src/utils/casing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAAS,MAAM,WAMtC,CAAA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKlD"}
1
+ {"version":3,"file":"casing.d.ts","sourceRoot":"","sources":["../../src/utils/casing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,WAMtC,CAAA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKlD"}
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,YAAa,MAAM,KAAG,IAEzC,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,MAAM,KAAG,IAEtC,CAAA;AAED,eAAO,MAAM,KAAK,YAAa,MAAM,KAAG,IAEvC,CAAA;AAED,eAAO,MAAM,KAAK,YAAa,MAAM,KAAG,IAIvC,CAAA;AAED,eAAO,MAAM,GAAG,YAAa,MAAM,KAAG,IAErC,CAAA"}
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,KAAG,IAEzC,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,SAAS,MAAM,KAAG,IAEtC,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,SAAS,MAAM,KAAG,IAEvC,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,SAAS,MAAM,KAAG,IAIvC,CAAA;AAED,eAAO,MAAM,GAAG,GAAI,SAAS,MAAM,KAAG,IAErC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-payload-app",
3
- "version": "3.85.0",
3
+ "version": "4.0.0-internal.1f9ae9a",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -67,10 +67,10 @@
67
67
  "devDependencies": {
68
68
  "@types/esprima": "^4.0.6",
69
69
  "@types/fs-extra": "^9.0.12",
70
- "@types/node": "22.15.30"
70
+ "@types/node": "24.12.3"
71
71
  },
72
72
  "engines": {
73
- "node": "^18.20.2 || >=20.9.0"
73
+ "node": ">=24.15.0"
74
74
  },
75
75
  "scripts": {
76
76
  "build": "pnpm pack-template-files && pnpm typecheck && pnpm build:swc",