create-payload-app 4.0.0-internal.ea6e8f8 → 4.0.0-internal.ec73d44

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.
@@ -484,7 +484,7 @@ export function removeSharp(sourceFile) {
484
484
  };
485
485
  }
486
486
  export async function writeTransformedFile(sourceFile, options = {}) {
487
- const { formatWithPrettier = true, validateStructure: shouldValidate = true } = options;
487
+ const { formatWithOxfmt = true, validateStructure: shouldValidate = true } = options;
488
488
  debug(`[AST] Writing transformed file: ${sourceFile.getFilePath()}`);
489
489
  // Validate if requested
490
490
  if (shouldValidate) {
@@ -501,27 +501,27 @@ export async function writeTransformedFile(sourceFile, options = {}) {
501
501
  // Write file
502
502
  debug('[AST] Writing file to disk');
503
503
  await sourceFile.save();
504
- // Format with prettier if requested
505
- if (formatWithPrettier) {
506
- debug('[AST] Running prettier formatting via CLI');
504
+ // Format with oxfmt if requested
505
+ if (formatWithOxfmt) {
506
+ debug('[AST] Running oxfmt formatting via CLI');
507
507
  try {
508
508
  // Detect project directory (go up from file until we find package.json or use dirname)
509
509
  const projectDir = path.dirname(filePath);
510
- // Run prettier via CLI (avoids Jest/ESM compatibility issues)
511
- const prettierCmd = `npx prettier --write "${filePath}"`;
512
- debug(`[AST] Executing: ${prettierCmd}`);
513
- execSync(prettierCmd, {
510
+ // Run oxfmt via CLI (avoids Jest/ESM compatibility issues)
511
+ const oxfmtCmd = `npx oxfmt "${filePath}"`;
512
+ debug(`[AST] Executing: ${oxfmtCmd}`);
513
+ execSync(oxfmtCmd, {
514
514
  cwd: projectDir,
515
515
  stdio: 'pipe'
516
516
  });
517
- debug('[AST] ✓ Prettier formatting successful');
517
+ debug('[AST] ✓ Oxfmt formatting successful');
518
518
  } catch (error) {
519
- // Log but don't fail if prettier fails (might not be installed)
520
- debug(`[AST] ⚠ Prettier formatting failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
519
+ // Log but don't fail if oxfmt fails (might not be installed)
520
+ debug(`[AST] ⚠ Oxfmt formatting failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
521
521
  debug('[AST] Continuing with unformatted output');
522
522
  }
523
523
  } else {
524
- debug('[AST] Skipping prettier formatting (disabled)');
524
+ debug('[AST] Skipping oxfmt formatting (disabled)');
525
525
  }
526
526
  debug('[AST] ✓ File written successfully');
527
527
  return {
@@ -635,7 +635,7 @@ export async function configurePayloadConfig(filePath, options = {}) {
635
635
  }
636
636
  // Write transformed file with validation and formatting
637
637
  return await writeTransformedFile(sourceFile, {
638
- formatWithPrettier: options.formatWithPrettier,
638
+ formatWithOxfmt: options.formatWithOxfmt,
639
639
  validateStructure: options.validateStructure ?? true
640
640
  });
641
641
  } catch (error) {
@@ -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 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,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,K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,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"}
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 { formatWithOxfmt = 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 oxfmt if requested\n if (formatWithOxfmt) {\n debug('[AST] Running oxfmt 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 oxfmt via CLI (avoids Jest/ESM compatibility issues)\n const oxfmtCmd = `npx oxfmt \"${filePath}\"`\n\n debug(`[AST] Executing: ${oxfmtCmd}`)\n execSync(oxfmtCmd, {\n cwd: projectDir,\n stdio: 'pipe', // Suppress output\n })\n debug('[AST] ✓ Oxfmt formatting successful')\n } catch (error) {\n // Log but don't fail if oxfmt fails (might not be installed)\n debug(\n `[AST] ⚠ Oxfmt formatting failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n debug('[AST] Continuing with unformatted output')\n }\n } else {\n debug('[AST] Skipping oxfmt 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 formatWithOxfmt: options.formatWithOxfmt,\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","formatWithOxfmt","shouldValidate","validation","filePath","formatText","save","projectDir","dirname","oxfmtCmd","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,W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+108,7 @@ export type TransformOptions = {
108
108
  };
109
109
  };
110
110
  export type WriteOptions = {
111
- formatWithPrettier?: boolean;
111
+ formatWithOxfmt?: boolean;
112
112
  validateStructure?: boolean;
113
113
  };
114
114
  export type WriteResult = {
@@ -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;QACv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 @@
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 '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;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 '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 formatWithOxfmt?: 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;CACD,CAAS"}
@@ -54,7 +54,7 @@ import { configurePayloadConfig as configurePayloadConfigAST } from './ast/paylo
54
54
  type: args.dbType,
55
55
  envVarName
56
56
  },
57
- formatWithPrettier: true,
57
+ formatWithOxfmt: true,
58
58
  removeSharp: args.sharp === false,
59
59
  storage: args.storageAdapter,
60
60
  validateStructure: false
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/configure-payload-config.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport globby from 'globby'\nimport path from 'path'\n\nimport type { DbType, StorageAdapterType } from '../types.js'\n\nimport { warning } from '../utils/log.js'\nimport { updatePackageJson } from './ast/package-json.js'\nimport { configurePayloadConfig as configurePayloadConfigAST } from './ast/payload-config.js'\n\n/** Get default env var name for db type */\nfunction getEnvVarName(dbType: DbType, customEnvName?: string): string {\n if (customEnvName) {\n return customEnvName\n }\n // Default env var names per adapter type\n if (dbType === 'vercel-postgres') {\n return 'POSTGRES_URL'\n }\n return 'DATABASE_URL'\n}\n\n/** Update payload config with necessary imports and adapters */\nexport async function configurePayloadConfig(args: {\n dbType?: DbType\n envNames?: {\n dbUri: string\n }\n packageJsonName?: string\n projectDirOrConfigPath: { payloadConfigPath: string } | { projectDir: string }\n sharp?: boolean\n storageAdapter?: StorageAdapterType\n}): Promise<void> {\n if (!args.dbType) {\n return\n }\n\n // Update package.json\n const packageJsonPath =\n 'projectDir' in args.projectDirOrConfigPath &&\n path.resolve(args.projectDirOrConfigPath.projectDir, 'package.json')\n\n if (packageJsonPath && fse.existsSync(packageJsonPath)) {\n try {\n updatePackageJson(packageJsonPath, {\n databaseAdapter: args.dbType,\n packageName: args.packageJsonName,\n removeSharp: args.sharp === false,\n storageAdapter: args.storageAdapter,\n })\n } catch (err: unknown) {\n warning(`Unable to configure Payload in package.json`)\n warning(err instanceof Error ? err.message : '')\n }\n }\n\n // Update payload.config.ts\n try {\n let payloadConfigPath: string | undefined\n if (!('payloadConfigPath' in args.projectDirOrConfigPath)) {\n payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: args.projectDirOrConfigPath.projectDir,\n })\n )?.[0]\n } else {\n payloadConfigPath = args.projectDirOrConfigPath.payloadConfigPath\n }\n\n if (!payloadConfigPath) {\n warning('Unable to update payload.config.ts with plugins. Could not find payload.config.ts.')\n return\n }\n\n const envVarName = getEnvVarName(args.dbType, args.envNames?.dbUri)\n\n const result = await configurePayloadConfigAST(payloadConfigPath, {\n db: {\n type: args.dbType,\n envVarName,\n },\n formatWithPrettier: true,\n removeSharp: args.sharp === false,\n storage: args.storageAdapter,\n validateStructure: false,\n })\n\n if (!result.success && result.error) {\n warning(`Unable to update payload.config.ts: ${result.error.userMessage}`)\n }\n } catch (err: unknown) {\n warning(\n `Unable to update payload.config.ts with plugins: ${err instanceof Error ? err.message : ''}`,\n )\n }\n}\n"],"names":["fse","globby","path","warning","updatePackageJson","configurePayloadConfig","configurePayloadConfigAST","getEnvVarName","dbType","customEnvName","args","packageJsonPath","projectDirOrConfigPath","resolve","projectDir","existsSync","databaseAdapter","packageName","packageJsonName","removeSharp","sharp","storageAdapter","err","Error","message","payloadConfigPath","absolute","cwd","envVarName","envNames","dbUri","result","db","type","formatWithPrettier","storage","validateStructure","success","error","userMessage"],"mappings":"AAAA,OAAOA,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,OAAOC,UAAU,OAAM;AAIvB,SAASC,OAAO,QAAQ,kBAAiB;AACzC,SAASC,iBAAiB,QAAQ,wBAAuB;AACzD,SAASC,0BAA0BC,yBAAyB,QAAQ,0BAAyB;AAE7F,yCAAyC,GACzC,SAASC,cAAcC,MAAc,EAAEC,aAAsB;IAC3D,IAAIA,eAAe;QACjB,OAAOA;IACT;IACA,yCAAyC;IACzC,IAAID,WAAW,mBAAmB;QAChC,OAAO;IACT;IACA,OAAO;AACT;AAEA,8DAA8D,GAC9D,OAAO,eAAeH,uBAAuBK,IAS5C;IACC,IAAI,CAACA,KAAKF,MAAM,EAAE;QAChB;IACF;IAEA,sBAAsB;IACtB,MAAMG,kBACJ,gBAAgBD,KAAKE,sBAAsB,IAC3CV,KAAKW,OAAO,CAACH,KAAKE,sBAAsB,CAACE,UAAU,EAAE;IAEvD,IAAIH,mBAAmBX,IAAIe,UAAU,CAACJ,kBAAkB;QACtD,IAAI;YACFP,kBAAkBO,iBAAiB;gBACjCK,iBAAiBN,KAAKF,MAAM;gBAC5BS,aAAaP,KAAKQ,eAAe;gBACjCC,aAAaT,KAAKU,KAAK,KAAK;gBAC5BC,gBAAgBX,KAAKW,cAAc;YACrC;QACF,EAAE,OAAOC,KAAc;YACrBnB,QAAQ,CAAC,2CAA2C,CAAC;YACrDA,QAAQmB,eAAeC,QAAQD,IAAIE,OAAO,GAAG;QAC/C;IACF;IAEA,2BAA2B;IAC3B,IAAI;QACF,IAAIC;QACJ,IAAI,CAAE,CAAA,uBAAuBf,KAAKE,sBAAsB,AAAD,GAAI;YACzDa,oBACE,CAAA,MAAMxB,OAAO,wBAAwB;gBACnCyB,UAAU;gBACVC,KAAKjB,KAAKE,sBAAsB,CAACE,UAAU;YAC7C,EAAC,GACA,CAAC,EAAE;QACR,OAAO;YACLW,oBAAoBf,KAAKE,sBAAsB,CAACa,iBAAiB;QACnE;QAEA,IAAI,CAACA,mBAAmB;YACtBtB,QAAQ;YACR;QACF;QAEA,MAAMyB,aAAarB,cAAcG,KAAKF,MAAM,EAAEE,KAAKmB,QAAQ,EAAEC;QAE7D,MAAMC,SAAS,MAAMzB,0BAA0BmB,mBAAmB;YAChEO,IAAI;gBACFC,MAAMvB,KAAKF,MAAM;gBACjBoB;YACF;YACAM,oBAAoB;YACpBf,aAAaT,KAAKU,KAAK,KAAK;YAC5Be,SAASzB,KAAKW,cAAc;YAC5Be,mBAAmB;QACrB;QAEA,IAAI,CAACL,OAAOM,OAAO,IAAIN,OAAOO,KAAK,EAAE;YACnCnC,QAAQ,CAAC,oCAAoC,EAAE4B,OAAOO,KAAK,CAACC,WAAW,EAAE;QAC3E;IACF,EAAE,OAAOjB,KAAc;QACrBnB,QACE,CAAC,iDAAiD,EAAEmB,eAAeC,QAAQD,IAAIE,OAAO,GAAG,IAAI;IAEjG;AACF"}
1
+ {"version":3,"sources":["../../src/lib/configure-payload-config.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport globby from 'globby'\nimport path from 'path'\n\nimport type { DbType, StorageAdapterType } from '../types.js'\n\nimport { warning } from '../utils/log.js'\nimport { updatePackageJson } from './ast/package-json.js'\nimport { configurePayloadConfig as configurePayloadConfigAST } from './ast/payload-config.js'\n\n/** Get default env var name for db type */\nfunction getEnvVarName(dbType: DbType, customEnvName?: string): string {\n if (customEnvName) {\n return customEnvName\n }\n // Default env var names per adapter type\n if (dbType === 'vercel-postgres') {\n return 'POSTGRES_URL'\n }\n return 'DATABASE_URL'\n}\n\n/** Update payload config with necessary imports and adapters */\nexport async function configurePayloadConfig(args: {\n dbType?: DbType\n envNames?: {\n dbUri: string\n }\n packageJsonName?: string\n projectDirOrConfigPath: { payloadConfigPath: string } | { projectDir: string }\n sharp?: boolean\n storageAdapter?: StorageAdapterType\n}): Promise<void> {\n if (!args.dbType) {\n return\n }\n\n // Update package.json\n const packageJsonPath =\n 'projectDir' in args.projectDirOrConfigPath &&\n path.resolve(args.projectDirOrConfigPath.projectDir, 'package.json')\n\n if (packageJsonPath && fse.existsSync(packageJsonPath)) {\n try {\n updatePackageJson(packageJsonPath, {\n databaseAdapter: args.dbType,\n packageName: args.packageJsonName,\n removeSharp: args.sharp === false,\n storageAdapter: args.storageAdapter,\n })\n } catch (err: unknown) {\n warning(`Unable to configure Payload in package.json`)\n warning(err instanceof Error ? err.message : '')\n }\n }\n\n // Update payload.config.ts\n try {\n let payloadConfigPath: string | undefined\n if (!('payloadConfigPath' in args.projectDirOrConfigPath)) {\n payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: args.projectDirOrConfigPath.projectDir,\n })\n )?.[0]\n } else {\n payloadConfigPath = args.projectDirOrConfigPath.payloadConfigPath\n }\n\n if (!payloadConfigPath) {\n warning('Unable to update payload.config.ts with plugins. Could not find payload.config.ts.')\n return\n }\n\n const envVarName = getEnvVarName(args.dbType, args.envNames?.dbUri)\n\n const result = await configurePayloadConfigAST(payloadConfigPath, {\n db: {\n type: args.dbType,\n envVarName,\n },\n formatWithOxfmt: true,\n removeSharp: args.sharp === false,\n storage: args.storageAdapter,\n validateStructure: false,\n })\n\n if (!result.success && result.error) {\n warning(`Unable to update payload.config.ts: ${result.error.userMessage}`)\n }\n } catch (err: unknown) {\n warning(\n `Unable to update payload.config.ts with plugins: ${err instanceof Error ? err.message : ''}`,\n )\n }\n}\n"],"names":["fse","globby","path","warning","updatePackageJson","configurePayloadConfig","configurePayloadConfigAST","getEnvVarName","dbType","customEnvName","args","packageJsonPath","projectDirOrConfigPath","resolve","projectDir","existsSync","databaseAdapter","packageName","packageJsonName","removeSharp","sharp","storageAdapter","err","Error","message","payloadConfigPath","absolute","cwd","envVarName","envNames","dbUri","result","db","type","formatWithOxfmt","storage","validateStructure","success","error","userMessage"],"mappings":"AAAA,OAAOA,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,OAAOC,UAAU,OAAM;AAIvB,SAASC,OAAO,QAAQ,kBAAiB;AACzC,SAASC,iBAAiB,QAAQ,wBAAuB;AACzD,SAASC,0BAA0BC,yBAAyB,QAAQ,0BAAyB;AAE7F,yCAAyC,GACzC,SAASC,cAAcC,MAAc,EAAEC,aAAsB;IAC3D,IAAIA,eAAe;QACjB,OAAOA;IACT;IACA,yCAAyC;IACzC,IAAID,WAAW,mBAAmB;QAChC,OAAO;IACT;IACA,OAAO;AACT;AAEA,8DAA8D,GAC9D,OAAO,eAAeH,uBAAuBK,IAS5C;IACC,IAAI,CAACA,KAAKF,MAAM,EAAE;QAChB;IACF;IAEA,sBAAsB;IACtB,MAAMG,kBACJ,gBAAgBD,KAAKE,sBAAsB,IAC3CV,KAAKW,OAAO,CAACH,KAAKE,sBAAsB,CAACE,UAAU,EAAE;IAEvD,IAAIH,mBAAmBX,IAAIe,UAAU,CAACJ,kBAAkB;QACtD,IAAI;YACFP,kBAAkBO,iBAAiB;gBACjCK,iBAAiBN,KAAKF,MAAM;gBAC5BS,aAAaP,KAAKQ,eAAe;gBACjCC,aAAaT,KAAKU,KAAK,KAAK;gBAC5BC,gBAAgBX,KAAKW,cAAc;YACrC;QACF,EAAE,OAAOC,KAAc;YACrBnB,QAAQ,CAAC,2CAA2C,CAAC;YACrDA,QAAQmB,eAAeC,QAAQD,IAAIE,OAAO,GAAG;QAC/C;IACF;IAEA,2BAA2B;IAC3B,IAAI;QACF,IAAIC;QACJ,IAAI,CAAE,CAAA,uBAAuBf,KAAKE,sBAAsB,AAAD,GAAI;YACzDa,oBACE,CAAA,MAAMxB,OAAO,wBAAwB;gBACnCyB,UAAU;gBACVC,KAAKjB,KAAKE,sBAAsB,CAACE,UAAU;YAC7C,EAAC,GACA,CAAC,EAAE;QACR,OAAO;YACLW,oBAAoBf,KAAKE,sBAAsB,CAACa,iBAAiB;QACnE;QAEA,IAAI,CAACA,mBAAmB;YACtBtB,QAAQ;YACR;QACF;QAEA,MAAMyB,aAAarB,cAAcG,KAAKF,MAAM,EAAEE,KAAKmB,QAAQ,EAAEC;QAE7D,MAAMC,SAAS,MAAMzB,0BAA0BmB,mBAAmB;YAChEO,IAAI;gBACFC,MAAMvB,KAAKF,MAAM;gBACjBoB;YACF;YACAM,iBAAiB;YACjBf,aAAaT,KAAKU,KAAK,KAAK;YAC5Be,SAASzB,KAAKW,cAAc;YAC5Be,mBAAmB;QACrB;QAEA,IAAI,CAACL,OAAOM,OAAO,IAAIN,OAAOO,KAAK,EAAE;YACnCnC,QAAQ,CAAC,oCAAoC,EAAE4B,OAAOO,KAAK,CAACC,WAAW,EAAE;QAC3E;IACF,EAAE,OAAOjB,KAAc;QACrBnB,QACE,CAAC,iDAAiD,EAAEmB,eAAeC,QAAQD,IAAIE,OAAO,GAAG,IAAI;IAEjG;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/download-example.ts"],"sourcesContent":["import { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport { x } from 'tar'\n\nimport type { ProjectExample } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\n\nexport async function downloadExample({\n debug,\n example,\n projectDir,\n}: {\n debug?: boolean\n example: ProjectExample\n projectDir: string\n}) {\n const branchOrTag = example.url.split('#')?.[1] || 'latest'\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`\n const filter = `payload-${branchOrTag.replace(/^v/, '')}/examples/${example.name}/`\n\n if (debug) {\n debugLog(`Using example url: ${example.url}`)\n debugLog(`Codeload url: ${url}`)\n debugLog(`Filter: ${filter}`)\n }\n\n await pipeline(\n await downloadTarStream(url),\n x({\n cwd: projectDir,\n filter: (p) => p.includes(filter),\n strip: 2 + example.name.split('/').length,\n }),\n )\n}\n\nasync function downloadTarStream(url: string) {\n const res = await fetch(url)\n\n if (!res.body) {\n throw new Error(`Failed to download: ${url}`)\n }\n\n return Readable.from(res.body as unknown as NodeJS.ReadableStream)\n}\n"],"names":["Readable","pipeline","x","debug","debugLog","downloadExample","example","projectDir","branchOrTag","url","split","filter","replace","name","downloadTarStream","cwd","p","includes","strip","length","res","fetch","body","Error","from"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAa;AACtC,SAASC,QAAQ,QAAQ,uBAAsB;AAC/C,SAASC,CAAC,QAAQ,MAAK;AAIvB,SAASC,SAASC,QAAQ,QAAQ,kBAAiB;AAEnD,OAAO,eAAeC,gBAAgB,EACpCF,KAAK,EACLG,OAAO,EACPC,UAAU,EAKX;IACC,MAAMC,cAAcF,QAAQG,GAAG,CAACC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI;IACnD,MAAMD,MAAM,CAAC,sDAAsD,EAAED,aAAa;IAClF,MAAMG,SAAS,CAAC,QAAQ,EAAEH,YAAYI,OAAO,CAAC,MAAM,IAAI,UAAU,EAAEN,QAAQO,IAAI,CAAC,CAAC,CAAC;IAEnF,IAAIV,OAAO;QACTC,SAAS,CAAC,mBAAmB,EAAEE,QAAQG,GAAG,EAAE;QAC5CL,SAAS,CAAC,cAAc,EAAEK,KAAK;QAC/BL,SAAS,CAAC,QAAQ,EAAEO,QAAQ;IAC9B;IAEA,MAAMV,SACJ,MAAMa,kBAAkBL,MACxBP,EAAE;QACAa,KAAKR;QACLI,QAAQ,CAACK,IAAMA,EAAEC,QAAQ,CAACN;QAC1BO,OAAO,IAAIZ,QAAQO,IAAI,CAACH,KAAK,CAAC,KAAKS,MAAM;IAC3C;AAEJ;AAEA,eAAeL,kBAAkBL,GAAW;IAC1C,MAAMW,MAAM,MAAMC,MAAMZ;IAExB,IAAI,CAACW,IAAIE,IAAI,EAAE;QACb,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEd,KAAK;IAC9C;IAEA,OAAOT,SAASwB,IAAI,CAACJ,IAAIE,IAAI;AAC/B"}
1
+ {"version":3,"sources":["../../src/lib/download-example.ts"],"sourcesContent":["import { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport { x } from 'tar'\n\nimport type { ProjectExample } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\n\nexport async function downloadExample({\n debug,\n example,\n projectDir,\n}: {\n debug?: boolean\n example: ProjectExample\n projectDir: string\n}) {\n const branchOrTag = example.url.split('#')?.[1] || 'latest'\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`\n const filter = `payload-${branchOrTag.replace(/^v/, '')}/examples/${example.name}/`\n\n if (debug) {\n debugLog(`Using example url: ${example.url}`)\n debugLog(`Codeload url: ${url}`)\n debugLog(`Filter: ${filter}`)\n }\n\n await pipeline(\n await downloadTarStream(url),\n x({\n cwd: projectDir,\n filter: (p) => p.includes(filter),\n strip: 2 + example.name.split('/').length,\n }),\n )\n}\n\nasync function downloadTarStream(url: string) {\n const res = await fetch(url)\n\n if (!res.body) {\n throw new Error(`Failed to download: ${url}`)\n }\n\n return Readable.from(res.body)\n}\n"],"names":["Readable","pipeline","x","debug","debugLog","downloadExample","example","projectDir","branchOrTag","url","split","filter","replace","name","downloadTarStream","cwd","p","includes","strip","length","res","fetch","body","Error","from"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAa;AACtC,SAASC,QAAQ,QAAQ,uBAAsB;AAC/C,SAASC,CAAC,QAAQ,MAAK;AAIvB,SAASC,SAASC,QAAQ,QAAQ,kBAAiB;AAEnD,OAAO,eAAeC,gBAAgB,EACpCF,KAAK,EACLG,OAAO,EACPC,UAAU,EAKX;IACC,MAAMC,cAAcF,QAAQG,GAAG,CAACC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI;IACnD,MAAMD,MAAM,CAAC,sDAAsD,EAAED,aAAa;IAClF,MAAMG,SAAS,CAAC,QAAQ,EAAEH,YAAYI,OAAO,CAAC,MAAM,IAAI,UAAU,EAAEN,QAAQO,IAAI,CAAC,CAAC,CAAC;IAEnF,IAAIV,OAAO;QACTC,SAAS,CAAC,mBAAmB,EAAEE,QAAQG,GAAG,EAAE;QAC5CL,SAAS,CAAC,cAAc,EAAEK,KAAK;QAC/BL,SAAS,CAAC,QAAQ,EAAEO,QAAQ;IAC9B;IAEA,MAAMV,SACJ,MAAMa,kBAAkBL,MACxBP,EAAE;QACAa,KAAKR;QACLI,QAAQ,CAACK,IAAMA,EAAEC,QAAQ,CAACN;QAC1BO,OAAO,IAAIZ,QAAQO,IAAI,CAACH,KAAK,CAAC,KAAKS,MAAM;IAC3C;AAEJ;AAEA,eAAeL,kBAAkBL,GAAW;IAC1C,MAAMW,MAAM,MAAMC,MAAMZ;IAExB,IAAI,CAACW,IAAIE,IAAI,EAAE;QACb,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEd,KAAK;IAC9C;IAEA,OAAOT,SAASwB,IAAI,CAACJ,IAAIE,IAAI;AAC/B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/download-template.ts"],"sourcesContent":["import { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport { x } from 'tar'\n\nimport type { ProjectTemplate } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\n\nexport async function downloadTemplate({\n debug,\n projectDir,\n template,\n}: {\n debug?: boolean\n projectDir: string\n template: ProjectTemplate\n}) {\n const branchOrTag = template.url.split('#')?.[1] || 'latest'\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`\n const filter = `payload-${branchOrTag.replace(/^v/, '').replaceAll('/', '-')}/templates/${template.name}/`\n\n if (debug) {\n debugLog(`Using template url: ${template.url}`)\n debugLog(`Codeload url: ${url}`)\n debugLog(`Filter: ${filter}`)\n }\n\n await pipeline(\n await downloadTarStream(url),\n x({\n cwd: projectDir,\n filter: (p) => p.includes(filter),\n strip: 2 + template.name.split('/').length,\n }),\n )\n}\n\nasync function downloadTarStream(url: string) {\n const res = await fetch(url)\n\n if (!res.body) {\n throw new Error(`Failed to download: ${url}`)\n }\n\n return Readable.from(res.body as unknown as NodeJS.ReadableStream)\n}\n"],"names":["Readable","pipeline","x","debug","debugLog","downloadTemplate","projectDir","template","branchOrTag","url","split","filter","replace","replaceAll","name","downloadTarStream","cwd","p","includes","strip","length","res","fetch","body","Error","from"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAa;AACtC,SAASC,QAAQ,QAAQ,uBAAsB;AAC/C,SAASC,CAAC,QAAQ,MAAK;AAIvB,SAASC,SAASC,QAAQ,QAAQ,kBAAiB;AAEnD,OAAO,eAAeC,iBAAiB,EACrCF,KAAK,EACLG,UAAU,EACVC,QAAQ,EAKT;IACC,MAAMC,cAAcD,SAASE,GAAG,CAACC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI;IACpD,MAAMD,MAAM,CAAC,sDAAsD,EAAED,aAAa;IAClF,MAAMG,SAAS,CAAC,QAAQ,EAAEH,YAAYI,OAAO,CAAC,MAAM,IAAIC,UAAU,CAAC,KAAK,KAAK,WAAW,EAAEN,SAASO,IAAI,CAAC,CAAC,CAAC;IAE1G,IAAIX,OAAO;QACTC,SAAS,CAAC,oBAAoB,EAAEG,SAASE,GAAG,EAAE;QAC9CL,SAAS,CAAC,cAAc,EAAEK,KAAK;QAC/BL,SAAS,CAAC,QAAQ,EAAEO,QAAQ;IAC9B;IAEA,MAAMV,SACJ,MAAMc,kBAAkBN,MACxBP,EAAE;QACAc,KAAKV;QACLK,QAAQ,CAACM,IAAMA,EAAEC,QAAQ,CAACP;QAC1BQ,OAAO,IAAIZ,SAASO,IAAI,CAACJ,KAAK,CAAC,KAAKU,MAAM;IAC5C;AAEJ;AAEA,eAAeL,kBAAkBN,GAAW;IAC1C,MAAMY,MAAM,MAAMC,MAAMb;IAExB,IAAI,CAACY,IAAIE,IAAI,EAAE;QACb,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEf,KAAK;IAC9C;IAEA,OAAOT,SAASyB,IAAI,CAACJ,IAAIE,IAAI;AAC/B"}
1
+ {"version":3,"sources":["../../src/lib/download-template.ts"],"sourcesContent":["import { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport { x } from 'tar'\n\nimport type { ProjectTemplate } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\n\nexport async function downloadTemplate({\n debug,\n projectDir,\n template,\n}: {\n debug?: boolean\n projectDir: string\n template: ProjectTemplate\n}) {\n const branchOrTag = template.url.split('#')?.[1] || 'latest'\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`\n const filter = `payload-${branchOrTag.replace(/^v/, '').replaceAll('/', '-')}/templates/${template.name}/`\n\n if (debug) {\n debugLog(`Using template url: ${template.url}`)\n debugLog(`Codeload url: ${url}`)\n debugLog(`Filter: ${filter}`)\n }\n\n await pipeline(\n await downloadTarStream(url),\n x({\n cwd: projectDir,\n filter: (p) => p.includes(filter),\n strip: 2 + template.name.split('/').length,\n }),\n )\n}\n\nasync function downloadTarStream(url: string) {\n const res = await fetch(url)\n\n if (!res.body) {\n throw new Error(`Failed to download: ${url}`)\n }\n\n return Readable.from(res.body)\n}\n"],"names":["Readable","pipeline","x","debug","debugLog","downloadTemplate","projectDir","template","branchOrTag","url","split","filter","replace","replaceAll","name","downloadTarStream","cwd","p","includes","strip","length","res","fetch","body","Error","from"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAa;AACtC,SAASC,QAAQ,QAAQ,uBAAsB;AAC/C,SAASC,CAAC,QAAQ,MAAK;AAIvB,SAASC,SAASC,QAAQ,QAAQ,kBAAiB;AAEnD,OAAO,eAAeC,iBAAiB,EACrCF,KAAK,EACLG,UAAU,EACVC,QAAQ,EAKT;IACC,MAAMC,cAAcD,SAASE,GAAG,CAACC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI;IACpD,MAAMD,MAAM,CAAC,sDAAsD,EAAED,aAAa;IAClF,MAAMG,SAAS,CAAC,QAAQ,EAAEH,YAAYI,OAAO,CAAC,MAAM,IAAIC,UAAU,CAAC,KAAK,KAAK,WAAW,EAAEN,SAASO,IAAI,CAAC,CAAC,CAAC;IAE1G,IAAIX,OAAO;QACTC,SAAS,CAAC,oBAAoB,EAAEG,SAASE,GAAG,EAAE;QAC9CL,SAAS,CAAC,cAAc,EAAEK,KAAK;QAC/BL,SAAS,CAAC,QAAQ,EAAEO,QAAQ;IAC9B;IAEA,MAAMV,SACJ,MAAMc,kBAAkBN,MACxBP,EAAE;QACAc,KAAKV;QACLK,QAAQ,CAACM,IAAMA,EAAEC,QAAQ,CAACP;QAC1BQ,OAAO,IAAIZ,SAASO,IAAI,CAACJ,KAAK,CAAC,KAAKU,MAAM;IAC5C;AAEJ;AAEA,eAAeL,kBAAkBN,GAAW;IAC1C,MAAMY,MAAM,MAAMC,MAAMb;IAExB,IAAI,CAACY,IAAIE,IAAI,EAAE;QACb,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEf,KAAK;IAC9C;IAEA,OAAOT,SAASyB,IAAI,CAACJ,IAAIE,IAAI;AAC/B"}
@@ -138,7 +138,7 @@ function getRequiredDependencies({ appDetails, dbType, payloadVersion }) {
138
138
  payload: payloadVersion
139
139
  };
140
140
  if (appDetails.kind === 'router-only') {
141
- dependencies['@tanstack/react-start'] = '^1.168.60';
141
+ dependencies['@tanstack/react-start'] = '^1.169.1';
142
142
  }
143
143
  return dependencies;
144
144
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/init-tanstack.ts"],"sourcesContent":["import path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport type { CliArgs, DbType, PackageManager, TanStackAppDetails } from '../types.js'\n\nimport { debug } from '../utils/log.js'\nimport {\n DEFAULT_PAYLOAD_VERSION_TAG,\n resolvePackageVersion,\n} from '../utils/resolvePackageVersion.js'\nimport { getDbPackageName } from './ast/adapter-config.js'\nimport { preparePackageJson } from './ast/package-json.js'\nimport { configurePayloadTsConfig } from './configure-payload-tsconfig.js'\nimport { ensurePnpmBuildApprovals } from './configure-pnpm-builds.js'\nimport { installPackages } from './install-packages.js'\nimport { getTanStackAppDetails } from './tanstack/detect.js'\nimport { applyPreparedWrites, prepareTanStackInit } from './tanstack/prepare.js'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\ntype InitTanStackArgs = {\n appDetails?: TanStackAppDetails\n dbType: DbType\n packageManager: PackageManager\n projectDir: string\n templateRoot?: string\n} & Pick<CliArgs, '--debug' | '--no-deps' | '--payload-version'>\n\ntype InitTanStackResult =\n | { payloadConfigPath: string; success: true }\n | { reason: string; success: false }\n\nexport async function initTanStack(args: InitTanStackArgs): Promise<InitTanStackResult> {\n const appDetailsResult = args.appDetails\n ? { details: args.appDetails, success: true as const }\n : await detectAppDetails({ projectDir: args.projectDir })\n\n if (!appDetailsResult.success) {\n return appDetailsResult\n }\n\n const { details: appDetails } = appDetailsResult\n const templateRoot = args.templateRoot ?? resolveTemplateRoot()\n\n if (args['--debug']) {\n debug(`Using TanStack template files from: ${templateRoot}`)\n }\n\n const prepared = await prepareTanStackInit({ appDetails, templateRoot })\n if (!prepared.success) {\n return prepared\n }\n\n const payloadVersion = await resolvePackageVersion({\n debug: args['--debug'],\n packageName: 'payload',\n versionOrTag: args['--payload-version'] ?? DEFAULT_PAYLOAD_VERSION_TAG,\n })\n const requiredDependencies = getRequiredDependencies({\n appDetails,\n dbType: args.dbType,\n payloadVersion,\n })\n let writes = prepared.writes\n if (appDetails.kind === 'router-only' || args['--no-deps']) {\n try {\n const packageJsonWrite = preparePackageJson({\n filePath: path.join(args.projectDir, 'package.json'),\n options: {\n addDependencies: args['--no-deps'] ? requiredDependencies : undefined,\n removeDependencies:\n appDetails.kind === 'router-only' ? ['@tanstack/router-plugin'] : undefined,\n },\n })\n writes = [...writes, packageJsonWrite]\n } catch (error) {\n return {\n reason: `Could not prepare package.json: ${error instanceof Error ? error.message : 'Unknown error'}`,\n success: false,\n }\n }\n }\n\n await applyPreparedWrites({ writes })\n\n if (!args['--no-deps']) {\n const packagesToInstall = Object.entries(requiredDependencies).map(\n ([packageName, version]) => `${packageName}@${version}`,\n )\n\n await ensurePnpmBuildApprovals({\n packageManager: args.packageManager,\n projectDir: args.projectDir,\n })\n\n let installation: { success: boolean }\n try {\n installation = await installPackages({\n packageManager: args.packageManager,\n packagesToInstall,\n projectDir: args.projectDir,\n })\n } catch {\n return { reason: 'Failed to install dependencies', success: false }\n }\n if (!installation.success) {\n return { reason: 'Failed to install dependencies', success: false }\n }\n }\n\n const payloadConfigPath = path.join(appDetails.sourceDir, 'payload.config.ts')\n await configurePayloadTsConfig({\n configPath: path.join(args.projectDir, 'tsconfig.json'),\n payloadConfigPath,\n })\n\n return { payloadConfigPath, success: true }\n}\n\nasync function detectAppDetails({\n projectDir,\n}: {\n projectDir: string\n}): Promise<{ details: TanStackAppDetails; success: true } | { reason: string; success: false }> {\n const detection = await getTanStackAppDetails({ projectDir })\n\n if (!detection.detected) {\n return {\n reason: `Could not detect a TanStack application in ${projectDir}.`,\n success: false,\n }\n }\n\n if (!detection.compatible) {\n return { reason: detection.reason, success: false }\n }\n\n return { details: detection.details, success: true }\n}\n\nfunction getRequiredDependencies({\n appDetails,\n dbType,\n payloadVersion,\n}: {\n appDetails: TanStackAppDetails\n dbType: DbType\n payloadVersion: string\n}): Record<string, string> {\n const dependencies: Record<string, string> = {\n '@payloadcms/plugin-mcp': payloadVersion,\n '@payloadcms/richtext-lexical': payloadVersion,\n '@payloadcms/tanstack-start': payloadVersion,\n '@payloadcms/ui': payloadVersion,\n '@vitejs/plugin-rsc': '^0.5.21',\n [getDbPackageName(dbType)]: payloadVersion,\n graphql: '^16.8.1',\n payload: payloadVersion,\n }\n\n if (appDetails.kind === 'router-only') {\n dependencies['@tanstack/react-start'] = '^1.168.60'\n }\n\n return dependencies\n}\n\nfunction resolveTemplateRoot(): string {\n return path.basename(path.dirname(dirname)) === 'dist'\n ? path.resolve(dirname, '../template-tanstack')\n : path.resolve(dirname, '../../../../templates/blank-tanstack/src')\n}\n"],"names":["path","fileURLToPath","debug","DEFAULT_PAYLOAD_VERSION_TAG","resolvePackageVersion","getDbPackageName","preparePackageJson","configurePayloadTsConfig","ensurePnpmBuildApprovals","installPackages","getTanStackAppDetails","applyPreparedWrites","prepareTanStackInit","filename","url","dirname","initTanStack","args","appDetailsResult","appDetails","details","success","detectAppDetails","projectDir","templateRoot","resolveTemplateRoot","prepared","payloadVersion","packageName","versionOrTag","requiredDependencies","getRequiredDependencies","dbType","writes","kind","packageJsonWrite","filePath","join","options","addDependencies","undefined","removeDependencies","error","reason","Error","message","packagesToInstall","Object","entries","map","version","packageManager","installation","payloadConfigPath","sourceDir","configPath","detection","detected","compatible","dependencies","graphql","payload","basename","resolve"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAC5B,SAASC,aAAa,QAAQ,WAAU;AAIxC,SAASC,KAAK,QAAQ,kBAAiB;AACvC,SACEC,2BAA2B,EAC3BC,qBAAqB,QAChB,oCAAmC;AAC1C,SAASC,gBAAgB,QAAQ,0BAAyB;AAC1D,SAASC,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,wBAAwB,QAAQ,kCAAiC;AAC1E,SAASC,wBAAwB,QAAQ,6BAA4B;AACrE,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,qBAAqB,QAAQ,uBAAsB;AAC5D,SAASC,mBAAmB,EAAEC,mBAAmB,QAAQ,wBAAuB;AAEhF,MAAMC,WAAWZ,cAAc,YAAYa,GAAG;AAC9C,MAAMC,UAAUf,KAAKe,OAAO,CAACF;AAc7B,OAAO,eAAeG,aAAaC,IAAsB;IACvD,MAAMC,mBAAmBD,KAAKE,UAAU,GACpC;QAAEC,SAASH,KAAKE,UAAU;QAAEE,SAAS;IAAc,IACnD,MAAMC,iBAAiB;QAAEC,YAAYN,KAAKM,UAAU;IAAC;IAEzD,IAAI,CAACL,iBAAiBG,OAAO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B2B,QAAQ,EAAEL;QAC5BiC,SAAS;QACTC,SAASlC;IACX;IAEA,IAAIR,WAAWe,IAAI,KAAK,eAAe;QACrCyB,YAAY,CAAC,wBAAwB,GAAG;IAC1C;IAEA,OAAOA;AACT;AAEA,SAASlC;IACP,OAAOzB,KAAK8D,QAAQ,CAAC9D,KAAKe,OAAO,CAACA,cAAc,SAC5Cf,KAAK+D,OAAO,CAAChD,SAAS,0BACtBf,KAAK+D,OAAO,CAAChD,SAAS;AAC5B"}
1
+ {"version":3,"sources":["../../src/lib/init-tanstack.ts"],"sourcesContent":["import path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport type { CliArgs, DbType, PackageManager, TanStackAppDetails } from '../types.js'\n\nimport { debug } from '../utils/log.js'\nimport {\n DEFAULT_PAYLOAD_VERSION_TAG,\n resolvePackageVersion,\n} from '../utils/resolvePackageVersion.js'\nimport { getDbPackageName } from './ast/adapter-config.js'\nimport { preparePackageJson } from './ast/package-json.js'\nimport { configurePayloadTsConfig } from './configure-payload-tsconfig.js'\nimport { ensurePnpmBuildApprovals } from './configure-pnpm-builds.js'\nimport { installPackages } from './install-packages.js'\nimport { getTanStackAppDetails } from './tanstack/detect.js'\nimport { applyPreparedWrites, prepareTanStackInit } from './tanstack/prepare.js'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\ntype InitTanStackArgs = {\n appDetails?: TanStackAppDetails\n dbType: DbType\n packageManager: PackageManager\n projectDir: string\n templateRoot?: string\n} & Pick<CliArgs, '--debug' | '--no-deps' | '--payload-version'>\n\ntype InitTanStackResult =\n | { payloadConfigPath: string; success: true }\n | { reason: string; success: false }\n\nexport async function initTanStack(args: InitTanStackArgs): Promise<InitTanStackResult> {\n const appDetailsResult = args.appDetails\n ? { details: args.appDetails, success: true as const }\n : await detectAppDetails({ projectDir: args.projectDir })\n\n if (!appDetailsResult.success) {\n return appDetailsResult\n }\n\n const { details: appDetails } = appDetailsResult\n const templateRoot = args.templateRoot ?? resolveTemplateRoot()\n\n if (args['--debug']) {\n debug(`Using TanStack template files from: ${templateRoot}`)\n }\n\n const prepared = await prepareTanStackInit({ appDetails, templateRoot })\n if (!prepared.success) {\n return prepared\n }\n\n const payloadVersion = await resolvePackageVersion({\n debug: args['--debug'],\n packageName: 'payload',\n versionOrTag: args['--payload-version'] ?? DEFAULT_PAYLOAD_VERSION_TAG,\n })\n const requiredDependencies = getRequiredDependencies({\n appDetails,\n dbType: args.dbType,\n payloadVersion,\n })\n let writes = prepared.writes\n if (appDetails.kind === 'router-only' || args['--no-deps']) {\n try {\n const packageJsonWrite = preparePackageJson({\n filePath: path.join(args.projectDir, 'package.json'),\n options: {\n addDependencies: args['--no-deps'] ? requiredDependencies : undefined,\n removeDependencies:\n appDetails.kind === 'router-only' ? ['@tanstack/router-plugin'] : undefined,\n },\n })\n writes = [...writes, packageJsonWrite]\n } catch (error) {\n return {\n reason: `Could not prepare package.json: ${error instanceof Error ? error.message : 'Unknown error'}`,\n success: false,\n }\n }\n }\n\n await applyPreparedWrites({ writes })\n\n if (!args['--no-deps']) {\n const packagesToInstall = Object.entries(requiredDependencies).map(\n ([packageName, version]) => `${packageName}@${version}`,\n )\n\n await ensurePnpmBuildApprovals({\n packageManager: args.packageManager,\n projectDir: args.projectDir,\n })\n\n let installation: { success: boolean }\n try {\n installation = await installPackages({\n packageManager: args.packageManager,\n packagesToInstall,\n projectDir: args.projectDir,\n })\n } catch {\n return { reason: 'Failed to install dependencies', success: false }\n }\n if (!installation.success) {\n return { reason: 'Failed to install dependencies', success: false }\n }\n }\n\n const payloadConfigPath = path.join(appDetails.sourceDir, 'payload.config.ts')\n await configurePayloadTsConfig({\n configPath: path.join(args.projectDir, 'tsconfig.json'),\n payloadConfigPath,\n })\n\n return { payloadConfigPath, success: true }\n}\n\nasync function detectAppDetails({\n projectDir,\n}: {\n projectDir: string\n}): Promise<{ details: TanStackAppDetails; success: true } | { reason: string; success: false }> {\n const detection = await getTanStackAppDetails({ projectDir })\n\n if (!detection.detected) {\n return {\n reason: `Could not detect a TanStack application in ${projectDir}.`,\n success: false,\n }\n }\n\n if (!detection.compatible) {\n return { reason: detection.reason, success: false }\n }\n\n return { details: detection.details, success: true }\n}\n\nfunction getRequiredDependencies({\n appDetails,\n dbType,\n payloadVersion,\n}: {\n appDetails: TanStackAppDetails\n dbType: DbType\n payloadVersion: string\n}): Record<string, string> {\n const dependencies: Record<string, string> = {\n '@payloadcms/plugin-mcp': payloadVersion,\n '@payloadcms/richtext-lexical': payloadVersion,\n '@payloadcms/tanstack-start': payloadVersion,\n '@payloadcms/ui': payloadVersion,\n '@vitejs/plugin-rsc': '^0.5.21',\n [getDbPackageName(dbType)]: payloadVersion,\n graphql: '^16.8.1',\n payload: payloadVersion,\n }\n\n if (appDetails.kind === 'router-only') {\n dependencies['@tanstack/react-start'] = '^1.169.1'\n }\n\n return dependencies\n}\n\nfunction resolveTemplateRoot(): string {\n return path.basename(path.dirname(dirname)) === 'dist'\n ? path.resolve(dirname, '../template-tanstack')\n : path.resolve(dirname, '../../../../templates/blank-tanstack/src')\n}\n"],"names":["path","fileURLToPath","debug","DEFAULT_PAYLOAD_VERSION_TAG","resolvePackageVersion","getDbPackageName","preparePackageJson","configurePayloadTsConfig","ensurePnpmBuildApprovals","installPackages","getTanStackAppDetails","applyPreparedWrites","prepareTanStackInit","filename","url","dirname","initTanStack","args","appDetailsResult","appDetails","details","success","detectAppDetails","projectDir","templateRoot","resolveTemplateRoot","prepared","payloadVersion","packageName","versionOrTag","requiredDependencies","getRequiredDependencies","dbType","writes","kind","packageJsonWrite","filePath","join","options","addDependencies","undefined","removeDependencies","error","reason","Error","message","packagesToInstall","Object","entries","map","version","packageManager","installation","payloadConfigPath","sourceDir","configPath","detection","detected","compatible","dependencies","graphql","payload","basename","resolve"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAC5B,SAASC,aAAa,QAAQ,WAAU;AAIxC,SAASC,KAAK,QAAQ,kBAAiB;AACvC,SACEC,2BAA2B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,SAAS;IAAK;AAC5C;AAEA,eAAeC,iBAAiB,EAC9BC,UAAU,EAGX;IACC,MAAMiC,YAAY,MAAM9C,sBAAsB;QAAEa;IAAW;IAE3D,IAAI,CAACiC,UAAUC,QAAQ,EAAE;QACvB,OAAO;YACLd,QAAQ,CAAC,2CAA2C,EAAEpB,WAAW,CAAC,CAAC;YACnEF,SAAS;QACX;IACF;IAEA,IAAI,CAACmC,UAAUE,UAAU,EAAE;QACzB,OAAO;YAAEf,QAAQa,UAAUb,MAAM;YAAEtB,SAAS;QAAM;IACpD;IAEA,OAAO;QAAED,SAASoC,UAAUpC,OAAO;QAAEC,SAAS;IAAK;AACrD;AAEA,SAASU,wBAAwB,EAC/BZ,UAAU,EACVa,MAAM,EACNL,cAAc,EAKf;IACC,MAAMgC,eAAuC;QAC3C,0BAA0BhC;QAC1B,gCAAgCA;QAChC,8BAA8BA;QAC9B,kBAAkBA;QAClB,sBAAsB;QACtB,CAACtB,iBAAiB2B,QAAQ,EAAEL;QAC5BiC,SAAS;QACTC,SAASlC;IACX;IAEA,IAAIR,WAAWe,IAAI,KAAK,eAAe;QACrCyB,YAAY,CAAC,wBAAwB,GAAG;IAC1C;IAEA,OAAOA;AACT;AAEA,SAASlC;IACP,OAAOzB,KAAK8D,QAAQ,CAAC9D,KAAKe,OAAO,CAACA,cAAc,SAC5Cf,KAAK+D,OAAO,CAAChD,SAAS,0BACtBf,KAAK+D,OAAO,CAAChD,SAAS;AAC5B"}
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 {\n CliArgs,\n NextAppDetails,\n TanStackAppDetails,\n TanStackDetectionResult,\n} 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, minimumNextVersion } from './lib/init-next.js'\nimport { initTanStack } from './lib/init-tanstack.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 { selectDb } from './lib/select-db.js'\nimport { getTanStackAppDetails } from './lib/tanstack/detect.js'\nimport { getValidTemplates, validateTemplate } from './lib/templates.js'\nimport {\n updatePayloadInNextProject,\n updatePayloadInTanStackProject,\n} from './lib/update-payload-in-project.js'\nimport { debug, error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successfulNextInit,\n successfulTanStackInit,\n successMessage,\n} from './utils/messages.js'\nimport {\n DEFAULT_PAYLOAD_VERSION_TAG,\n resolvePackageVersion,\n} from './utils/resolvePackageVersion.js'\n\nexport class Main {\n args: CliArgs\n\n constructor() {\n // @ts-expect-error bad typings\n this.args = arg(\n {\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 '--payload-version': String, // Install a specific Payload version or npm dist-tag (e.g. 3.40.0 or canary; default: canary)\n '--secret': String,\n '--template': String,\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 '-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 resolvePackageVersion({\n debug: debugFlag,\n packageName: 'payload',\n versionOrTag: this.args['--payload-version'] ?? DEFAULT_PAYLOAD_VERSION_TAG,\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 const tanStackDetection = await getTanStackAppDetails({ projectDir: process.cwd() })\n const nextAppDetails = await getNextAppDetails(process.cwd())\n const appFramework = resolveAppFramework({ nextAppDetails, tanStackDetection })\n\n if (appFramework.kind === 'ambiguous') {\n p.log.warn(\n 'Both Next.js and TanStack project markers were detected. Remove one framework before installing Payload.',\n )\n p.outro(feedbackOutro())\n return\n }\n\n if (appFramework.kind === 'unsupported-tanstack') {\n p.log.warn(appFramework.reason)\n p.outro(feedbackOutro())\n return\n }\n\n if (appFramework.kind === 'next' && !appFramework.appDetails.isSupportedNextVersion) {\n p.log.warn(\n `Next.js v${appFramework.appDetails.nextVersion} is unsupported. Next.js >= ${minimumNextVersion.major}.${minimumNextVersion.minor} is required to use Payload.`,\n )\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const hasPayload = appFramework.kind !== 'none' && appFramework.appDetails.isPayloadInstalled\n\n if (hasPayload) {\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 versionOrTag = this.args['--payload-version'] ?? DEFAULT_PAYLOAD_VERSION_TAG\n const updateResult =\n appFramework.kind === 'next'\n ? await updatePayloadInNextProject({\n appDetails: appFramework.appDetails,\n versionOrTag,\n })\n : await updatePayloadInTanStackProject({\n appDetails: appFramework.appDetails,\n versionOrTag,\n })\n\n const { message, success: updateSuccess } = updateResult\n if (updateSuccess) {\n info(message)\n } else {\n error(message)\n }\n }\n\n p.outro(feedbackOutro())\n return\n }\n\n if (appFramework.kind === 'next') {\n this.args['--name'] = slugify(\n path.basename(path.dirname(appFramework.appDetails.nextConfigPath!)),\n )\n } else if (appFramework.kind === 'tanstack') {\n this.args['--name'] = slugify(path.basename(appFramework.appDetails.projectDir))\n }\n\n const projectName = await parseProjectName(this.args)\n let projectDir: string\n if (appFramework.kind === 'next') {\n projectDir = path.dirname(appFramework.appDetails.nextConfigPath!)\n } else if (appFramework.kind === 'tanstack') {\n projectDir = appFramework.appDetails.projectDir\n } else {\n projectDir = path.resolve(process.cwd(), slugify(projectName))\n }\n\n const packageManager = await getPackageManager({ cliArgs: this.args, projectDir })\n\n if (appFramework.kind === 'next') {\n const { hasTopLevelLayout, nextAppDir } = appFramework.appDetails\n\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: appFramework.appDetails,\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 if (appFramework.kind === 'tanstack') {\n const frameworkName =\n appFramework.appDetails.kind === 'start' ? 'TanStack Start' : 'TanStack Router'\n p.log.step(chalk.bold(`${chalk.bgBlack(` ${frameworkName} `)} project detected!`))\n\n const proceed = await p.confirm({\n initialValue: true,\n message: chalk.bold(\n appFramework.appDetails.kind === 'start'\n ? 'Install Payload in this TanStack Start project?'\n : 'Convert this project to TanStack Start and install Payload?',\n ),\n })\n if (p.isCancel(proceed) || !proceed) {\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const dbDetails = await selectDb(this.args, projectName)\n const result = await initTanStack({\n ...this.args,\n appDetails: appFramework.appDetails,\n dbType: dbDetails.type,\n packageManager,\n projectDir,\n })\n\n if (result.success === false) {\n p.log.error(result.reason)\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(successfulTanStackInit(), chalk.bgGreen(chalk.black(' TanStack Start initialized ')))\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 await createProject({\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 await createProject({\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 await createProject({\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\ntype AppFramework =\n | { appDetails: NextAppDetails; kind: 'next' }\n | { appDetails: TanStackAppDetails; kind: 'tanstack' }\n | { kind: 'ambiguous' }\n | { kind: 'none' }\n | { kind: 'unsupported-tanstack'; reason: string }\n\nexport function resolveAppFramework({\n nextAppDetails,\n tanStackDetection,\n}: {\n nextAppDetails: NextAppDetails\n tanStackDetection: TanStackDetectionResult\n}): AppFramework {\n if (nextAppDetails.nextConfigPath && tanStackDetection.detected) {\n return { kind: 'ambiguous' }\n }\n\n if (nextAppDetails.nextConfigPath) {\n return { appDetails: nextAppDetails, kind: 'next' }\n }\n\n if (!tanStackDetection.detected) {\n return { kind: 'none' }\n }\n\n if (!tanStackDetection.compatible) {\n return { kind: 'unsupported-tanstack', reason: tanStackDetection.reason }\n }\n\n return { appDetails: tanStackDetection.details, kind: 'tanstack' }\n}\n"],"names":["p","slugify","arg","chalk","figures","path","configurePayloadConfig","createProject","parseExample","generateSecret","getPackageManager","getNextAppDetails","initNext","minimumNextVersion","initTanStack","manageEnvFiles","parseProjectName","parseTemplate","selectDb","getTanStackAppDetails","getValidTemplates","validateTemplate","updatePayloadInNextProject","updatePayloadInTanStackProject","debug","error","info","feedbackOutro","helpMessage","moveMessage","successfulNextInit","successfulTanStackInit","successMessage","DEFAULT_PAYLOAD_VERSION_TAG","resolvePackageVersion","Main","args","String","Boolean","permissive","init","debugFlag","process","env","DEBUG","LATEST_VERSION","packageName","versionOrTag","exit","console","log","intro","bgCyan","black","note","tanStackDetection","projectDir","cwd","nextAppDetails","appFramework","resolveAppFramework","kind","warn","outro","reason","appDetails","isSupportedNextVersion","nextVersion","major","minor","hasPayload","isPayloadInstalled","shouldUpdate","confirm","initialValue","message","bold","isCancel","updateResult","success","updateSuccess","basename","dirname","nextConfigPath","projectName","resolve","packageManager","cliArgs","hasTopLevelLayout","nextAppDir","step","bgBlack","triangleUp","proceed","green","dbDetails","result","dbType","type","projectDirOrConfigPath","payloadConfigPath","databaseType","databaseUri","dbUri","payloadSecret","bgGreen","frameworkName","templateArg","valid","templateName","exampleArg","example","name","branch","validTemplates","template","err","Error","detected","compatible","details"],"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;AASvB,SAASC,sBAAsB,QAAQ,oCAAmC;AAC1E,SAASC,aAAa,QAAQ,0BAAyB;AACvD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,iBAAiB,EAAEC,QAAQ,EAAEC,kBAAkB,QAAQ,qBAAoB;AACpF,SAASC,YAAY,QAAQ,yBAAwB;AACrD,SAASC,cAAc,QAAQ,4BAA2B;AAC1D,SAASC,gBAAgB,QAAQ,8BAA6B;AAC9D,SAASC,aAAa,QAAQ,0BAAyB;AACvD,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,qBAAqB,QAAQ,2BAA0B;AAChE,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,qBA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BACnB,KAAK;wBAAU;4BACb,MAAM3F,cAAc;gCAClBgF,SAAS,IAAI,CAACnD,IAAI;gCAClBkD;gCACA9B;gCACA4B;gCACA+B;4BACF;4BACA;wBACF;oBACA,KAAK;wBAAW;4BACd,MAAMpB,YAAY,MAAM7E,SAAS,IAAI,CAACkB,IAAI,EAAEgD,aAAa+B;4BACzD,MAAM5G,cAAc;gCAClBgF,SAAS,IAAI,CAACnD,IAAI;gCAClB2D;gCACAT;gCACA9B;gCACA4B;gCACA+B;4BACF;4BAEA;wBACF;gBACF;YACF;YAEAzF,KAAK;YACL1B,EAAEkD,GAAG,CAACwC,IAAI,CAACvF,MAAMsG,OAAO,CAACtG,MAAMkD,KAAK,CAAC;YACrCrD,EAAEkD,GAAG,CAACyB,OAAO,CAAC3C,eAAewB,YAAY8B;YACzCtF,EAAE+D,KAAK,CAACpC;QACV,EAAE,OAAOyF,KAAc;YACrB3F,MAAM2F,eAAeC,QAAQD,IAAIzC,OAAO,GAAG;QAC7C;IACF;AACF;AASA,OAAO,SAASf,oBAAoB,EAClCF,cAAc,EACdH,iBAAiB,EAIlB;IACC,IAAIG,eAAeyB,cAAc,IAAI5B,kBAAkB+D,QAAQ,EAAE;QAC/D,OAAO;YAAEzD,MAAM;QAAY;IAC7B;IAEA,IAAIH,eAAeyB,cAAc,EAAE;QACjC,OAAO;YAAElB,YAAYP;YAAgBG,MAAM;QAAO;IACpD;IAEA,IAAI,CAACN,kBAAkB+D,QAAQ,EAAE;QAC/B,OAAO;YAAEzD,MAAM;QAAO;IACxB;IAEA,IAAI,CAACN,kBAAkBgE,UAAU,EAAE;QACjC,OAAO;YAAE1D,MAAM;YAAwBG,QAAQT,kBAAkBS,MAAM;QAAC;IAC1E;IAEA,OAAO;QAAEC,YAAYV,kBAAkBiE,OAAO;QAAE3D,MAAM;IAAW;AACnE"}
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 {\n CliArgs,\n NextAppDetails,\n TanStackAppDetails,\n TanStackDetectionResult,\n} 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, minimumNextVersion } from './lib/init-next.js'\nimport { initTanStack } from './lib/init-tanstack.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 { selectDb } from './lib/select-db.js'\nimport { getTanStackAppDetails } from './lib/tanstack/detect.js'\nimport { getValidTemplates, validateTemplate } from './lib/templates.js'\nimport {\n updatePayloadInNextProject,\n updatePayloadInTanStackProject,\n} from './lib/update-payload-in-project.js'\nimport { debug, error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successfulNextInit,\n successfulTanStackInit,\n successMessage,\n} from './utils/messages.js'\nimport {\n DEFAULT_PAYLOAD_VERSION_TAG,\n resolvePackageVersion,\n} from './utils/resolvePackageVersion.js'\n\nexport class Main {\n args: CliArgs\n\n constructor() {\n // @ts-expect-error bad typings\n this.args = arg(\n {\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 '--payload-version': String, // Install a specific Payload version or npm dist-tag (e.g. 3.40.0 or beta; default: this CLI's own dist-tag)\n '--secret': String,\n '--template': String,\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 '-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 resolvePackageVersion({\n debug: debugFlag,\n packageName: 'payload',\n versionOrTag: this.args['--payload-version'] ?? DEFAULT_PAYLOAD_VERSION_TAG,\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 const tanStackDetection = await getTanStackAppDetails({ projectDir: process.cwd() })\n const nextAppDetails = await getNextAppDetails(process.cwd())\n const appFramework = resolveAppFramework({ nextAppDetails, tanStackDetection })\n\n if (appFramework.kind === 'ambiguous') {\n p.log.warn(\n 'Both Next.js and TanStack project markers were detected. Remove one framework before installing Payload.',\n )\n p.outro(feedbackOutro())\n return\n }\n\n if (appFramework.kind === 'unsupported-tanstack') {\n p.log.warn(appFramework.reason)\n p.outro(feedbackOutro())\n return\n }\n\n if (appFramework.kind === 'next' && !appFramework.appDetails.isSupportedNextVersion) {\n p.log.warn(\n `Next.js v${appFramework.appDetails.nextVersion} is unsupported. Next.js >= ${minimumNextVersion.major}.${minimumNextVersion.minor} is required to use Payload.`,\n )\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const hasPayload = appFramework.kind !== 'none' && appFramework.appDetails.isPayloadInstalled\n\n if (hasPayload) {\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 versionOrTag = this.args['--payload-version'] ?? DEFAULT_PAYLOAD_VERSION_TAG\n const updateResult =\n appFramework.kind === 'next'\n ? await updatePayloadInNextProject({\n appDetails: appFramework.appDetails,\n versionOrTag,\n })\n : await updatePayloadInTanStackProject({\n appDetails: appFramework.appDetails,\n versionOrTag,\n })\n\n const { message, success: updateSuccess } = updateResult\n if (updateSuccess) {\n info(message)\n } else {\n error(message)\n }\n }\n\n p.outro(feedbackOutro())\n return\n }\n\n if (appFramework.kind === 'next') {\n this.args['--name'] = slugify(\n path.basename(path.dirname(appFramework.appDetails.nextConfigPath!)),\n )\n } else if (appFramework.kind === 'tanstack') {\n this.args['--name'] = slugify(path.basename(appFramework.appDetails.projectDir))\n }\n\n const projectName = await parseProjectName(this.args)\n let projectDir: string\n if (appFramework.kind === 'next') {\n projectDir = path.dirname(appFramework.appDetails.nextConfigPath!)\n } else if (appFramework.kind === 'tanstack') {\n projectDir = appFramework.appDetails.projectDir\n } else {\n projectDir = path.resolve(process.cwd(), slugify(projectName))\n }\n\n const packageManager = await getPackageManager({ cliArgs: this.args, projectDir })\n\n if (appFramework.kind === 'next') {\n const { hasTopLevelLayout, nextAppDir } = appFramework.appDetails\n\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: appFramework.appDetails,\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 if (appFramework.kind === 'tanstack') {\n const frameworkName =\n appFramework.appDetails.kind === 'start' ? 'TanStack Start' : 'TanStack Router'\n p.log.step(chalk.bold(`${chalk.bgBlack(` ${frameworkName} `)} project detected!`))\n\n const proceed = await p.confirm({\n initialValue: true,\n message: chalk.bold(\n appFramework.appDetails.kind === 'start'\n ? 'Install Payload in this TanStack Start project?'\n : 'Convert this project to TanStack Start and install Payload?',\n ),\n })\n if (p.isCancel(proceed) || !proceed) {\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const dbDetails = await selectDb(this.args, projectName)\n const result = await initTanStack({\n ...this.args,\n appDetails: appFramework.appDetails,\n dbType: dbDetails.type,\n packageManager,\n projectDir,\n })\n\n if (result.success === false) {\n p.log.error(result.reason)\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(successfulTanStackInit(), chalk.bgGreen(chalk.black(' TanStack Start initialized ')))\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 await createProject({\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 await createProject({\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 await createProject({\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\ntype AppFramework =\n | { appDetails: NextAppDetails; kind: 'next' }\n | { appDetails: TanStackAppDetails; kind: 'tanstack' }\n | { kind: 'ambiguous' }\n | { kind: 'none' }\n | { kind: 'unsupported-tanstack'; reason: string }\n\nexport function resolveAppFramework({\n nextAppDetails,\n tanStackDetection,\n}: {\n nextAppDetails: NextAppDetails\n tanStackDetection: TanStackDetectionResult\n}): AppFramework {\n if (nextAppDetails.nextConfigPath && tanStackDetection.detected) {\n return { kind: 'ambiguous' }\n }\n\n if (nextAppDetails.nextConfigPath) {\n return { appDetails: nextAppDetails, kind: 'next' }\n }\n\n if (!tanStackDetection.detected) {\n return { kind: 'none' }\n }\n\n if (!tanStackDetection.compatible) {\n return { kind: 'unsupported-tanstack', reason: tanStackDetection.reason }\n }\n\n return { appDetails: tanStackDetection.details, kind: 'tanstack' }\n}\n"],"names":["p","slugify","arg","chalk","figures","path","configurePayloadConfig","createProject","parseExample","generateSecret","getPackageManager","getNextAppDetails","initNext","minimumNextVersion","initTanStack","manageEnvFiles","parseProjectName","parseTemplate","selectDb","getTanStackAppDetails","getValidTemplates","validateTemplate","updatePayloadInNextProject","updatePayloadInTanStackProject","debug","error","info","feedbackOutro","helpMessage","moveMessage","successfulNextInit","successfulTanStackInit","successMessage","DEFAULT_PAYLOAD_VERSION_TAG","resolvePackageVersion","Main","args","String","Boolean","permissive","init","debugFlag","process","env","DEBUG","LATEST_VERSION","packageName","versionOrTag","exit","console","log","intro","bgCyan","black","note","tanStackDetection","projectDir","cwd","nextAppDetails","appFramework","resolveAppFramework","kind","warn","outro","reason","appDetails","isSupportedNextVersion","nextVersion","major","minor","hasPayload","isPayloadInstalled","shouldUpdate","confirm","initialValue","message","bold","isCancel","updateResult","success","updateSuccess","basename","dirname","nextConfigPath","projectName","resolve","packageManager","cliArgs","hasTopLevelLayout","nextAppDir","step","bgBlack","triangleUp","proceed","green","dbDetails","result","dbType","type","projectDirOrConfigPath","payloadConfigPath","databaseType","databaseUri","dbUri","payloadSecret","bgGreen","frameworkName","templateArg","valid","templateName","exampleArg","example","name","branch","validTemplates","template","err","Error","detected","compatible","details"],"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;AASvB,SAASC,sBAAsB,QAAQ,oCAAmC;AAC1E,SAASC,aAAa,QAAQ,0BAAyB;AACvD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,iBAAiB,EAAEC,QAAQ,EAAEC,kBAAkB,QAAQ,qBAAoB;AACpF,SAASC,YAAY,QAAQ,yBAAwB;AACrD,SAASC,cA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AM;YAAwBG,QAAQT,kBAAkBS,MAAM;QAAC;IAC1E;IAEA,OAAO;QAAEC,YAAYV,kBAAkBiE,OAAO;QAAE3D,MAAM;IAAW;AACnE"}
@@ -9,8 +9,8 @@ import { CollectionCards as CollectionCards_ab83ff7e88da8d3530831f296ec4756a } f
9
9
  import { CollectionQueryWidget as CollectionQueryWidget_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
10
10
  import { QueryPresetsWhereField as QueryPresetsWhereField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
11
11
  import { CollectionQuerySortField as CollectionQuerySortField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
12
- import { RecentlyViewedWidget as RecentlyViewedWidget_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
13
- import { RecentlyViewedCollectionsField as RecentlyViewedCollectionsField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
12
+ import { ActivityWidget as ActivityWidget_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
13
+ import { CollectionFilter as CollectionFilter_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
14
14
 
15
15
  /** @type import('payload').ImportMap */
16
16
  export const importMap = {
@@ -28,7 +28,6 @@ export const importMap = {
28
28
  '@payloadcms/ui#QueryPresetsWhereField': QueryPresetsWhereField_3817bf644402e67bfe6577f60ef982de,
29
29
  '@payloadcms/ui#CollectionQuerySortField':
30
30
  CollectionQuerySortField_3817bf644402e67bfe6577f60ef982de,
31
- '@payloadcms/ui/rsc#RecentlyViewedWidget': RecentlyViewedWidget_ab83ff7e88da8d3530831f296ec4756a,
32
- '@payloadcms/ui#RecentlyViewedCollectionsField':
33
- RecentlyViewedCollectionsField_3817bf644402e67bfe6577f60ef982de,
31
+ '@payloadcms/ui/rsc#ActivityWidget': ActivityWidget_ab83ff7e88da8d3530831f296ec4756a,
32
+ '@payloadcms/ui#CollectionFilter': CollectionFilter_3817bf644402e67bfe6577f60ef982de,
34
33
  }
@@ -1,5 +1,5 @@
1
1
  /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. MODIFY AT YOUR OWN RISK. */
2
- import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
2
+ import { payloadApiHandlers } from '@payloadcms/tanstack-start/routes'
3
3
  import { createFileRoute } from '@tanstack/react-router'
4
4
 
5
5
  export const Route = createFileRoute('/_payload/api/$')({
@@ -8,8 +8,8 @@ import { CollectionCards as CollectionCards_ab83ff7e88da8d3530831f296ec4756a } f
8
8
  import { CollectionQueryWidget as CollectionQueryWidget_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
9
9
  import { QueryPresetsWhereField as QueryPresetsWhereField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
10
10
  import { CollectionQuerySortField as CollectionQuerySortField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
11
- import { RecentlyViewedWidget as RecentlyViewedWidget_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
12
- import { RecentlyViewedCollectionsField as RecentlyViewedCollectionsField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
11
+ import { ActivityWidget as ActivityWidget_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
12
+ import { CollectionFilter as CollectionFilter_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
13
13
 
14
14
  /** @type import('payload').ImportMap */
15
15
  export const importMap = {
@@ -26,7 +26,7 @@ export const importMap = {
26
26
  '@payloadcms/ui#QueryPresetsWhereField': QueryPresetsWhereField_3817bf644402e67bfe6577f60ef982de,
27
27
  '@payloadcms/ui#CollectionQuerySortField':
28
28
  CollectionQuerySortField_3817bf644402e67bfe6577f60ef982de,
29
- '@payloadcms/ui/rsc#RecentlyViewedWidget': RecentlyViewedWidget_ab83ff7e88da8d3530831f296ec4756a,
30
- '@payloadcms/ui#RecentlyViewedCollectionsField':
31
- RecentlyViewedCollectionsField_3817bf644402e67bfe6577f60ef982de,
29
+ '@payloadcms/ui/rsc#ActivityWidget': ActivityWidget_ab83ff7e88da8d3530831f296ec4756a,
30
+ '@payloadcms/ui#CollectionFilter':
31
+ CollectionFilter_3817bf644402e67bfe6577f60ef982de,
32
32
  }
@@ -33,16 +33,12 @@ const runPayloadServerFn = createServerFn({ method: 'POST' })
33
33
  .validator((args: ServerFunctionClientArgs): ServerFunctionClientArgs => args)
34
34
  .handler(async ({ data }) => {
35
35
  const { handleServerFunctions } = await import('@payloadcms/tanstack-start/server')
36
- const result = await handleServerFunctions({
36
+ return handleServerFunctions({
37
37
  args: data.args,
38
38
  config: await getConfig(),
39
39
  importMap: await getImportMap(),
40
40
  name: data.name,
41
41
  })
42
-
43
- // TanStack validates the adapter-sanitized result at the server-function boundary.
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- return result as any
46
42
  })
47
43
 
48
44
  export const serverFunctionHandler = createServerFunctionClient({
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/utils/messages.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,aAAa,CAAA;AAMlE,eAAO,MAAM,cAAc,QAE1B,CAAA;AAID,wBAAgB,WAAW,IAAI,IAAI,CAgClC;AAQD,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,CAiBzF;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAWD,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAgBpF;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/utils/messages.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,aAAa,CAAA;AAOlE,eAAO,MAAM,cAAc,QAE1B,CAAA;AAID,wBAAgB,WAAW,IAAI,IAAI,CAgClC;AAQD,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,CAiBzF;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAWD,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAgBpF;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
@@ -2,6 +2,7 @@
2
2
  import path from 'path';
3
3
  import terminalLink from 'terminal-link';
4
4
  import { getValidTemplates } from '../lib/templates.js';
5
+ import { DEFAULT_PAYLOAD_VERSION_TAG } from './resolvePackageVersion.js';
5
6
  const header = (message)=>chalk.bold(message);
6
7
  export const welcomeMessage = chalk`
7
8
  {green Welcome to Payload. Let's create a project! }
@@ -36,7 +37,7 @@ export function helpMessage() {
36
37
  --use-pnpm Use pnpm to install dependencies
37
38
  --use-bun Use bun to install dependencies (experimental)
38
39
  --no-deps Do not install any dependencies
39
- --payload-version {underline value} Install a specific Payload version or npm dist-tag (default: canary)
40
+ --payload-version {underline value} Install a specific Payload version or npm dist-tag (default: ${DEFAULT_PAYLOAD_VERSION_TAG})
40
41
  -h Show help
41
42
  `);
42
43
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/messages.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport chalk from 'chalk'\nimport path from 'path'\nimport terminalLink from 'terminal-link'\n\nimport type { PackageManager, ProjectTemplate } from '../types.js'\n\nimport { getValidTemplates } from '../lib/templates.js'\n\nconst header = (message: string): string => chalk.bold(message)\n\nexport const welcomeMessage = chalk`\n {green Welcome to Payload. Let's create a project! }\n`\n\nconst spacer = ' '.repeat(8)\n\nexport function helpMessage(): void {\n const validTemplates = getValidTemplates()\n console.log(chalk`\n {bold USAGE}\n\n {dim Inside of an existing Next.js or TanStack project}\n\n {dim $} {bold npx create-payload-app}\n\n {dim Create a new project from scratch}\n\n {dim $} {bold npx create-payload-app}\n {dim $} {bold npx create-payload-app} my-project\n {dim $} {bold npx create-payload-app} -n my-project -t template-name\n\n {bold OPTIONS}\n\n -n {underline my-payload-app} Set project name\n -t {underline template_name} Choose specific template\n -e {underline example_name} Choose specific example\n\n {dim Available templates: ${formatTemplates(validTemplates)}}\n\n --no-agent Skip writing AGENTS.md\n --use-npm Use npm to install dependencies\n --use-yarn Use yarn to install dependencies\n --use-pnpm Use pnpm to install dependencies\n --use-bun Use bun to install dependencies (experimental)\n --no-deps Do not install any dependencies\n --payload-version {underline value} Install a specific Payload version or npm dist-tag (default: canary)\n -h Show help\n`)\n}\n\nfunction formatTemplates(templates: ProjectTemplate[]) {\n return `\\n\\n${spacer}${templates\n .map((t) => `${t.name}${' '.repeat(28 - t.name.length)}${t.description}`)\n .join(`\\n${spacer}`)}`\n}\n\nexport function successMessage(projectDir: string, packageManager: PackageManager): string {\n const relativePath = path.relative(process.cwd(), projectDir)\n return `\n${header('Launch Application:')}\n\n - cd ./${relativePath}\n - ${packageManager === 'npm' ? 'npm run' : packageManager} dev or follow directions in README.md\n\n${header('Documentation:')}\n\n - ${createTerminalLink(\n 'Getting Started',\n 'https://payloadcms.com/docs/getting-started/what-is-payload',\n )}\n - ${createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview')}\n\n`\n}\n\nexport function successfulNextInit(): string {\n return successfulFrameworkInit()\n}\n\nexport function successfulTanStackInit(): string {\n return successfulFrameworkInit()\n}\n\nfunction successfulFrameworkInit(): string {\n return `- ${createTerminalLink(\n 'Getting Started',\n 'https://payloadcms.com/docs/getting-started/what-is-payload',\n )}\n- ${createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview')}\n`\n}\n\nexport function moveMessage(args: { nextAppDir: string; projectDir: string }): string {\n const relativeAppDir = path.relative(process.cwd(), args.nextAppDir)\n return `\n${header('Next Steps:')}\n\nPayload does not support a top-level layout.tsx file in the app directory.\n\n${chalk.bold('To continue:')}\n\n- Create a new directory in ./${relativeAppDir} such as ./${relativeAppDir}/${chalk.bold('(app)')}\n- Move all files from ./${relativeAppDir} into that directory\n\nIt is recommended to do this from your IDE if your app has existing file references.\n\nOnce moved, rerun the create-payload-app command again.\n`\n}\n\nexport function feedbackOutro(): string {\n return `${chalk.bgCyan(chalk.black(' Have feedback? '))} Visit us on ${createTerminalLink('GitHub', 'https://github.com/payloadcms/payload')}.`\n}\n\n// Create terminalLink with fallback for unsupported terminals\nfunction createTerminalLink(text: string, url: string) {\n return terminalLink(text, url, {\n fallback: (text, url) => `${text}: ${url}`,\n })\n}\n"],"names":["chalk","path","terminalLink","getValidTemplates","header","message","bold","welcomeMessage","spacer","repeat","helpMessage","validTemplates","console","log","formatTemplates","templates","map","t","name","length","description","join","successMessage","projectDir","packageManager","relativePath","relative","process","cwd","createTerminalLink","successfulNextInit","successfulFrameworkInit","successfulTanStackInit","moveMessage","args","relativeAppDir","nextAppDir","feedbackOutro","bgCyan","black","text","url","fallback"],"mappings":"AAAA,6BAA6B,GAC7B,OAAOA,WAAW,QAAO;AACzB,OAAOC,UAAU,OAAM;AACvB,OAAOC,kBAAkB,gBAAe;AAIxC,SAASC,iBAAiB,QAAQ,sBAAqB;AAEvD,MAAMC,SAAS,CAACC,UAA4BL,MAAMM,IAAI,CAACD;AAEvD,OAAO,MAAME,iBAAiBP,KAAK,CAAC;;AAEpC,CAAC,CAAA;AAED,MAAMQ,SAAS,IAAIC,MAAM,CAAC;AAE1B,OAAO,SAASC;IACd,MAAMC,iBAAiBR;IACvBS,QAAQC,GAAG,CAACb,KAAK,CAAC;;;;;;;;;;;;;;;;;;;kCAmBc,EAAEc,gBAAgBH,gBAAgB;;;;;;;;;;AAUpE,CAAC;AACD;A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AU,yCAAyC,CAAC,CAAC;AACjJ;AAEA,8DAA8D;AAC9D,SAASA,mBAAmBW,IAAY,EAAEC,GAAW;IACnD,OAAOvC,aAAasC,MAAMC,KAAK;QAC7BC,UAAU,CAACF,MAAMC,MAAQ,GAAGD,KAAK,EAAE,EAAEC,KAAK;IAC5C;AACF"}
1
+ {"version":3,"sources":["../../src/utils/messages.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport chalk from 'chalk'\nimport path from 'path'\nimport terminalLink from 'terminal-link'\n\nimport type { PackageManager, ProjectTemplate } from '../types.js'\n\nimport { getValidTemplates } from '../lib/templates.js'\nimport { DEFAULT_PAYLOAD_VERSION_TAG } from './resolvePackageVersion.js'\n\nconst header = (message: string): string => chalk.bold(message)\n\nexport const welcomeMessage = chalk`\n {green Welcome to Payload. Let's create a project! }\n`\n\nconst spacer = ' '.repeat(8)\n\nexport function helpMessage(): void {\n const validTemplates = getValidTemplates()\n console.log(chalk`\n {bold USAGE}\n\n {dim Inside of an existing Next.js or TanStack project}\n\n {dim $} {bold npx create-payload-app}\n\n {dim Create a new project from scratch}\n\n {dim $} {bold npx create-payload-app}\n {dim $} {bold npx create-payload-app} my-project\n {dim $} {bold npx create-payload-app} -n my-project -t template-name\n\n {bold OPTIONS}\n\n -n {underline my-payload-app} Set project name\n -t {underline template_name} Choose specific template\n -e {underline example_name} Choose specific example\n\n {dim Available templates: ${formatTemplates(validTemplates)}}\n\n --no-agent Skip writing AGENTS.md\n --use-npm Use npm to install dependencies\n --use-yarn Use yarn to install dependencies\n --use-pnpm Use pnpm to install dependencies\n --use-bun Use bun to install dependencies (experimental)\n --no-deps Do not install any dependencies\n --payload-version {underline value} Install a specific Payload version or npm dist-tag (default: ${DEFAULT_PAYLOAD_VERSION_TAG})\n -h Show help\n`)\n}\n\nfunction formatTemplates(templates: ProjectTemplate[]) {\n return `\\n\\n${spacer}${templates\n .map((t) => `${t.name}${' '.repeat(28 - t.name.length)}${t.description}`)\n .join(`\\n${spacer}`)}`\n}\n\nexport function successMessage(projectDir: string, packageManager: PackageManager): string {\n const relativePath = path.relative(process.cwd(), projectDir)\n return `\n${header('Launch Application:')}\n\n - cd ./${relativePath}\n - ${packageManager === 'npm' ? 'npm run' : packageManager} dev or follow directions in README.md\n\n${header('Documentation:')}\n\n - ${createTerminalLink(\n 'Getting Started',\n 'https://payloadcms.com/docs/getting-started/what-is-payload',\n )}\n - ${createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview')}\n\n`\n}\n\nexport function successfulNextInit(): string {\n return successfulFrameworkInit()\n}\n\nexport function successfulTanStackInit(): string {\n return successfulFrameworkInit()\n}\n\nfunction successfulFrameworkInit(): string {\n return `- ${createTerminalLink(\n 'Getting Started',\n 'https://payloadcms.com/docs/getting-started/what-is-payload',\n )}\n- ${createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview')}\n`\n}\n\nexport function moveMessage(args: { nextAppDir: string; projectDir: string }): string {\n const relativeAppDir = path.relative(process.cwd(), args.nextAppDir)\n return `\n${header('Next Steps:')}\n\nPayload does not support a top-level layout.tsx file in the app directory.\n\n${chalk.bold('To continue:')}\n\n- Create a new directory in ./${relativeAppDir} such as ./${relativeAppDir}/${chalk.bold('(app)')}\n- Move all files from ./${relativeAppDir} into that directory\n\nIt is recommended to do this from your IDE if your app has existing file references.\n\nOnce moved, rerun the create-payload-app command again.\n`\n}\n\nexport function feedbackOutro(): string {\n return `${chalk.bgCyan(chalk.black(' Have feedback? '))} Visit us on ${createTerminalLink('GitHub', 'https://github.com/payloadcms/payload')}.`\n}\n\n// Create terminalLink with fallback for unsupported terminals\nfunction createTerminalLink(text: string, url: string) {\n return terminalLink(text, url, {\n fallback: (text, url) => `${text}: ${url}`,\n })\n}\n"],"names":["chalk","path","terminalLink","getValidTemplates","DEFAULT_PAYLOAD_VERSION_TAG","header","message","bold","welcomeMessage","spacer","repeat","helpMessage","validTemplates","console","log","formatTemplates","templates","map","t","name","length","description","join","successMessage","projectDir","packageManager","relativePath","relative","process","cwd","createTerminalLink","successfulNextInit","successfulFrameworkInit","successfulTanStackInit","moveMessage","args","relativeAppDir","nextAppDir","feedbackOutro","bgCyan","black","text","url","fallback"],"mappings":"AAAA,6BAA6B,GAC7B,OAAOA,WAAW,QAAO;AACzB,OAAOC,UAAU,OAAM;AACvB,OAAOC,kBAAkB,gBAAe;AAIxC,SAASC,iBAAiB,QAAQ,sBAAqB;AACvD,SAASC,2BAA2B,QAAQ,6BAA4B;AAExE,MAAMC,SAAS,CAACC,UAA4BN,MAAMO,IAAI,CAACD;AAEvD,OAAO,MAAME,iBAAiBR,KAAK,CAAC;;AAEpC,CAAC,CAAA;AAED,MAAMS,SAAS,IAAIC,MAAM,CAAC;AAE1B,OAAO,SAASC;IACd,MAAMC,iBAAiBT;IACvBU,QAAQC,GAAG,CAACd,KAAK,CAAC;;;;;;;;;;;;;;;;;;;kCAmBc,EAAEe,gBAAgBH,gBAAgB;;;;;;;;6GAQyC,EAAER,4BAA4B;;AAE3I,CAAC;AACD;AAEA,SAASW,gBAAgBC,SAA4B;IACnD,OAAO,CAAC,IAAI,EAAEP,SAASO,UACpBC,GAAG,CAAC,CAACC,IAAM,GAAGA,EAAEC,IAAI,GAAG,IAAIT,MAAM,CAAC,KAAKQ,EAAEC,IAAI,CAACC,MAAM,IAAIF,EAAEG,WAAW,EAAE,EACvEC,IAAI,CAAC,CAAC,EAAE,EAAEb,QAAQ,GAAG;AAC1B;AAEA,OAAO,SAASc,eAAeC,UAAkB,EAAEC,cAA8B;IAC/E,MAAMC,eAAezB,KAAK0B,QAAQ,CAACC,QAAQC,GAAG,IAAIL;IAClD,OAAO,CAAC;AACV,EAAEnB,OAAO,uBAAuB;;SAEvB,EAAEqB,aAAa;IACpB,EAAED,mBAAmB,QAAQ,YAAYA,eAAe;;AAE5D,EAAEpB,OAAO,kBAAkB;;IAEvB,EAAEyB,mBACF,mBACA,+DACA;IACA,EAAEA,mBAAmB,iBAAiB,sDAAsD;;AAEhG,CAAC;AACD;AAEA,OAAO,SAASC;IACd,OAAOC;AACT;AAEA,OAAO,SAASC;IACd,OAAOD;AACT;AAEA,SAASA;IACP,OAAO,CAAC,EAAE,EAAEF,mBACV,mBACA,+DACA;EACF,EAAEA,mBAAmB,iBAAiB,sDAAsD;AAC9F,CAAC;AACD;AAEA,OAAO,SAASI,YAAYC,IAAgD;IAC1E,MAAMC,iBAAiBnC,KAAK0B,QAAQ,CAACC,QAAQC,GAAG,IAAIM,KAAKE,UAAU;IACnE,OAAO,CAAC;AACV,EAAEhC,OAAO,eAAe;;;;AAIxB,EAAEL,MAAMO,IAAI,CAAC,gBAAgB;;8BAEC,EAAE6B,eAAe,WAAW,EAAEA,eAAe,CAAC,EAAEpC,MAAMO,IAAI,CAAC,SAAS;wBAC1E,EAAE6B,eAAe;;;;;AAKzC,CAAC;AACD;AAEA,OAAO,SAASE;IACd,OAAO,GAAGtC,MAAMuC,MAAM,CAACvC,MAAMwC,KAAK,CAAC,qBAAqB,aAAa,EAAEV,mBAAmB,UAAU,yCAAyC,CAAC,CAAC;AACjJ;AAEA,8DAA8D;AAC9D,SAASA,mBAAmBW,IAAY,EAAEC,GAAW;IACnD,OAAOxC,aAAauC,MAAMC,KAAK;QAC7BC,UAAU,CAACF,MAAMC,MAAQ,GAAGD,KAAK,EAAE,EAAEC,KAAK;IAC5C;AACF"}
@@ -1,10 +1,16 @@
1
1
  /**
2
2
  * Default npm dist-tag used by the create-payload-app CLI when no
3
- * `--payload-version` is provided. The CLI scaffolds against canary by default.
3
+ * `--payload-version` is provided.
4
4
  */
5
- export declare const DEFAULT_PAYLOAD_VERSION_TAG = "canary";
5
+ export declare const DEFAULT_PAYLOAD_VERSION_TAG: string;
6
6
  /**
7
- * Resolves a package version from either an npm dist-tag (e.g. `canary`) or an
7
+ * Every package in the monorepo (this one included) is versioned and published in
8
+ * lockstep, so the CLI's own prerelease id is the dist-tag it was installed under
9
+ * (`create-payload-app@beta` -> `beta`). Stable builds resolve to `latest`.
10
+ */
11
+ export declare function resolveDefaultPayloadTag(version?: string | undefined): string;
12
+ /**
13
+ * Resolves a package version from either an npm dist-tag (e.g. `beta`) or an
8
14
  * explicit version number (e.g. `3.40.0`).
9
15
  *
10
16
  * A value matching a published dist-tag resolves to that tag's concrete version.
@@ -20,7 +26,7 @@ export declare function resolvePackageVersion({ debug, packageName, versionOrTag
20
26
  */
21
27
  packageName?: string;
22
28
  /**
23
- * An npm dist-tag (e.g. `latest`, `canary`) or an explicit version (e.g. `3.40.0`).
29
+ * An npm dist-tag (e.g. `latest`, `beta`) or an explicit version (e.g. `3.40.0`).
24
30
  *
25
31
  * @default 'latest'
26
32
  */
@@ -1 +1 @@
1
- {"version":3,"file":"resolvePackageVersion.d.ts","sourceRoot":"","sources":["../../src/utils/resolvePackageVersion.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,2BAA2B,WAAW,CAAA;AAEnD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,KAAa,EACb,WAAuB,EACvB,YAAuB,GACxB,EAAE;IACD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBlB"}
1
+ {"version":3,"file":"resolvePackageVersion.d.ts","sourceRoot":"","sources":["../../src/utils/resolvePackageVersion.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,eAAO,MAAM,2BAA2B,QAA6B,CAAA;AAErE;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,MAAM,GAAG,SAA4B,GAAG,MAAM,CAE/F;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,KAAa,EACb,WAAuB,EACvB,YAAuB,GACxB,EAAE;IACD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBlB"}
@@ -1,9 +1,21 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ /** Dist-tag used when the CLI's own version carries no prerelease id. */ const STABLE_TAG = 'latest';
5
+ /** Captures the prerelease id, e.g. `beta` from `4.0.0-beta.3`. */ const PRERELEASE_ID_PATTERN = /^\d+\.\d+\.\d+-([\da-z-]+)/i;
1
6
  /**
2
7
  * Default npm dist-tag used by the create-payload-app CLI when no
3
- * `--payload-version` is provided. The CLI scaffolds against canary by default.
4
- */ export const DEFAULT_PAYLOAD_VERSION_TAG = 'canary';
8
+ * `--payload-version` is provided.
9
+ */ export const DEFAULT_PAYLOAD_VERSION_TAG = resolveDefaultPayloadTag();
5
10
  /**
6
- * Resolves a package version from either an npm dist-tag (e.g. `canary`) or an
11
+ * Every package in the monorepo (this one included) is versioned and published in
12
+ * lockstep, so the CLI's own prerelease id is the dist-tag it was installed under
13
+ * (`create-payload-app@beta` -> `beta`). Stable builds resolve to `latest`.
14
+ */ export function resolveDefaultPayloadTag(version = readOwnVersion()) {
15
+ return version?.match(PRERELEASE_ID_PATTERN)?.[1] ?? STABLE_TAG;
16
+ }
17
+ /**
18
+ * Resolves a package version from either an npm dist-tag (e.g. `beta`) or an
7
19
  * explicit version number (e.g. `3.40.0`).
8
20
  *
9
21
  * A value matching a published dist-tag resolves to that tag's concrete version.
@@ -37,5 +49,14 @@ async function verifyVersionExists({ packageName, version }) {
37
49
  throw new Error(`No version or tag "${version}" found for package: ${packageName}`);
38
50
  }
39
51
  }
52
+ function readOwnVersion() {
53
+ try {
54
+ const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json');
55
+ const { version } = JSON.parse(readFileSync(pkgPath, 'utf8'));
56
+ return typeof version === 'string' ? version : undefined;
57
+ } catch {
58
+ return undefined;
59
+ }
60
+ }
40
61
 
41
62
  //# sourceMappingURL=resolvePackageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/resolvePackageVersion.ts"],"sourcesContent":["/**\n * Default npm dist-tag used by the create-payload-app CLI when no\n * `--payload-version` is provided. The CLI scaffolds against canary by default.\n */\nexport const DEFAULT_PAYLOAD_VERSION_TAG = 'canary'\n\n/**\n * Resolves a package version from either an npm dist-tag (e.g. `canary`) or an\n * explicit version number (e.g. `3.40.0`).\n *\n * A value matching a published dist-tag resolves to that tag's concrete version.\n * Any other value is treated as an explicit version and verified to exist on the\n * registry. Throws if neither a matching tag nor a published version is found.\n */\nexport async function resolvePackageVersion({\n debug = false,\n packageName = 'payload',\n versionOrTag = 'latest',\n}: {\n debug?: boolean\n /**\n * Package name to resolve against the npm registry.\n *\n * @default 'payload'\n */\n packageName?: string\n /**\n * An npm dist-tag (e.g. `latest`, `canary`) or an explicit version (e.g. `3.40.0`).\n *\n * @default 'latest'\n */\n versionOrTag?: string\n}): Promise<string> {\n const distTags = await fetchDistTags(packageName)\n\n const taggedVersion = distTags[versionOrTag]\n if (taggedVersion) {\n if (debug) {\n console.log(`Resolved ${packageName}@${versionOrTag} to ${taggedVersion}`)\n }\n return taggedVersion\n }\n\n await verifyVersionExists({ packageName, version: versionOrTag })\n\n if (debug) {\n console.log(`Using ${packageName}@${versionOrTag}`)\n }\n return versionOrTag\n}\n\nasync function fetchDistTags(packageName: string): Promise<Record<string, string>> {\n const response = await fetch(`https://registry.npmjs.org/-/package/${packageName}/dist-tags`)\n return (await response.json()) as Record<string, string>\n}\n\nasync function verifyVersionExists({\n packageName,\n version,\n}: {\n packageName: string\n version: string\n}): Promise<void> {\n const response = await fetch(`https://registry.npmjs.org/${packageName}/${version}`)\n if (response.status !== 200) {\n throw new Error(`No version or tag \"${version}\" found for package: ${packageName}`)\n }\n}\n"],"names":["DEFAULT_PAYLOAD_VERSION_TAG","resolvePackageVersion","debug","packageName","versionOrTag","distTags","fetchDistTags","taggedVersion","console","log","verifyVersionExists","version","response","fetch","json","status","Error"],"mappings":"AAAA;;;CAGC,GACD,OAAO,MAAMA,8BAA8B,SAAQ;AAEnD;;;;;;;CAOC,GACD,OAAO,eAAeC,sBAAsB,EAC1CC,QAAQ,KAAK,EACbC,cAAc,SAAS,EACvBC,eAAe,QAAQ,EAexB;IACC,MAAMC,WAAW,MAAMC,cAAcH;IAErC,MAAMI,gBAAgBF,QAAQ,CAACD,aAAa;IAC5C,IAAIG,eAAe;QACjB,IAAIL,OAAO;YACTM,QAAQC,GAAG,CAAC,CAAC,SAAS,EAAEN,YAAY,CAAC,EAAEC,aAAa,IAAI,EAAEG,eAAe;QAC3E;QACA,OAAOA;IACT;IAEA,MAAMG,oBAAoB;QAAEP;QAAaQ,SAASP;IAAa;IAE/D,IAAIF,OAAO;QACTM,QAAQC,GAAG,CAAC,CAAC,MAAM,EAAEN,YAAY,CAAC,EAAEC,cAAc;IACpD;IACA,OAAOA;AACT;AAEA,eAAeE,cAAcH,WAAmB;IAC9C,MAAMS,WAAW,MAAMC,MAAM,CAAC,qCAAqC,EAAEV,YAAY,UAAU,CAAC;IAC5F,OAAQ,MAAMS,SAASE,IAAI;AAC7B;AAEA,eAAeJ,oBAAoB,EACjCP,WAAW,EACXQ,OAAO,EAIR;IACC,MAAMC,WAAW,MAAMC,MAAM,CAAC,2BAA2B,EAAEV,YAAY,CAAC,EAAEQ,SAAS;IACnF,IAAIC,SAASG,MAAM,KAAK,KAAK;QAC3B,MAAM,IAAIC,MAAM,CAAC,mBAAmB,EAAEL,QAAQ,qBAAqB,EAAER,aAAa;IACpF;AACF"}
1
+ {"version":3,"sources":["../../src/utils/resolvePackageVersion.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/** Dist-tag used when the CLI's own version carries no prerelease id. */\nconst STABLE_TAG = 'latest'\n\n/** Captures the prerelease id, e.g. `beta` from `4.0.0-beta.3`. */\nconst PRERELEASE_ID_PATTERN = /^\\d+\\.\\d+\\.\\d+-([\\da-z-]+)/i\n\n/**\n * Default npm dist-tag used by the create-payload-app CLI when no\n * `--payload-version` is provided.\n */\nexport const DEFAULT_PAYLOAD_VERSION_TAG = resolveDefaultPayloadTag()\n\n/**\n * Every package in the monorepo (this one included) is versioned and published in\n * lockstep, so the CLI's own prerelease id is the dist-tag it was installed under\n * (`create-payload-app@beta` -> `beta`). Stable builds resolve to `latest`.\n */\nexport function resolveDefaultPayloadTag(version: string | undefined = readOwnVersion()): string {\n return version?.match(PRERELEASE_ID_PATTERN)?.[1] ?? STABLE_TAG\n}\n\n/**\n * Resolves a package version from either an npm dist-tag (e.g. `beta`) or an\n * explicit version number (e.g. `3.40.0`).\n *\n * A value matching a published dist-tag resolves to that tag's concrete version.\n * Any other value is treated as an explicit version and verified to exist on the\n * registry. Throws if neither a matching tag nor a published version is found.\n */\nexport async function resolvePackageVersion({\n debug = false,\n packageName = 'payload',\n versionOrTag = 'latest',\n}: {\n debug?: boolean\n /**\n * Package name to resolve against the npm registry.\n *\n * @default 'payload'\n */\n packageName?: string\n /**\n * An npm dist-tag (e.g. `latest`, `beta`) or an explicit version (e.g. `3.40.0`).\n *\n * @default 'latest'\n */\n versionOrTag?: string\n}): Promise<string> {\n const distTags = await fetchDistTags(packageName)\n\n const taggedVersion = distTags[versionOrTag]\n if (taggedVersion) {\n if (debug) {\n console.log(`Resolved ${packageName}@${versionOrTag} to ${taggedVersion}`)\n }\n return taggedVersion\n }\n\n await verifyVersionExists({ packageName, version: versionOrTag })\n\n if (debug) {\n console.log(`Using ${packageName}@${versionOrTag}`)\n }\n return versionOrTag\n}\n\nasync function fetchDistTags(packageName: string): Promise<Record<string, string>> {\n const response = await fetch(`https://registry.npmjs.org/-/package/${packageName}/dist-tags`)\n return (await response.json()) as Record<string, string>\n}\n\nasync function verifyVersionExists({\n packageName,\n version,\n}: {\n packageName: string\n version: string\n}): Promise<void> {\n const response = await fetch(`https://registry.npmjs.org/${packageName}/${version}`)\n if (response.status !== 200) {\n throw new Error(`No version or tag \"${version}\" found for package: ${packageName}`)\n }\n}\n\nfunction readOwnVersion(): string | undefined {\n try {\n const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json')\n const { version } = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version?: unknown }\n return typeof version === 'string' ? version : undefined\n } catch {\n return undefined\n }\n}\n"],"names":["readFileSync","dirname","resolve","fileURLToPath","STABLE_TAG","PRERELEASE_ID_PATTERN","DEFAULT_PAYLOAD_VERSION_TAG","resolveDefaultPayloadTag","version","readOwnVersion","match","resolvePackageVersion","debug","packageName","versionOrTag","distTags","fetchDistTags","taggedVersion","console","log","verifyVersionExists","response","fetch","json","status","Error","pkgPath","url","JSON","parse","undefined"],"mappings":"AAAA,SAASA,YAAY,QAAQ,UAAS;AACtC,SAASC,OAAO,EAAEC,OAAO,QAAQ,YAAW;AAC5C,SAASC,aAAa,QAAQ,WAAU;AAExC,uEAAuE,GACvE,MAAMC,aAAa;AAEnB,iEAAiE,GACjE,MAAMC,wBAAwB;AAE9B;;;CAGC,GACD,OAAO,MAAMC,8BAA8BC,2BAA0B;AAErE;;;;CAIC,GACD,OAAO,SAASA,yBAAyBC,UAA8BC,gBAAgB;IACrF,OAAOD,SAASE,MAAML,wBAAwB,CAAC,EAAE,IAAID;AACvD;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeO,sBAAsB,EAC1CC,QAAQ,KAAK,EACbC,cAAc,SAAS,EACvBC,eAAe,QAAQ,EAexB;IACC,MAAMC,WAAW,MAAMC,cAAcH;IAErC,MAAMI,gBAAgBF,QAAQ,CAACD,aAAa;IAC5C,IAAIG,eAAe;QACjB,IAAIL,OAAO;YACTM,QAAQC,GAAG,CAAC,CAAC,SAAS,EAAEN,YAAY,CAAC,EAAEC,aAAa,IAAI,EAAEG,eAAe;QAC3E;QACA,OAAOA;IACT;IAEA,MAAMG,oBAAoB;QAAEP;QAAaL,SAASM;IAAa;IAE/D,IAAIF,OAAO;QACTM,QAAQC,GAAG,CAAC,CAAC,MAAM,EAAEN,YAAY,CAAC,EAAEC,cAAc;IACpD;IACA,OAAOA;AACT;AAEA,eAAeE,cAAcH,WAAmB;IAC9C,MAAMQ,WAAW,MAAMC,MAAM,CAAC,qCAAqC,EAAET,YAAY,UAAU,CAAC;IAC5F,OAAQ,MAAMQ,SAASE,IAAI;AAC7B;AAEA,eAAeH,oBAAoB,EACjCP,WAAW,EACXL,OAAO,EAIR;IACC,MAAMa,WAAW,MAAMC,MAAM,CAAC,2BAA2B,EAAET,YAAY,CAAC,EAAEL,SAAS;IACnF,IAAIa,SAASG,MAAM,KAAK,KAAK;QAC3B,MAAM,IAAIC,MAAM,CAAC,mBAAmB,EAAEjB,QAAQ,qBAAqB,EAAEK,aAAa;IACpF;AACF;AAEA,SAASJ;IACP,IAAI;QACF,MAAMiB,UAAUxB,QAAQD,QAAQE,cAAc,YAAYwB,GAAG,IAAI,MAAM,MAAM;QAC7E,MAAM,EAAEnB,OAAO,EAAE,GAAGoB,KAAKC,KAAK,CAAC7B,aAAa0B,SAAS;QACrD,OAAO,OAAOlB,YAAY,WAAWA,UAAUsB;IACjD,EAAE,OAAM;QACN,OAAOA;IACT;AACF"}
package/package.json CHANGED
@@ -1,12 +1,7 @@
1
1
  {
2
2
  "name": "create-payload-app",
3
- "version": "4.0.0-internal.ea6e8f8",
3
+ "version": "4.0.0-internal.ec73d44",
4
4
  "homepage": "https://payloadcms.com",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/payloadcms/payload.git",
8
- "directory": "packages/create-payload-app"
9
- },
10
5
  "license": "MIT",
11
6
  "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
12
7
  "maintainers": [
@@ -16,8 +11,21 @@
16
11
  "url": "https://payloadcms.com"
17
12
  }
18
13
  ],
19
- "sideEffects": false,
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/payloadcms/payload.git",
17
+ "directory": "packages/create-payload-app"
18
+ },
19
+ "bin": {
20
+ "create-payload-app": "bin/cli.js"
21
+ },
22
+ "files": [
23
+ "package.json",
24
+ "dist",
25
+ "bin"
26
+ ],
20
27
  "type": "module",
28
+ "sideEffects": false,
21
29
  "exports": {
22
30
  "./types": {
23
31
  "import": "./src/types.ts",
@@ -39,14 +47,6 @@
39
47
  "types": "./src/utils/*"
40
48
  }
41
49
  },
42
- "bin": {
43
- "create-payload-app": "bin/cli.js"
44
- },
45
- "files": [
46
- "package.json",
47
- "dist",
48
- "bin"
49
- ],
50
50
  "dependencies": {
51
51
  "@clack/prompts": "^0.7.0",
52
52
  "@sindresorhus/slugify": "^1.1.0",
@@ -59,7 +59,7 @@
59
59
  "figures": "^6.1.0",
60
60
  "fs-extra": "^9.0.1",
61
61
  "globby": "11.1.0",
62
- "prettier": "^3.5.0",
62
+ "oxfmt": "^0.73.0",
63
63
  "tar": "^7.5.22",
64
64
  "terminal-link": "^2.1.1",
65
65
  "ts-morph": "^28.0.0"
@@ -70,15 +70,13 @@
70
70
  "@types/node": "24.12.3"
71
71
  },
72
72
  "engines": {
73
- "node": ">=24.15.0"
73
+ "node": ">=24.22.1"
74
74
  },
75
75
  "scripts": {
76
76
  "build": "pnpm pack-template-files && pnpm typecheck && pnpm build:swc",
77
77
  "build:debug": "pnpm build",
78
78
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
79
79
  "clean": "rimraf -g {dist,*.tsbuildinfo}",
80
- "lint": "eslint .",
81
- "lint:fix": "eslint . --fix",
82
80
  "pack-template-files": "node --no-deprecation --import @swc-node/register/esm-register src/scripts/pack-template-files.ts",
83
81
  "test": "vitest --run",
84
82
  "typecheck": "tsc"