@payloadcms/codemod 4.0.0-internal.77191e5 → 4.0.0-internal.8001944
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -30
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.help.d.ts +4 -0
- package/dist/cli.help.d.ts.map +1 -0
- package/dist/cli.help.js +29 -0
- package/dist/cli.help.js.map +1 -0
- package/dist/cli.js +49 -27
- package/dist/cli.js.map +1 -1
- package/dist/cli.parseFlags.d.ts +15 -0
- package/dist/cli.parseFlags.d.ts.map +1 -1
- package/dist/cli.parseFlags.js +35 -2
- package/dist/cli.parseFlags.js.map +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +8 -0
- package/dist/registry.js.map +1 -1
- package/dist/runbook/payload-v4-upgrade.md +55 -0
- package/dist/runbook/v4.mdx +2179 -0
- package/dist/transforms/add-override-access-true/basic.input.js +41 -0
- package/dist/transforms/add-override-access-true/basic.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/basic.output.js +50 -0
- package/dist/transforms/add-override-access-true/basic.output.js.map +1 -0
- package/dist/transforms/add-override-access-true/comment-between-properties.input.js +11 -0
- package/dist/transforms/add-override-access-true/comment-between-properties.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/comment-between-properties.output.js +12 -0
- package/dist/transforms/add-override-access-true/comment-between-properties.output.js.map +1 -0
- package/dist/transforms/add-override-access-true/index.d.ts +20 -0
- package/dist/transforms/add-override-access-true/index.d.ts.map +1 -0
- package/dist/transforms/add-override-access-true/index.js +208 -0
- package/dist/transforms/add-override-access-true/index.js.map +1 -0
- package/dist/transforms/add-override-access-true/javascript.input.d.ts +6 -0
- package/dist/transforms/add-override-access-true/javascript.input.d.ts.map +1 -0
- package/dist/transforms/add-override-access-true/javascript.input.js +24 -0
- package/dist/transforms/add-override-access-true/javascript.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/javascript.output.d.ts +6 -0
- package/dist/transforms/add-override-access-true/javascript.output.d.ts.map +1 -0
- package/dist/transforms/add-override-access-true/javascript.output.js +26 -0
- package/dist/transforms/add-override-access-true/javascript.output.js.map +1 -0
- package/dist/transforms/add-override-access-true/non-matching.input.js +42 -0
- package/dist/transforms/add-override-access-true/non-matching.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/non-matching.output.js +42 -0
- package/dist/transforms/add-override-access-true/non-matching.output.js.map +1 -0
- package/dist/transforms/add-override-access-true/single-line.input.js +13 -0
- package/dist/transforms/add-override-access-true/single-line.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/single-line.output.js +17 -0
- package/dist/transforms/add-override-access-true/single-line.output.js.map +1 -0
- package/dist/transforms/add-override-access-true/trailing-comment.input.js +10 -0
- package/dist/transforms/add-override-access-true/trailing-comment.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/trailing-comment.output.js +12 -0
- package/dist/transforms/add-override-access-true/trailing-comment.output.js.map +1 -0
- package/dist/transforms/migrate-aliased-exports/index.d.ts.map +1 -1
- package/dist/transforms/migrate-aliased-exports/index.js +6 -5
- package/dist/transforms/migrate-aliased-exports/index.js.map +1 -1
- package/dist/transforms/migrate-aliased-exports/request.input.js +6 -0
- package/dist/transforms/migrate-aliased-exports/request.input.js.map +1 -0
- package/dist/transforms/migrate-aliased-exports/request.output.js +5 -0
- package/dist/transforms/migrate-aliased-exports/request.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/already-set.input.js +15 -0
- package/dist/transforms/migrate-authorship-default/already-set.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/already-set.output.js +15 -0
- package/dist/transforms/migrate-authorship-default/already-set.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/basic.input.js +16 -0
- package/dist/transforms/migrate-authorship-default/basic.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/basic.output.js +18 -0
- package/dist/transforms/migrate-authorship-default/basic.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/build-config.input.js +32 -0
- package/dist/transforms/migrate-authorship-default/build-config.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/build-config.output.js +35 -0
- package/dist/transforms/migrate-authorship-default/build-config.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/globals.input.js +16 -0
- package/dist/transforms/migrate-authorship-default/globals.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/globals.output.js +17 -0
- package/dist/transforms/migrate-authorship-default/globals.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/index.d.ts +11 -0
- package/dist/transforms/migrate-authorship-default/index.d.ts.map +1 -0
- package/dist/transforms/migrate-authorship-default/index.js +141 -0
- package/dist/transforms/migrate-authorship-default/index.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/non-matching.input.js +18 -0
- package/dist/transforms/migrate-authorship-default/non-matching.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/non-matching.output.js +18 -0
- package/dist/transforms/migrate-authorship-default/non-matching.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/satisfies.input.js +11 -0
- package/dist/transforms/migrate-authorship-default/satisfies.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/satisfies.output.js +13 -0
- package/dist/transforms/migrate-authorship-default/satisfies.output.js.map +1 -0
- package/dist/transforms/migrate-field-component-types/basic.input.js +8 -0
- package/dist/transforms/migrate-field-component-types/basic.input.js.map +1 -0
- package/dist/transforms/migrate-field-component-types/basic.output.js +8 -0
- package/dist/transforms/migrate-field-component-types/basic.output.js.map +1 -0
- package/dist/transforms/migrate-field-component-types/index.d.ts +3 -0
- package/dist/transforms/migrate-field-component-types/index.d.ts.map +1 -0
- package/dist/transforms/migrate-field-component-types/index.js +620 -0
- package/dist/transforms/migrate-field-component-types/index.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.input.js +8 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.output.js +31 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/collision.input.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/collision.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/comments.input.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/comments.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/comments.output.js +34 -0
- package/dist/transforms/migrate-payload-request-creation/comments.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/empty.input.js +5 -0
- package/dist/transforms/migrate-payload-request-creation/empty.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/empty.output.js +7 -0
- package/dist/transforms/migrate-payload-request-creation/empty.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/evaluation-order.input.js +10 -0
- package/dist/transforms/migrate-payload-request-creation/evaluation-order.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/expression.input.js +8 -0
- package/dist/transforms/migrate-payload-request-creation/expression.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/expression.output.js +8 -0
- package/dist/transforms/migrate-payload-request-creation/expression.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/getters.input.js +52 -0
- package/dist/transforms/migrate-payload-request-creation/getters.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/index.d.ts +3 -0
- package/dist/transforms/migrate-payload-request-creation/index.d.ts.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/index.js +236 -0
- package/dist/transforms/migrate-payload-request-creation/index.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/internal.input.js +6 -0
- package/dist/transforms/migrate-payload-request-creation/internal.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/internal.output.js +6 -0
- package/dist/transforms/migrate-payload-request-creation/internal.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/non-matching.input.js +5 -0
- package/dist/transforms/migrate-payload-request-creation/non-matching.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/populated.input.js +7 -0
- package/dist/transforms/migrate-payload-request-creation/populated.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/populated.output.js +30 -0
- package/dist/transforms/migrate-payload-request-creation/populated.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.input.js +7 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.output.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.input.js +12 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.output.js +12 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/unsupported.input.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/unsupported.input.js.map +1 -0
- package/dist/transforms/migrate-versions-default/index.js +5 -5
- package/dist/transforms/migrate-versions-default/index.js.map +1 -1
- package/dist/transforms/remove-publish-specific-locale/index.d.ts.map +1 -1
- package/dist/transforms/remove-publish-specific-locale/index.js.map +1 -1
- package/dist/transforms/remove-storage-always-insert-fields/index.d.ts.map +1 -1
- package/dist/transforms/remove-storage-always-insert-fields/index.js +4 -0
- package/dist/transforms/remove-storage-always-insert-fields/index.js.map +1 -1
- package/dist/transforms/remove-versions-true/index.js +4 -4
- package/dist/transforms/remove-versions-true/index.js.map +1 -1
- package/dist/transforms/rename-experimental-table-feature/index.d.ts.map +1 -1
- package/dist/transforms/rename-experimental-table-feature/index.js +7 -1
- package/dist/transforms/rename-experimental-table-feature/index.js.map +1 -1
- package/dist/upgrade/defaultTag.d.ts +9 -0
- package/dist/upgrade/defaultTag.d.ts.map +1 -0
- package/dist/upgrade/defaultTag.js +25 -0
- package/dist/upgrade/defaultTag.js.map +1 -0
- package/dist/upgrade/detectPackageManager.d.ts +8 -0
- package/dist/upgrade/detectPackageManager.d.ts.map +1 -0
- package/dist/upgrade/detectPackageManager.js +38 -0
- package/dist/upgrade/detectPackageManager.js.map +1 -0
- package/dist/upgrade/dispatch.d.ts +38 -0
- package/dist/upgrade/dispatch.d.ts.map +1 -0
- package/dist/upgrade/dispatch.js +132 -0
- package/dist/upgrade/dispatch.js.map +1 -0
- package/dist/upgrade/index.d.ts +25 -0
- package/dist/upgrade/index.d.ts.map +1 -0
- package/dist/upgrade/index.js +209 -0
- package/dist/upgrade/index.js.map +1 -0
- package/dist/upgrade/prompt.d.ts +14 -0
- package/dist/upgrade/prompt.d.ts.map +1 -0
- package/dist/upgrade/prompt.js +77 -0
- package/dist/upgrade/prompt.js.map +1 -0
- package/dist/upgrade/report.d.ts +21 -0
- package/dist/upgrade/report.d.ts.map +1 -0
- package/dist/upgrade/report.js +47 -0
- package/dist/upgrade/report.js.map +1 -0
- package/dist/upgrade/resolveVersions.d.ts +13 -0
- package/dist/upgrade/resolveVersions.d.ts.map +1 -0
- package/dist/upgrade/resolveVersions.js +55 -0
- package/dist/upgrade/resolveVersions.js.map +1 -0
- package/dist/upgrade/rewritePackageJson.d.ts +32 -0
- package/dist/upgrade/rewritePackageJson.d.ts.map +1 -0
- package/dist/upgrade/rewritePackageJson.js +164 -0
- package/dist/upgrade/rewritePackageJson.js.map +1 -0
- package/dist/upgrade/runInstall.d.ts +16 -0
- package/dist/upgrade/runInstall.d.ts.map +1 -0
- package/dist/upgrade/runInstall.js +17 -0
- package/dist/upgrade/runInstall.js.map +1 -0
- package/dist/upgrade/selectAgent.d.ts +45 -0
- package/dist/upgrade/selectAgent.d.ts.map +1 -0
- package/dist/upgrade/selectAgent.js +54 -0
- package/dist/upgrade/selectAgent.js.map +1 -0
- package/dist/upgrade/selfCommand.d.ts +13 -0
- package/dist/upgrade/selfCommand.d.ts.map +1 -0
- package/dist/upgrade/selfCommand.js +17 -0
- package/dist/upgrade/selfCommand.js.map +1 -0
- package/dist/upgrade/types.d.ts +47 -0
- package/dist/upgrade/types.d.ts.map +1 -0
- package/dist/upgrade/types.js +11 -0
- package/dist/upgrade/types.js.map +1 -0
- package/dist/utils/project.d.ts +10 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +43 -0
- package/dist/utils/project.js.map +1 -0
- package/package.json +8 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/index.ts"],"sourcesContent":["import type { CallExpression, ImportSpecifier, TypeReferenceNode } from 'ts-morph'\n\nimport { Node, SymbolFlags, SyntaxKind, VariableDeclarationKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst RENAMES = {\n payload: {\n createLocalReq: 'createPayloadRequest',\n CreateLocalReqOptions: 'CreatePayloadRequestArgs',\n createPayloadRequest: 'createPayloadRequestFromWebRequest',\n InitReqResult: 'AdminContext',\n },\n 'payload/internal': {\n initReq: 'initAdminContext',\n InitReqArgs: 'InitAdminContextArgs',\n InitReqCache: 'AdminContextCache',\n InitReqPartialResult: 'PartialAdminContext',\n },\n} as const\n\nconst OPTION_NAMES = [\n 'context',\n 'depth',\n 'fallbackLocale',\n 'locale',\n 'req',\n 'urlSuffix',\n 'user',\n] as const\n\nconst getImportPriority = (name: string): number => {\n if (name === 'createPayloadRequest') {\n return 0\n }\n\n if (name === 'CreateLocalReqOptions') {\n return 2\n }\n\n return 1\n}\n\nexport const migratePayloadRequestCreation: Transform = {\n name: 'migrate-payload-request-creation',\n apply: ({ project }) => {\n const originals = new Map(project.getSourceFiles().map((file) => [file, file.getFullText()]))\n const notes: string[] = []\n\n for (const file of project.getSourceFiles()) {\n // Check call options before replacing type imports that may only resolve after upgrading Payload.\n const imports = file\n .getImportDeclarations()\n .flatMap((declaration) =>\n declaration\n .getNamedImports()\n .map((spec) => ({ source: declaration.getModuleSpecifierValue(), spec })),\n )\n .sort((a, b) => getImportPriority(a.spec.getName()) - getImportPriority(b.spec.getName()))\n\n for (const { source, spec } of imports) {\n if (source !== 'payload' && (source.startsWith('.') || source.startsWith('payload/'))) {\n if (spec.getName() === 'CreateLocalReqOptions') {\n notes.push(\n `${file.getFilePath()}: Unsupported CreateLocalReqOptions import source \\`${source}\\`; migrate this private/relative type import manually to Omit<CreatePayloadRequestArgs, 'payload'> from payload.`,\n )\n }\n }\n\n if (!Object.hasOwn(RENAMES, source)) {\n continue\n }\n\n const renames: Record<string, string> = RENAMES[source as keyof typeof RENAMES]\n\n const importedName = spec.getName()\n const aliasName = spec.getAliasNode()?.getText()\n const isAliasedExportMigrationArtifact =\n source === 'payload' &&\n importedName === 'createPayloadRequestFromWebRequest' &&\n aliasName === 'createPayloadRequest'\n const originalName = isAliasedExportMigrationArtifact ? aliasName : importedName\n\n if (!Object.hasOwn(renames, originalName)) {\n continue\n }\n\n const newName = renames[originalName]!\n const hadAlias = Boolean(spec.getAliasNode())\n\n // An explicit alias limits ts-morph references and renames to this local binding.\n // Renaming an unaliased import can also rename the dependency's export.\n if (!hadAlias) {\n spec.setAlias(originalName)\n }\n\n const binding = spec.getAliasNode()!\n const references = binding.findReferencesAsNodes().filter((node) => node !== binding)\n const isCurrentPayloadRequestCreator =\n source === 'payload' &&\n importedName === 'createPayloadRequest' &&\n !isAliasedExportMigrationArtifact &&\n references.some(isPayloadRequestCreationReference)\n\n if (isCurrentPayloadRequestCreator) {\n if (!hadAlias) {\n spec.removeAlias()\n }\n continue\n }\n\n const hasCollision =\n (!hadAlias || isAliasedExportMigrationArtifact) &&\n [binding, ...references].some((node) =>\n node\n .getSymbolsInScope(SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Alias)\n .some((symbol) => symbol.getName() === newName),\n )\n\n if (hasCollision) {\n notes.push(\n `${file.getFilePath()}: Skipped \\`${binding.getText()}\\`: binding collision with \\`${newName}\\`; migrate manually.`,\n )\n if (!hadAlias) {\n spec.removeAlias()\n }\n continue\n }\n\n const calls: CallExpression[] = []\n const optionsTypes: TypeReferenceNode[] = []\n let hasUnsupportedUse = false\n\n if (source === 'payload' && originalName === 'CreateLocalReqOptions') {\n for (const reference of references) {\n const parent = reference.getParent()\n const omitSymbol = reference\n .getSymbolsInScope(SymbolFlags.Type | SymbolFlags.Alias)\n .find((symbol) => symbol.getName() === 'Omit')\n const isOmitShadowed = omitSymbol\n ?.getDeclarations()\n .some((node) => node.getSourceFile().getBaseName() !== 'lib.es5.d.ts')\n\n if (\n Node.isTypeReference(parent) &&\n parent.getTypeName() === reference &&\n parent.getTypeArguments().length === 0 &&\n !isOmitShadowed\n ) {\n optionsTypes.push(parent)\n } else {\n hasUnsupportedUse = true\n notes.push(\n `${reference.getSourceFile().getFilePath()}:${reference.getStartLineNumber()}: Unsupported CreateLocalReqOptions usage \\`${parent?.getText() ?? reference.getText()}\\` or shadowed Omit type; left the import and all its uses unchanged. Migrate manually to an options-only type.`,\n )\n }\n }\n }\n\n if (source === 'payload' && originalName === 'createLocalReq') {\n for (const reference of references) {\n const parent = reference.getParent()\n\n if (\n Node.isCallExpression(parent) &&\n parent.getExpression() === reference &&\n !parent.getQuestionDotTokenNode() &&\n parent.getArguments().length === 2 &&\n !parent.getArguments().some(Node.isSpreadElement)\n ) {\n const [optionsArgument, payloadArgument] = parent.getArguments()\n const unsafeOptionsReason = getUnsafeOptionsReason({ options: optionsArgument! })\n\n if (!Node.isIdentifier(payloadArgument)) {\n hasUnsupportedUse = true\n notes.push(\n `${reference.getSourceFile().getFilePath()}:${reference.getStartLineNumber()}: Unsupported payload argument \\`${payloadArgument!.getText()}\\` in \\`${parent.getText()}\\`: automatic migration cannot preserve evaluation order. Left the import and all its uses unchanged; migrate manually.`,\n )\n } else if (unsafeOptionsReason) {\n hasUnsupportedUse = true\n notes.push(\n `${reference.getSourceFile().getFilePath()}:${reference.getStartLineNumber()}: Unsupported options argument \\`${optionsArgument!.getText()}\\` in \\`${parent.getText()}\\`: ${unsafeOptionsReason}. Left the import and all its uses unchanged; migrate manually.`,\n )\n } else {\n calls.push(parent)\n }\n } else {\n hasUnsupportedUse = true\n notes.push(\n `${reference.getSourceFile().getFilePath()}:${reference.getStartLineNumber()}: Unsupported use of \\`${binding.getText()}\\`: \\`${parent?.getText() ?? reference.getText()}\\`. Left the import and all its uses unchanged; migrate manually.`,\n )\n }\n }\n }\n\n if (hasUnsupportedUse) {\n if (!hadAlias) {\n spec.removeAlias()\n }\n continue\n }\n\n renameImport({ hadAlias, isAliasedExportMigrationArtifact, newName, spec })\n\n for (const optionsType of optionsTypes.sort((a, b) => b.getStart() - a.getStart())) {\n optionsType.replaceWithText(`Omit<${optionsType.getText()}, 'payload'>`)\n }\n\n // Inner calls must be rewritten before replacing an enclosing call's text.\n for (const call of calls.sort((a, b) => b.getStart() - a.getStart())) {\n rewriteCall({ call })\n }\n }\n }\n\n return {\n filesChanged: [...originals]\n .filter(([file, original]) => file.getFullText() !== original)\n .map(([file]) => file.getFilePath()),\n ...(notes.length > 0 ? { notes } : {}),\n }\n },\n description:\n 'Renames Payload request and admin-context imports, preserves options-only types, and migrates safe createLocalReq calls by capturing payload before projecting the seven old option properties; reports unsupported bindings for manual migration.',\n}\n\nfunction isPayloadRequestCreationReference(reference: Node): boolean {\n const parent = reference.getParent()\n\n if (\n !Node.isCallExpression(parent) ||\n parent.getExpression() !== reference ||\n parent.getArguments().length !== 1\n ) {\n return false\n }\n\n const [argument] = parent.getArguments()\n\n return (\n (Node.isObjectLiteralExpression(argument) && Boolean(argument.getProperty('payload'))) ||\n Boolean(argument?.getType().getProperty('payload'))\n )\n}\n\nfunction getUnsafeOptionsReason({ options }: { options: Node }): string | undefined {\n if (Node.isObjectLiteralExpression(options)) {\n return options.getProperties().length === 0\n ? undefined\n : 'only an empty inline options object can be migrated safely'\n }\n\n if (!Node.isIdentifier(options)) {\n return 'expected {} or a stable local const options identifier to preserve option reads and evaluation order'\n }\n\n const declarations = options.getSymbol()?.getDeclarations()\n const declaration = declarations?.length === 1 ? declarations[0] : undefined\n\n const isStable =\n Node.isVariableDeclaration(declaration) &&\n declaration.getSourceFile() === options.getSourceFile() &&\n Node.isIdentifier(declaration.getNameNode()) &&\n Boolean(declaration.getInitializer()) &&\n declaration.getVariableStatement()?.getDeclarationKind() === VariableDeclarationKind.Const\n\n if (!isStable) {\n return 'the options identifier must resolve to an initialized local const binding so getters cannot change the receiver between property reads'\n }\n\n const type = options.getType()\n const missing = type.isAny() ? [] : OPTION_NAMES.filter((name) => !type.getProperty(name))\n\n if (missing.length > 0) {\n return `the options type does not expose ${missing.join(', ')}; projecting these properties would be unsafe for typechecking`\n }\n\n return undefined\n}\n\nfunction renameImport({\n hadAlias,\n isAliasedExportMigrationArtifact,\n newName,\n spec,\n}: {\n hadAlias: boolean\n isAliasedExportMigrationArtifact: boolean\n newName: string\n spec: ImportSpecifier\n}): void {\n if (isAliasedExportMigrationArtifact) {\n spec.getAliasNode()!.rename(newName, { usePrefixAndSuffixText: true })\n spec.removeAlias()\n } else if (hadAlias) {\n spec.setName(newName)\n } else {\n spec.getAliasNode()!.rename(newName, { usePrefixAndSuffixText: true })\n spec.setName(newName)\n spec.removeAlias()\n }\n}\n\nfunction rewriteCall({ call }: { call: CallExpression }): void {\n const [options, payload] = call.getArguments()\n const open = call.getFirstChildByKindOrThrow(SyntaxKind.OpenParenToken)\n const close = call.getLastChildByKindOrThrow(SyntaxKind.CloseParenToken)\n const commas = options!\n .getParentSyntaxListOrThrow()\n .getChildren()\n .filter((node) => node.getKind() === SyntaxKind.CommaToken)\n const comma = commas[0]!\n const trailingComma = commas[1]\n const text = call.getSourceFile().getFullText()\n const isEmpty = Node.isObjectLiteralExpression(options) && options.getProperties().length === 0\n const prefix = [\n text.slice(open.getEnd(), options!.getStart()),\n isEmpty ? options.getText().slice(1, -1) : '',\n text.slice(options!.getEnd(), comma.getStart()),\n text.slice(comma.getEnd(), payload!.getStart()),\n ].join('')\n // Forward reads into the async helper so throwing option getters still reject its promise.\n const contents = [\n prefix.trim() ? prefix : ' ',\n 'payload: ',\n payload!.getText(),\n text.slice(payload!.getEnd(), trailingComma?.getStart() ?? close.getStart()),\n isEmpty\n ? ''\n : `, ${OPTION_NAMES.map((name) => `get ${name}() { return ${options!.getText()}.${name} }`).join(', ')}`,\n trailingComma ? text.slice(trailingComma.getStart(), close.getStart()) : ' ',\n ].join('')\n\n call.replaceWithText(\n `${text.slice(call.getStart(), open.getEnd())}{${contents}}${text.slice(close.getStart(), call.getEnd())}`,\n )\n}\n"],"names":["Node","SymbolFlags","SyntaxKind","VariableDeclarationKind","RENAMES","payload","createLocalReq","CreateLocalReqOptions","createPayloadRequest","InitReqResult","initReq","InitReqArgs","InitReqCache","InitReqPartialResult","OPTION_NAMES","getImportPriority","name","migratePayloadRequestCreation","apply","project","originals","Map","getSourceFiles","map","file","getFullText","notes","imports","getImportDeclarations","flatMap","declaration","getNamedImports","spec","source","getModuleSpecifierValue","sort","a","b","getName","startsWith","push","getFilePath","Object","hasOwn","renames","importedName","aliasName","getAliasNode","getText","isAliasedExportMigrationArtifact","originalName","newName","hadAlias","Boolean","setAlias","binding","references","findReferencesAsNodes","filter","node","isCurrentPayloadRequestCreator","some","isPayloadRequestCreationReference","removeAlias","hasCollision","getSymbolsInScope","Value","Type","Alias","symbol","calls","optionsTypes","hasUnsupportedUse","reference","parent","getParent","omitSymbol","find","isOmitShadowed","getDeclarations","getSourceFile","getBaseName","isTypeReference","getTypeName","getTypeArguments","length","getStartLineNumber","isCallExpression","getExpression","getQuestionDotTokenNode","getArguments","isSpreadElement","optionsArgument","payloadArgument","unsafeOptionsReason","getUnsafeOptionsReason","options","isIdentifier","renameImport","optionsType","getStart","replaceWithText","call","rewriteCall","filesChanged","original","description","argument","isObjectLiteralExpression","getProperty","getType","getProperties","undefined","declarations","getSymbol","isStable","isVariableDeclaration","getNameNode","getInitializer","getVariableStatement","getDeclarationKind","Const","type","missing","isAny","join","rename","usePrefixAndSuffixText","setName","open","getFirstChildByKindOrThrow","OpenParenToken","close","getLastChildByKindOrThrow","CloseParenToken","commas","getParentSyntaxListOrThrow","getChildren","getKind","CommaToken","comma","trailingComma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F,QAAQ,IAAI6B,KAAKiB,MAAM,IAAI,CAAC,EAAEC,SAAS,CAAC,EAAEL,KAAKG,KAAK,CAACb,MAAMhC,QAAQ,IAAIE,KAAK4C,MAAM,KAAK;AAE9G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/internal.input.ts"],"sourcesContent":["import { initReq, type InitReqArgs, type InitReqCache, type InitReqPartialResult } from 'payload/internal'\nimport { initReq as initialize, type InitReqArgs as Args } from 'payload/internal'\n\nconst context = initReq(args as InitReqArgs)\nconst aliased = initialize(args as Args)\ntype Cache = InitReqCache\ntype PartialContext = InitReqPartialResult\n"],"names":["initReq","initialize","context","args","aliased"],"mappings":"AAAA,SAASA,OAAO,QAAwE,mBAAkB;AAC1G,SAASA,WAAWC,UAAU,QAAkC,mBAAkB;AAElF,MAAMC,UAAUF,QAAQG;AACxB,MAAMC,UAAUH,WAAWE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/internal.output.ts"],"sourcesContent":["import { initAdminContext, type InitAdminContextArgs, type AdminContextCache, type PartialAdminContext } from 'payload/internal'\nimport { initAdminContext as initialize, type InitAdminContextArgs as Args } from 'payload/internal'\n\nconst context = initAdminContext(args as InitAdminContextArgs)\nconst aliased = initialize(args as Args)\ntype Cache = AdminContextCache\ntype PartialContext = PartialAdminContext\n"],"names":["initAdminContext","initialize","context","args","aliased"],"mappings":"AAAA,SAASA,gBAAgB,QAAqF,mBAAkB;AAChI,SAASA,oBAAoBC,UAAU,QAA2C,mBAAkB;AAEpG,MAAMC,UAAUF,iBAAiBG;AACjC,MAAMC,UAAUH,WAAWE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/non-matching.input.ts"],"sourcesContent":["import { createLocalReq, initReq, type InitReqResult } from 'unrelated'\nimport { unrelated } from 'payload'\n\nconst req=createLocalReq({},payload);\nconst context = initReq(args)\ntype Result = InitReqResult\n"],"names":["createLocalReq","initReq","req","payload","context","args"],"mappings":"AAAA,SAASA,cAAc,EAAEC,OAAO,QAA4B,YAAW;AAGvE,MAAMC,MAAIF,eAAe,CAAC,GAAEG;AAC5B,MAAMC,UAAUH,QAAQI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/populated.input.ts"],"sourcesContent":["import { createLocalReq, type CreateLocalReqOptions } from 'payload'\n\nconst options: CreateLocalReqOptions = { user }\nconst req = await createLocalReq(options, payload)\n"],"names":["createLocalReq","options","user","req","payload"],"mappings":"AAAA,SAASA,cAAc,QAAoC,UAAS;AAEpE,MAAMC,UAAiC;IAAEC;AAAK;AAC9C,MAAMC,MAAM,MAAMH,eAAeC,SAASG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createPayloadRequest } from 'payload';
|
|
2
|
+
const options = {
|
|
3
|
+
user
|
|
4
|
+
};
|
|
5
|
+
const req = await createPayloadRequest({
|
|
6
|
+
payload: payload,
|
|
7
|
+
get context () {
|
|
8
|
+
return options.context;
|
|
9
|
+
},
|
|
10
|
+
get depth () {
|
|
11
|
+
return options.depth;
|
|
12
|
+
},
|
|
13
|
+
get fallbackLocale () {
|
|
14
|
+
return options.fallbackLocale;
|
|
15
|
+
},
|
|
16
|
+
get locale () {
|
|
17
|
+
return options.locale;
|
|
18
|
+
},
|
|
19
|
+
get req () {
|
|
20
|
+
return options.req;
|
|
21
|
+
},
|
|
22
|
+
get urlSuffix () {
|
|
23
|
+
return options.urlSuffix;
|
|
24
|
+
},
|
|
25
|
+
get user () {
|
|
26
|
+
return options.user;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=populated.output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/populated.output.ts"],"sourcesContent":["import { createPayloadRequest, type CreatePayloadRequestArgs } from 'payload'\n\nconst options: Omit<CreatePayloadRequestArgs, 'payload'> = { user }\nconst req = await createPayloadRequest({ payload: payload, get context() { return options.context }, get depth() { return options.depth }, get fallbackLocale() { return options.fallbackLocale }, get locale() { return options.locale }, get req() { return options.req }, get urlSuffix() { return options.urlSuffix }, get user() { return options.user } })\n"],"names":["createPayloadRequest","options","user","req","payload","context","depth","fallbackLocale","locale","urlSuffix"],"mappings":"AAAA,SAASA,oBAAoB,QAAuC,UAAS;AAE7E,MAAMC,UAAqD;IAAEC;AAAK;AAClE,MAAMC,MAAM,MAAMH,qBAAqB;IAAEI,SAASA;IAAS,IAAIC,WAAU;QAAE,OAAOJ,QAAQI,OAAO;IAAC;IAAG,IAAIC,SAAQ;QAAE,OAAOL,QAAQK,KAAK;IAAC;IAAG,IAAIC,kBAAiB;QAAE,OAAON,QAAQM,cAAc;IAAC;IAAG,IAAIC,UAAS;QAAE,OAAOP,QAAQO,MAAM;IAAC;IAAG,IAAIL,OAAM;QAAE,OAAOF,QAAQE,GAAG;IAAC;IAAG,IAAIM,aAAY;QAAE,OAAOR,QAAQQ,SAAS;IAAC;IAAG,IAAIP,QAAO;QAAE,OAAOD,QAAQC,IAAI;IAAC;AAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/shadowed.input.ts"],"sourcesContent":["import { createLocalReq } from 'payload'\n\nconst req = createLocalReq({}, payload)\nfunction unrelated(createLocalReq: Function) {\n return createLocalReq({}, payload)\n}\n"],"names":["createLocalReq","req","payload","unrelated"],"mappings":"AAAA,SAASA,cAAc,QAAQ,UAAS;AAExC,MAAMC,MAAMD,eAAe,CAAC,GAAGE;AAC/B,SAASC,UAAUH,cAAwB;IACzC,OAAOA,eAAe,CAAC,GAAGE;AAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/shadowed.output.ts"],"sourcesContent":["import { createPayloadRequest } from 'payload'\n\nconst req = createPayloadRequest({ payload: payload })\nfunction unrelated(createLocalReq: Function) {\n return createLocalReq({}, payload)\n}\n"],"names":["createPayloadRequest","req","payload","unrelated","createLocalReq"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,UAAS;AAE9C,MAAMC,MAAMD,qBAAqB;IAAEE,SAASA;AAAQ;AACpD,SAASC,UAAUC,cAAwB;IACzC,OAAOA,eAAe,CAAC,GAAGF;AAC5B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createPayloadRequest } from 'payload';
|
|
2
|
+
import { initReq } from 'payload/internal';
|
|
3
|
+
const handlers = {
|
|
4
|
+
createPayloadRequest,
|
|
5
|
+
initReq
|
|
6
|
+
};
|
|
7
|
+
const requestKey = 'createPayloadRequest';
|
|
8
|
+
const contextKey = 'initReq';
|
|
9
|
+
handlers[requestKey](args);
|
|
10
|
+
handlers[contextKey](args);
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=shorthand.input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/shorthand.input.ts"],"sourcesContent":["import { createPayloadRequest } from 'payload'\nimport { initReq } from 'payload/internal'\n\nconst handlers = { createPayloadRequest, initReq }\nconst requestKey: string = 'createPayloadRequest'\nconst contextKey: string = 'initReq'\nhandlers[requestKey](args)\nhandlers[contextKey](args)\n"],"names":["createPayloadRequest","initReq","handlers","requestKey","contextKey","args"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,UAAS;AAC9C,SAASC,OAAO,QAAQ,mBAAkB;AAE1C,MAAMC,WAAW;IAAEF;IAAsBC;AAAQ;AACjD,MAAME,aAAqB;AAC3B,MAAMC,aAAqB;AAC3BF,QAAQ,CAACC,WAAW,CAACE;AACrBH,QAAQ,CAACE,WAAW,CAACC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createPayloadRequestFromWebRequest } from 'payload';
|
|
2
|
+
import { initAdminContext } from 'payload/internal';
|
|
3
|
+
const handlers = {
|
|
4
|
+
createPayloadRequest: createPayloadRequestFromWebRequest,
|
|
5
|
+
initReq: initAdminContext
|
|
6
|
+
};
|
|
7
|
+
const requestKey = 'createPayloadRequest';
|
|
8
|
+
const contextKey = 'initReq';
|
|
9
|
+
handlers[requestKey](args);
|
|
10
|
+
handlers[contextKey](args);
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=shorthand.output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/shorthand.output.ts"],"sourcesContent":["import { createPayloadRequestFromWebRequest } from 'payload'\nimport { initAdminContext } from 'payload/internal'\n\nconst handlers = { createPayloadRequest: createPayloadRequestFromWebRequest, initReq: initAdminContext }\nconst requestKey: string = 'createPayloadRequest'\nconst contextKey: string = 'initReq'\nhandlers[requestKey](args)\nhandlers[contextKey](args)\n"],"names":["createPayloadRequestFromWebRequest","initAdminContext","handlers","createPayloadRequest","initReq","requestKey","contextKey","args"],"mappings":"AAAA,SAASA,kCAAkC,QAAQ,UAAS;AAC5D,SAASC,gBAAgB,QAAQ,mBAAkB;AAEnD,MAAMC,WAAW;IAAEC,sBAAsBH;IAAoCI,SAASH;AAAiB;AACvG,MAAMI,aAAqB;AAC3B,MAAMC,aAAqB;AAC3BJ,QAAQ,CAACG,WAAW,CAACE;AACrBL,QAAQ,CAACI,WAAW,CAACC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createLocalReq, createLocalReq as optional, createLocalReq as spread, createLocalReq as indirect } from 'payload';
|
|
2
|
+
const safe = createLocalReq({}, payload);
|
|
3
|
+
const wrong = createLocalReq(options);
|
|
4
|
+
const maybe = optional?.({}, payload);
|
|
5
|
+
const variadic = spread(...args, payload);
|
|
6
|
+
const callback = indirect;
|
|
7
|
+
const viaCall = indirect.call(null, {}, payload);
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=unsupported.input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-payload-request-creation/unsupported.input.ts"],"sourcesContent":["import { createLocalReq, createLocalReq as optional, createLocalReq as spread, createLocalReq as indirect } from 'payload'\n\nconst safe = createLocalReq({}, payload)\nconst wrong = createLocalReq(options)\nconst maybe = optional?.({}, payload)\nconst variadic = spread(...args, payload)\nconst callback = indirect\nconst viaCall = indirect.call(null, {}, payload)\n"],"names":["createLocalReq","optional","spread","indirect","safe","payload","wrong","options","maybe","variadic","args","callback","viaCall","call"],"mappings":"AAAA,SAASA,cAAc,EAAEA,kBAAkBC,QAAQ,EAAED,kBAAkBE,MAAM,EAAEF,kBAAkBG,QAAQ,QAAQ,UAAS;AAE1H,MAAMC,OAAOJ,eAAe,CAAC,GAAGK;AAChC,MAAMC,QAAQN,eAAeO;AAC7B,MAAMC,QAAQP,WAAW,CAAC,GAAGI;AAC7B,MAAMI,WAAWP,UAAUQ,MAAML;AACjC,MAAMM,WAAWR;AACjB,MAAMS,UAAUT,SAASU,IAAI,CAAC,MAAM,CAAC,GAAGR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node
|
|
1
|
+
import { Node } from 'ts-morph';
|
|
2
2
|
const VERSIONED_CONFIG_TYPE_NAMES = new Set([
|
|
3
3
|
'CollectionConfig',
|
|
4
4
|
'GlobalConfig',
|
|
@@ -69,8 +69,8 @@ const isVersionedConfigTypeName = (typeText)=>{
|
|
|
69
69
|
return undefined;
|
|
70
70
|
}
|
|
71
71
|
// Form 2: { ... } satisfies CollectionConfig
|
|
72
|
-
if (
|
|
73
|
-
const typeNode = node.getTypeNode
|
|
72
|
+
if (Node.isSatisfiesExpression(node)) {
|
|
73
|
+
const typeNode = node.getTypeNode();
|
|
74
74
|
if (!typeNode) {
|
|
75
75
|
return undefined;
|
|
76
76
|
}
|
|
@@ -78,8 +78,8 @@ const isVersionedConfigTypeName = (typeText)=>{
|
|
|
78
78
|
if (!isVersionedConfigTypeName(typeText)) {
|
|
79
79
|
return undefined;
|
|
80
80
|
}
|
|
81
|
-
const expr = node.getExpression
|
|
82
|
-
if (
|
|
81
|
+
const expr = node.getExpression();
|
|
82
|
+
if (Node.isObjectLiteralExpression(expr)) {
|
|
83
83
|
return expr;
|
|
84
84
|
}
|
|
85
85
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transforms/migrate-versions-default/index.ts"],"sourcesContent":["import { Node
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/migrate-versions-default/index.ts"],"sourcesContent":["import { Node } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst VERSIONED_CONFIG_TYPE_NAMES = new Set([\n 'CollectionConfig',\n 'GlobalConfig',\n 'SanitizedCollectionConfig',\n 'SanitizedGlobalConfig',\n])\n\nconst isVersionedConfigTypeName = (typeText: string): boolean => {\n const baseName = typeText.replace(/<.*>$/, '').trim()\n return VERSIONED_CONFIG_TYPE_NAMES.has(baseName)\n}\n\n/**\n * Finds object literals typed as CollectionConfig or GlobalConfig and adds\n * `versions: false` if the property is absent. Covers three annotation forms:\n * const X: CollectionConfig = { ... }\n * { ... } satisfies GlobalConfig\n * { ... } as CollectionConfig\n */\nexport const migrateVersionsDefault: Transform = {\n name: 'migrate-versions-default',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n\n for (const sourceFile of project.getSourceFiles()) {\n let mutated = false\n\n sourceFile.forEachDescendant((node) => {\n const objectLiteral = resolveVersionedConfigObject(node)\n if (!objectLiteral) {\n return\n }\n\n if (objectLiteral.getProperty('versions')) {\n return\n }\n\n objectLiteral.addPropertyAssignment({\n name: 'versions',\n initializer: 'false',\n })\n\n mutated = true\n })\n\n if (mutated) {\n filesChanged.add(sourceFile.getFilePath())\n }\n }\n\n return { filesChanged: [...filesChanged] }\n },\n description:\n 'Add `versions: false` to CollectionConfig and GlobalConfig objects that do not already have a versions property, preserving the previous opt-in behaviour after versions became enabled by default.',\n}\n\n/**\n * Given a node, returns its ObjectLiteralExpression if the node represents a\n * CollectionConfig- or GlobalConfig-typed value in one of the three recognised forms.\n * Returns undefined for everything else.\n */\nconst resolveVersionedConfigObject = (node: Node) => {\n // Form 1: const X: CollectionConfig = { ... }\n if (Node.isVariableDeclaration(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode) {\n return undefined\n }\n const typeText = typeNode.getText().trim()\n if (!isVersionedConfigTypeName(typeText)) {\n return undefined\n }\n const initializer = node.getInitializer()\n if (initializer && Node.isObjectLiteralExpression(initializer)) {\n return initializer\n }\n return undefined\n }\n\n // Form 2: { ... } satisfies CollectionConfig\n if (Node.isSatisfiesExpression(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode) {\n return undefined\n }\n const typeText = typeNode.getText().trim()\n if (!isVersionedConfigTypeName(typeText)) {\n return undefined\n }\n const expr = node.getExpression()\n if (Node.isObjectLiteralExpression(expr)) {\n return expr\n }\n return undefined\n }\n\n // Form 3: { ... } as CollectionConfig\n if (Node.isAsExpression(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode) {\n return undefined\n }\n const typeText = typeNode.getText().trim()\n if (!isVersionedConfigTypeName(typeText)) {\n return undefined\n }\n const expr = node.getExpression()\n if (Node.isObjectLiteralExpression(expr)) {\n return expr\n }\n return undefined\n }\n\n return undefined\n}\n"],"names":["Node","VERSIONED_CONFIG_TYPE_NAMES","Set","isVersionedConfigTypeName","typeText","baseName","replace","trim","has","migrateVersionsDefault","name","apply","project","filesChanged","sourceFile","getSourceFiles","mutated","forEachDescendant","node","objectLiteral","resolveVersionedConfigObject","getProperty","addPropertyAssignment","initializer","add","getFilePath","description","isVariableDeclaration","typeNode","getTypeNode","undefined","getText","getInitializer","isObjectLiteralExpression","isSatisfiesExpression","expr","getExpression","isAsExpression"],"mappings":"AAAA,SAASA,IAAI,QAAQ,WAAU;AAI/B,MAAMC,8BAA8B,IAAIC,IAAI;IAC1C;IACA;I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YACb,OAAOE;QACT;QACA,MAAM1B,WAAWwB,SAASG,OAAO,GAAGxB,IAAI;QACxC,IAAI,CAACJ,0BAA0BC,WAAW;YACxC,OAAO0B;QACT;QACA,MAAMK,OAAOjB,KAAKkB,aAAa;QAC/B,IAAIpC,KAAKiC,yBAAyB,CAACE,OAAO;YACxC,OAAOA;QACT;QACA,OAAOL;IACT;IAEA,sCAAsC;IACtC,IAAI9B,KAAKqC,cAAc,CAACnB,OAAO;QAC7B,MAAMU,WAAWV,KAAKW,WAAW;QACjC,IAAI,CAACD,UAAU;YACb,OAAOE;QACT;QACA,MAAM1B,WAAWwB,SAASG,OAAO,GAAGxB,IAAI;QACxC,IAAI,CAACJ,0BAA0BC,WAAW;YACxC,OAAO0B;QACT;QACA,MAAMK,OAAOjB,KAAKkB,aAAa;QAC/B,IAAIpC,KAAKiC,yBAAyB,CAACE,OAAO;YACxC,OAAOA;QACT;QACA,OAAOL;IACT;IAEA,OAAOA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/remove-publish-specific-locale/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/remove-publish-specific-locale/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,EAAE,SA6EzC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transforms/remove-publish-specific-locale/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/remove-publish-specific-locale/index.ts"],"sourcesContent":["import { Node } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\n/**\n * Removes `publishSpecificLocale` from `payload.update()` and\n * `payload.updateGlobal()` call-site options objects.\n *\n * If the object already has a `locale` property, `publishSpecificLocale` is\n * simply removed. If it does not, the property is renamed to `locale` so the\n * same locale value is preserved.\n */\nexport const removePublishSpecificLocale: Transform = {\n name: 'remove-publish-specific-locale',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n\n for (const sourceFile of project.getSourceFiles()) {\n let mutated = false\n\n sourceFile.forEachDescendant((node) => {\n if (!Node.isCallExpression(node)) {\n return\n }\n\n const expr = node.getExpression()\n if (!Node.isPropertyAccessExpression(expr)) {\n return\n }\n\n const methodName = expr.getName()\n if (methodName !== 'update' && methodName !== 'updateGlobal') {\n return\n }\n\n const args = node.getArguments()\n if (args.length === 0) {\n return\n }\n\n // The options object is always the first argument\n const optionsArg = args[0]\n if (!Node.isObjectLiteralExpression(optionsArg)) {\n return\n }\n\n const options = optionsArg\n const publishSpecificLocaleProp = options.getProperty('publishSpecificLocale')\n if (!publishSpecificLocaleProp) {\n return\n }\n\n const localeProp = options.getProperty('locale')\n\n if (localeProp) {\n // Already has `locale` — just drop publishSpecificLocale\n publishSpecificLocaleProp.remove()\n } else {\n // Rename publishSpecificLocale → locale to keep the value\n if (\n Node.isPropertyAssignment(publishSpecificLocaleProp) ||\n Node.isShorthandPropertyAssignment(publishSpecificLocaleProp)\n ) {\n if (Node.isPropertyAssignment(publishSpecificLocaleProp)) {\n const valueText = publishSpecificLocaleProp.getInitializer()?.getText() ?? 'undefined'\n publishSpecificLocaleProp.replaceWithText(`locale: ${valueText}`)\n } else {\n // shorthand: publishSpecificLocale → locale: publishSpecificLocale\n const name = publishSpecificLocaleProp.getName()\n publishSpecificLocaleProp.replaceWithText(`locale: ${name}`)\n }\n } else {\n // spread or method — just remove, we can't safely rename\n publishSpecificLocaleProp.remove()\n }\n }\n\n mutated = true\n })\n\n if (mutated) {\n filesChanged.add(sourceFile.getFilePath())\n }\n }\n\n return { filesChanged: [...filesChanged] }\n },\n description:\n 'Remove `publishSpecificLocale` from payload.update() and payload.updateGlobal() call sites. When `locale` is already present the property is simply removed; otherwise it is renamed to `locale` to preserve the value.',\n}\n"],"names":["Node","removePublishSpecificLocale","name","apply","project","filesChanged","Set","sourceFile","getSourceFiles","mutated","forEachDescendant","node","isCallExpression","expr","getExpression","isPropertyAccessExpression","methodName","getName","args","getArguments","length","optionsArg","isObjectLiteralExpression","options","publishSpecificLocaleProp","getProperty","localeProp","remove","isPropertyAssignment","isShorthandPropertyAssignment","valueText","getInitializer","getText","replaceWithText","add","getFilePath","description"],"mappings":"AAAA,SAASA,IAAI,QAAQ,WAAU;AAI/B;;;;;;;CAOC,GACD,OAAO,MAAMC,8BAAyC;IACpDC,MAAM;IACNC,OAAO,CAAC,EAAEC,OAAO,EAAE;QACjB,MAAMC,eAAe,IAAIC;QAEzB,KAAK,MAAMC,cAAcH,QAAQI,cAAc,GAAI;YACjD,IAAIC,UAAU;YAEdF,WAAWG,iBAAiB,CAAC,CAACC;gBAC5B,IAAI,CAACX,KAAKY,gBAAgB,CAACD,OAAO;oBAChC;gBACF;gBAEA,MAAME,OAAOF,KAAKG,aAAa;gBAC/B,IAAI,CAACd,KAAKe,0BAA0B,CAACF,OAAO;oBAC1C;gBACF;gBAEA,MAAMG,aAAaH,KAAKI,OAAO;gBAC/B,IAAID,eAAe,YAAYA,eAAe,gBAAgB;oBAC5D;gBACF;gBAEA,MAAME,OAAOP,KAAKQ,YAAY;gBAC9B,IAAID,KAAKE,MAAM,KAAK,GAAG;oBACrB;gBACF;gBAEA,kDAAkD;gBAClD,MAAMC,aAAaH,IAAI,CAAC,EAAE;gBAC1B,IAAI,CAAClB,KAAKsB,yBAAyB,CAACD,aAAa;oBAC/C;gBACF;gBAEA,MAAME,UAAUF;gBAChB,MAAMG,4BAA4BD,QAAQE,WAAW,CAAC;gBACtD,IAAI,CAACD,2BAA2B;oBAC9B;gBACF;gBAEA,MAAME,aAAaH,QAAQE,WAAW,CAAC;gBAEvC,IAAIC,YAAY;oBACd,yDAAyD;oBACzDF,0BAA0BG,MAAM;gBAClC,OAAO;oBACL,0DAA0D;oBAC1D,IACE3B,KAAK4B,oBAAoB,CAACJ,8BAC1BxB,KAAK6B,6BAA6B,CAACL,4BACnC;wBACA,IAAIxB,KAAK4B,oBAAoB,CAACJ,4BAA4B;4BACxD,MAAMM,YAAYN,0BAA0BO,cAAc,IAAIC,aAAa;4BAC3ER,0BAA0BS,eAAe,CAAC,CAAC,QAAQ,EAAEH,WAAW;wBAClE,OAAO;4BACL,mEAAmE;4BACnE,MAAM5B,OAAOsB,0BAA0BP,OAAO;4BAC9CO,0BAA0BS,eAAe,CAAC,CAAC,QAAQ,EAAE/B,MAAM;wBAC7D;oBACF,OAAO;wBACL,yDAAyD;wBACzDsB,0BAA0BG,MAAM;oBAClC;gBACF;gBAEAlB,UAAU;YACZ;YAEA,IAAIA,SAAS;gBACXJ,aAAa6B,GAAG,CAAC3B,WAAW4B,WAAW;YACzC;QACF;QAEA,OAAO;YAAE9B,cAAc;mBAAIA;aAAa;QAAC;IAC3C;IACA+B,aACE;AACJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/remove-storage-always-insert-fields/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAW/C,eAAO,MAAM,+BAA+B,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/remove-storage-always-insert-fields/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAW/C,eAAO,MAAM,+BAA+B,EAAE,SAgE7C,CAAA"}
|
|
@@ -40,6 +40,10 @@ export const removeStorageAlwaysInsertFields = {
|
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
42
|
const localStorageFactoryName = storageFactoryImport.getAliasNode() ?? storageFactoryImport.getNameNode();
|
|
43
|
+
// Always an Identifier in valid code: a string-literal import name requires an alias.
|
|
44
|
+
if (!Node.isIdentifier(localStorageFactoryName)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
43
47
|
for (const reference of localStorageFactoryName.findReferencesAsNodes()){
|
|
44
48
|
const call = reference.getParentIfKind(SyntaxKind.CallExpression);
|
|
45
49
|
if (!call || call.getExpression() !== reference) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transforms/remove-storage-always-insert-fields/index.ts"],"sourcesContent":["import { Node, SyntaxKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst storageFactoryByPackage = new Map([\n ['@payloadcms/plugin-cloud-storage', 'cloudStoragePlugin'],\n ['@payloadcms/storage-azure', 'azureStorage'],\n ['@payloadcms/storage-gcs', 'gcsStorage'],\n ['@payloadcms/storage-r2', 'r2Storage'],\n ['@payloadcms/storage-s3', 's3Storage'],\n ['@payloadcms/storage-vercel-blob', 'vercelBlobStorage'],\n])\n\nexport const removeStorageAlwaysInsertFields: Transform = {\n name: 'remove-storage-always-insert-fields',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n\n for (const sourceFile of project.getSourceFiles()) {\n for (const importDeclaration of sourceFile.getImportDeclarations()) {\n const storageFactoryName = storageFactoryByPackage.get(\n importDeclaration.getModuleSpecifierValue(),\n )\n\n if (!storageFactoryName) {\n continue\n }\n\n const storageFactoryImport = importDeclaration\n .getNamedImports()\n .find((namedImport) => namedImport.getName() === storageFactoryName)\n\n if (!storageFactoryImport) {\n continue\n }\n\n const localStorageFactoryName =\n storageFactoryImport.getAliasNode() ?? storageFactoryImport.getNameNode()\n\n for (const reference of localStorageFactoryName.findReferencesAsNodes()) {\n const call = reference.getParentIfKind(SyntaxKind.CallExpression)\n\n if (!call || call.getExpression() !== reference) {\n continue\n }\n\n const [options] = call.getArguments()\n\n if (!options || !Node.isObjectLiteralExpression(options)) {\n continue\n }\n\n if (options.getProperties().some((property) => Node.isSpreadAssignment(property))) {\n continue\n }\n\n const alwaysInsertFieldsProperty = options.getProperty('alwaysInsertFields')\n\n if (!alwaysInsertFieldsProperty) {\n continue\n }\n\n alwaysInsertFieldsProperty.remove()\n filesChanged.add(sourceFile.getFilePath())\n }\n }\n }\n\n return { filesChanged: Array.from(filesChanged) }\n },\n description:\n 'Remove the obsolete `alwaysInsertFields` option from cloud storage plugin and storage adapter configs. The prefix field is now always inserted.',\n}\n"],"names":["Node","SyntaxKind","storageFactoryByPackage","Map","removeStorageAlwaysInsertFields","name","apply","project","filesChanged","Set","sourceFile","getSourceFiles","importDeclaration","getImportDeclarations","storageFactoryName","get","getModuleSpecifierValue","storageFactoryImport","getNamedImports","find","namedImport","getName","localStorageFactoryName","getAliasNode","getNameNode","reference","findReferencesAsNodes","call","getParentIfKind","CallExpression","getExpression","options","getArguments","isObjectLiteralExpression","getProperties","some","property","isSpreadAssignment","alwaysInsertFieldsProperty","getProperty","remove","add","getFilePath","Array","from","description"],"mappings":"AAAA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAU;AAI3C,MAAMC,0BAA0B,IAAIC,IAAI;IACtC;QAAC;QAAoC;KAAqB;IAC1D;QAAC;QAA6B;KAAe;IAC7C;QAAC;QAA2B;KAAa;IACzC;QAAC;QAA0B;KAAY;IACvC;QAAC;QAA0B;KAAY;IACvC;QAAC;QAAmC;KAAoB;CACzD;AAED,OAAO,MAAMC,kCAA6C;IACxDC,MAAM;IACNC,OAAO,CAAC,EAAEC,OAAO,EAAE;QACjB,MAAMC,eAAe,IAAIC;QAEzB,KAAK,MAAMC,cAAcH,QAAQI,cAAc,GAAI;YACjD,KAAK,MAAMC,qBAAqBF,WAAWG,qBAAqB,GAAI;gBAClE,MAAMC,qBAAqBZ,wBAAwBa,GAAG,CACpDH,kBAAkBI,uBAAuB;gBAG3C,IAAI,CAACF,oBAAoB;oBACvB;gBACF;gBAEA,MAAMG,uBAAuBL,kBAC1BM,eAAe,GACfC,IAAI,CAAC,CAACC,cAAgBA,YAAYC,OAAO,OAAOP;gBAEnD,IAAI,CAACG,sBAAsB;oBACzB;gBACF;gBAEA,MAAMK,0BACJL,qBAAqBM,YAAY,MAAMN,qBAAqBO,WAAW;gBAEzE,KAAK,
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/remove-storage-always-insert-fields/index.ts"],"sourcesContent":["import { Node, SyntaxKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst storageFactoryByPackage = new Map([\n ['@payloadcms/plugin-cloud-storage', 'cloudStoragePlugin'],\n ['@payloadcms/storage-azure', 'azureStorage'],\n ['@payloadcms/storage-gcs', 'gcsStorage'],\n ['@payloadcms/storage-r2', 'r2Storage'],\n ['@payloadcms/storage-s3', 's3Storage'],\n ['@payloadcms/storage-vercel-blob', 'vercelBlobStorage'],\n])\n\nexport const removeStorageAlwaysInsertFields: Transform = {\n name: 'remove-storage-always-insert-fields',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n\n for (const sourceFile of project.getSourceFiles()) {\n for (const importDeclaration of sourceFile.getImportDeclarations()) {\n const storageFactoryName = storageFactoryByPackage.get(\n importDeclaration.getModuleSpecifierValue(),\n )\n\n if (!storageFactoryName) {\n continue\n }\n\n const storageFactoryImport = importDeclaration\n .getNamedImports()\n .find((namedImport) => namedImport.getName() === storageFactoryName)\n\n if (!storageFactoryImport) {\n continue\n }\n\n const localStorageFactoryName =\n storageFactoryImport.getAliasNode() ?? storageFactoryImport.getNameNode()\n\n // Always an Identifier in valid code: a string-literal import name requires an alias.\n if (!Node.isIdentifier(localStorageFactoryName)) {\n continue\n }\n\n for (const reference of localStorageFactoryName.findReferencesAsNodes()) {\n const call = reference.getParentIfKind(SyntaxKind.CallExpression)\n\n if (!call || call.getExpression() !== reference) {\n continue\n }\n\n const [options] = call.getArguments()\n\n if (!options || !Node.isObjectLiteralExpression(options)) {\n continue\n }\n\n if (options.getProperties().some((property) => Node.isSpreadAssignment(property))) {\n continue\n }\n\n const alwaysInsertFieldsProperty = options.getProperty('alwaysInsertFields')\n\n if (!alwaysInsertFieldsProperty) {\n continue\n }\n\n alwaysInsertFieldsProperty.remove()\n filesChanged.add(sourceFile.getFilePath())\n }\n }\n }\n\n return { filesChanged: Array.from(filesChanged) }\n },\n description:\n 'Remove the obsolete `alwaysInsertFields` option from cloud storage plugin and storage adapter configs. The prefix field is now always inserted.',\n}\n"],"names":["Node","SyntaxKind","storageFactoryByPackage","Map","removeStorageAlwaysInsertFields","name","apply","project","filesChanged","Set","sourceFile","getSourceFiles","importDeclaration","getImportDeclarations","storageFactoryName","get","getModuleSpecifierValue","storageFactoryImport","getNamedImports","find","namedImport","getName","localStorageFactoryName","getAliasNode","getNameNode","isIdentifier","reference","findReferencesAsNodes","call","getParentIfKind","CallExpression","getExpression","options","getArguments","isObjectLiteralExpression","getProperties","some","property","isSpreadAssignment","alwaysInsertFieldsProperty","getProperty","remove","add","getFilePath","Array","from","description"],"mappings":"AAAA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAU;AAI3C,MAAMC,0BAA0B,IAAIC,IAAI;IACtC;QAAC;QAAoC;KAAqB;IAC1D;QAAC;QAA6B;KAAe;IAC7C;QAAC;QAA2B;KAAa;IACzC;QAAC;QAA0B;KAAY;IACvC;QAAC;QAA0B;KAAY;IACvC;QAAC;QAAmC;KAAoB;CACzD;AAED,OAAO,MAAMC,kCAA6C;IACxDC,MAAM;IACNC,OAAO,CAAC,EAAEC,OAAO,EAAE;QACjB,MAAMC,eAAe,IAAIC;QAEzB,KAAK,MAAMC,cAAcH,QAAQI,cAAc,GAAI;YACjD,KAAK,MAAMC,qBAAqBF,WAAWG,qBAAqB,GAAI;gBAClE,MAAMC,qBAAqBZ,wBAAwBa,GAAG,CACpDH,kBAAkBI,uBAAuB;gBAG3C,IAAI,CAACF,oBAAoB;oBACvB;gBACF;gBAEA,MAAMG,uBAAuBL,kBAC1BM,eAAe,GACfC,IAAI,CAAC,CAACC,cAAgBA,YAAYC,OAAO,OAAOP;gBAEnD,IAAI,CAACG,sBAAsB;oBACzB;gBACF;gBAEA,MAAMK,0BACJL,qBAAqBM,YAAY,MAAMN,qBAAqBO,WAAW;gBAEzE,sFAAsF;gBACtF,IAAI,CAACxB,KAAKyB,YAAY,CAACH,0BAA0B;oBAC/C;gBACF;gBAEA,KAAK,MAAMI,aAAaJ,wBAAwBK,qBAAqB,GAAI;oBACvE,MAAMC,OAAOF,UAAUG,eAAe,CAAC5B,WAAW6B,cAAc;oBAEhE,IAAI,CAACF,QAAQA,KAAKG,aAAa,OAAOL,WAAW;wBAC/C;oBACF;oBAEA,MAAM,CAACM,QAAQ,GAAGJ,KAAKK,YAAY;oBAEnC,IAAI,CAACD,WAAW,CAAChC,KAAKkC,yBAAyB,CAACF,UAAU;wBACxD;oBACF;oBAEA,IAAIA,QAAQG,aAAa,GAAGC,IAAI,CAAC,CAACC,WAAarC,KAAKsC,kBAAkB,CAACD,YAAY;wBACjF;oBACF;oBAEA,MAAME,6BAA6BP,QAAQQ,WAAW,CAAC;oBAEvD,IAAI,CAACD,4BAA4B;wBAC/B;oBACF;oBAEAA,2BAA2BE,MAAM;oBACjCjC,aAAakC,GAAG,CAAChC,WAAWiC,WAAW;gBACzC;YACF;QACF;QAEA,OAAO;YAAEnC,cAAcoC,MAAMC,IAAI,CAACrC;QAAc;IAClD;IACAsC,aACE;AACJ,EAAC"}
|
|
@@ -71,13 +71,13 @@ const isVersionedConfigTypeName = (typeText)=>{
|
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
73
|
// Form 2: { ... } satisfies CollectionConfig
|
|
74
|
-
if (
|
|
75
|
-
const typeNode = node.getTypeNode
|
|
74
|
+
if (Node.isSatisfiesExpression(node)) {
|
|
75
|
+
const typeNode = node.getTypeNode();
|
|
76
76
|
if (!typeNode || !isVersionedConfigTypeName(typeNode.getText().trim())) {
|
|
77
77
|
return undefined;
|
|
78
78
|
}
|
|
79
|
-
const expr = node.getExpression
|
|
80
|
-
if (
|
|
79
|
+
const expr = node.getExpression();
|
|
80
|
+
if (Node.isObjectLiteralExpression(expr)) {
|
|
81
81
|
return expr;
|
|
82
82
|
}
|
|
83
83
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transforms/remove-versions-true/index.ts"],"sourcesContent":["import { Node, SyntaxKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst VERSIONED_CONFIG_TYPE_NAMES = new Set([\n 'CollectionConfig',\n 'GlobalConfig',\n 'SanitizedCollectionConfig',\n 'SanitizedGlobalConfig',\n])\n\nconst isVersionedConfigTypeName = (typeText: string): boolean => {\n const baseName = typeText.replace(/<.*>$/, '').trim()\n return VERSIONED_CONFIG_TYPE_NAMES.has(baseName)\n}\n\n/**\n * Removes `versions: true` (bare boolean true — not an object) from\n * CollectionConfig and GlobalConfig objects. Now that versions defaults to\n * true, the explicit property is redundant.\n *\n * Only removes the property when the initializer is exactly the `true` keyword.\n * Object-form versions configs (e.g. `versions: { drafts: true }`) are left\n * untouched.\n */\nexport const removeVersionsTrue: Transform = {\n name: 'remove-versions-true',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n\n for (const sourceFile of project.getSourceFiles()) {\n let mutated = false\n\n sourceFile.forEachDescendant((node) => {\n const objectLiteral = resolveVersionedConfigObject(node)\n if (!objectLiteral) {\n return\n }\n\n const versionsProp = objectLiteral.getProperty('versions')\n if (!versionsProp || !Node.isPropertyAssignment(versionsProp)) {\n return\n }\n\n const initializer = versionsProp.getInitializer()\n if (!initializer || initializer.getKind() !== SyntaxKind.TrueKeyword) {\n return\n }\n\n versionsProp.remove()\n mutated = true\n })\n\n if (mutated) {\n filesChanged.add(sourceFile.getFilePath())\n }\n }\n\n return { filesChanged: [...filesChanged] }\n },\n description:\n 'Remove redundant `versions: true` from CollectionConfig and GlobalConfig objects. Versions are now enabled by default so the explicit boolean true is no longer needed.',\n}\n\n/**\n * Given a node, returns its ObjectLiteralExpression if the node represents a\n * CollectionConfig- or GlobalConfig-typed value in one of the three recognised forms.\n */\nconst resolveVersionedConfigObject = (node: Node) => {\n // Form 1: const X: CollectionConfig = { ... }\n if (Node.isVariableDeclaration(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode) {\n return undefined\n }\n if (!isVersionedConfigTypeName(typeNode.getText().trim())) {\n return undefined\n }\n const initializer = node.getInitializer()\n if (initializer && Node.isObjectLiteralExpression(initializer)) {\n return initializer\n }\n return undefined\n }\n\n // Form 2: { ... } satisfies CollectionConfig\n if (
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/remove-versions-true/index.ts"],"sourcesContent":["import { Node, SyntaxKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst VERSIONED_CONFIG_TYPE_NAMES = new Set([\n 'CollectionConfig',\n 'GlobalConfig',\n 'SanitizedCollectionConfig',\n 'SanitizedGlobalConfig',\n])\n\nconst isVersionedConfigTypeName = (typeText: string): boolean => {\n const baseName = typeText.replace(/<.*>$/, '').trim()\n return VERSIONED_CONFIG_TYPE_NAMES.has(baseName)\n}\n\n/**\n * Removes `versions: true` (bare boolean true — not an object) from\n * CollectionConfig and GlobalConfig objects. Now that versions defaults to\n * true, the explicit property is redundant.\n *\n * Only removes the property when the initializer is exactly the `true` keyword.\n * Object-form versions configs (e.g. `versions: { drafts: true }`) are left\n * untouched.\n */\nexport const removeVersionsTrue: Transform = {\n name: 'remove-versions-true',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n\n for (const sourceFile of project.getSourceFiles()) {\n let mutated = false\n\n sourceFile.forEachDescendant((node) => {\n const objectLiteral = resolveVersionedConfigObject(node)\n if (!objectLiteral) {\n return\n }\n\n const versionsProp = objectLiteral.getProperty('versions')\n if (!versionsProp || !Node.isPropertyAssignment(versionsProp)) {\n return\n }\n\n const initializer = versionsProp.getInitializer()\n if (!initializer || initializer.getKind() !== SyntaxKind.TrueKeyword) {\n return\n }\n\n versionsProp.remove()\n mutated = true\n })\n\n if (mutated) {\n filesChanged.add(sourceFile.getFilePath())\n }\n }\n\n return { filesChanged: [...filesChanged] }\n },\n description:\n 'Remove redundant `versions: true` from CollectionConfig and GlobalConfig objects. Versions are now enabled by default so the explicit boolean true is no longer needed.',\n}\n\n/**\n * Given a node, returns its ObjectLiteralExpression if the node represents a\n * CollectionConfig- or GlobalConfig-typed value in one of the three recognised forms.\n */\nconst resolveVersionedConfigObject = (node: Node) => {\n // Form 1: const X: CollectionConfig = { ... }\n if (Node.isVariableDeclaration(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode) {\n return undefined\n }\n if (!isVersionedConfigTypeName(typeNode.getText().trim())) {\n return undefined\n }\n const initializer = node.getInitializer()\n if (initializer && Node.isObjectLiteralExpression(initializer)) {\n return initializer\n }\n return undefined\n }\n\n // Form 2: { ... } satisfies CollectionConfig\n if (Node.isSatisfiesExpression(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode || !isVersionedConfigTypeName(typeNode.getText().trim())) {\n return undefined\n }\n const expr = node.getExpression()\n if (Node.isObjectLiteralExpression(expr)) {\n return expr\n }\n return undefined\n }\n\n // Form 3: { ... } as CollectionConfig\n if (Node.isAsExpression(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode || !isVersionedConfigTypeName(typeNode.getText().trim())) {\n return undefined\n }\n const expr = node.getExpression()\n if (Node.isObjectLiteralExpression(expr)) {\n return expr\n }\n return undefined\n }\n\n return undefined\n}\n"],"names":["Node","SyntaxKind","VERSIONED_CONFIG_TYPE_NAMES","Set","isVersionedConfigTypeName","typeText","baseName","replace","trim","has","removeVersionsTrue","name","apply","project","filesChanged","sourceFile","getSourceFiles","mutated","forEachDescendant","node","objectLiteral","resolveVersionedConfigObject","versionsProp","getProperty","isPropertyAssignment","initializer","getInitializer","getKind","TrueKeyword","remove","add","getFilePath","description","isVariableDeclaration","typeNode","getTypeNode","undefined","getText","isObjectLiteralExpression","isSatisfiesExpression","expr","getExpression","isAsExpression"],"mappings":"AAAA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAU;AAI3C,MAAMC,8BAA8B,IAAIC,IAAI;IAC1C;IACA;IACA;IACA;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A,6CAA6C;IAC7C,IAAIpC,KAAKuC,qBAAqB,CAACpB,OAAO;QACpC,MAAMe,WAAWf,KAAKgB,WAAW;QACjC,IAAI,CAACD,YAAY,CAAC9B,0BAA0B8B,SAASG,OAAO,GAAG7B,IAAI,KAAK;YACtE,OAAO4B;QACT;QACA,MAAMI,OAAOrB,KAAKsB,aAAa;QAC/B,IAAIzC,KAAKsC,yBAAyB,CAACE,OAAO;YACxC,OAAOA;QACT;QACA,OAAOJ;IACT;IAEA,sCAAsC;IACtC,IAAIpC,KAAK0C,cAAc,CAACvB,OAAO;QAC7B,MAAMe,WAAWf,KAAKgB,WAAW;QACjC,IAAI,CAACD,YAAY,CAAC9B,0BAA0B8B,SAASG,OAAO,GAAG7B,IAAI,KAAK;YACtE,OAAO4B;QACT;QACA,MAAMI,OAAOrB,KAAKsB,aAAa;QAC/B,IAAIzC,KAAKsC,yBAAyB,CAACE,OAAO;YACxC,OAAOA;QACT;QACA,OAAOJ;IACT;IAEA,OAAOA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/rename-experimental-table-feature/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/rename-experimental-table-feature/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAM/C,eAAO,MAAM,8BAA8B,EAAE,SAkD5C,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Node } from 'ts-morph';
|
|
1
2
|
const PACKAGE_NAME = '@payloadcms/richtext-lexical';
|
|
2
3
|
const OLD_NAME = 'EXPERIMENTAL_TableFeature';
|
|
3
4
|
const NEW_NAME = 'TableFeature';
|
|
@@ -27,7 +28,12 @@ export const renameExperimentalTableFeature = {
|
|
|
27
28
|
} else {
|
|
28
29
|
// No alias: the imported name is also the local binding, so rename it to update
|
|
29
30
|
// every call site (e.g. `EXPERIMENTAL_TableFeature()`) in the same pass.
|
|
30
|
-
spec.getNameNode()
|
|
31
|
+
const nameNode = spec.getNameNode();
|
|
32
|
+
// Always an Identifier in valid code: a string-literal import name requires an alias.
|
|
33
|
+
if (!Node.isIdentifier(nameNode)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
nameNode.rename(NEW_NAME);
|
|
31
37
|
}
|
|
32
38
|
filesChanged.add(file.getFilePath());
|
|
33
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transforms/rename-experimental-table-feature/index.ts"],"sourcesContent":["import type { Transform } from '../../types.js'\n\nconst PACKAGE_NAME = '@payloadcms/richtext-lexical'\nconst OLD_NAME = 'EXPERIMENTAL_TableFeature'\nconst NEW_NAME = 'TableFeature'\n\nexport const renameExperimentalTableFeature: Transform = {\n name: 'rename-experimental-table-feature',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n\n for (const file of project.getSourceFiles()) {\n for (const importDecl of file.getImportDeclarations()) {\n if (importDecl.getModuleSpecifierValue() !== PACKAGE_NAME) {\n continue\n }\n\n const named = importDecl.getNamedImports()\n const spec = named.find((specifier) => specifier.getName() === OLD_NAME)\n if (!spec) {\n continue\n }\n\n // Skip if `TableFeature` is already imported here too, to avoid a collision.\n const hasNewName = named.some(\n (specifier) => (specifier.getAliasNode()?.getText() ?? specifier.getName()) === NEW_NAME,\n )\n if (hasNewName) {\n continue\n }\n\n if (spec.getAliasNode()) {\n // Aliased usages (`EXPERIMENTAL_TableFeature as Foo`) only reference the alias,\n // so the imported name can be swapped without touching call sites.\n spec.setName(NEW_NAME)\n } else {\n // No alias: the imported name is also the local binding, so rename it to update\n // every call site (e.g. `EXPERIMENTAL_TableFeature()`) in the same pass.\n spec.getNameNode().rename(NEW_NAME)\n }\n\n filesChanged.add(file.getFilePath())\n }\n }\n\n return { filesChanged: [...filesChanged] }\n },\n description:\n 'Renames imports of `EXPERIMENTAL_TableFeature` from `@payloadcms/richtext-lexical` to `TableFeature` (the table feature is now stable) and updates all local usages.',\n}\n"],"names":["PACKAGE_NAME","OLD_NAME","NEW_NAME","renameExperimentalTableFeature","name","apply","project","filesChanged","Set","file","getSourceFiles","importDecl","getImportDeclarations","getModuleSpecifierValue","named","getNamedImports","spec","find","specifier","getName","hasNewName","some","getAliasNode","getText","setName","getNameNode","rename","add","getFilePath","description"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/rename-experimental-table-feature/index.ts"],"sourcesContent":["import { Node } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst PACKAGE_NAME = '@payloadcms/richtext-lexical'\nconst OLD_NAME = 'EXPERIMENTAL_TableFeature'\nconst NEW_NAME = 'TableFeature'\n\nexport const renameExperimentalTableFeature: Transform = {\n name: 'rename-experimental-table-feature',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n\n for (const file of project.getSourceFiles()) {\n for (const importDecl of file.getImportDeclarations()) {\n if (importDecl.getModuleSpecifierValue() !== PACKAGE_NAME) {\n continue\n }\n\n const named = importDecl.getNamedImports()\n const spec = named.find((specifier) => specifier.getName() === OLD_NAME)\n if (!spec) {\n continue\n }\n\n // Skip if `TableFeature` is already imported here too, to avoid a collision.\n const hasNewName = named.some(\n (specifier) => (specifier.getAliasNode()?.getText() ?? specifier.getName()) === NEW_NAME,\n )\n if (hasNewName) {\n continue\n }\n\n if (spec.getAliasNode()) {\n // Aliased usages (`EXPERIMENTAL_TableFeature as Foo`) only reference the alias,\n // so the imported name can be swapped without touching call sites.\n spec.setName(NEW_NAME)\n } else {\n // No alias: the imported name is also the local binding, so rename it to update\n // every call site (e.g. `EXPERIMENTAL_TableFeature()`) in the same pass.\n const nameNode = spec.getNameNode()\n\n // Always an Identifier in valid code: a string-literal import name requires an alias.\n if (!Node.isIdentifier(nameNode)) {\n continue\n }\n\n nameNode.rename(NEW_NAME)\n }\n\n filesChanged.add(file.getFilePath())\n }\n }\n\n return { filesChanged: [...filesChanged] }\n },\n description:\n 'Renames imports of `EXPERIMENTAL_TableFeature` from `@payloadcms/richtext-lexical` to `TableFeature` (the table feature is now stable) and updates all local usages.',\n}\n"],"names":["Node","PACKAGE_NAME","OLD_NAME","NEW_NAME","renameExperimentalTableFeature","name","apply","project","filesChanged","Set","file","getSourceFiles","importDecl","getImportDeclarations","getModuleSpecifierValue","named","getNamedImports","spec","find","specifier","getName","hasNewName","some","getAliasNode","getText","setName","nameNode","getNameNode","isIdentifier","rename","add","getFilePath","description"],"mappings":"AAAA,SAASA,IAAI,QAAQ,WAAU;AAI/B,MAAMC,eAAe;AACrB,MAAMC,WAAW;AACjB,MAAMC,WAAW;AAEjB,OAAO,MAAMC,iCAA4C;IACvDC,MAAM;IACNC,OAAO,CAAC,EAAEC,OAAO,EAAE;QACjB,MAAMC,eAAe,IAAIC;QAEzB,KAAK,MAAMC,QAAQH,QAAQI,cAAc,GAAI;YAC3C,KAAK,MAAMC,cAAcF,KAAKG,qBAAqB,GAAI;gBACrD,IAAID,WAAWE,uBAAuB,OAAOb,cAAc;oBACzD;gBACF;gBAEA,MAAMc,QAAQH,WAAWI,eAAe;gBACxC,MAAMC,OAAOF,MAAMG,IAAI,CAAC,CAACC,YAAcA,UAAUC,OAAO,OAAOlB;gBAC/D,IAAI,CAACe,MAAM;oBACT;gBACF;gBAEA,6EAA6E;gBAC7E,MAAMI,aAAaN,MAAMO,IAAI,CAC3B,CAACH,YAAc,AAACA,CAAAA,UAAUI,YAAY,IAAIC,aAAaL,UAAUC,OAAO,EAAC,MAAOjB;gBAElF,IAAIkB,YAAY;oBACd;gBACF;gBAEA,IAAIJ,KAAKM,YAAY,IAAI;oBACvB,gFAAgF;oBAChF,mEAAmE;oBACnEN,KAAKQ,OAAO,CAACtB;gBACf,OAAO;oBACL,gFAAgF;oBAChF,yEAAyE;oBACzE,MAAMuB,WAAWT,KAAKU,WAAW;oBAEjC,sFAAsF;oBACtF,IAAI,CAAC3B,KAAK4B,YAAY,CAACF,WAAW;wBAChC;oBACF;oBAEAA,SAASG,MAAM,CAAC1B;gBAClB;gBAEAK,aAAasB,GAAG,CAACpB,KAAKqB,WAAW;YACnC;QACF;QAEA,OAAO;YAAEvB,cAAc;mBAAIA;aAAa;QAAC;IAC3C;IACAwB,aACE;AACJ,EAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Payload dist-tag when the caller did not pass --tag. Every package in
|
|
3
|
+
* the monorepo (this one included) is versioned and published in lockstep, so
|
|
4
|
+
* the dist-tag the codemod was invoked under (`npx @payloadcms/codemod@beta`)
|
|
5
|
+
* surfaces as its own version's prerelease id. Follow that train; fall back to
|
|
6
|
+
* canary for stable or local dev builds that carry no prerelease id.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveDefaultTag(version?: string | undefined): string;
|
|
9
|
+
//# sourceMappingURL=defaultTag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultTag.d.ts","sourceRoot":"","sources":["../../src/upgrade/defaultTag.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,MAAM,GAAG,SAA4B,GAAG,MAAM,CAGxF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
/** Dist-tag used when neither --tag nor the running version implies one. */ const FALLBACK_TAG = 'canary';
|
|
6
|
+
/**
|
|
7
|
+
* Default Payload dist-tag when the caller did not pass --tag. Every package in
|
|
8
|
+
* the monorepo (this one included) is versioned and published in lockstep, so
|
|
9
|
+
* the dist-tag the codemod was invoked under (`npx @payloadcms/codemod@beta`)
|
|
10
|
+
* surfaces as its own version's prerelease id. Follow that train; fall back to
|
|
11
|
+
* canary for stable or local dev builds that carry no prerelease id.
|
|
12
|
+
*/ export function resolveDefaultTag(version = readOwnVersion()) {
|
|
13
|
+
const id = version ? semver.prerelease(version)?.[0] : undefined;
|
|
14
|
+
return typeof id === 'string' ? id : FALLBACK_TAG;
|
|
15
|
+
}
|
|
16
|
+
function readOwnVersion() {
|
|
17
|
+
try {
|
|
18
|
+
const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json');
|
|
19
|
+
return JSON.parse(readFileSync(pkgPath, 'utf8')).version;
|
|
20
|
+
} catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=defaultTag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/upgrade/defaultTag.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport semver from 'semver'\n\n/** Dist-tag used when neither --tag nor the running version implies one. */\nconst FALLBACK_TAG = 'canary'\n\n/**\n * Default Payload dist-tag when the caller did not pass --tag. Every package in\n * the monorepo (this one included) is versioned and published in lockstep, so\n * the dist-tag the codemod was invoked under (`npx @payloadcms/codemod@beta`)\n * surfaces as its own version's prerelease id. Follow that train; fall back to\n * canary for stable or local dev builds that carry no prerelease id.\n */\nexport function resolveDefaultTag(version: string | undefined = readOwnVersion()): string {\n const id = version ? semver.prerelease(version)?.[0] : undefined\n return typeof id === 'string' ? id : FALLBACK_TAG\n}\n\nfunction readOwnVersion(): string | undefined {\n try {\n const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json')\n return JSON.parse(readFileSync(pkgPath, 'utf8')).version as string\n } catch {\n return undefined\n }\n}\n"],"names":["readFileSync","dirname","resolve","fileURLToPath","semver","FALLBACK_TAG","resolveDefaultTag","version","readOwnVersion","id","prerelease","undefined","pkgPath","url","JSON","parse"],"mappings":"AAAA,SAASA,YAAY,QAAQ,UAAS;AACtC,SAASC,OAAO,EAAEC,OAAO,QAAQ,YAAW;AAC5C,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,YAAY,SAAQ;AAE3B,0EAA0E,GAC1E,MAAMC,eAAe;AAErB;;;;;;CAMC,GACD,OAAO,SAASC,kBAAkBC,UAA8BC,gBAAgB;IAC9E,MAAMC,KAAKF,UAAUH,OAAOM,UAAU,CAACH,UAAU,CAAC,EAAE,GAAGI;IACvD,OAAO,OAAOF,OAAO,WAAWA,KAAKJ;AACvC;AAEA,SAASG;IACP,IAAI;QACF,MAAMI,UAAUV,QAAQD,QAAQE,cAAc,YAAYU,GAAG,IAAI,MAAM,MAAM;QAC7E,OAAOC,KAAKC,KAAK,CAACf,aAAaY,SAAS,SAASL,OAAO;IAC1D,EAAE,OAAM;QACN,OAAOI;IACT;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PackageManager } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Map a project directory's lockfile to its package manager. `exists` is
|
|
4
|
+
* injectable so callers can test offline; it defaults to the real filesystem.
|
|
5
|
+
* pnpm is checked first, so it wins in a multi-lockfile repo.
|
|
6
|
+
*/
|
|
7
|
+
export declare function detectPackageManager(projectPath: string, exists?: (path: string) => boolean): PackageManager;
|
|
8
|
+
//# sourceMappingURL=detectPackageManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectPackageManager.d.ts","sourceRoot":"","sources":["../../src/upgrade/detectPackageManager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAUhD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAoB,GAC7C,cAAc,CAOhB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const LOCKFILES = [
|
|
4
|
+
{
|
|
5
|
+
file: 'pnpm-lock.yaml',
|
|
6
|
+
pm: 'pnpm'
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
file: 'yarn.lock',
|
|
10
|
+
pm: 'yarn'
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
file: 'bun.lockb',
|
|
14
|
+
pm: 'bun'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
file: 'bun.lock',
|
|
18
|
+
pm: 'bun'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
file: 'package-lock.json',
|
|
22
|
+
pm: 'npm'
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Map a project directory's lockfile to its package manager. `exists` is
|
|
27
|
+
* injectable so callers can test offline; it defaults to the real filesystem.
|
|
28
|
+
* pnpm is checked first, so it wins in a multi-lockfile repo.
|
|
29
|
+
*/ export function detectPackageManager(projectPath, exists = existsSync) {
|
|
30
|
+
for (const { file, pm } of LOCKFILES){
|
|
31
|
+
if (exists(join(projectPath, file))) {
|
|
32
|
+
return pm;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return 'npm';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=detectPackageManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/upgrade/detectPackageManager.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport type { PackageManager } from './types.js'\n\nconst LOCKFILES: { file: string; pm: PackageManager }[] = [\n { file: 'pnpm-lock.yaml', pm: 'pnpm' },\n { file: 'yarn.lock', pm: 'yarn' },\n { file: 'bun.lockb', pm: 'bun' },\n { file: 'bun.lock', pm: 'bun' },\n { file: 'package-lock.json', pm: 'npm' },\n]\n\n/**\n * Map a project directory's lockfile to its package manager. `exists` is\n * injectable so callers can test offline; it defaults to the real filesystem.\n * pnpm is checked first, so it wins in a multi-lockfile repo.\n */\nexport function detectPackageManager(\n projectPath: string,\n exists: (path: string) => boolean = existsSync,\n): PackageManager {\n for (const { file, pm } of LOCKFILES) {\n if (exists(join(projectPath, file))) {\n return pm\n }\n }\n return 'npm'\n}\n"],"names":["existsSync","join","LOCKFILES","file","pm","detectPackageManager","projectPath","exists"],"mappings":"AAAA,SAASA,UAAU,QAAQ,UAAS;AACpC,SAASC,IAAI,QAAQ,YAAW;AAIhC,MAAMC,YAAoD;IACxD;QAAEC,MAAM;QAAkBC,IAAI;IAAO;IACrC;QAAED,MAAM;QAAaC,IAAI;IAAO;IAChC;QAAED,MAAM;QAAaC,IAAI;IAAM;IAC/B;QAAED,MAAM;QAAYC,IAAI;IAAM;IAC9B;QAAED,MAAM;QAAqBC,IAAI;IAAM;CACxC;AAED;;;;CAIC,GACD,OAAO,SAASC,qBACdC,WAAmB,EACnBC,SAAoCP,UAAU;IAE9C,KAAK,MAAM,EAAEG,IAAI,EAAEC,EAAE,EAAE,IAAIF,UAAW;QACpC,IAAIK,OAAON,KAAKK,aAAaH,QAAQ;YACnC,OAAOC;QACT;IACF;IACA,OAAO;AACT"}
|