@payloadcms/codemod 4.0.0-internal.f15737c → 4.0.0-internal.f2a04f7

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.
Files changed (50) hide show
  1. package/README.md +5 -2
  2. package/dist/registry.d.ts.map +1 -1
  3. package/dist/registry.js +6 -0
  4. package/dist/registry.js.map +1 -1
  5. package/dist/runbook/payload-v4-upgrade.md +2 -2
  6. package/dist/runbook/v4.mdx +291 -74
  7. package/dist/transforms/migrate-admin-context-properties/basic.input.js +32 -0
  8. package/dist/transforms/migrate-admin-context-properties/basic.input.js.map +1 -0
  9. package/dist/transforms/migrate-admin-context-properties/basic.output.js +30 -0
  10. package/dist/transforms/migrate-admin-context-properties/basic.output.js.map +1 -0
  11. package/dist/transforms/migrate-admin-context-properties/index.d.ts +3 -0
  12. package/dist/transforms/migrate-admin-context-properties/index.d.ts.map +1 -0
  13. package/dist/transforms/migrate-admin-context-properties/index.js +302 -0
  14. package/dist/transforms/migrate-admin-context-properties/index.js.map +1 -0
  15. package/dist/transforms/migrate-admin-context-properties/no-match.input.js +30 -0
  16. package/dist/transforms/migrate-admin-context-properties/no-match.input.js.map +1 -0
  17. package/dist/transforms/migrate-admin-context-properties/no-match.output.js +30 -0
  18. package/dist/transforms/migrate-admin-context-properties/no-match.output.js.map +1 -0
  19. package/dist/transforms/migrate-displayed-field-value-args/basic.input.js +4 -0
  20. package/dist/transforms/migrate-displayed-field-value-args/basic.input.js.map +1 -0
  21. package/dist/transforms/migrate-displayed-field-value-args/basic.output.js +8 -0
  22. package/dist/transforms/migrate-displayed-field-value-args/basic.output.js.map +1 -0
  23. package/dist/transforms/migrate-displayed-field-value-args/index.d.ts +3 -0
  24. package/dist/transforms/migrate-displayed-field-value-args/index.d.ts.map +1 -0
  25. package/dist/transforms/migrate-displayed-field-value-args/index.js +84 -0
  26. package/dist/transforms/migrate-displayed-field-value-args/index.js.map +1 -0
  27. package/dist/transforms/migrate-displayed-field-value-args/namespace.input.js +4 -0
  28. package/dist/transforms/migrate-displayed-field-value-args/namespace.input.js.map +1 -0
  29. package/dist/transforms/migrate-displayed-field-value-args/namespace.output.js +8 -0
  30. package/dist/transforms/migrate-displayed-field-value-args/namespace.output.js.map +1 -0
  31. package/dist/transforms/migrate-displayed-field-value-args/no-match.input.js +4 -0
  32. package/dist/transforms/migrate-displayed-field-value-args/no-match.input.js.map +1 -0
  33. package/dist/transforms/migrate-displayed-field-value-args/no-match.output.js +4 -0
  34. package/dist/transforms/migrate-displayed-field-value-args/no-match.output.js.map +1 -0
  35. package/dist/transforms/rename-diff-value-props/basic.input.js +38 -0
  36. package/dist/transforms/rename-diff-value-props/basic.input.js.map +1 -0
  37. package/dist/transforms/rename-diff-value-props/basic.output.js +38 -0
  38. package/dist/transforms/rename-diff-value-props/basic.output.js.map +1 -0
  39. package/dist/transforms/rename-diff-value-props/index.d.ts +3 -0
  40. package/dist/transforms/rename-diff-value-props/index.d.ts.map +1 -0
  41. package/dist/transforms/rename-diff-value-props/index.js +328 -0
  42. package/dist/transforms/rename-diff-value-props/index.js.map +1 -0
  43. package/dist/transforms/rename-diff-value-props/no-match.input.js +8 -0
  44. package/dist/transforms/rename-diff-value-props/no-match.input.js.map +1 -0
  45. package/dist/upgrade/defaultTag.d.ts +1 -1
  46. package/dist/upgrade/defaultTag.js +2 -2
  47. package/dist/upgrade/defaultTag.js.map +1 -1
  48. package/dist/upgrade/prompt.js +2 -2
  49. package/dist/upgrade/prompt.js.map +1 -1
  50. package/package.json +8 -8
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/migrate-displayed-field-value-args/index.ts"],"sourcesContent":["import type { CallExpression, Identifier } from 'ts-morph'\n\nimport { Node } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst moduleName = '@payloadcms/ui/utilities/getDisplayedFieldValue'\nconst functionName = 'getDisplayedFieldValue'\n\nexport const migrateDisplayedFieldValueArgs: Transform = {\n name: 'migrate-displayed-field-value-args',\n apply: ({ project }) => {\n const filesChanged: string[] = []\n const notes: string[] = []\n\n for (const file of project.getSourceFiles()) {\n const calls = new Set<CallExpression>()\n\n for (const declaration of file.getImportDeclarations()) {\n if (declaration.getModuleSpecifierValue() !== moduleName) {\n continue\n }\n\n for (const specifier of declaration.getNamedImports()) {\n if (specifier.getName() !== functionName || specifier.isTypeOnly()) {\n continue\n }\n\n const localName = specifier.getAliasNode() ?? specifier.getNameNode()\n\n if (Node.isIdentifier(localName)) {\n collectCalls({ calls, localName, notes })\n }\n }\n\n const namespace = declaration.getNamespaceImport()\n\n if (namespace) {\n collectCalls({ calls, isNamespace: true, localName: namespace, notes })\n }\n }\n\n const original = file.getFullText()\n\n for (const call of [...calls].sort((a, b) => b.getStart() - a.getStart())) {\n const args = call.getArguments()\n\n if (args.length === 1 && Node.isObjectLiteralExpression(args[0])) {\n continue\n }\n\n if (args.length !== 3 || args.some(Node.isSpreadElement)) {\n notes.push(\n `${file.getFilePath()}:${call.getStartLineNumber()}: ${call.getText()} has unsupported arguments; migrate manually.`,\n )\n continue\n }\n\n call.replaceWithText(\n `${call.getExpression().getText()}({ cellData: ${args[0]!.getText()}, field: ${args[1]!.getText()}, i18n: ${args[2]!.getText()} })`,\n )\n }\n\n if (file.getFullText() !== original) {\n filesChanged.push(file.getFilePath())\n }\n }\n\n return { filesChanged, ...(notes.length > 0 ? { notes } : {}) }\n },\n description:\n 'Migrates `getDisplayedFieldValue(cellData, field, i18n)` calls imported from `@payloadcms/ui/utilities/getDisplayedFieldValue` to object arguments.',\n}\n\nfunction collectCalls({\n calls,\n isNamespace = false,\n localName,\n notes,\n}: {\n calls: Set<CallExpression>\n isNamespace?: boolean\n localName: Identifier\n notes: string[]\n}): void {\n for (const reference of localName.findReferencesAsNodes()) {\n if (reference === localName) {\n continue\n }\n\n const parent = reference.getParent()\n const expression = isNamespace\n ? Node.isPropertyAccessExpression(parent) &&\n parent.getExpression() === reference &&\n parent.getName() === functionName\n ? parent\n : undefined\n : reference\n\n if (!expression) {\n continue\n }\n\n const call = expression.getParent()\n\n if (Node.isCallExpression(call) && call.getExpression() === expression) {\n calls.add(call)\n } else {\n notes.push(\n `${reference.getSourceFile().getFilePath()}:${reference.getStartLineNumber()}: ${expression.getText()} is referenced without a direct call; migrate manually.`,\n )\n }\n }\n}\n"],"names":["Node","moduleName","functionName","migrateDisplayedFieldValueArgs","name","apply","project","filesChanged","notes","file","getSourceFiles","calls","Set","declaration","getImportDeclarations","getModuleSpecifierValue","specifier","getNamedImports","getName","isTypeOnly","localName","getAliasNode","getNameNode","isIdentifier","collectCalls","namespace","getNamespaceImport","isNamespace","original","getFullText","call","sort","a","b","getStart","args","getArguments","length","isObjectLiteralExpression","some","isSpreadElement","push","getFilePath","getStartLineNumber","getText","replaceWithText","getExpression","description","reference","findReferencesAsNodes","parent","getParent","expression","isPropertyAccessExpression","undefined","isCallExpression","add","getSourceFile"],"mappings":"AAEA,SAASA,IAAI,QAAQ,WAAU;AAI/B,MAAMC,aAAa;AACnB,MAAMC,eAAe;AAErB,OAAO,MAAMC,iCAA4C;IACvDC,MAAM;IACNC,OAAO,CAAC,EAAEC,OAAO,EAAE;QACjB,MAAMC,eAAyB,EAAE;QACjC,MAAMC,QAAkB,EAAE;QAE1B,KAAK,MAAMC,QAAQH,QAAQI,cAAc,GAAI;YAC3C,MAAMC,QAAQ,IAAIC;YAElB,KAAK,MAAMC,eAAeJ,KAAKK,qBAAqB,GAAI;gBACtD,IAAID,YAAYE,uBAAuB,OAAOd,YAAY;oBACxD;gBACF;gBAEA,KAAK,MAAMe,aAAaH,YAAYI,eAAe,GAAI;oBACrD,IAAID,UAAUE,OAAO,OAAOhB,gBAAgBc,UAAUG,UAAU,IAAI;wBAClE;oBACF;oBAEA,MAAMC,YAAYJ,UAAUK,YAAY,MAAML,UAAUM,WAAW;oBAEnE,IAAItB,KAAKuB,YAAY,CAACH,YAAY;wBAChCI,aAAa;4BAAEb;4BAAOS;4BAAWZ;wBAAM;oBACzC;gBACF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MAAMwC,aAAa5B,UAAU6B,qBAAqB,GAAI;QACzD,IAAID,cAAc5B,WAAW;YAC3B;QACF;QAEA,MAAM8B,SAASF,UAAUG,SAAS;QAClC,MAAMC,aAAazB,cACf3B,KAAKqD,0BAA0B,CAACH,WAChCA,OAAOJ,aAAa,OAAOE,aAC3BE,OAAOhC,OAAO,OAAOhB,eACnBgD,SACAI,YACFN;QAEJ,IAAI,CAACI,YAAY;YACf;QACF;QAEA,MAAMtB,OAAOsB,WAAWD,SAAS;QAEjC,IAAInD,KAAKuD,gBAAgB,CAACzB,SAASA,KAAKgB,aAAa,OAAOM,YAAY;YACtEzC,MAAM6C,GAAG,CAAC1B;QACZ,OAAO;YACLtB,MAAMiC,IAAI,CACR,GAAGO,UAAUS,aAAa,GAAGf,WAAW,GAAG,CAAC,EAAEM,UAAUL,kBAAkB,GAAG,EAAE,EAAES,WAAWR,OAAO,GAAG,uDAAuD,CAAC;QAElK;IACF;AACF"}
@@ -0,0 +1,4 @@
1
+ import * as display from '@payloadcms/ui/utilities/getDisplayedFieldValue';
2
+ const result = display.getDisplayedFieldValue(fileSize, field, i18n);
3
+
4
+ //# sourceMappingURL=namespace.input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/migrate-displayed-field-value-args/namespace.input.ts"],"sourcesContent":["import * as display from '@payloadcms/ui/utilities/getDisplayedFieldValue'\n\nconst result = display.getDisplayedFieldValue(fileSize, field, i18n)\n"],"names":["display","result","getDisplayedFieldValue","fileSize","field","i18n"],"mappings":"AAAA,YAAYA,aAAa,kDAAiD;AAE1E,MAAMC,SAASD,QAAQE,sBAAsB,CAACC,UAAUC,OAAOC"}
@@ -0,0 +1,8 @@
1
+ import * as display from '@payloadcms/ui/utilities/getDisplayedFieldValue';
2
+ const result = display.getDisplayedFieldValue({
3
+ cellData: fileSize,
4
+ field: field,
5
+ i18n: i18n
6
+ });
7
+
8
+ //# sourceMappingURL=namespace.output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/migrate-displayed-field-value-args/namespace.output.ts"],"sourcesContent":["import * as display from '@payloadcms/ui/utilities/getDisplayedFieldValue'\n\nconst result = display.getDisplayedFieldValue({ cellData: fileSize, field: field, i18n: i18n })\n"],"names":["display","result","getDisplayedFieldValue","cellData","fileSize","field","i18n"],"mappings":"AAAA,YAAYA,aAAa,kDAAiD;AAE1E,MAAMC,SAASD,QAAQE,sBAAsB,CAAC;IAAEC,UAAUC;IAAUC,OAAOA;IAAOC,MAAMA;AAAK"}
@@ -0,0 +1,4 @@
1
+ import { getDisplayedFieldValue } from './local-display.js';
2
+ const result = getDisplayedFieldValue(fileSize, field, i18n);
3
+
4
+ //# sourceMappingURL=no-match.input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/migrate-displayed-field-value-args/no-match.input.ts"],"sourcesContent":["import { getDisplayedFieldValue } from './local-display.js'\n\nconst result = getDisplayedFieldValue(fileSize, field, i18n)\n"],"names":["getDisplayedFieldValue","result","fileSize","field","i18n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,qBAAoB;AAE3D,MAAMC,SAASD,uBAAuBE,UAAUC,OAAOC"}
@@ -0,0 +1,4 @@
1
+ import { getDisplayedFieldValue } from './local-display.js';
2
+ const result = getDisplayedFieldValue(fileSize, field, i18n);
3
+
4
+ //# sourceMappingURL=no-match.output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/migrate-displayed-field-value-args/no-match.output.ts"],"sourcesContent":["import { getDisplayedFieldValue } from './local-display.js'\n\nconst result = getDisplayedFieldValue(fileSize, field, i18n)\n"],"names":["getDisplayedFieldValue","result","fileSize","field","i18n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,qBAAoB;AAE3D,MAAMC,SAASD,uBAAuBE,UAAUC,OAAOC"}
@@ -0,0 +1,38 @@
1
+ export const Destructured = ({ comparisonValue, field, versionValue })=>{
2
+ const hasChanged = comparisonValue !== versionValue;
3
+ return hasChanged ? `${String(comparisonValue)} -> ${String(versionValue)}` : field.name;
4
+ };
5
+ export const LegacyComponentType = ({ comparisonValue, versionValue = '' })=>`${String(comparisonValue)} -> ${String(versionValue)}`;
6
+ export const Aliased = ({ comparisonValue: before, versionValue: valueTo })=>[
7
+ before,
8
+ valueTo
9
+ ];
10
+ export default async function PropsObject(props) {
11
+ const { comparisonValue, req } = props;
12
+ return [
13
+ comparisonValue,
14
+ props.versionValue,
15
+ props['comparisonValue'],
16
+ req.locale
17
+ ];
18
+ }
19
+ export function LocalPropsType({ label, versionValue }) {
20
+ return [
21
+ label,
22
+ versionValue
23
+ ];
24
+ }
25
+ export const RestProps = ({ field, ...rest })=>[
26
+ field,
27
+ rest.comparisonValue
28
+ ];
29
+ export const NameCollision = ({ comparisonValue })=>{
30
+ const valueFrom = 'unrelated';
31
+ return [
32
+ comparisonValue,
33
+ valueFrom
34
+ ];
35
+ };
36
+ export const formatValue = (value)=>String(value);
37
+
38
+ //# sourceMappingURL=basic.input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/rename-diff-value-props/basic.input.ts"],"sourcesContent":["import type {\n FieldDiffServerProps,\n TextFieldDiffClientComponent,\n TextFieldDiffClientProps,\n TextFieldDiffServerProps,\n} from 'payload'\nimport type React from 'react'\n\nexport const Destructured: React.FC<TextFieldDiffClientProps> = ({\n comparisonValue,\n field,\n versionValue,\n}) => {\n const hasChanged = comparisonValue !== versionValue\n return hasChanged ? `${String(comparisonValue)} -> ${String(versionValue)}` : field.name\n}\n\nexport const LegacyComponentType: TextFieldDiffClientComponent = ({\n comparisonValue,\n versionValue = '',\n}) => `${String(comparisonValue)} -> ${String(versionValue)}`\n\nexport const Aliased = ({\n comparisonValue: before,\n versionValue: valueTo,\n}: TextFieldDiffClientProps) => [before, valueTo]\n\nexport default async function PropsObject(props: TextFieldDiffServerProps) {\n const { comparisonValue, req } = props\n return [comparisonValue, props.versionValue, props['comparisonValue'], req.locale]\n}\n\ntype PropsWithLabel = { label: string } & TextFieldDiffClientProps\n\nexport function LocalPropsType({ label, versionValue }: PropsWithLabel) {\n return [label, versionValue]\n}\n\nexport const RestProps = ({ field, ...rest }: FieldDiffServerProps) => [field, rest.comparisonValue]\n\nexport const NameCollision = ({ comparisonValue }: TextFieldDiffClientProps) => {\n const valueFrom = 'unrelated'\n return [comparisonValue, valueFrom]\n}\n\nexport const formatValue = (value: TextFieldDiffClientProps['versionValue']) => String(value)\n"],"names":["Destructured","comparisonValue","field","versionValue","hasChanged","String","name","LegacyComponentType","Aliased","before","valueTo","PropsObject","props","req","locale","LocalPropsType","label","RestProps","rest","NameCollision","valueFrom","formatValue","value"],"mappings":"AAQA,OAAO,MAAMA,eAAmD,CAAC,EAC/DC,eAAe,EACfC,KAAK,EACLC,YAAY,EACb;IACC,MAAMC,aAAaH,oBAAoBE;IACvC,OAAOC,aAAa,GAAGC,OAAOJ,iBAAiB,IAAI,EAAEI,OAAOF,eAAe,GAAGD,MAAMI,IAAI;AAC1F,EAAC;AAED,OAAO,MAAMC,sBAAoD,CAAC,EAChEN,eAAe,EACfE,eAAe,EAAE,EAClB,GAAK,GAAGE,OAAOJ,iBAAiB,IAAI,EAAEI,OAAOF,eAAe,CAAA;AAE7D,OAAO,MAAMK,UAAU,CAAC,EACtBP,iBAAiBQ,MAAM,EACvBN,cAAcO,OAAO,EACI,GAAK;QAACD;QAAQC;KAAQ,CAAA;AAEjD,eAAe,eAAeC,YAAYC,KAA+B;IACvE,MAAM,EAAEX,eAAe,EAAEY,GAAG,EAAE,GAAGD;IACjC,OAAO;QAACX;QAAiBW,MAAMT,YAAY;QAAES,KAAK,CAAC,kBAAkB;QAAEC,IAAIC,MAAM;KAAC;AACpF;AAIA,OAAO,SAASC,eAAe,EAAEC,KAAK,EAAEb,YAAY,EAAkB;IACpE,OAAO;QAACa;QAAOb;KAAa;AAC9B;AAEA,OAAO,MAAMc,YAAY,CAAC,EAAEf,KAAK,EAAE,GAAGgB,MAA4B,GAAK;QAAChB;QAAOgB,KAAKjB,eAAe;KAAC,CAAA;AAEpG,OAAO,MAAMkB,gBAAgB,CAAC,EAAElB,eAAe,EAA4B;IACzE,MAAMmB,YAAY;IAClB,OAAO;QAACnB;QAAiBmB;KAAU;AACrC,EAAC;AAED,OAAO,MAAMC,cAAc,CAACC,QAAoDjB,OAAOiB,OAAM"}
@@ -0,0 +1,38 @@
1
+ export const Destructured = ({ valueFrom, field, valueTo })=>{
2
+ const hasChanged = valueFrom !== valueTo;
3
+ return hasChanged ? `${String(valueFrom)} -> ${String(valueTo)}` : field.name;
4
+ };
5
+ export const LegacyComponentType = ({ valueFrom, valueTo = '' })=>`${String(valueFrom)} -> ${String(valueTo)}`;
6
+ export const Aliased = ({ valueFrom: before, valueTo })=>[
7
+ before,
8
+ valueTo
9
+ ];
10
+ export default async function PropsObject(props) {
11
+ const { valueFrom, req } = props;
12
+ return [
13
+ valueFrom,
14
+ props.valueTo,
15
+ props['valueFrom'],
16
+ req.locale
17
+ ];
18
+ }
19
+ export function LocalPropsType({ label, valueTo }) {
20
+ return [
21
+ label,
22
+ valueTo
23
+ ];
24
+ }
25
+ export const RestProps = ({ field, ...rest })=>[
26
+ field,
27
+ rest.valueFrom
28
+ ];
29
+ export const NameCollision = ({ valueFrom: comparisonValue })=>{
30
+ const valueFrom = 'unrelated';
31
+ return [
32
+ comparisonValue,
33
+ valueFrom
34
+ ];
35
+ };
36
+ export const formatValue = (value)=>String(value);
37
+
38
+ //# sourceMappingURL=basic.output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/rename-diff-value-props/basic.output.ts"],"sourcesContent":["import type {\n FieldDiffServerProps,\n TextFieldDiffClientComponent,\n TextFieldDiffClientProps,\n TextFieldDiffServerProps,\n} from 'payload'\nimport type React from 'react'\n\nexport const Destructured: React.FC<TextFieldDiffClientProps> = ({\n valueFrom,\n field,\n valueTo,\n}) => {\n const hasChanged = valueFrom !== valueTo\n return hasChanged ? `${String(valueFrom)} -> ${String(valueTo)}` : field.name\n}\n\nexport const LegacyComponentType: TextFieldDiffClientComponent = ({\n valueFrom,\n valueTo = '',\n}) => `${String(valueFrom)} -> ${String(valueTo)}`\n\nexport const Aliased = ({\n valueFrom: before,\n valueTo,\n}: TextFieldDiffClientProps) => [before, valueTo]\n\nexport default async function PropsObject(props: TextFieldDiffServerProps) {\n const { valueFrom, req } = props\n return [valueFrom, props.valueTo, props['valueFrom'], req.locale]\n}\n\ntype PropsWithLabel = { label: string } & TextFieldDiffClientProps\n\nexport function LocalPropsType({ label, valueTo }: PropsWithLabel) {\n return [label, valueTo]\n}\n\nexport const RestProps = ({ field, ...rest }: FieldDiffServerProps) => [field, rest.valueFrom]\n\nexport const NameCollision = ({ valueFrom: comparisonValue }: TextFieldDiffClientProps) => {\n const valueFrom = 'unrelated'\n return [comparisonValue, valueFrom]\n}\n\nexport const formatValue = (value: TextFieldDiffClientProps['valueTo']) => String(value)\n"],"names":["Destructured","valueFrom","field","valueTo","hasChanged","String","name","LegacyComponentType","Aliased","before","PropsObject","props","req","locale","LocalPropsType","label","RestProps","rest","NameCollision","comparisonValue","formatValue","value"],"mappings":"AAQA,OAAO,MAAMA,eAAmD,CAAC,EAC/DC,SAAS,EACTC,KAAK,EACLC,OAAO,EACR;IACC,MAAMC,aAAaH,cAAcE;IACjC,OAAOC,aAAa,GAAGC,OAAOJ,WAAW,IAAI,EAAEI,OAAOF,UAAU,GAAGD,MAAMI,IAAI;AAC/E,EAAC;AAED,OAAO,MAAMC,sBAAoD,CAAC,EAChEN,SAAS,EACTE,UAAU,EAAE,EACb,GAAK,GAAGE,OAAOJ,WAAW,IAAI,EAAEI,OAAOF,UAAU,CAAA;AAElD,OAAO,MAAMK,UAAU,CAAC,EACtBP,WAAWQ,MAAM,EACjBN,OAAO,EACkB,GAAK;QAACM;QAAQN;KAAQ,CAAA;AAEjD,eAAe,eAAeO,YAAYC,KAA+B;IACvE,MAAM,EAAEV,SAAS,EAAEW,GAAG,EAAE,GAAGD;IAC3B,OAAO;QAACV;QAAWU,MAAMR,OAAO;QAAEQ,KAAK,CAAC,YAAY;QAAEC,IAAIC,MAAM;KAAC;AACnE;AAIA,OAAO,SAASC,eAAe,EAAEC,KAAK,EAAEZ,OAAO,EAAkB;IAC/D,OAAO;QAACY;QAAOZ;KAAQ;AACzB;AAEA,OAAO,MAAMa,YAAY,CAAC,EAAEd,KAAK,EAAE,GAAGe,MAA4B,GAAK;QAACf;QAAOe,KAAKhB,SAAS;KAAC,CAAA;AAE9F,OAAO,MAAMiB,gBAAgB,CAAC,EAAEjB,WAAWkB,eAAe,EAA4B;IACpF,MAAMlB,YAAY;IAClB,OAAO;QAACkB;QAAiBlB;KAAU;AACrC,EAAC;AAED,OAAO,MAAMmB,cAAc,CAACC,QAA+ChB,OAAOgB,OAAM"}
@@ -0,0 +1,3 @@
1
+ import type { Transform } from '../../types.js';
2
+ export declare const renameDiffValueProps: Transform;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/rename-diff-value-props/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAsB/C,eAAO,MAAM,oBAAoB,EAAE,SAwClC,CAAA"}
@@ -0,0 +1,328 @@
1
+ import { Node, SyntaxKind } from 'ts-morph';
2
+ const RENAMED_PROPS = new Map([
3
+ [
4
+ 'comparisonValue',
5
+ 'valueFrom'
6
+ ],
7
+ [
8
+ 'versionValue',
9
+ 'valueTo'
10
+ ]
11
+ ]);
12
+ /**
13
+ * Matches every Diff component type exported from `payload`, in both the v3 component-alias
14
+ * form (`TextFieldDiffClientComponent`) and the props form (`TextFieldDiffClientProps`), so this
15
+ * transform works regardless of whether `migrate-field-component-types` has already run.
16
+ */ const DIFF_TYPE_NAME_PATTERN = /^[A-Za-z]*FieldDiff(?:Client|Server)(?:Component|Props)$/;
17
+ /**
18
+ * Every rewrite removes one old prop name, so the per-file loop always terminates. This cap only
19
+ * guards against an unexpected regression turning it into an infinite loop.
20
+ */ const MAX_REWRITES_PER_FILE = 1000;
21
+ export const renameDiffValueProps = {
22
+ name: 'rename-diff-value-props',
23
+ apply: ({ project })=>{
24
+ const filesChanged = [];
25
+ const notes = [];
26
+ for (const sourceFile of project.getSourceFiles()){
27
+ if (sourceFile.isDeclarationFile() || sourceFile.isInNodeModules()) {
28
+ continue;
29
+ }
30
+ const diffTypeNames = collectDiffTypeNames({
31
+ sourceFile
32
+ });
33
+ if (diffTypeNames.size === 0) {
34
+ continue;
35
+ }
36
+ let rewriteCount = 0;
37
+ while(rewriteCount < MAX_REWRITES_PER_FILE && rewriteNextOccurrence({
38
+ diffTypeNames,
39
+ sourceFile
40
+ })){
41
+ rewriteCount++;
42
+ }
43
+ if (rewriteCount > 0) {
44
+ filesChanged.push(sourceFile.getFilePath());
45
+ }
46
+ notes.push(...collectLeftoverNotes({
47
+ sourceFile
48
+ }));
49
+ }
50
+ return {
51
+ filesChanged,
52
+ ...notes.length > 0 ? {
53
+ notes
54
+ } : {}
55
+ };
56
+ },
57
+ description: 'Rename the `comparisonValue` and `versionValue` props read by custom Diff components to `valueFrom` and `valueTo`.'
58
+ };
59
+ /**
60
+ * Returns the local names of Diff component types imported from `payload`, plus same-file type
61
+ * aliases and interfaces built from them (e.g. `type Props = TextFieldDiffClientProps & { ... }`).
62
+ */ function collectDiffTypeNames({ sourceFile }) {
63
+ const diffTypeNames = new Set();
64
+ for (const importDeclaration of sourceFile.getImportDeclarations()){
65
+ if (importDeclaration.getModuleSpecifierValue() !== 'payload') {
66
+ continue;
67
+ }
68
+ for (const namedImport of importDeclaration.getNamedImports()){
69
+ if (DIFF_TYPE_NAME_PATTERN.test(namedImport.getName())) {
70
+ diffTypeNames.add(namedImport.getAliasNode()?.getText() ?? namedImport.getName());
71
+ }
72
+ }
73
+ }
74
+ if (diffTypeNames.size === 0) {
75
+ return diffTypeNames;
76
+ }
77
+ let hasFoundNewName = true;
78
+ while(hasFoundNewName){
79
+ hasFoundNewName = false;
80
+ const derivedTypeNames = [
81
+ ...sourceFile.getTypeAliases().filter((typeAlias)=>referencesDiffType({
82
+ diffTypeNames,
83
+ typeNode: typeAlias.getTypeNodeOrThrow()
84
+ })),
85
+ ...sourceFile.getInterfaces().filter((declaration)=>declaration.getExtends().some((heritage)=>diffTypeNames.has(heritage.getExpression().getText())))
86
+ ].map((declaration)=>declaration.getName());
87
+ for (const typeName of derivedTypeNames){
88
+ if (!diffTypeNames.has(typeName)) {
89
+ diffTypeNames.add(typeName);
90
+ hasFoundNewName = true;
91
+ }
92
+ }
93
+ }
94
+ return diffTypeNames;
95
+ }
96
+ /**
97
+ * Applies a single rewrite and reports whether one was made. Renames replace source text, which
98
+ * invalidates previously queried nodes, so the caller re-scans the file after every rewrite.
99
+ */ function rewriteNextOccurrence({ diffTypeNames, sourceFile }) {
100
+ for (const component of findDiffComponents({
101
+ diffTypeNames,
102
+ sourceFile
103
+ })){
104
+ const propsParameterName = component.getParameters()[0].getNameNode();
105
+ const propsBindingPatterns = [];
106
+ const propsIdentifiers = [];
107
+ if (Node.isObjectBindingPattern(propsParameterName)) {
108
+ propsBindingPatterns.push(propsParameterName);
109
+ const restElementName = propsParameterName.getElements().find((element)=>element.getDotDotDotToken())?.getNameNode();
110
+ if (restElementName && Node.isIdentifier(restElementName)) {
111
+ propsIdentifiers.push(restElementName);
112
+ }
113
+ } else if (Node.isIdentifier(propsParameterName)) {
114
+ propsIdentifiers.push(propsParameterName);
115
+ }
116
+ const readsProps = (node)=>Node.isIdentifier(node) && propsIdentifiers.some((propsIdentifier)=>isReferenceTo({
117
+ declaration: propsIdentifier,
118
+ identifier: node
119
+ }));
120
+ for (const declaration of component.getDescendantsOfKind(SyntaxKind.VariableDeclaration)){
121
+ const declarationName = declaration.getNameNode();
122
+ const initializer = declaration.getInitializer();
123
+ if (Node.isObjectBindingPattern(declarationName) && initializer && readsProps(initializer)) {
124
+ propsBindingPatterns.push(declarationName);
125
+ }
126
+ }
127
+ for (const pattern of propsBindingPatterns){
128
+ for (const element of pattern.getElements()){
129
+ if (rewriteBindingElement({
130
+ component,
131
+ element
132
+ })) {
133
+ return true;
134
+ }
135
+ }
136
+ }
137
+ for (const access of component.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)){
138
+ const newName = RENAMED_PROPS.get(access.getName());
139
+ if (newName && readsProps(access.getExpression())) {
140
+ access.getNameNode().replaceWithText(newName);
141
+ return true;
142
+ }
143
+ }
144
+ for (const access of component.getDescendantsOfKind(SyntaxKind.ElementAccessExpression)){
145
+ const argument = access.getArgumentExpression();
146
+ if (!argument || !Node.isStringLiteral(argument) || !readsProps(access.getExpression())) {
147
+ continue;
148
+ }
149
+ const newName = RENAMED_PROPS.get(argument.getLiteralValue());
150
+ if (newName) {
151
+ argument.setLiteralValue(newName);
152
+ return true;
153
+ }
154
+ }
155
+ }
156
+ for (const indexedAccess of sourceFile.getDescendantsOfKind(SyntaxKind.IndexedAccessType)){
157
+ const indexType = indexedAccess.getIndexTypeNode();
158
+ const literal = Node.isLiteralTypeNode(indexType) ? indexType.getLiteral() : undefined;
159
+ if (!literal || !Node.isStringLiteral(literal) || !referencesDiffType({
160
+ diffTypeNames,
161
+ typeNode: indexedAccess.getObjectTypeNode()
162
+ })) {
163
+ continue;
164
+ }
165
+ const newName = RENAMED_PROPS.get(literal.getLiteralValue());
166
+ if (newName) {
167
+ literal.setLiteralValue(newName);
168
+ return true;
169
+ }
170
+ }
171
+ return false;
172
+ }
173
+ /**
174
+ * Finds functions whose first parameter is typed with a Diff type, either directly
175
+ * (`(props: TextFieldDiffClientProps) => ...`) or through the variable they are assigned to
176
+ * (`const Diff: React.FC<TextFieldDiffClientProps> = (props) => ...`).
177
+ */ function findDiffComponents({ diffTypeNames, sourceFile }) {
178
+ const functions = [
179
+ ...sourceFile.getDescendantsOfKind(SyntaxKind.ArrowFunction),
180
+ ...sourceFile.getDescendantsOfKind(SyntaxKind.FunctionDeclaration),
181
+ ...sourceFile.getDescendantsOfKind(SyntaxKind.FunctionExpression)
182
+ ];
183
+ return functions.filter((component)=>{
184
+ const propsParameter = component.getParameters()[0];
185
+ if (!propsParameter) {
186
+ return false;
187
+ }
188
+ const parent = component.getParent();
189
+ const typeNodes = [
190
+ propsParameter.getTypeNode(),
191
+ Node.isVariableDeclaration(parent) ? parent.getTypeNode() : undefined
192
+ ];
193
+ return typeNodes.some((typeNode)=>typeNode && referencesDiffType({
194
+ diffTypeNames,
195
+ typeNode
196
+ }));
197
+ });
198
+ }
199
+ function referencesDiffType({ diffTypeNames, typeNode }) {
200
+ return [
201
+ typeNode,
202
+ ...typeNode.getDescendantsOfKind(SyntaxKind.TypeReference)
203
+ ].some((node)=>Node.isTypeReference(node) && diffTypeNames.has(node.getTypeName().getText()) && !isWrappedWithin({
204
+ node,
205
+ root: typeNode
206
+ }));
207
+ }
208
+ /**
209
+ * Whether `node` sits inside a type that wraps the props rather than describing them, such as
210
+ * `{ diff: TextFieldDiffClientProps }` or `TextFieldDiffClientProps['valueFrom']`.
211
+ */ function isWrappedWithin({ node, root }) {
212
+ const stopAt = root.getParent();
213
+ for(let ancestor = node.getParent(); ancestor && ancestor !== stopAt; ancestor = ancestor.getParent()){
214
+ if (Node.isPropertySignature(ancestor) || Node.isIndexedAccessTypeNode(ancestor)) {
215
+ return true;
216
+ }
217
+ }
218
+ return false;
219
+ }
220
+ /**
221
+ * Renames the destructured key of a single binding element. Returns `false` when the element
222
+ * doesn't destructure one of the renamed props.
223
+ */ function rewriteBindingElement({ component, element }) {
224
+ if (element.getDotDotDotToken()) {
225
+ return false;
226
+ }
227
+ const nameNode = element.getNameNode();
228
+ const propertyNameNode = element.getPropertyNameNode();
229
+ const propertyName = propertyNameNode ? getPropertyNameText({
230
+ node: propertyNameNode
231
+ }) : nameNode.getText();
232
+ const newName = propertyName ? RENAMED_PROPS.get(propertyName) : undefined;
233
+ if (!propertyName || !newName) {
234
+ return false;
235
+ }
236
+ const initializer = element.getInitializer();
237
+ const initializerText = initializer ? ` = ${initializer.getText()}` : '';
238
+ if (propertyNameNode) {
239
+ const localName = nameNode.getText();
240
+ element.replaceWithText(localName === newName ? `${newName}${initializerText}` : `${newName}: ${localName}${initializerText}`);
241
+ return true;
242
+ }
243
+ // A shorthand `{ comparisonValue }` also declares a local variable. Renaming it through the
244
+ // language service updates every reference, and `usePrefixAndSuffixText` leaves the element as
245
+ // `comparisonValue: valueFrom`, which the next pass collapses to `valueFrom`.
246
+ if (Node.isIdentifier(nameNode) && !containsIdentifierNamed({
247
+ name: newName,
248
+ node: component
249
+ })) {
250
+ const sourceFile = element.getSourceFile();
251
+ const textBeforeRename = sourceFile.getFullText();
252
+ try {
253
+ nameNode.rename(newName, {
254
+ usePrefixAndSuffixText: true
255
+ });
256
+ } catch {
257
+ // Fall back to keeping the local variable name below
258
+ }
259
+ if (sourceFile.getFullText() !== textBeforeRename) {
260
+ return true;
261
+ }
262
+ }
263
+ element.replaceWithText(`${newName}: ${propertyName}${initializerText}`);
264
+ return true;
265
+ }
266
+ function getPropertyNameText({ node }) {
267
+ if (Node.isIdentifier(node)) {
268
+ return node.getText();
269
+ }
270
+ if (Node.isStringLiteral(node)) {
271
+ return node.getLiteralValue();
272
+ }
273
+ return undefined;
274
+ }
275
+ function containsIdentifierNamed({ name, node }) {
276
+ return node.getDescendantsOfKind(SyntaxKind.Identifier).some((identifier)=>identifier.getText() === name);
277
+ }
278
+ /**
279
+ * Compares symbols so an inner variable that shadows the props parameter isn't mistaken for it.
280
+ * Falls back to comparing names when the type checker can't resolve a symbol.
281
+ */ function isReferenceTo({ declaration, identifier }) {
282
+ if (identifier.getText() !== declaration.getText()) {
283
+ return false;
284
+ }
285
+ const declarationSymbol = declaration.getSymbol();
286
+ return !declarationSymbol || identifier.getSymbol() === declarationSymbol;
287
+ }
288
+ /**
289
+ * Flags old prop names that remain in a property position, e.g. a JSX attribute passing
290
+ * `comparisonValue` to another component, or `Pick<Props, 'versionValue'>`. Local variables that
291
+ * merely share the old name are left alone.
292
+ */ function collectLeftoverNotes({ sourceFile }) {
293
+ const notedLocations = new Set();
294
+ const notes = [];
295
+ const candidates = [
296
+ ...sourceFile.getDescendantsOfKind(SyntaxKind.Identifier).filter((identifier)=>isPropertyNamePosition({
297
+ identifier
298
+ })),
299
+ ...sourceFile.getDescendantsOfKind(SyntaxKind.StringLiteral)
300
+ ].sort((a, b)=>a.getStart() - b.getStart());
301
+ for (const candidate of candidates){
302
+ const oldName = Node.isStringLiteral(candidate) ? candidate.getLiteralValue() : candidate.getText();
303
+ const newName = RENAMED_PROPS.get(oldName);
304
+ const location = `${sourceFile.getFilePath()}:${candidate.getStartLineNumber()}`;
305
+ if (!newName || notedLocations.has(`${location}:${oldName}`)) {
306
+ continue;
307
+ }
308
+ notedLocations.add(`${location}:${oldName}`);
309
+ notes.push(`${location}: \`${oldName}\` was not migrated. If it refers to a Diff component prop, rename it to \`${newName}\`.`);
310
+ }
311
+ return notes;
312
+ }
313
+ function isPropertyNamePosition({ identifier }) {
314
+ const parent = identifier.getParent();
315
+ if (Node.isShorthandPropertyAssignment(parent) || Node.isJsxAttribute(parent)) {
316
+ return true;
317
+ }
318
+ if (Node.isBindingElement(parent)) {
319
+ const propertyNameNode = parent.getPropertyNameNode();
320
+ return propertyNameNode ? propertyNameNode === identifier : !parent.getDotDotDotToken();
321
+ }
322
+ if (Node.isPropertyAccessExpression(parent) || Node.isPropertyAssignment(parent) || Node.isPropertySignature(parent)) {
323
+ return parent.getNameNode() === identifier;
324
+ }
325
+ return false;
326
+ }
327
+
328
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/rename-diff-value-props/index.ts"],"sourcesContent":["import type {\n ArrowFunction,\n BindingElement,\n FunctionDeclaration,\n FunctionExpression,\n Identifier,\n ObjectBindingPattern,\n SourceFile,\n TypeNode,\n} from 'ts-morph'\n\nimport { Node, SyntaxKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst RENAMED_PROPS = new Map([\n ['comparisonValue', 'valueFrom'],\n ['versionValue', 'valueTo'],\n])\n\n/**\n * Matches every Diff component type exported from `payload`, in both the v3 component-alias\n * form (`TextFieldDiffClientComponent`) and the props form (`TextFieldDiffClientProps`), so this\n * transform works regardless of whether `migrate-field-component-types` has already run.\n */\nconst DIFF_TYPE_NAME_PATTERN = /^[A-Za-z]*FieldDiff(?:Client|Server)(?:Component|Props)$/\n\n/**\n * Every rewrite removes one old prop name, so the per-file loop always terminates. This cap only\n * guards against an unexpected regression turning it into an infinite loop.\n */\nconst MAX_REWRITES_PER_FILE = 1000\n\ntype ComponentFunction = ArrowFunction | FunctionDeclaration | FunctionExpression\n\nexport const renameDiffValueProps: Transform = {\n name: 'rename-diff-value-props',\n apply: ({ project }) => {\n const filesChanged: string[] = []\n const notes: string[] = []\n\n for (const sourceFile of project.getSourceFiles()) {\n if (sourceFile.isDeclarationFile() || sourceFile.isInNodeModules()) {\n continue\n }\n\n const diffTypeNames = collectDiffTypeNames({ sourceFile })\n\n if (diffTypeNames.size === 0) {\n continue\n }\n\n let rewriteCount = 0\n\n while (\n rewriteCount < MAX_REWRITES_PER_FILE &&\n rewriteNextOccurrence({ diffTypeNames, sourceFile })\n ) {\n rewriteCount++\n }\n\n if (rewriteCount > 0) {\n filesChanged.push(sourceFile.getFilePath())\n }\n\n notes.push(...collectLeftoverNotes({ sourceFile }))\n }\n\n return {\n filesChanged,\n ...(notes.length > 0 ? { notes } : {}),\n }\n },\n description:\n 'Rename the `comparisonValue` and `versionValue` props read by custom Diff components to `valueFrom` and `valueTo`.',\n}\n\n/**\n * Returns the local names of Diff component types imported from `payload`, plus same-file type\n * aliases and interfaces built from them (e.g. `type Props = TextFieldDiffClientProps & { ... }`).\n */\nfunction collectDiffTypeNames({ sourceFile }: { sourceFile: SourceFile }): Set<string> {\n const diffTypeNames = new Set<string>()\n\n for (const importDeclaration of sourceFile.getImportDeclarations()) {\n if (importDeclaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n for (const namedImport of importDeclaration.getNamedImports()) {\n if (DIFF_TYPE_NAME_PATTERN.test(namedImport.getName())) {\n diffTypeNames.add(namedImport.getAliasNode()?.getText() ?? namedImport.getName())\n }\n }\n }\n\n if (diffTypeNames.size === 0) {\n return diffTypeNames\n }\n\n let hasFoundNewName = true\n\n while (hasFoundNewName) {\n hasFoundNewName = false\n\n const derivedTypeNames = [\n ...sourceFile\n .getTypeAliases()\n .filter((typeAlias) =>\n referencesDiffType({ diffTypeNames, typeNode: typeAlias.getTypeNodeOrThrow() }),\n ),\n ...sourceFile\n .getInterfaces()\n .filter((declaration) =>\n declaration\n .getExtends()\n .some((heritage) => diffTypeNames.has(heritage.getExpression().getText())),\n ),\n ].map((declaration) => declaration.getName())\n\n for (const typeName of derivedTypeNames) {\n if (!diffTypeNames.has(typeName)) {\n diffTypeNames.add(typeName)\n hasFoundNewName = true\n }\n }\n }\n\n return diffTypeNames\n}\n\n/**\n * Applies a single rewrite and reports whether one was made. Renames replace source text, which\n * invalidates previously queried nodes, so the caller re-scans the file after every rewrite.\n */\nfunction rewriteNextOccurrence({\n diffTypeNames,\n sourceFile,\n}: {\n diffTypeNames: Set<string>\n sourceFile: SourceFile\n}): boolean {\n for (const component of findDiffComponents({ diffTypeNames, sourceFile })) {\n const propsParameterName = component.getParameters()[0]!.getNameNode()\n const propsBindingPatterns: ObjectBindingPattern[] = []\n const propsIdentifiers: Identifier[] = []\n\n if (Node.isObjectBindingPattern(propsParameterName)) {\n propsBindingPatterns.push(propsParameterName)\n\n const restElementName = propsParameterName\n .getElements()\n .find((element) => element.getDotDotDotToken())\n ?.getNameNode()\n\n if (restElementName && Node.isIdentifier(restElementName)) {\n propsIdentifiers.push(restElementName)\n }\n } else if (Node.isIdentifier(propsParameterName)) {\n propsIdentifiers.push(propsParameterName)\n }\n\n const readsProps = (node: Node): boolean =>\n Node.isIdentifier(node) &&\n propsIdentifiers.some((propsIdentifier) =>\n isReferenceTo({ declaration: propsIdentifier, identifier: node }),\n )\n\n for (const declaration of component.getDescendantsOfKind(SyntaxKind.VariableDeclaration)) {\n const declarationName = declaration.getNameNode()\n const initializer = declaration.getInitializer()\n\n if (Node.isObjectBindingPattern(declarationName) && initializer && readsProps(initializer)) {\n propsBindingPatterns.push(declarationName)\n }\n }\n\n for (const pattern of propsBindingPatterns) {\n for (const element of pattern.getElements()) {\n if (rewriteBindingElement({ component, element })) {\n return true\n }\n }\n }\n\n for (const access of component.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {\n const newName = RENAMED_PROPS.get(access.getName())\n\n if (newName && readsProps(access.getExpression())) {\n access.getNameNode().replaceWithText(newName)\n return true\n }\n }\n\n for (const access of component.getDescendantsOfKind(SyntaxKind.ElementAccessExpression)) {\n const argument = access.getArgumentExpression()\n\n if (!argument || !Node.isStringLiteral(argument) || !readsProps(access.getExpression())) {\n continue\n }\n\n const newName = RENAMED_PROPS.get(argument.getLiteralValue())\n\n if (newName) {\n argument.setLiteralValue(newName)\n return true\n }\n }\n }\n\n for (const indexedAccess of sourceFile.getDescendantsOfKind(SyntaxKind.IndexedAccessType)) {\n const indexType = indexedAccess.getIndexTypeNode()\n const literal = Node.isLiteralTypeNode(indexType) ? indexType.getLiteral() : undefined\n\n if (\n !literal ||\n !Node.isStringLiteral(literal) ||\n !referencesDiffType({ diffTypeNames, typeNode: indexedAccess.getObjectTypeNode() })\n ) {\n continue\n }\n\n const newName = RENAMED_PROPS.get(literal.getLiteralValue())\n\n if (newName) {\n literal.setLiteralValue(newName)\n return true\n }\n }\n\n return false\n}\n\n/**\n * Finds functions whose first parameter is typed with a Diff type, either directly\n * (`(props: TextFieldDiffClientProps) => ...`) or through the variable they are assigned to\n * (`const Diff: React.FC<TextFieldDiffClientProps> = (props) => ...`).\n */\nfunction findDiffComponents({\n diffTypeNames,\n sourceFile,\n}: {\n diffTypeNames: Set<string>\n sourceFile: SourceFile\n}): ComponentFunction[] {\n const functions: ComponentFunction[] = [\n ...sourceFile.getDescendantsOfKind(SyntaxKind.ArrowFunction),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.FunctionDeclaration),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.FunctionExpression),\n ]\n\n return functions.filter((component) => {\n const propsParameter = component.getParameters()[0]\n\n if (!propsParameter) {\n return false\n }\n\n const parent = component.getParent()\n const typeNodes = [\n propsParameter.getTypeNode(),\n Node.isVariableDeclaration(parent) ? parent.getTypeNode() : undefined,\n ]\n\n return typeNodes.some((typeNode) => typeNode && referencesDiffType({ diffTypeNames, typeNode }))\n })\n}\n\nfunction referencesDiffType({\n diffTypeNames,\n typeNode,\n}: {\n diffTypeNames: Set<string>\n typeNode: TypeNode\n}): boolean {\n return [typeNode, ...typeNode.getDescendantsOfKind(SyntaxKind.TypeReference)].some(\n (node) =>\n Node.isTypeReference(node) &&\n diffTypeNames.has(node.getTypeName().getText()) &&\n !isWrappedWithin({ node, root: typeNode }),\n )\n}\n\n/**\n * Whether `node` sits inside a type that wraps the props rather than describing them, such as\n * `{ diff: TextFieldDiffClientProps }` or `TextFieldDiffClientProps['valueFrom']`.\n */\nfunction isWrappedWithin({ node, root }: { node: Node; root: TypeNode }): boolean {\n const stopAt = root.getParent()\n\n for (\n let ancestor = node.getParent();\n ancestor && ancestor !== stopAt;\n ancestor = ancestor.getParent()\n ) {\n if (Node.isPropertySignature(ancestor) || Node.isIndexedAccessTypeNode(ancestor)) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Renames the destructured key of a single binding element. Returns `false` when the element\n * doesn't destructure one of the renamed props.\n */\nfunction rewriteBindingElement({\n component,\n element,\n}: {\n component: ComponentFunction\n element: BindingElement\n}): boolean {\n if (element.getDotDotDotToken()) {\n return false\n }\n\n const nameNode = element.getNameNode()\n const propertyNameNode = element.getPropertyNameNode()\n const propertyName = propertyNameNode\n ? getPropertyNameText({ node: propertyNameNode })\n : nameNode.getText()\n const newName = propertyName ? RENAMED_PROPS.get(propertyName) : undefined\n\n if (!propertyName || !newName) {\n return false\n }\n\n const initializer = element.getInitializer()\n const initializerText = initializer ? ` = ${initializer.getText()}` : ''\n\n if (propertyNameNode) {\n const localName = nameNode.getText()\n\n element.replaceWithText(\n localName === newName\n ? `${newName}${initializerText}`\n : `${newName}: ${localName}${initializerText}`,\n )\n return true\n }\n\n // A shorthand `{ comparisonValue }` also declares a local variable. Renaming it through the\n // language service updates every reference, and `usePrefixAndSuffixText` leaves the element as\n // `comparisonValue: valueFrom`, which the next pass collapses to `valueFrom`.\n if (Node.isIdentifier(nameNode) && !containsIdentifierNamed({ name: newName, node: component })) {\n const sourceFile = element.getSourceFile()\n const textBeforeRename = sourceFile.getFullText()\n\n try {\n nameNode.rename(newName, { usePrefixAndSuffixText: true })\n } catch {\n // Fall back to keeping the local variable name below\n }\n\n if (sourceFile.getFullText() !== textBeforeRename) {\n return true\n }\n }\n\n element.replaceWithText(`${newName}: ${propertyName}${initializerText}`)\n return true\n}\n\nfunction getPropertyNameText({ node }: { node: Node }): string | undefined {\n if (Node.isIdentifier(node)) {\n return node.getText()\n }\n\n if (Node.isStringLiteral(node)) {\n return node.getLiteralValue()\n }\n\n return undefined\n}\n\nfunction containsIdentifierNamed({ name, node }: { name: string; node: Node }): boolean {\n return node\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some((identifier) => identifier.getText() === name)\n}\n\n/**\n * Compares symbols so an inner variable that shadows the props parameter isn't mistaken for it.\n * Falls back to comparing names when the type checker can't resolve a symbol.\n */\nfunction isReferenceTo({\n declaration,\n identifier,\n}: {\n declaration: Identifier\n identifier: Identifier\n}): boolean {\n if (identifier.getText() !== declaration.getText()) {\n return false\n }\n\n const declarationSymbol = declaration.getSymbol()\n\n return !declarationSymbol || identifier.getSymbol() === declarationSymbol\n}\n\n/**\n * Flags old prop names that remain in a property position, e.g. a JSX attribute passing\n * `comparisonValue` to another component, or `Pick<Props, 'versionValue'>`. Local variables that\n * merely share the old name are left alone.\n */\nfunction collectLeftoverNotes({ sourceFile }: { sourceFile: SourceFile }): string[] {\n const notedLocations = new Set<string>()\n const notes: string[] = []\n const candidates = [\n ...sourceFile\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .filter((identifier) => isPropertyNamePosition({ identifier })),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.StringLiteral),\n ].sort((a, b) => a.getStart() - b.getStart())\n\n for (const candidate of candidates) {\n const oldName = Node.isStringLiteral(candidate)\n ? candidate.getLiteralValue()\n : candidate.getText()\n const newName = RENAMED_PROPS.get(oldName)\n const location = `${sourceFile.getFilePath()}:${candidate.getStartLineNumber()}`\n\n if (!newName || notedLocations.has(`${location}:${oldName}`)) {\n continue\n }\n\n notedLocations.add(`${location}:${oldName}`)\n notes.push(\n `${location}: \\`${oldName}\\` was not migrated. If it refers to a Diff component prop, rename it to \\`${newName}\\`.`,\n )\n }\n\n return notes\n}\n\nfunction isPropertyNamePosition({ identifier }: { identifier: Identifier }): boolean {\n const parent = identifier.getParent()\n\n if (Node.isShorthandPropertyAssignment(parent) || Node.isJsxAttribute(parent)) {\n return true\n }\n\n if (Node.isBindingElement(parent)) {\n const propertyNameNode = parent.getPropertyNameNode()\n\n return propertyNameNode ? propertyNameNode === identifier : !parent.getDotDotDotToken()\n }\n\n if (\n Node.isPropertyAccessExpression(parent) ||\n Node.isPropertyAssignment(parent) ||\n Node.isPropertySignature(parent)\n ) {\n return parent.getNameNode() === identifier\n }\n\n return false\n}\n"],"names":["Node","SyntaxKind","RENAMED_PROPS","Map","DIFF_TYPE_NAME_PATTERN","MAX_REWRITES_PER_FILE","renameDiffValueProps","name","apply","project","filesChanged","notes","sourceFile","getSourceFiles","isDeclarationFile","isInNodeModules","diffTypeNames","collectDiffTypeNames","size","rewriteCount","rewriteNextOccurrence","push","getFilePath","collectLeftoverNotes","length","description","Set","importDeclaration","getImportDeclarations","getModuleSpecifierValue","namedImport","getNamedImports","test","getName","add","getAliasNode","getText","hasFoundNewName","derivedTypeNames","getTypeAliases","filter","typeAlias","referencesDiffType","typeNode","getTypeNodeOrThrow","getInterfaces","declaration","getExtends","some","heritage","has","getExpression","map","typeName","component","findDiffComponents","propsParameterName","getParameters","getNameNode","propsBindingPatterns","propsIdentifiers","isObjectBindingPattern","restElementName","getElements","find","element","getDotDotDotToken","isIdentifier","readsProps","node","propsIdentifier","isReferenceTo","identifier","getDescendantsOfKind","VariableDeclaration","declarationName","initializer","getInitializer","pattern","rewriteBindingElement","access","PropertyAccessExpression","newName","get","replaceWithText","ElementAccessExpression","argument","getArgumentExpression","isStringLiteral","getLiteralValue","setLiteralValue","indexedAccess","IndexedAccessType","indexType","getIndexTypeNode","literal","isLiteralTypeNode","getLiteral","undefined","getObjectTypeNode","functions","ArrowFunction","FunctionDeclaration","FunctionExpression","propsParameter","parent","getParent","typeNodes","getTypeNode","isVariableDeclaration","TypeReference","isTypeReference","getTypeName","isWrappedWithin","root","stopAt","ancestor","isPropertySignature","isIndexedAccessTypeNode","nameNode","propertyNameNode","getPropertyNameNode","propertyName","getPropertyNameText","initializerText","localName","containsIdentifierNamed","getSourceFile","textBeforeRename","getFullText","rename","usePrefixAndSuffixText","Identifier","declarationSymbol","getSymbol","notedLocations","candidates","isPropertyNamePosition","StringLiteral","sort","a","b","getStart","candidate","oldName","location","getStartLineNumber","isShorthandPropertyAssignment","isJsxAttribute","isBindingElement","isPropertyAccessExpression","isPropertyAssignment"],"mappings":"AAWA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAU;AAI3C,MAAMC,gBAAgB,IAAIC,IAAI;IAC5B;QAAC;QAAmB;KAAY;IAChC;QAAC;QAAgB;KAAU;CAC5B;AAED;;;;CAIC,GACD,MAAMC,yBAAyB;AAE/B;;;CAGC,GACD,MAAMC,wBAAwB;AAI9B,OAAO,MAAMC,uBAAkC;IAC7CC,MAAM;IACNC,OAAO,CAAC,EAAEC,OAAO,EAAE;QACjB,MAAMC,eAAyB,EAAE;QACjC,MAAMC,QAAkB,EAAE;QAE1B,KAAK,MAAMC,cAAcH,QAAQI,cAAc,G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AWU,WAAW,GAAG,CAAC,EAAEyH,UAAUG,kBAAkB,IAAI;QAEhF,IAAI,CAAChE,WAAWqD,eAAerF,GAAG,CAAC,GAAG+F,SAAS,CAAC,EAAED,SAAS,GAAG;YAC5D;QACF;QAEAT,eAAerG,GAAG,CAAC,GAAG+G,SAAS,CAAC,EAAED,SAAS;QAC3CrI,MAAMU,IAAI,CACR,GAAG4H,SAAS,IAAI,EAAED,QAAQ,2EAA2E,EAAE9D,QAAQ,GAAG,CAAC;IAEvH;IAEA,OAAOvE;AACT;AAEA,SAAS8H,uBAAuB,EAAEjE,UAAU,EAA8B;IACxE,MAAMiC,SAASjC,WAAWkC,SAAS;IAEnC,IAAI1G,KAAKmJ,6BAA6B,CAAC1C,WAAWzG,KAAKoJ,cAAc,CAAC3C,SAAS;QAC7E,OAAO;IACT;IAEA,IAAIzG,KAAKqJ,gBAAgB,CAAC5C,SAAS;QACjC,MAAMe,mBAAmBf,OAAOgB,mBAAmB;QAEnD,OAAOD,mBAAmBA,qBAAqBhD,aAAa,CAACiC,OAAOvC,iBAAiB;IACvF;IAEA,IACElE,KAAKsJ,0BAA0B,CAAC7C,WAChCzG,KAAKuJ,oBAAoB,CAAC9C,WAC1BzG,KAAKqH,mBAAmB,CAACZ,SACzB;QACA,OAAOA,OAAO/C,WAAW,OAAOc;IAClC;IAEA,OAAO;AACT"}
@@ -0,0 +1,8 @@
1
+ export const isUnchanged = ({ comparisonValue, versionValue })=>comparisonValue === versionValue;
2
+ export const TextField = (props)=>props.versionValue;
3
+ export const versionValueField = {
4
+ name: 'versionValue',
5
+ type: 'text'
6
+ };
7
+
8
+ //# sourceMappingURL=no-match.input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/rename-diff-value-props/no-match.input.ts"],"sourcesContent":["import type { Field, TextFieldClientProps } from 'payload'\n\ntype Comparison = { comparisonValue: unknown; versionValue: unknown }\n\nexport const isUnchanged = ({ comparisonValue, versionValue }: Comparison) =>\n comparisonValue === versionValue\n\nexport const TextField = (props: TextFieldClientProps & Comparison) => props.versionValue\n\nexport const versionValueField: Field = { name: 'versionValue', type: 'text' }\n"],"names":["isUnchanged","comparisonValue","versionValue","TextField","props","versionValueField","name","type"],"mappings":"AAIA,OAAO,MAAMA,cAAc,CAAC,EAAEC,eAAe,EAAEC,YAAY,EAAc,GACvED,oBAAoBC,aAAY;AAElC,OAAO,MAAMC,YAAY,CAACC,QAA6CA,MAAMF,YAAY,CAAA;AAEzF,OAAO,MAAMG,oBAA2B;IAAEC,MAAM;IAAgBC,MAAM;AAAO,EAAC"}
@@ -3,7 +3,7 @@
3
3
  * the monorepo (this one included) is versioned and published in lockstep, so
4
4
  * the dist-tag the codemod was invoked under (`npx @payloadcms/codemod@beta`)
5
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.
6
+ * beta for stable or local dev builds that carry no prerelease id.
7
7
  */
8
8
  export declare function resolveDefaultTag(version?: string | undefined): string;
9
9
  //# sourceMappingURL=defaultTag.d.ts.map
@@ -2,13 +2,13 @@ import { readFileSync } from 'node:fs';
2
2
  import { dirname, resolve } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import semver from 'semver';
5
- /** Dist-tag used when neither --tag nor the running version implies one. */ const FALLBACK_TAG = 'canary';
5
+ /** Dist-tag used when neither --tag nor the running version implies one. */ const FALLBACK_TAG = 'beta';
6
6
  /**
7
7
  * Default Payload dist-tag when the caller did not pass --tag. Every package in
8
8
  * the monorepo (this one included) is versioned and published in lockstep, so
9
9
  * the dist-tag the codemod was invoked under (`npx @payloadcms/codemod@beta`)
10
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.
11
+ * beta for stable or local dev builds that carry no prerelease id.
12
12
  */ export function resolveDefaultTag(version = readOwnVersion()) {
13
13
  const id = version ? semver.prerelease(version)?.[0] : undefined;
14
14
  return typeof id === 'string' ? id : FALLBACK_TAG;
@@ -1 +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"}
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 = 'beta'\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 * beta 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"}
@@ -30,8 +30,8 @@ Run this from the project root:
30
30
 
31
31
  ${command} upgrade run
32
32
 
33
- By default it resolves Payload from the dist-tag this CLI was installed under (\`beta\` when you
34
- ran \`@payloadcms/codemod@beta\`, else \`canary\`). Add \`--tag <dist-tag>\` to pin a specific one.
33
+ By default it resolves Payload from the dist-tag this CLI was installed under (its own
34
+ prerelease id, else \`beta\`). Add \`--tag <dist-tag>\` to pin a specific one.
35
35
  This pins the Payload packages to v4, removes conflicting overrides, writes the toolchain
36
36
  floors, installs, and runs the AST transforms. Read its report:
37
37
  - It prints the resolved payload version, the required Next target, and the path to the