create-payload-app 4.0.0-internal.fec2230 → 4.0.0-internal.ff27d6e

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 (107) hide show
  1. package/dist/lib/agent-config.d.ts +2 -5
  2. package/dist/lib/agent-config.d.ts.map +1 -1
  3. package/dist/lib/agent-config.js +1 -8
  4. package/dist/lib/agent-config.js.map +1 -1
  5. package/dist/lib/ast/adapter-config.d.ts +2 -0
  6. package/dist/lib/ast/adapter-config.d.ts.map +1 -1
  7. package/dist/lib/ast/adapter-config.js +6 -0
  8. package/dist/lib/ast/adapter-config.js.map +1 -1
  9. package/dist/lib/ast/package-json.d.ts.map +1 -1
  10. package/dist/lib/ast/package-json.js +11 -6
  11. package/dist/lib/ast/package-json.js.map +1 -1
  12. package/dist/lib/ast/payload-config.d.ts.map +1 -1
  13. package/dist/lib/ast/payload-config.js +101 -55
  14. package/dist/lib/ast/payload-config.js.map +1 -1
  15. package/dist/lib/ast/types.d.ts +1 -1
  16. package/dist/lib/ast/types.d.ts.map +1 -1
  17. package/dist/lib/ast/types.js.map +1 -1
  18. package/dist/lib/configure-payload-config.js +1 -1
  19. package/dist/lib/configure-payload-config.js.map +1 -1
  20. package/dist/lib/create-project.d.ts.map +1 -1
  21. package/dist/lib/create-project.js +51 -8
  22. package/dist/lib/create-project.js.map +1 -1
  23. package/dist/lib/download-example.js.map +1 -1
  24. package/dist/lib/download-template.js.map +1 -1
  25. package/dist/lib/get-package-manager.d.ts +9 -0
  26. package/dist/lib/get-package-manager.d.ts.map +1 -1
  27. package/dist/lib/get-package-manager.js +20 -0
  28. package/dist/lib/get-package-manager.js.map +1 -1
  29. package/dist/lib/init-next.d.ts +5 -0
  30. package/dist/lib/init-next.d.ts.map +1 -1
  31. package/dist/lib/init-next.js +14 -3
  32. package/dist/lib/init-next.js.map +1 -1
  33. package/dist/lib/init-tanstack.js +2 -3
  34. package/dist/lib/init-tanstack.js.map +1 -1
  35. package/dist/lib/tanstack/template-files.d.ts +4 -4
  36. package/dist/lib/tanstack/template-files.d.ts.map +1 -1
  37. package/dist/lib/tanstack/template-files.js +5 -5
  38. package/dist/lib/tanstack/template-files.js.map +1 -1
  39. package/dist/lib/update-payload-in-project.js +3 -3
  40. package/dist/lib/update-payload-in-project.js.map +1 -1
  41. package/dist/main.d.ts.map +1 -1
  42. package/dist/main.js +2 -3
  43. package/dist/main.js.map +1 -1
  44. package/dist/template/src/app/(frontend)/styles.css +7 -0
  45. package/dist/template/src/app/(payload)/admin/[[...segments]]/not-found.tsx +1 -2
  46. package/dist/template/src/app/(payload)/admin/[[...segments]]/page.tsx +1 -2
  47. package/dist/template/src/app/(payload)/admin/importMap.js +14 -0
  48. package/dist/template/src/app/(payload)/api/[...slug]/route.ts +1 -2
  49. package/dist/template/src/app/(payload)/api/graphql/route.ts +1 -2
  50. package/dist/template/src/app/(payload)/api/graphql-playground/route.ts +1 -2
  51. package/dist/template/src/app/(payload)/layout.tsx +1 -2
  52. package/dist/template/src/payload.config.ts +5 -3
  53. package/dist/template-tanstack/routes/_payload/admin.$.tsx +20 -3
  54. package/dist/template-tanstack/routes/_payload/admin.index.tsx +20 -3
  55. package/dist/template-tanstack/routes/_payload/api.$.ts +2 -1
  56. package/dist/template-tanstack/routes/_payload/custom.css +0 -0
  57. package/dist/template-tanstack/routes/_payload/importMap.js +5 -5
  58. package/dist/template-tanstack/routes/_payload/server.functions.ts +3 -5
  59. package/dist/template-tanstack/routes/_payload.tsx +1 -2
  60. package/dist/template-tanstack/src/payload.config.ts +1 -3
  61. package/dist/utils/messages.d.ts.map +1 -1
  62. package/dist/utils/messages.js +3 -2
  63. package/dist/utils/messages.js.map +1 -1
  64. package/dist/utils/resolvePackageVersion.d.ts +10 -4
  65. package/dist/utils/resolvePackageVersion.d.ts.map +1 -1
  66. package/dist/utils/resolvePackageVersion.js +24 -3
  67. package/dist/utils/resolvePackageVersion.js.map +1 -1
  68. package/package.json +19 -21
  69. package/dist/ast-integration.spec.js +0 -132
  70. package/dist/ast-integration.spec.js.map +0 -1
  71. package/dist/lib/agent-config.spec.js +0 -23
  72. package/dist/lib/agent-config.spec.js.map +0 -1
  73. package/dist/lib/ast/package-json.spec.js +0 -139
  74. package/dist/lib/ast/package-json.spec.js.map +0 -1
  75. package/dist/lib/ast/payload-config.spec.js +0 -365
  76. package/dist/lib/ast/payload-config.spec.js.map +0 -1
  77. package/dist/lib/ast/utils.spec.js +0 -226
  78. package/dist/lib/ast/utils.spec.js.map +0 -1
  79. package/dist/lib/configure-payload-tsconfig.spec.js +0 -135
  80. package/dist/lib/configure-payload-tsconfig.spec.js.map +0 -1
  81. package/dist/lib/create-project.spec.js +0 -199
  82. package/dist/lib/create-project.spec.js.map +0 -1
  83. package/dist/lib/init-tanstack-default-template.spec.js +0 -121
  84. package/dist/lib/init-tanstack-default-template.spec.js.map +0 -1
  85. package/dist/lib/init-tanstack.spec.js +0 -394
  86. package/dist/lib/init-tanstack.spec.js.map +0 -1
  87. package/dist/lib/manage-env-files.spec.js +0 -118
  88. package/dist/lib/manage-env-files.spec.js.map +0 -1
  89. package/dist/lib/tanstack/detect.spec.js +0 -227
  90. package/dist/lib/tanstack/detect.spec.js.map +0 -1
  91. package/dist/lib/tanstack/prepare.spec.js +0 -288
  92. package/dist/lib/tanstack/prepare.spec.js.map +0 -1
  93. package/dist/lib/tanstack/transform-root-route.spec.js +0 -484
  94. package/dist/lib/tanstack/transform-root-route.spec.js.map +0 -1
  95. package/dist/lib/tanstack/transform-router.spec.js +0 -264
  96. package/dist/lib/tanstack/transform-router.spec.js.map +0 -1
  97. package/dist/lib/tanstack/transform-vite-config.spec.js +0 -456
  98. package/dist/lib/tanstack/transform-vite-config.spec.js.map +0 -1
  99. package/dist/lib/update-payload-in-project.spec.js +0 -262
  100. package/dist/lib/update-payload-in-project.spec.js.map +0 -1
  101. package/dist/lib/wrap-next-config.spec.js +0 -167
  102. package/dist/lib/wrap-next-config.spec.js.map +0 -1
  103. package/dist/main.spec.js +0 -102
  104. package/dist/main.spec.js.map +0 -1
  105. package/dist/template-tanstack/src/payload.css +0 -1
  106. package/dist/utils/resolvePackageVersion.spec.js +0 -77
  107. package/dist/utils/resolvePackageVersion.spec.js.map +0 -1
@@ -1,262 +0,0 @@
1
- import fse from 'fs-extra';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
- import { updatePayloadInNextProject, updatePayloadInTanStackProject, updatePayloadPackages } from './update-payload-in-project.js';
7
- const dirname = path.dirname(fileURLToPath(import.meta.url));
8
- const mocks = vi.hoisted(()=>({
9
- getPackageManager: vi.fn(),
10
- installPackages: vi.fn(),
11
- resolvePackageVersion: vi.fn()
12
- }));
13
- vi.mock('../utils/resolvePackageVersion.js', async (importOriginal)=>({
14
- ...await importOriginal(),
15
- resolvePackageVersion: mocks.resolvePackageVersion
16
- }));
17
- vi.mock('./get-package-manager.js', ()=>({
18
- getPackageManager: mocks.getPackageManager
19
- }));
20
- vi.mock('./install-packages.js', ()=>({
21
- installPackages: mocks.installPackages
22
- }));
23
- describe('Payload project updates', ()=>{
24
- let projectDir;
25
- let templateRoot;
26
- beforeEach(()=>{
27
- vi.clearAllMocks();
28
- projectDir = fse.mkdtempSync(path.join(os.tmpdir(), 'cpa-update-project-'));
29
- templateRoot = fse.mkdtempSync(path.join(os.tmpdir(), 'cpa-update-template-'));
30
- mocks.getPackageManager.mockResolvedValue('pnpm');
31
- mocks.installPackages.mockResolvedValue({
32
- success: true
33
- });
34
- mocks.resolvePackageVersion.mockResolvedValue('4.2.0');
35
- });
36
- afterEach(()=>{
37
- fse.removeSync(projectDir);
38
- fse.removeSync(templateRoot);
39
- });
40
- it('should update every installed Payload dependency to one version without a Next config', async ()=>{
41
- fse.writeJsonSync(path.join(projectDir, 'package.json'), {
42
- dependencies: {
43
- '@payloadcms/db-mongodb': '^3.0.0',
44
- '@payloadcms/richtext-lexical': '^3.0.0',
45
- payload: '^3.0.0',
46
- react: '^19.0.0'
47
- }
48
- });
49
- const result = await updatePayloadPackages({
50
- projectDir,
51
- versionOrTag: 'beta'
52
- });
53
- expect(result).toEqual({
54
- message: 'Payload updated successfully.',
55
- success: true
56
- });
57
- expect(mocks.resolvePackageVersion).toHaveBeenCalledOnce();
58
- expect(mocks.resolvePackageVersion).toHaveBeenCalledWith({
59
- packageName: 'payload',
60
- versionOrTag: 'beta'
61
- });
62
- expect(mocks.installPackages).toHaveBeenCalledWith({
63
- packageManager: 'pnpm',
64
- packagesToInstall: [
65
- 'payload@4.2.0',
66
- '@payloadcms/db-mongodb@4.2.0',
67
- '@payloadcms/richtext-lexical@4.2.0'
68
- ],
69
- projectDir
70
- });
71
- });
72
- it('should update a stale Payload package when payload is already at the target version', async ()=>{
73
- fse.writeJsonSync(path.join(projectDir, 'package.json'), {
74
- dependencies: {
75
- '@payloadcms/ui': '4.1.0',
76
- payload: '4.2.0'
77
- }
78
- });
79
- const result = await updatePayloadPackages({
80
- projectDir,
81
- versionOrTag: 'beta'
82
- });
83
- expect(result).toEqual({
84
- message: 'Payload updated successfully.',
85
- success: true
86
- });
87
- expect(mocks.installPackages).toHaveBeenCalledWith({
88
- packageManager: 'pnpm',
89
- packagesToInstall: [
90
- 'payload@4.2.0',
91
- '@payloadcms/ui@4.2.0'
92
- ],
93
- projectDir
94
- });
95
- });
96
- it('should update Payload packages installed as development dependencies', async ()=>{
97
- fse.writeJsonSync(path.join(projectDir, 'package.json'), {
98
- dependencies: {
99
- '@payloadcms/ui': '4.1.0',
100
- payload: '4.1.0'
101
- },
102
- devDependencies: {
103
- '@payloadcms/graphql': '4.1.0',
104
- vitest: '^4.0.0'
105
- }
106
- });
107
- const result = await updatePayloadPackages({
108
- projectDir,
109
- versionOrTag: 'beta'
110
- });
111
- expect(result).toEqual({
112
- message: 'Payload updated successfully.',
113
- success: true
114
- });
115
- expect(mocks.installPackages).toHaveBeenCalledWith({
116
- packageManager: 'pnpm',
117
- packagesToInstall: [
118
- 'payload@4.2.0',
119
- '@payloadcms/ui@4.2.0',
120
- '@payloadcms/graphql@4.2.0'
121
- ],
122
- projectDir
123
- });
124
- });
125
- it('should refresh Next Payload routes without overwriting custom CSS', async ()=>{
126
- writeProjectPackage(projectDir);
127
- const nextConfigPath = path.join(projectDir, 'next.config.ts');
128
- const payloadDir = path.join(projectDir, 'src/app/(payload)');
129
- const importMapPath = path.join(payloadDir, 'admin/importMap.js');
130
- const customCssPath = path.join(payloadDir, 'custom.css');
131
- const sourceImportMapPath = path.resolve(dirname, '../../../../templates/blank/src/app/(payload)/admin/importMap.js');
132
- fse.outputFileSync(importMapPath, 'stale import map\n');
133
- fse.outputFileSync(customCssPath, '.custom { color: rebeccapurple; }\n');
134
- const appDetails = {
135
- hasTopLevelLayout: false,
136
- isPayloadInstalled: true,
137
- isSrcDir: true,
138
- isSupportedNextVersion: true,
139
- nextConfigPath,
140
- nextVersion: '15.0.0'
141
- };
142
- const result = await updatePayloadInNextProject({
143
- appDetails,
144
- versionOrTag: 'beta'
145
- });
146
- expect(result).toEqual({
147
- message: 'Payload updated successfully.',
148
- success: true
149
- });
150
- expect(fse.readFileSync(importMapPath, 'utf8')).toBe(fse.readFileSync(sourceImportMapPath, 'utf8'));
151
- expect(fse.readFileSync(customCssPath, 'utf8')).toBe('.custom { color: rebeccapurple; }\n');
152
- });
153
- it('should refresh Payload-owned TanStack files without overwriting custom styles', async ()=>{
154
- writeProjectPackage(projectDir);
155
- writeFiles({
156
- files: {
157
- 'routes/_payload.tsx': 'fresh payload layout\n',
158
- 'routes/_payload/admin.$.tsx': 'fresh admin splat\n',
159
- 'routes/_payload/admin.index.tsx': 'fresh admin index\n',
160
- 'routes/_payload/api.$.ts': 'fresh API route\n',
161
- 'routes/_payload/importMap.js': 'fresh import map\n',
162
- 'routes/_payload/server.functions.ts': 'fresh server functions\n',
163
- 'src/payload.css': 'template Payload route CSS\n',
164
- 'src/payload.config.ts': 'template Payload config\n'
165
- },
166
- root: templateRoot
167
- });
168
- writeFiles({
169
- files: {
170
- 'src/router.tsx': 'custom router\n',
171
- 'src/routes/__root.tsx': 'custom root route\n',
172
- 'src/routes/_frontend.tsx': 'custom frontend layout\n',
173
- 'src/routes/_frontend/index.tsx': 'custom frontend route\n',
174
- 'src/routes/_payload.tsx': 'stale payload layout\n',
175
- 'src/routes/_payload/admin.$.tsx': 'stale admin splat\n',
176
- 'src/routes/_payload/admin.index.tsx': 'stale admin index\n',
177
- 'src/routes/_payload/api.$.ts': 'stale API route\n',
178
- 'src/routes/_payload/importMap.js': 'stale import map\n',
179
- 'src/routes/_payload/server.functions.ts': 'stale server functions\n',
180
- 'src/payload.css': 'custom Payload CSS\n',
181
- 'src/styles.css': 'custom frontend CSS\n',
182
- 'vite.config.ts': 'custom Vite config\n'
183
- },
184
- root: projectDir
185
- });
186
- const appDetails = {
187
- isPayloadInstalled: true,
188
- kind: 'start',
189
- projectDir,
190
- rootRoutePath: path.join(projectDir, 'src/routes/__root.tsx'),
191
- routerPath: path.join(projectDir, 'src/router.tsx'),
192
- routesDir: path.join(projectDir, 'src/routes'),
193
- sourceDir: path.join(projectDir, 'src'),
194
- viteConfigPath: path.join(projectDir, 'vite.config.ts')
195
- };
196
- const preservedFiles = [
197
- appDetails.viteConfigPath,
198
- appDetails.routerPath,
199
- appDetails.rootRoutePath,
200
- path.join(appDetails.routesDir, '_frontend.tsx'),
201
- path.join(appDetails.routesDir, '_frontend/index.tsx'),
202
- path.join(appDetails.sourceDir, 'payload.css'),
203
- path.join(appDetails.sourceDir, 'styles.css')
204
- ];
205
- const before = new Map(preservedFiles.map((filePath)=>[
206
- filePath,
207
- fse.readFileSync(filePath, 'utf8')
208
- ]));
209
- const result = await updatePayloadInTanStackProject({
210
- appDetails,
211
- templateRoot,
212
- versionOrTag: 'beta'
213
- });
214
- expect(result).toEqual({
215
- message: 'Payload updated successfully.',
216
- success: true
217
- });
218
- expect(fse.readFileSync(path.join(appDetails.routesDir, '_payload.tsx'), 'utf8')).toBe('fresh payload layout\n');
219
- expect(fse.readFileSync(path.join(appDetails.routesDir, '_payload/server.functions.ts'), 'utf8')).toBe('fresh server functions\n');
220
- for (const [filePath, content] of before){
221
- expect(fse.readFileSync(filePath, 'utf8')).toBe(content);
222
- }
223
- });
224
- it('should refresh TanStack routes from the source template by default', async ()=>{
225
- writeProjectPackage(projectDir);
226
- const payloadLayoutPath = path.join(projectDir, 'src/routes/_payload.tsx');
227
- const sourcePayloadLayoutPath = path.resolve(dirname, '../../../../templates/blank-tanstack/src/app/_payload.tsx');
228
- const sourcePayloadStylesPath = path.resolve(dirname, '../../../../templates/blank-tanstack/src/payload.css');
229
- fse.outputFileSync(payloadLayoutPath, 'stale payload layout\n');
230
- const appDetails = {
231
- isPayloadInstalled: true,
232
- kind: 'start',
233
- projectDir,
234
- rootRoutePath: path.join(projectDir, 'src/routes/__root.tsx'),
235
- routerPath: path.join(projectDir, 'src/router.tsx'),
236
- routesDir: path.join(projectDir, 'src/routes'),
237
- sourceDir: path.join(projectDir, 'src'),
238
- viteConfigPath: path.join(projectDir, 'vite.config.ts')
239
- };
240
- await updatePayloadInTanStackProject({
241
- appDetails,
242
- versionOrTag: 'beta'
243
- });
244
- expect(fse.readFileSync(payloadLayoutPath, 'utf8')).toBe(fse.readFileSync(sourcePayloadLayoutPath, 'utf8'));
245
- expect(fse.readFileSync(path.join(appDetails.sourceDir, 'payload.css'), 'utf8')).toBe(fse.readFileSync(sourcePayloadStylesPath, 'utf8'));
246
- });
247
- });
248
- function writeFiles({ files, root }) {
249
- for (const [relativePath, content] of Object.entries(files)){
250
- fse.outputFileSync(path.join(root, relativePath), content);
251
- }
252
- }
253
- function writeProjectPackage(projectDir) {
254
- fse.writeJsonSync(path.join(projectDir, 'package.json'), {
255
- dependencies: {
256
- '@payloadcms/ui': '^3.0.0',
257
- payload: '^3.0.0'
258
- }
259
- });
260
- }
261
-
262
- //# sourceMappingURL=update-payload-in-project.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/update-payload-in-project.spec.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'\n\nimport type { NextAppDetails, TanStackAppDetails } from '../types.js'\n\nimport {\n updatePayloadInNextProject,\n updatePayloadInTanStackProject,\n updatePayloadPackages,\n} from './update-payload-in-project.js'\n\nconst dirname = path.dirname(fileURLToPath(import.meta.url))\n\nconst mocks = vi.hoisted(() => ({\n getPackageManager: vi.fn(),\n installPackages: vi.fn(),\n resolvePackageVersion: vi.fn(),\n}))\n\nvi.mock('../utils/resolvePackageVersion.js', async (importOriginal) => ({\n ...(await importOriginal()),\n resolvePackageVersion: mocks.resolvePackageVersion,\n}))\n\nvi.mock('./get-package-manager.js', () => ({\n getPackageManager: mocks.getPackageManager,\n}))\n\nvi.mock('./install-packages.js', () => ({\n installPackages: mocks.installPackages,\n}))\n\ndescribe('Payload project updates', () => {\n let projectDir: string\n let templateRoot: string\n\n beforeEach(() => {\n vi.clearAllMocks()\n projectDir = fse.mkdtempSync(path.join(os.tmpdir(), 'cpa-update-project-'))\n templateRoot = fse.mkdtempSync(path.join(os.tmpdir(), 'cpa-update-template-'))\n mocks.getPackageManager.mockResolvedValue('pnpm')\n mocks.installPackages.mockResolvedValue({ success: true })\n mocks.resolvePackageVersion.mockResolvedValue('4.2.0')\n })\n\n afterEach(() => {\n fse.removeSync(projectDir)\n fse.removeSync(templateRoot)\n })\n\n it('should update every installed Payload dependency to one version without a Next config', async () => {\n fse.writeJsonSync(path.join(projectDir, 'package.json'), {\n dependencies: {\n '@payloadcms/db-mongodb': '^3.0.0',\n '@payloadcms/richtext-lexical': '^3.0.0',\n payload: '^3.0.0',\n react: '^19.0.0',\n },\n })\n\n const result = await updatePayloadPackages({ projectDir, versionOrTag: 'beta' })\n\n expect(result).toEqual({ message: 'Payload updated successfully.', success: true })\n expect(mocks.resolvePackageVersion).toHaveBeenCalledOnce()\n expect(mocks.resolvePackageVersion).toHaveBeenCalledWith({\n packageName: 'payload',\n versionOrTag: 'beta',\n })\n expect(mocks.installPackages).toHaveBeenCalledWith({\n packageManager: 'pnpm',\n packagesToInstall: [\n 'payload@4.2.0',\n '@payloadcms/db-mongodb@4.2.0',\n '@payloadcms/richtext-lexical@4.2.0',\n ],\n projectDir,\n })\n })\n\n it('should update a stale Payload package when payload is already at the target version', async () => {\n fse.writeJsonSync(path.join(projectDir, 'package.json'), {\n dependencies: {\n '@payloadcms/ui': '4.1.0',\n payload: '4.2.0',\n },\n })\n\n const result = await updatePayloadPackages({ projectDir, versionOrTag: 'beta' })\n\n expect(result).toEqual({ message: 'Payload updated successfully.', success: true })\n expect(mocks.installPackages).toHaveBeenCalledWith({\n packageManager: 'pnpm',\n packagesToInstall: ['payload@4.2.0', '@payloadcms/ui@4.2.0'],\n projectDir,\n })\n })\n\n it('should update Payload packages installed as development dependencies', async () => {\n fse.writeJsonSync(path.join(projectDir, 'package.json'), {\n dependencies: {\n '@payloadcms/ui': '4.1.0',\n payload: '4.1.0',\n },\n devDependencies: {\n '@payloadcms/graphql': '4.1.0',\n vitest: '^4.0.0',\n },\n })\n\n const result = await updatePayloadPackages({ projectDir, versionOrTag: 'beta' })\n\n expect(result).toEqual({ message: 'Payload updated successfully.', success: true })\n expect(mocks.installPackages).toHaveBeenCalledWith({\n packageManager: 'pnpm',\n packagesToInstall: ['payload@4.2.0', '@payloadcms/ui@4.2.0', '@payloadcms/graphql@4.2.0'],\n projectDir,\n })\n })\n\n it('should refresh Next Payload routes without overwriting custom CSS', async () => {\n writeProjectPackage(projectDir)\n const nextConfigPath = path.join(projectDir, 'next.config.ts')\n const payloadDir = path.join(projectDir, 'src/app/(payload)')\n const importMapPath = path.join(payloadDir, 'admin/importMap.js')\n const customCssPath = path.join(payloadDir, 'custom.css')\n const sourceImportMapPath = path.resolve(\n dirname,\n '../../../../templates/blank/src/app/(payload)/admin/importMap.js',\n )\n fse.outputFileSync(importMapPath, 'stale import map\\n')\n fse.outputFileSync(customCssPath, '.custom { color: rebeccapurple; }\\n')\n\n const appDetails: NextAppDetails = {\n hasTopLevelLayout: false,\n isPayloadInstalled: true,\n isSrcDir: true,\n isSupportedNextVersion: true,\n nextConfigPath,\n nextVersion: '15.0.0',\n }\n\n const result = await updatePayloadInNextProject({ appDetails, versionOrTag: 'beta' })\n\n expect(result).toEqual({ message: 'Payload updated successfully.', success: true })\n expect(fse.readFileSync(importMapPath, 'utf8')).toBe(\n fse.readFileSync(sourceImportMapPath, 'utf8'),\n )\n expect(fse.readFileSync(customCssPath, 'utf8')).toBe('.custom { color: rebeccapurple; }\\n')\n })\n\n it('should refresh Payload-owned TanStack files without overwriting custom styles', async () => {\n writeProjectPackage(projectDir)\n writeFiles({\n files: {\n 'routes/_payload.tsx': 'fresh payload layout\\n',\n 'routes/_payload/admin.$.tsx': 'fresh admin splat\\n',\n 'routes/_payload/admin.index.tsx': 'fresh admin index\\n',\n 'routes/_payload/api.$.ts': 'fresh API route\\n',\n 'routes/_payload/importMap.js': 'fresh import map\\n',\n 'routes/_payload/server.functions.ts': 'fresh server functions\\n',\n 'src/payload.css': 'template Payload route CSS\\n',\n 'src/payload.config.ts': 'template Payload config\\n',\n },\n root: templateRoot,\n })\n writeFiles({\n files: {\n 'src/router.tsx': 'custom router\\n',\n 'src/routes/__root.tsx': 'custom root route\\n',\n 'src/routes/_frontend.tsx': 'custom frontend layout\\n',\n 'src/routes/_frontend/index.tsx': 'custom frontend route\\n',\n 'src/routes/_payload.tsx': 'stale payload layout\\n',\n 'src/routes/_payload/admin.$.tsx': 'stale admin splat\\n',\n 'src/routes/_payload/admin.index.tsx': 'stale admin index\\n',\n 'src/routes/_payload/api.$.ts': 'stale API route\\n',\n 'src/routes/_payload/importMap.js': 'stale import map\\n',\n 'src/routes/_payload/server.functions.ts': 'stale server functions\\n',\n 'src/payload.css': 'custom Payload CSS\\n',\n 'src/styles.css': 'custom frontend CSS\\n',\n 'vite.config.ts': 'custom Vite config\\n',\n },\n root: projectDir,\n })\n\n const appDetails: TanStackAppDetails = {\n isPayloadInstalled: true,\n kind: 'start',\n projectDir,\n rootRoutePath: path.join(projectDir, 'src/routes/__root.tsx'),\n routerPath: path.join(projectDir, 'src/router.tsx'),\n routesDir: path.join(projectDir, 'src/routes'),\n sourceDir: path.join(projectDir, 'src'),\n viteConfigPath: path.join(projectDir, 'vite.config.ts'),\n }\n\n const preservedFiles = [\n appDetails.viteConfigPath,\n appDetails.routerPath,\n appDetails.rootRoutePath,\n path.join(appDetails.routesDir, '_frontend.tsx'),\n path.join(appDetails.routesDir, '_frontend/index.tsx'),\n path.join(appDetails.sourceDir, 'payload.css'),\n path.join(appDetails.sourceDir, 'styles.css'),\n ]\n const before = new Map(\n preservedFiles.map((filePath) => [filePath, fse.readFileSync(filePath, 'utf8')]),\n )\n\n const result = await updatePayloadInTanStackProject({\n appDetails,\n templateRoot,\n versionOrTag: 'beta',\n })\n\n expect(result).toEqual({ message: 'Payload updated successfully.', success: true })\n expect(fse.readFileSync(path.join(appDetails.routesDir, '_payload.tsx'), 'utf8')).toBe(\n 'fresh payload layout\\n',\n )\n expect(\n fse.readFileSync(path.join(appDetails.routesDir, '_payload/server.functions.ts'), 'utf8'),\n ).toBe('fresh server functions\\n')\n for (const [filePath, content] of before) {\n expect(fse.readFileSync(filePath, 'utf8')).toBe(content)\n }\n })\n\n it('should refresh TanStack routes from the source template by default', async () => {\n writeProjectPackage(projectDir)\n const payloadLayoutPath = path.join(projectDir, 'src/routes/_payload.tsx')\n const sourcePayloadLayoutPath = path.resolve(\n dirname,\n '../../../../templates/blank-tanstack/src/app/_payload.tsx',\n )\n const sourcePayloadStylesPath = path.resolve(\n dirname,\n '../../../../templates/blank-tanstack/src/payload.css',\n )\n fse.outputFileSync(payloadLayoutPath, 'stale payload layout\\n')\n\n const appDetails: TanStackAppDetails = {\n isPayloadInstalled: true,\n kind: 'start',\n projectDir,\n rootRoutePath: path.join(projectDir, 'src/routes/__root.tsx'),\n routerPath: path.join(projectDir, 'src/router.tsx'),\n routesDir: path.join(projectDir, 'src/routes'),\n sourceDir: path.join(projectDir, 'src'),\n viteConfigPath: path.join(projectDir, 'vite.config.ts'),\n }\n\n await updatePayloadInTanStackProject({ appDetails, versionOrTag: 'beta' })\n\n expect(fse.readFileSync(payloadLayoutPath, 'utf8')).toBe(\n fse.readFileSync(sourcePayloadLayoutPath, 'utf8'),\n )\n expect(fse.readFileSync(path.join(appDetails.sourceDir, 'payload.css'), 'utf8')).toBe(\n fse.readFileSync(sourcePayloadStylesPath, 'utf8'),\n )\n })\n})\n\nfunction writeFiles({ files, root }: { files: Record<string, string>; root: string }): void {\n for (const [relativePath, content] of Object.entries(files)) {\n fse.outputFileSync(path.join(root, relativePath), content)\n }\n}\n\nfunction writeProjectPackage(projectDir: string): void {\n fse.writeJsonSync(path.join(projectDir, 'package.json'), {\n dependencies: {\n '@payloadcms/ui': '^3.0.0',\n payload: '^3.0.0',\n },\n })\n}\n"],"names":["fse","os","path","fileURLToPath","afterEach","beforeEach","describe","expect","it","vi","updatePayloadInNextProject","updatePayloadInTanStackProject","updatePayloadPackages","dirname","url","mocks","hoisted","getPackageManager","fn","installPackages","resolvePackageVersion","mock","importOriginal","projectDir","templateRoot","clearAllMocks","mkdtempSync","join","tmpdir","mockResolvedValue","success","removeSync","writeJsonSync","dependencies","payload","react","result","versionOrTag","toEqual","message","toHaveBeenCalledOnce","toHaveBeenCalledWith","packageName","packageManager","packagesToInstall","devDependencies","vitest","writeProjectPackage","nextConfigPath","payloadDir","importMapPath","customCssPath","sourceImportMapPath","resolve","outputFileSync","appDetails","hasTopLevelLayout","isPayloadInstalled","isSrcDir","isSupportedNextVersion","nextVersion","readFileSync","toBe","writeFiles","files","root","kind","rootRoutePath","routerPath","routesDir","sourceDir","viteConfigPath","preservedFiles","before","Map","map","filePath","content","payloadLayoutPath","sourcePayloadLayoutPath","sourcePayloadStylesPath","relativePath","Object","entries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AAeJ;IACpD;AACF;AAEA,SAAS9B,oBAAoBxB,UAAkB;IAC7CvB,IAAIgC,aAAa,CAAC9B,KAAKyB,IAAI,CAACJ,YAAY,iBAAiB;QACvDU,cAAc;YACZ,kBAAkB;YAClBC,SAAS;QACX;IACF;AACF"}
@@ -1,167 +0,0 @@
1
- import * as p from '@clack/prompts';
2
- import { describe, it, expect, vitest } from 'vitest';
3
- import { parseAndModifyConfigContent, withPayloadStatement } from './wrap-next-config.js';
4
- const tsConfigs = {
5
- defaultNextConfig: `import type { NextConfig } from "next";
6
-
7
- const nextConfig: NextConfig = {};
8
- export default nextConfig;`,
9
- nextConfigExportNamedDefault: `import type { NextConfig } from "next";
10
- const nextConfig: NextConfig = {};
11
- const wrapped = someFunc(asdf);
12
- export { wrapped as default };
13
- `,
14
- nextConfigWithFunc: `import type { NextConfig } from "next";
15
- const nextConfig: NextConfig = {};
16
- export default someFunc(nextConfig);
17
- `,
18
- nextConfigWithFuncMultiline: `import type { NextConfig } from "next";
19
- const nextConfig: NextConfig = {};
20
- export default someFunc(
21
- nextConfig
22
- );
23
- `,
24
- nextConfigWithSpread: `import type { NextConfig } from "next";
25
- const nextConfig: NextConfig = {
26
- ...someConfig,
27
- };
28
- export default nextConfig;
29
- `
30
- };
31
- const esmConfigs = {
32
- defaultNextConfig: `/** @type {import('next').NextConfig} */
33
- const nextConfig = {};
34
- export default nextConfig;
35
- `,
36
- nextConfigExportNamedDefault: `const nextConfig = {};
37
- const wrapped = someFunc(asdf);
38
- export { wrapped as default };
39
- `,
40
- nextConfigWithFunc: `const nextConfig = {};
41
- export default someFunc(nextConfig);
42
- `,
43
- nextConfigWithFuncMultiline: `const nextConfig = {};;
44
- export default someFunc(
45
- nextConfig
46
- );
47
- `,
48
- nextConfigWithSpread: `const nextConfig = {
49
- ...someConfig,
50
- };
51
- export default nextConfig;
52
- `
53
- };
54
- const cjsConfigs = {
55
- anonConfig: `module.exports = {};`,
56
- defaultNextConfig: `
57
- /** @type {import('next').NextConfig} */
58
- const nextConfig = {};
59
- module.exports = nextConfig;
60
- `,
61
- nextConfigExportNamedDefault: `const nextConfig = {};
62
- const wrapped = someFunc(asdf);
63
- module.exports = wrapped;
64
- `,
65
- nextConfigWithFunc: `const nextConfig = {};
66
- module.exports = someFunc(nextConfig);
67
- `,
68
- nextConfigWithFuncMultiline: `const nextConfig = {};
69
- module.exports = someFunc(
70
- nextConfig
71
- );
72
- `,
73
- nextConfigWithSpread: `const nextConfig = { ...someConfig };
74
- module.exports = nextConfig;
75
- `
76
- };
77
- describe('parseAndInsertWithPayload', ()=>{
78
- describe('ts', ()=>{
79
- const configType = 'ts';
80
- const importStatement = withPayloadStatement[configType];
81
- it('should parse the default next config', async ()=>{
82
- const { modifiedConfigContent } = await parseAndModifyConfigContent(tsConfigs.defaultNextConfig, configType);
83
- expect(modifiedConfigContent).toContain(importStatement);
84
- expect(modifiedConfigContent).toContain('withPayload(nextConfig)');
85
- });
86
- it('should parse the config with a function', async ()=>{
87
- const { modifiedConfigContent: modifiedConfigContent2 } = await parseAndModifyConfigContent(tsConfigs.nextConfigWithFunc, configType);
88
- expect(modifiedConfigContent2).toContain('withPayload(someFunc(nextConfig))');
89
- });
90
- it('should parse the config with a multi-lined function', async ()=>{
91
- const { modifiedConfigContent } = await parseAndModifyConfigContent(tsConfigs.nextConfigWithFuncMultiline, configType);
92
- expect(modifiedConfigContent).toContain(importStatement);
93
- expect(modifiedConfigContent).toMatch(/withPayload\(someFunc\(\n {2}nextConfig\n\)\)/);
94
- });
95
- it('should parse the config with a spread', async ()=>{
96
- const { modifiedConfigContent } = await parseAndModifyConfigContent(tsConfigs.nextConfigWithSpread, configType);
97
- expect(modifiedConfigContent).toContain(importStatement);
98
- expect(modifiedConfigContent).toContain('withPayload(nextConfig)');
99
- });
100
- });
101
- describe('esm', ()=>{
102
- const configType = 'esm';
103
- const importStatement = withPayloadStatement[configType];
104
- it('should parse the default next config', async ()=>{
105
- const { modifiedConfigContent } = await parseAndModifyConfigContent(esmConfigs.defaultNextConfig, configType);
106
- expect(modifiedConfigContent).toContain(importStatement);
107
- expect(modifiedConfigContent).toContain('withPayload(nextConfig)');
108
- });
109
- it('should parse the config with a function', async ()=>{
110
- const { modifiedConfigContent } = await parseAndModifyConfigContent(esmConfigs.nextConfigWithFunc, configType);
111
- expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))');
112
- });
113
- it('should parse the config with a multi-lined function', async ()=>{
114
- const { modifiedConfigContent } = await parseAndModifyConfigContent(esmConfigs.nextConfigWithFuncMultiline, configType);
115
- expect(modifiedConfigContent).toContain(importStatement);
116
- expect(modifiedConfigContent).toMatch(/withPayload\(someFunc\(\n {2}nextConfig\n\)\)/);
117
- });
118
- it('should parse the config with a spread', async ()=>{
119
- const { modifiedConfigContent } = await parseAndModifyConfigContent(esmConfigs.nextConfigWithSpread, configType);
120
- expect(modifiedConfigContent).toContain(importStatement);
121
- expect(modifiedConfigContent).toContain('withPayload(nextConfig)');
122
- });
123
- // Unsupported: export { wrapped as default }
124
- it('should give warning with a named export as default', async ()=>{
125
- const warnLogSpy = vitest.spyOn(p.log, 'warn').mockImplementation(()=>{});
126
- const { modifiedConfigContent, success } = await parseAndModifyConfigContent(esmConfigs.nextConfigExportNamedDefault, configType);
127
- expect(modifiedConfigContent).toContain(importStatement);
128
- expect(success).toBe(false);
129
- expect(warnLogSpy).toHaveBeenCalledWith(expect.stringContaining('Could not automatically wrap'));
130
- });
131
- });
132
- describe('cjs', ()=>{
133
- const configType = 'cjs';
134
- const requireStatement = withPayloadStatement[configType];
135
- it('should parse the default next config', async ()=>{
136
- const { modifiedConfigContent } = await parseAndModifyConfigContent(cjsConfigs.defaultNextConfig, configType);
137
- expect(modifiedConfigContent).toContain(requireStatement);
138
- expect(modifiedConfigContent).toContain('withPayload(nextConfig)');
139
- });
140
- it('should parse anonymous default config', async ()=>{
141
- const { modifiedConfigContent } = await parseAndModifyConfigContent(cjsConfigs.anonConfig, configType);
142
- expect(modifiedConfigContent).toContain(requireStatement);
143
- expect(modifiedConfigContent).toContain('withPayload({})');
144
- });
145
- it('should parse the config with a function', async ()=>{
146
- const { modifiedConfigContent } = await parseAndModifyConfigContent(cjsConfigs.nextConfigWithFunc, configType);
147
- expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))');
148
- });
149
- it('should parse the config with a multi-lined function', async ()=>{
150
- const { modifiedConfigContent } = await parseAndModifyConfigContent(cjsConfigs.nextConfigWithFuncMultiline, configType);
151
- expect(modifiedConfigContent).toContain(requireStatement);
152
- expect(modifiedConfigContent).toMatch(/withPayload\(someFunc\(\n {2}nextConfig\n\)\)/);
153
- });
154
- it('should parse the config with a named export as default', async ()=>{
155
- const { modifiedConfigContent } = await parseAndModifyConfigContent(cjsConfigs.nextConfigExportNamedDefault, configType);
156
- expect(modifiedConfigContent).toContain(requireStatement);
157
- expect(modifiedConfigContent).toContain('withPayload(wrapped)');
158
- });
159
- it('should parse the config with a spread', async ()=>{
160
- const { modifiedConfigContent } = await parseAndModifyConfigContent(cjsConfigs.nextConfigWithSpread, configType);
161
- expect(modifiedConfigContent).toContain(requireStatement);
162
- expect(modifiedConfigContent).toContain('withPayload(nextConfig)');
163
- });
164
- });
165
- });
166
-
167
- //# sourceMappingURL=wrap-next-config.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/wrap-next-config.spec.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport { describe, it, expect, vitest } from 'vitest'\n\nimport { parseAndModifyConfigContent, withPayloadStatement } from './wrap-next-config.js'\n\nconst tsConfigs = {\n defaultNextConfig: `import type { NextConfig } from \"next\";\n\nconst nextConfig: NextConfig = {};\nexport default nextConfig;`,\n\n nextConfigExportNamedDefault: `import type { NextConfig } from \"next\";\nconst nextConfig: NextConfig = {};\nconst wrapped = someFunc(asdf);\nexport { wrapped as default };\n`,\n nextConfigWithFunc: `import type { NextConfig } from \"next\";\nconst nextConfig: NextConfig = {};\nexport default someFunc(nextConfig);\n`,\n nextConfigWithFuncMultiline: `import type { NextConfig } from \"next\";\nconst nextConfig: NextConfig = {};\nexport default someFunc(\n nextConfig\n);\n`,\n nextConfigWithSpread: `import type { NextConfig } from \"next\";\nconst nextConfig: NextConfig = {\n ...someConfig,\n};\nexport default nextConfig;\n`,\n}\n\nconst esmConfigs = {\n defaultNextConfig: `/** @type {import('next').NextConfig} */\nconst nextConfig = {};\nexport default nextConfig;\n`,\n nextConfigExportNamedDefault: `const nextConfig = {};\nconst wrapped = someFunc(asdf);\nexport { wrapped as default };\n`,\n nextConfigWithFunc: `const nextConfig = {};\nexport default someFunc(nextConfig);\n`,\n nextConfigWithFuncMultiline: `const nextConfig = {};;\nexport default someFunc(\n nextConfig\n);\n`,\n nextConfigWithSpread: `const nextConfig = {\n ...someConfig,\n};\nexport default nextConfig;\n`,\n}\n\nconst cjsConfigs = {\n anonConfig: `module.exports = {};`,\n defaultNextConfig: `\n /** @type {import('next').NextConfig} */\nconst nextConfig = {};\nmodule.exports = nextConfig;\n`,\n nextConfigExportNamedDefault: `const nextConfig = {};\nconst wrapped = someFunc(asdf);\nmodule.exports = wrapped;\n`,\n nextConfigWithFunc: `const nextConfig = {};\nmodule.exports = someFunc(nextConfig);\n`,\n nextConfigWithFuncMultiline: `const nextConfig = {};\nmodule.exports = someFunc(\n nextConfig\n);\n`,\n nextConfigWithSpread: `const nextConfig = { ...someConfig };\nmodule.exports = nextConfig;\n`,\n}\n\ndescribe('parseAndInsertWithPayload', () => {\n describe('ts', () => {\n const configType = 'ts'\n const importStatement = withPayloadStatement[configType]\n\n it('should parse the default next config', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n tsConfigs.defaultNextConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n\n it('should parse the config with a function', async () => {\n const { modifiedConfigContent: modifiedConfigContent2 } = await parseAndModifyConfigContent(\n tsConfigs.nextConfigWithFunc,\n configType,\n )\n expect(modifiedConfigContent2).toContain('withPayload(someFunc(nextConfig))')\n })\n\n it('should parse the config with a multi-lined function', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n tsConfigs.nextConfigWithFuncMultiline,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toMatch(/withPayload\\(someFunc\\(\\n {2}nextConfig\\n\\)\\)/)\n })\n\n it('should parse the config with a spread', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n tsConfigs.nextConfigWithSpread,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n })\n describe('esm', () => {\n const configType = 'esm'\n const importStatement = withPayloadStatement[configType]\n it('should parse the default next config', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n esmConfigs.defaultNextConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n it('should parse the config with a function', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n esmConfigs.nextConfigWithFunc,\n configType,\n )\n expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))')\n })\n\n it('should parse the config with a multi-lined function', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n esmConfigs.nextConfigWithFuncMultiline,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toMatch(/withPayload\\(someFunc\\(\\n {2}nextConfig\\n\\)\\)/)\n })\n\n it('should parse the config with a spread', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n esmConfigs.nextConfigWithSpread,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n\n // Unsupported: export { wrapped as default }\n it('should give warning with a named export as default', async () => {\n const warnLogSpy = vitest.spyOn(p.log, 'warn').mockImplementation(() => {})\n\n const { modifiedConfigContent, success } = await parseAndModifyConfigContent(\n esmConfigs.nextConfigExportNamedDefault,\n configType,\n )\n expect(modifiedConfigContent).toContain(importStatement)\n expect(success).toBe(false)\n\n expect(warnLogSpy).toHaveBeenCalledWith(\n expect.stringContaining('Could not automatically wrap'),\n )\n })\n })\n\n describe('cjs', () => {\n const configType = 'cjs'\n const requireStatement = withPayloadStatement[configType]\n it('should parse the default next config', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.defaultNextConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n it('should parse anonymous default config', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.anonConfig,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload({})')\n })\n it('should parse the config with a function', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.nextConfigWithFunc,\n configType,\n )\n expect(modifiedConfigContent).toContain('withPayload(someFunc(nextConfig))')\n })\n it('should parse the config with a multi-lined function', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.nextConfigWithFuncMultiline,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toMatch(/withPayload\\(someFunc\\(\\n {2}nextConfig\\n\\)\\)/)\n })\n it('should parse the config with a named export as default', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.nextConfigExportNamedDefault,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload(wrapped)')\n })\n\n it('should parse the config with a spread', async () => {\n const { modifiedConfigContent } = await parseAndModifyConfigContent(\n cjsConfigs.nextConfigWithSpread,\n configType,\n )\n expect(modifiedConfigContent).toContain(requireStatement)\n expect(modifiedConfigContent).toContain('withPayload(nextConfig)')\n })\n })\n})\n"],"names":["p","describe","it","expect","vitest","parseAndModifyConfigContent","withPayloadStatement","tsConfigs","defaultNextConfig","nextConfigExportNamedDefault","nextConfigWithFunc","nextConfigWithFuncMultiline","nextConfigWithSpread","esmConfigs","cjsConfigs","anonConfig","configType","importStatement","modifiedConfigContent","toContain","modifiedConfigContent2","toMatch","warnLogSpy","spyOn","log","mockImplementation","success","toBe","toHaveBeenCalledWith","stringContaining","requireStatement"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,SAASC,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,MAAM,QAAQ,SAAQ;AAErD,SAASC,2BAA2B,EAAEC,oBAAoB,QAAQ,wBAAuB;AAEzF,MAAMC,YAAY;IAChBC,mBAAmB,CAAC;;;0BAGI,CAAC;IAEzBC,8BAA8B,CAAC;;;;AAIjC,CAAC;IACCC,oBAAoB,CAAC;;;AAGvB,CAAC;IACCC,6BAA6B,CAAC;;;;;AAKhC,CAAC;IACCC,sBAAsB,CAAC;;;;;AAKzB,CAAC;AACD;AAEA,MAAMC,aAAa;IACjBL,mBAAmB,CAAC;;;AAGtB,CAAC;IACCC,8BAA8B,CAAC;;;AAGjC,CAAC;IACCC,oBAAoB,CAAC;;AAEvB,CAAC;IACCC,6BAA6B,CAAC;;;;AAIhC,CAAC;IACCC,sBAAsB,CAAC;;;;AAIzB,CAAC;AACD;AAEA,MAAME,aAAa;IACjBC,YAAY,CAAC,oBAAoB,CAAC;IAClCP,mBAAmB,CAAC;;;;AAItB,CAAC;IACCC,8BAA8B,CAAC;;;AAGjC,CAAC;IACCC,oBAAoB,CAAC;;AAEvB,CAAC;IACCC,6BAA6B,CAAC;;;;AAIhC,CAAC;IACCC,sBAAsB,CAAC;;AAEzB,CAAC;AACD;AAEAX,SAAS,6BAA6B;IACpCA,SAAS,MAAM;QACb,MAAMe,aAAa;QACnB,MAAMC,kBAAkBX,oBAAoB,CAACU,WAAW;QAExDd,GAAG,wCAAwC;YACzC,MAAM,EAAEgB,qBAAqB,EAAE,G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G,MAAMb,4BACtCS,WAAWH,2BAA2B,EACtCK;YAEFb,OAAOe,uBAAuBC,SAAS,CAACW;YACxC3B,OAAOe,uBAAuBG,OAAO,CAAC;QACxC;QACAnB,GAAG,0DAA0D;YAC3D,MAAM,EAAEgB,qBAAqB,EAAE,GAAG,MAAMb,4BACtCS,WAAWL,4BAA4B,EACvCO;YAEFb,OAAOe,uBAAuBC,SAAS,CAACW;YACxC3B,OAAOe,uBAAuBC,SAAS,CAAC;QAC1C;QAEAjB,GAAG,yCAAyC;YAC1C,MAAM,EAAEgB,qBAAqB,EAAE,GAAG,MAAMb,4BACtCS,WAAWF,oBAAoB,EAC/BI;YAEFb,OAAOe,uBAAuBC,SAAS,CAACW;YACxC3B,OAAOe,uBAAuBC,SAAS,CAAC;QAC1C;IACF;AACF"}
package/dist/main.spec.js DELETED
@@ -1,102 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { resolveAppFramework } from './main.js';
3
- describe('resolveAppFramework', ()=>{
4
- it('should reject ambiguous recognized hosts before choosing a framework', ()=>{
5
- expect(resolveAppFramework({
6
- nextAppDetails: createNextAppDetails({
7
- isPayloadInstalled: true
8
- }),
9
- tanStackDetection: createTanStackDetection({
10
- isPayloadInstalled: true
11
- })
12
- })).toEqual({
13
- kind: 'ambiguous'
14
- });
15
- });
16
- it('should resolve a Next host', ()=>{
17
- const nextAppDetails = createNextAppDetails({
18
- isPayloadInstalled: true
19
- });
20
- expect(resolveAppFramework({
21
- nextAppDetails,
22
- tanStackDetection: {
23
- detected: false
24
- }
25
- })).toEqual({
26
- appDetails: nextAppDetails,
27
- kind: 'next'
28
- });
29
- });
30
- it('should resolve a compatible TanStack host', ()=>{
31
- const tanStackDetection = createTanStackDetection({
32
- isPayloadInstalled: false
33
- });
34
- expect(resolveAppFramework({
35
- nextAppDetails: createNoNextAppDetails(),
36
- tanStackDetection
37
- })).toEqual({
38
- appDetails: tanStackDetection.details,
39
- kind: 'tanstack'
40
- });
41
- });
42
- it('should preserve an incompatible TanStack reason', ()=>{
43
- const tanStackDetection = {
44
- compatible: false,
45
- detected: true,
46
- reason: 'TanStack Solid projects are not supported.'
47
- };
48
- expect(resolveAppFramework({
49
- nextAppDetails: createNoNextAppDetails(),
50
- tanStackDetection
51
- })).toEqual({
52
- kind: 'unsupported-tanstack',
53
- reason: tanStackDetection.reason
54
- });
55
- });
56
- it('should continue the new-project flow when no host is detected', ()=>{
57
- expect(resolveAppFramework({
58
- nextAppDetails: createNoNextAppDetails(),
59
- tanStackDetection: {
60
- detected: false
61
- }
62
- })).toEqual({
63
- kind: 'none'
64
- });
65
- });
66
- });
67
- function createNextAppDetails({ isPayloadInstalled }) {
68
- return {
69
- ...createNoNextAppDetails(),
70
- isPayloadInstalled,
71
- isSupportedNextVersion: true,
72
- nextConfigPath: '/project/next.config.ts',
73
- nextVersion: '15.0.0'
74
- };
75
- }
76
- function createNoNextAppDetails() {
77
- return {
78
- hasTopLevelLayout: false,
79
- isSrcDir: true,
80
- isSupportedNextVersion: false,
81
- nextVersion: null
82
- };
83
- }
84
- function createTanStackDetection({ isPayloadInstalled }) {
85
- const details = {
86
- isPayloadInstalled,
87
- kind: 'start',
88
- projectDir: '/project',
89
- rootRoutePath: '/project/src/routes/__root.tsx',
90
- routerPath: '/project/src/router.tsx',
91
- routesDir: '/project/src/routes',
92
- sourceDir: '/project/src',
93
- viteConfigPath: '/project/vite.config.ts'
94
- };
95
- return {
96
- compatible: true,
97
- details,
98
- detected: true
99
- };
100
- }
101
-
102
- //# sourceMappingURL=main.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/main.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport type { NextAppDetails, TanStackAppDetails, TanStackDetectionResult } from './types.js'\n\nimport { resolveAppFramework } from './main.js'\n\ndescribe('resolveAppFramework', () => {\n it('should reject ambiguous recognized hosts before choosing a framework', () => {\n expect(\n resolveAppFramework({\n nextAppDetails: createNextAppDetails({ isPayloadInstalled: true }),\n tanStackDetection: createTanStackDetection({ isPayloadInstalled: true }),\n }),\n ).toEqual({ kind: 'ambiguous' })\n })\n\n it('should resolve a Next host', () => {\n const nextAppDetails = createNextAppDetails({ isPayloadInstalled: true })\n\n expect(resolveAppFramework({ nextAppDetails, tanStackDetection: { detected: false } })).toEqual(\n { appDetails: nextAppDetails, kind: 'next' },\n )\n })\n\n it('should resolve a compatible TanStack host', () => {\n const tanStackDetection = createTanStackDetection({ isPayloadInstalled: false })\n\n expect(\n resolveAppFramework({ nextAppDetails: createNoNextAppDetails(), tanStackDetection }),\n ).toEqual({ appDetails: tanStackDetection.details, kind: 'tanstack' })\n })\n\n it('should preserve an incompatible TanStack reason', () => {\n const tanStackDetection: TanStackDetectionResult = {\n compatible: false,\n detected: true,\n reason: 'TanStack Solid projects are not supported.',\n }\n\n expect(\n resolveAppFramework({ nextAppDetails: createNoNextAppDetails(), tanStackDetection }),\n ).toEqual({ kind: 'unsupported-tanstack', reason: tanStackDetection.reason })\n })\n\n it('should continue the new-project flow when no host is detected', () => {\n expect(\n resolveAppFramework({\n nextAppDetails: createNoNextAppDetails(),\n tanStackDetection: { detected: false },\n }),\n ).toEqual({ kind: 'none' })\n })\n})\n\nfunction createNextAppDetails({ isPayloadInstalled }: { isPayloadInstalled: boolean }) {\n return {\n ...createNoNextAppDetails(),\n isPayloadInstalled,\n isSupportedNextVersion: true,\n nextConfigPath: '/project/next.config.ts',\n nextVersion: '15.0.0',\n } satisfies NextAppDetails\n}\n\nfunction createNoNextAppDetails(): NextAppDetails {\n return {\n hasTopLevelLayout: false,\n isSrcDir: true,\n isSupportedNextVersion: false,\n nextVersion: null,\n }\n}\n\nfunction createTanStackDetection({\n isPayloadInstalled,\n}: {\n isPayloadInstalled: boolean\n}): Extract<TanStackDetectionResult, { compatible: true }> {\n const details: TanStackAppDetails = {\n isPayloadInstalled,\n kind: 'start',\n projectDir: '/project',\n rootRoutePath: '/project/src/routes/__root.tsx',\n routerPath: '/project/src/router.tsx',\n routesDir: '/project/src/routes',\n sourceDir: '/project/src',\n viteConfigPath: '/project/vite.config.ts',\n }\n\n return { compatible: true, details, detected: true }\n}\n"],"names":["describe","expect","it","resolveAppFramework","nextAppDetails","createNextAppDetails","isPayloadInstalled","tanStackDetection","createTanStackDetection","toEqual","kind","detected","appDetails","createNoNextAppDetails","details","compatible","reason","isSupportedNextVersion","nextConfigPath","nextVersion","hasTopLevelLayout","isSrcDir","projectDir","rootRoutePath","routerPath","routesDir","sourceDir","viteConfigPath"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAI7C,SAASC,mBAAmB,QAAQ,YAAW;AAE/CH,SAAS,uBAAuB;IAC9BE,GAAG,wEAAwE;QACzED,OACEE,oBAAoB;YAClBC,gBAAgBC,qBAAqB;gBAAEC,oBAAoB;YAAK;YAChEC,mBAAmBC,wBAAwB;gBAAEF,oBAAoB;YAAK;QACxE,IACAG,OAAO,CAAC;YAAEC,MAAM;QAAY;IAChC;IAEAR,GAAG,8BAA8B;QAC/B,MAAME,iBAAiBC,qBAAqB;YAAEC,oBAAoB;QAAK;QAEvEL,OAAOE,oBAAoB;YAAEC;YAAgBG,mBAAmB;gBAAEI,UAAU;YAAM;QAAE,IAAIF,OAAO,CAC7F;YAAEG,YAAYR;YAAgBM,MAAM;QAAO;IAE/C;IAEAR,GAAG,6CAA6C;QAC9C,MAAMK,oBAAoBC,wBAAwB;YAAEF,oBAAoB;QAAM;QAE9EL,OACEE,oBAAoB;YAAEC,gBAAgBS;YAA0BN;QAAkB,IAClFE,OAAO,CAAC;YAAEG,YAAYL,kBAAkBO,OAAO;YAAEJ,MAAM;QAAW;IACtE;IAEAR,GAAG,mDAAmD;QACpD,MAAMK,oBAA6C;YACjDQ,YAAY;YACZJ,UAAU;YACVK,QAAQ;QACV;QAEAf,OACEE,oBAAoB;YAAEC,gBAAgBS;YAA0BN;QAAkB,IAClFE,OAAO,CAAC;YAAEC,MAAM;YAAwBM,QAAQ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