create-payload-app 4.0.0-internal.7b031c8 → 4.0.0-internal.7e57eed
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/lib/create-project.spec.js +9 -0
- package/dist/lib/create-project.spec.js.map +1 -1
- package/dist/lib/templates.d.ts.map +1 -1
- package/dist/lib/templates.js +6 -0
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/update-payload-in-project.d.ts.map +1 -1
- package/dist/lib/update-payload-in-project.js +12 -3
- package/dist/lib/update-payload-in-project.js.map +1 -1
- package/dist/template/src/app/(frontend)/styles.css +1 -1
- package/dist/template/src/app/(payload)/layout.tsx +1 -1
- package/package.json +1 -1
- /package/dist/template/src/app/(payload)/{custom.scss → custom.css} +0 -0
package/README.md
CHANGED
|
@@ -111,10 +111,19 @@ describe('createProject', ()=>{
|
|
|
111
111
|
[
|
|
112
112
|
'blank',
|
|
113
113
|
'postgres'
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
'blank-tanstack',
|
|
117
|
+
'mongodb'
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
'blank-tanstack',
|
|
121
|
+
'postgres'
|
|
114
122
|
]
|
|
115
123
|
])('update config and deps: %s, %s', async (templateName, db)=>{
|
|
116
124
|
const projectName = 'starter-project';
|
|
117
125
|
const template = templates.find((t)=>t.name === templateName);
|
|
126
|
+
expect(template).toBeDefined();
|
|
118
127
|
const cliArgs = {
|
|
119
128
|
...args,
|
|
120
129
|
'--db': db,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/create-project.spec.ts"],"sourcesContent":["import fs from 'fs'\nimport fse from 'fs-extra'\nimport globby from 'globby'\nimport * as os from 'node:os'\nimport path from 'path'\nimport { afterEach, beforeAll, beforeEach, describe, expect, it, vitest } from 'vitest'\nimport type { CliArgs, DbType, ProjectExample, ProjectTemplate } from '../types.js'\n\nimport { createProject, updatePackageJSONDependencies } from './create-project.js'\nimport { getValidTemplates } from './templates.js'\n\ndescribe('createProject', () => {\n let projectDir: string\n\n beforeAll(() => {\n // eslint-disable-next-line no-console\n console.log = vitest.fn()\n })\n\n beforeEach(() => {\n const tempDirectory = fs.realpathSync(os.tmpdir())\n projectDir = `${tempDirectory}/${Math.random().toString(36).substring(7)}`\n })\n\n afterEach(() => {\n if (fse.existsSync(projectDir)) {\n fse.rmSync(projectDir, { recursive: true })\n }\n })\n\n describe('#createProject', () => {\n const args = {\n _: ['project-name'],\n '--db': 'mongodb',\n '--local-template': 'blank',\n '--no-deps': true,\n } as CliArgs\n const packageManager = 'yarn'\n\n it('creates plugin template', async () => {\n const projectName = 'plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin',\n }\n\n await createProject({\n cliArgs: { ...args, '--local-template': 'plugin' } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toStrictEqual(projectName)\n })\n\n it('updates project name in plugin template importMap file', async () => {\n const projectName = 'my-custom-plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin',\n }\n\n await createProject({\n cliArgs: { ...args, '--local-template': 'plugin' } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n const importMapPath = path.resolve(projectDir, './dev/app/(payload)/admin/importMap.js')\n const importMapFile = fse.readFileSync(importMapPath, 'utf-8')\n\n expect(importMapFile).not.toContain('plugin-package-name-placeholder')\n expect(importMapFile).toContain('my-custom-plugin')\n })\n\n it('creates example', async () => {\n const projectName = 'custom-server-example'\n const example: ProjectExample = {\n name: 'custom-server',\n url: 'https://github.com/payloadcms/payload/examples/custom-server#main',\n }\n\n await createProject({\n cliArgs: {\n ...args,\n '--local-template': undefined,\n '--local-example': 'custom-server',\n } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n example,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toStrictEqual(projectName)\n }, 90_000)\n\n describe('creates project from template', () => {\n const templates = getValidTemplates()\n\n it.each([\n ['blank', 'mongodb'],\n ['blank', 'postgres'],\n\n // TODO: Re-enable these once 3.0 is stable and templates updated\n // ['website', 'mongodb'],\n // ['website', 'postgres'],\n // ['ecommerce', 'mongodb'],\n // ['ecommerce', 'postgres'],\n ])('update config and deps: %s, %s', async (templateName, db) => {\n const projectName = 'starter-project'\n\n const template = templates.find((t) => t.name === templateName)\n\n const cliArgs = {\n ...args,\n '--db': db,\n '--local-template': templateName,\n } as CliArgs\n\n await createProject({\n cliArgs,\n dbDetails: {\n type: db as DbType,\n dbUri: `${db}://localhost:27017/create-project-test`,\n },\n packageManager,\n projectDir,\n projectName,\n template: template as ProjectTemplate,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Verify git was initialized\n expect(fse.existsSync(path.resolve(projectDir, '.git'))).toBe(true)\n\n // Should only have one db adapter\n expect(\n Object.keys(packageJson.dependencies).filter((n) => n.startsWith('@payloadcms/db-')),\n ).toHaveLength(1)\n\n const payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: projectDir,\n })\n )?.[0]\n\n const content = fse.readFileSync(payloadConfigPath, 'utf-8')\n\n // Check payload.config.ts doesn't have placeholder comments\n expect(content).not.toContain('// database-adapter-import')\n expect(content).not.toContain('// database-adapter-config-start')\n expect(content).not.toContain('// database-adapter-config-end')\n\n // Verify correct adapter import and usage based on db type\n if (db === 'mongodb') {\n expect(content).toContain(\"import { mongooseAdapter } from '@payloadcms/db-mongodb'\")\n expect(content).toContain('mongooseAdapter')\n } else if (db === 'postgres') {\n expect(content).toContain(\"import { postgresAdapter } from '@payloadcms/db-postgres'\")\n expect(content).toContain('postgresAdapter')\n }\n })\n })\n\n describe('updates package.json', () => {\n it('updates package name and bumps workspace versions', async () => {\n const latestVersion = '3.0.0'\n const initialJSON = {\n name: 'test-project',\n version: '1.0.0',\n dependencies: {\n '@payloadcms/db-mongodb': 'workspace:*',\n payload: 'workspace:*',\n '@payloadcms/ui': 'workspace:*',\n },\n }\n\n const correctlyModifiedJSON = {\n name: 'test-project',\n version: '1.0.0',\n dependencies: {\n '@payloadcms/db-mongodb': `${latestVersion}`,\n payload: `${latestVersion}`,\n '@payloadcms/ui': `${latestVersion}`,\n },\n }\n\n updatePackageJSONDependencies({\n latestVersion,\n packageJson: initialJSON,\n })\n\n expect(initialJSON).toEqual(correctlyModifiedJSON)\n })\n })\n })\n})\n"],"names":["fs","fse","globby","os","path","afterEach","beforeAll","beforeEach","describe","expect","it","vitest","createProject","updatePackageJSONDependencies","getValidTemplates","projectDir","console","log","fn","tempDirectory","realpathSync","tmpdir","Math","random","toString","substring","existsSync","rmSync","recursive","args","_","packageManager","projectName","template","name","type","description","url","cliArgs","packageJsonPath","resolve","packageJson","readJsonSync","toStrictEqual","importMapPath","importMapFile","readFileSync","not","toContain","example","undefined","templates","each","templateName","db","find","t","dbDetails","dbUri","toBe","Object","keys","dependencies","filter","n","startsWith","toHaveLength","payloadConfigPath","absolute","cwd","content","latestVersion","initialJSON","version","payload","correctlyModifiedJSON","toEqual"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,YAAYC,QAAQ,UAAS;AAC7B,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAGvF,SAASC,aAAa,EAAEC,6BAA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+D,aAAaI,OAAO,CAACD;YAC9B;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/create-project.spec.ts"],"sourcesContent":["import fs from 'fs'\nimport fse from 'fs-extra'\nimport globby from 'globby'\nimport * as os from 'node:os'\nimport path from 'path'\nimport { afterEach, beforeAll, beforeEach, describe, expect, it, vitest } from 'vitest'\nimport type { CliArgs, DbType, ProjectExample, ProjectTemplate } from '../types.js'\n\nimport { createProject, updatePackageJSONDependencies } from './create-project.js'\nimport { getValidTemplates } from './templates.js'\n\ndescribe('createProject', () => {\n let projectDir: string\n\n beforeAll(() => {\n // eslint-disable-next-line no-console\n console.log = vitest.fn()\n })\n\n beforeEach(() => {\n const tempDirectory = fs.realpathSync(os.tmpdir())\n projectDir = `${tempDirectory}/${Math.random().toString(36).substring(7)}`\n })\n\n afterEach(() => {\n if (fse.existsSync(projectDir)) {\n fse.rmSync(projectDir, { recursive: true })\n }\n })\n\n describe('#createProject', () => {\n const args = {\n _: ['project-name'],\n '--db': 'mongodb',\n '--local-template': 'blank',\n '--no-deps': true,\n } as CliArgs\n const packageManager = 'yarn'\n\n it('creates plugin template', async () => {\n const projectName = 'plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin',\n }\n\n await createProject({\n cliArgs: { ...args, '--local-template': 'plugin' } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toStrictEqual(projectName)\n })\n\n it('updates project name in plugin template importMap file', async () => {\n const projectName = 'my-custom-plugin'\n const template: ProjectTemplate = {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin',\n }\n\n await createProject({\n cliArgs: { ...args, '--local-template': 'plugin' } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n\n const importMapPath = path.resolve(projectDir, './dev/app/(payload)/admin/importMap.js')\n const importMapFile = fse.readFileSync(importMapPath, 'utf-8')\n\n expect(importMapFile).not.toContain('plugin-package-name-placeholder')\n expect(importMapFile).toContain('my-custom-plugin')\n })\n\n it('creates example', async () => {\n const projectName = 'custom-server-example'\n const example: ProjectExample = {\n name: 'custom-server',\n url: 'https://github.com/payloadcms/payload/examples/custom-server#main',\n }\n\n await createProject({\n cliArgs: {\n ...args,\n '--local-template': undefined,\n '--local-example': 'custom-server',\n } as CliArgs,\n packageManager,\n projectDir,\n projectName,\n example,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Check package name and description\n expect(packageJson.name).toStrictEqual(projectName)\n }, 90_000)\n\n describe('creates project from template', () => {\n const templates = getValidTemplates()\n\n it.each([\n ['blank', 'mongodb'],\n ['blank', 'postgres'],\n ['blank-tanstack', 'mongodb'],\n ['blank-tanstack', 'postgres'],\n\n // TODO: Re-enable these once 3.0 is stable and templates updated\n // ['website', 'mongodb'],\n // ['website', 'postgres'],\n // ['ecommerce', 'mongodb'],\n // ['ecommerce', 'postgres'],\n ])('update config and deps: %s, %s', async (templateName, db) => {\n const projectName = 'starter-project'\n\n const template = templates.find((t) => t.name === templateName)\n\n expect(template).toBeDefined()\n\n const cliArgs = {\n ...args,\n '--db': db,\n '--local-template': templateName,\n } as CliArgs\n\n await createProject({\n cliArgs,\n dbDetails: {\n type: db as DbType,\n dbUri: `${db}://localhost:27017/create-project-test`,\n },\n packageManager,\n projectDir,\n projectName,\n template: template as ProjectTemplate,\n })\n\n const packageJsonPath = path.resolve(projectDir, 'package.json')\n const packageJson = fse.readJsonSync(packageJsonPath)\n\n // Verify git was initialized\n expect(fse.existsSync(path.resolve(projectDir, '.git'))).toBe(true)\n\n // Should only have one db adapter\n expect(\n Object.keys(packageJson.dependencies).filter((n) => n.startsWith('@payloadcms/db-')),\n ).toHaveLength(1)\n\n const payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: projectDir,\n })\n )?.[0]\n\n const content = fse.readFileSync(payloadConfigPath, 'utf-8')\n\n // Check payload.config.ts doesn't have placeholder comments\n expect(content).not.toContain('// database-adapter-import')\n expect(content).not.toContain('// database-adapter-config-start')\n expect(content).not.toContain('// database-adapter-config-end')\n\n // Verify correct adapter import and usage based on db type\n if (db === 'mongodb') {\n expect(content).toContain(\"import { mongooseAdapter } from '@payloadcms/db-mongodb'\")\n expect(content).toContain('mongooseAdapter')\n } else if (db === 'postgres') {\n expect(content).toContain(\"import { postgresAdapter } from '@payloadcms/db-postgres'\")\n expect(content).toContain('postgresAdapter')\n }\n })\n })\n\n describe('updates package.json', () => {\n it('updates package name and bumps workspace versions', async () => {\n const latestVersion = '3.0.0'\n const initialJSON = {\n name: 'test-project',\n version: '1.0.0',\n dependencies: {\n '@payloadcms/db-mongodb': 'workspace:*',\n payload: 'workspace:*',\n '@payloadcms/ui': 'workspace:*',\n },\n }\n\n const correctlyModifiedJSON = {\n name: 'test-project',\n version: '1.0.0',\n dependencies: {\n '@payloadcms/db-mongodb': `${latestVersion}`,\n payload: `${latestVersion}`,\n '@payloadcms/ui': `${latestVersion}`,\n },\n }\n\n updatePackageJSONDependencies({\n latestVersion,\n packageJson: initialJSON,\n })\n\n expect(initialJSON).toEqual(correctlyModifiedJSON)\n })\n })\n })\n})\n"],"names":["fs","fse","globby","os","path","afterEach","beforeAll","beforeEach","describe","expect","it","vitest","createProject","updatePackageJSONDependencies","getValidTemplates","projectDir","console","log","fn","tempDirectory","realpathSync","tmpdir","Math","random","toString","substring","existsSync","rmSync","recursive","args","_","packageManager","projectName","template","name","type","description","url","cliArgs","packageJsonPath","resolve","packageJson","readJsonSync","toStrictEqual","importMapPath","importMapFile","readFileSync","not","toContain","example","undefined","templates","each","templateName","db","find","t","toBeDefined","dbDetails","dbUri","toBe","Object","keys","dependencies","filter","n","startsWith","toHaveLength","payloadConfigPath","absolute","cwd","content","latestVersion","initialJSON","version","payload","correctlyModifiedJSON","toEqual"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,YAAYC,QAAQ,UAAS;AAC7B,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAGvF,SAASC,aAAa,EAAEC,6BAA6B,QAAQ,sBAAqB;AAClF,SAASC,iBAAiB,QAAQ,iBAAgB;AAElDN,SAAS,iBAAiB;IACxB,IAAIO;IAEJT,UAAU;QACR,sCAAsC;QACtCU,QAAQC,GAAG,GAAGN,OAAOO,EAAE;IACzB;IAEAX,WAAW;QACT,MAAMY,gBAAgBnB,GAAGoB,YAAY,CAACjB,GAAGkB,MAAM;QAC/CN,aAAa,GAAGI,cAAc,CAAC,EAAEG,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,IAAI;IAC5E;IAEApB,UAAU;QACR,IAAIJ,IAAIyB,UAAU,CAACX,aAAa;YAC9Bd,IAAI0B,MAAM,CAACZ,YAAY;gBAAEa,WAAW;YAAK;QAC3C;IACF;IAEApB,SAAS,kBAAkB;QACzB,MAAMqB,OAAO;YACXC,GAAG;gBAAC;aAAe;YACnB,QAAQ;YACR,oBAAoB;YACpB,aAAa;QACf;QACA,MAAMC,iBAAiB;QAEvBrB,GAAG,2BAA2B;YAC5B,MAAMsB,cAAc;YACpB,MAAMC,WAA4B;gBAChCC,MAAM;gBACNC,MAAM;gBACNC,aAAa;gBACbC,KAAK;YACP;YAEA,MAAMzB,cAAc;gBAClB0B,SAAS;oBAAE,GAAGT,IAAI;oBAAE,oBAAoB;gBAAS;gBACjDE;gBACAhB;gBACAiB;gBACAC;YACF;YAEA,MAAMM,kBAAkBnC,KAA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ASvB,SAAS,CAAC;gBAC5B;YACF;QACF;QAEAxC,SAAS,wBAAwB;YAC/BE,GAAG,qDAAqD;gBACtD,MAAM8D,gBAAgB;gBACtB,MAAMC,cAAc;oBAClBvC,MAAM;oBACNwC,SAAS;oBACTX,cAAc;wBACZ,0BAA0B;wBAC1BY,SAAS;wBACT,kBAAkB;oBACpB;gBACF;gBAEA,MAAMC,wBAAwB;oBAC5B1C,MAAM;oBACNwC,SAAS;oBACTX,cAAc;wBACZ,0BAA0B,GAAGS,eAAe;wBAC5CG,SAAS,GAAGH,eAAe;wBAC3B,kBAAkB,GAAGA,eAAe;oBACtC;gBACF;gBAEA3D,8BAA8B;oBAC5B2D;oBACA/B,aAAagC;gBACf;gBAEAhE,OAAOgE,aAAaI,OAAO,CAACD;YAC9B;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,wBAAgB,gBAAgB,CAAC,EAAE,YAAY,EAAE,EAAE;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAQpF;AAED,wBAAgB,iBAAiB,IAAI,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,wBAAgB,gBAAgB,CAAC,EAAE,YAAY,EAAE,EAAE;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAQpF;AAED,wBAAgB,iBAAiB,IAAI,eAAe,EAAE,CAyCrD"}
|
package/dist/lib/templates.js
CHANGED
|
@@ -17,6 +17,12 @@ export function getValidTemplates() {
|
|
|
17
17
|
description: 'Blank 3.0 Template',
|
|
18
18
|
url: `https://github.com/payloadcms/payload/templates/blank#main`
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
name: 'blank-tanstack',
|
|
22
|
+
type: 'starter',
|
|
23
|
+
description: 'Blank TanStack Start Template',
|
|
24
|
+
url: 'https://github.com/payloadcms/payload/templates/blank-tanstack#main'
|
|
25
|
+
},
|
|
20
26
|
{
|
|
21
27
|
name: 'website',
|
|
22
28
|
type: 'starter',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/templates.ts"],"sourcesContent":["import type { ProjectTemplate } from '../types.js'\n\nimport { error, info } from '../utils/log.js'\n\nexport function validateTemplate({ templateName }: { templateName: string }): boolean {\n const validTemplates = getValidTemplates()\n if (!validTemplates.map((t) => t.name).includes(templateName)) {\n error(`'${templateName}' is not a valid template.`)\n info(`Valid templates: ${validTemplates.map((t) => t.name).join(', ')}`)\n return false\n }\n return true\n}\n\nexport function getValidTemplates(): ProjectTemplate[] {\n // Starters _must_ be a valid template name from the templates/ directory\n return [\n {\n name: 'blank',\n type: 'starter',\n description: 'Blank 3.0 Template',\n url: `https://github.com/payloadcms/payload/templates/blank#main`,\n },\n {\n name: 'website',\n type: 'starter',\n description: 'Website Template',\n url: `https://github.com/payloadcms/payload/templates/website#main`,\n },\n {\n name: 'ecommerce',\n type: 'starter',\n description: 'Ecommerce template',\n url: 'https://github.com/payloadcms/payload/templates/ecommerce#main',\n },\n {\n name: 'with-cloudflare-d1',\n type: 'starter',\n dbType: 'd1-sqlite',\n description: 'Blank template with Cloudflare D1 and Workers integration',\n url: 'https://github.com/payloadcms/payload/templates/with-cloudflare-d1#main',\n },\n {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin#main',\n },\n ]\n}\n"],"names":["error","info","validateTemplate","templateName","validTemplates","getValidTemplates","map","t","name","includes","join","type","description","url","dbType"],"mappings":"AAEA,SAASA,KAAK,EAAEC,IAAI,QAAQ,kBAAiB;AAE7C,OAAO,SAASC,iBAAiB,EAAEC,YAAY,EAA4B;IACzE,MAAMC,iBAAiBC;IACvB,IAAI,CAACD,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEC,QAAQ,CAACN,eAAe;QAC7DH,MAAM,CAAC,CAAC,EAAEG,aAAa,0BAA0B,CAAC;QAClDF,KAAK,CAAC,iBAAiB,EAAEG,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEE,IAAI,CAAC,OAAO;QACvE,OAAO;IACT;IACA,OAAO;AACT;AAEA,OAAO,SAASL;IACd,yEAAyE;IACzE,OAAO;QACL;YACEG,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK,CAAC,0DAA0D,CAAC;QACnE;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK,CAAC,4DAA4D,CAAC;QACrE;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEL,MAAM;YACNG,MAAM;YACNG,QAAQ;YACRF,aAAa;YACbC,KAAK;QACP;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;KACD;AACH"}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/templates.ts"],"sourcesContent":["import type { ProjectTemplate } from '../types.js'\n\nimport { error, info } from '../utils/log.js'\n\nexport function validateTemplate({ templateName }: { templateName: string }): boolean {\n const validTemplates = getValidTemplates()\n if (!validTemplates.map((t) => t.name).includes(templateName)) {\n error(`'${templateName}' is not a valid template.`)\n info(`Valid templates: ${validTemplates.map((t) => t.name).join(', ')}`)\n return false\n }\n return true\n}\n\nexport function getValidTemplates(): ProjectTemplate[] {\n // Starters _must_ be a valid template name from the templates/ directory\n return [\n {\n name: 'blank',\n type: 'starter',\n description: 'Blank 3.0 Template',\n url: `https://github.com/payloadcms/payload/templates/blank#main`,\n },\n {\n name: 'blank-tanstack',\n type: 'starter',\n description: 'Blank TanStack Start Template',\n url: 'https://github.com/payloadcms/payload/templates/blank-tanstack#main',\n },\n {\n name: 'website',\n type: 'starter',\n description: 'Website Template',\n url: `https://github.com/payloadcms/payload/templates/website#main`,\n },\n {\n name: 'ecommerce',\n type: 'starter',\n description: 'Ecommerce template',\n url: 'https://github.com/payloadcms/payload/templates/ecommerce#main',\n },\n {\n name: 'with-cloudflare-d1',\n type: 'starter',\n dbType: 'd1-sqlite',\n description: 'Blank template with Cloudflare D1 and Workers integration',\n url: 'https://github.com/payloadcms/payload/templates/with-cloudflare-d1#main',\n },\n {\n name: 'plugin',\n type: 'plugin',\n description: 'Template for creating a Payload plugin',\n url: 'https://github.com/payloadcms/payload/templates/plugin#main',\n },\n ]\n}\n"],"names":["error","info","validateTemplate","templateName","validTemplates","getValidTemplates","map","t","name","includes","join","type","description","url","dbType"],"mappings":"AAEA,SAASA,KAAK,EAAEC,IAAI,QAAQ,kBAAiB;AAE7C,OAAO,SAASC,iBAAiB,EAAEC,YAAY,EAA4B;IACzE,MAAMC,iBAAiBC;IACvB,IAAI,CAACD,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEC,QAAQ,CAACN,eAAe;QAC7DH,MAAM,CAAC,CAAC,EAAEG,aAAa,0BAA0B,CAAC;QAClDF,KAAK,CAAC,iBAAiB,EAAEG,eAAeE,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEE,IAAI,CAAC,OAAO;QACvE,OAAO;IACT;IACA,OAAO;AACT;AAEA,OAAO,SAASL;IACd,yEAAyE;IACzE,OAAO;QACL;YACEG,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK,CAAC,0DAA0D,CAAC;QACnE;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK,CAAC,4DAA4D,CAAC;QACrE;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;QACA;YACEL,MAAM;YACNG,MAAM;YACNG,QAAQ;YACRF,aAAa;YACbC,KAAK;QACP;QACA;YACEL,MAAM;YACNG,MAAM;YACNC,aAAa;YACbC,KAAK;QACP;KACD;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-payload-in-project.d.ts","sourceRoot":"","sources":["../../src/lib/update-payload-in-project.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAQjD,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,cAAc,EAC1B,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"update-payload-in-project.d.ts","sourceRoot":"","sources":["../../src/lib/update-payload-in-project.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAQjD,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,cAAc,EAC1B,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAmFhD"}
|
|
@@ -59,9 +59,18 @@ export async function updatePayloadInProject(appDetails, versionOrTag) {
|
|
|
59
59
|
info(`Updating Payload Next.js files...`);
|
|
60
60
|
const templateFilesPath = process.env.JEST_WORKER_ID !== undefined ? path.resolve(dirname, '../../../../templates/blank') : path.resolve(dirname, '../..', 'dist/template');
|
|
61
61
|
const templateSrcDir = path.resolve(templateFilesPath, 'src/app/(payload)');
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const payloadDirPath = path.resolve(projectDir, appDetails.isSrcDir ? 'src/app' : 'app', '(payload)');
|
|
63
|
+
// Rename a pre-migration `custom.scss` so the user's styles carry over to the `custom.css`
|
|
64
|
+
// that the refreshed `layout.tsx` imports, and stay protected by the ignore pattern below.
|
|
65
|
+
const legacyCustomStylesPath = path.resolve(payloadDirPath, 'custom.scss');
|
|
66
|
+
const customCssPath = path.resolve(payloadDirPath, 'custom.css');
|
|
67
|
+
if (fse.existsSync(legacyCustomStylesPath) && !fse.existsSync(customCssPath)) {
|
|
68
|
+
fse.renameSync(legacyCustomStylesPath, customCssPath);
|
|
69
|
+
info('Renamed `(payload)/custom.scss` to `custom.css`. If it contained Sass syntax (nesting, `$variables`, `@mixin`, etc.), convert it to plain CSS — it is no longer transpiled.');
|
|
70
|
+
}
|
|
71
|
+
copyRecursiveSync(templateSrcDir, payloadDirPath, [
|
|
72
|
+
'custom.css$'
|
|
73
|
+
]); // Do not overwrite user's custom.css
|
|
65
74
|
return {
|
|
66
75
|
message: 'Payload updated successfully.',
|
|
67
76
|
success: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/update-payload-in-project.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nimport type { NextAppDetails } from '../types.js'\n\nimport { copyRecursiveSync } from '../utils/copy-recursive-sync.js'\nimport { info } from '../utils/log.js'\nimport { resolvePackageVersion } from '../utils/resolvePackageVersion.js'\nimport { getPackageManager } from './get-package-manager.js'\nimport { installPackages } from './install-packages.js'\n\nexport async function updatePayloadInProject(\n appDetails: NextAppDetails,\n versionOrTag?: string,\n): Promise<{ message: string; success: boolean }> {\n if (!appDetails.nextConfigPath) {\n return { message: 'No Next.js config found', success: false }\n }\n\n const projectDir = path.dirname(appDetails.nextConfigPath)\n\n const packageObj = (await fse.readJson(path.resolve(projectDir, 'package.json'))) as {\n dependencies?: Record<string, string>\n }\n if (!packageObj?.dependencies) {\n throw new Error('No package.json found in this project')\n }\n\n const payloadVersion = packageObj.dependencies?.payload\n if (!payloadVersion) {\n throw new Error('Payload is not installed in this project')\n }\n\n const packageManager = await getPackageManager({ projectDir })\n\n // Resolve the requested Payload version (dist-tag or explicit version)\n const latestPayloadVersion = await resolvePackageVersion({ packageName: 'payload', versionOrTag })\n\n if (payloadVersion === latestPayloadVersion) {\n return { message: `Payload v${payloadVersion} is already up to date.`, success: true }\n }\n\n // Update all existing Payload packages\n const payloadPackages = Object.keys(packageObj.dependencies).filter((dep) =>\n dep.startsWith('@payloadcms/'),\n )\n\n const packageNames = ['payload', ...payloadPackages]\n\n const packagesToUpdate = packageNames.map((pkg) => `${pkg}@${latestPayloadVersion}`)\n\n info(`Using ${packageManager}.\\n`)\n info(\n `Updating ${packagesToUpdate.length} Payload packages to v${latestPayloadVersion}...\\n\\n${packageNames.map((p) => ` - ${p}`).join('\\n')}`,\n )\n\n const { success: updateSuccess } = await installPackages({\n packageManager,\n packagesToInstall: packagesToUpdate,\n projectDir,\n })\n\n if (!updateSuccess) {\n throw new Error('Failed to update Payload packages')\n }\n info('Payload packages updated successfully.')\n\n info(`Updating Payload Next.js files...`)\n\n const templateFilesPath =\n process.env.JEST_WORKER_ID !== undefined\n ? path.resolve(dirname, '../../../../templates/blank')\n : path.resolve(dirname, '../..', 'dist/template')\n\n const templateSrcDir = path.resolve(templateFilesPath, 'src/app/(payload)')\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/lib/update-payload-in-project.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nimport type { NextAppDetails } from '../types.js'\n\nimport { copyRecursiveSync } from '../utils/copy-recursive-sync.js'\nimport { info } from '../utils/log.js'\nimport { resolvePackageVersion } from '../utils/resolvePackageVersion.js'\nimport { getPackageManager } from './get-package-manager.js'\nimport { installPackages } from './install-packages.js'\n\nexport async function updatePayloadInProject(\n appDetails: NextAppDetails,\n versionOrTag?: string,\n): Promise<{ message: string; success: boolean }> {\n if (!appDetails.nextConfigPath) {\n return { message: 'No Next.js config found', success: false }\n }\n\n const projectDir = path.dirname(appDetails.nextConfigPath)\n\n const packageObj = (await fse.readJson(path.resolve(projectDir, 'package.json'))) as {\n dependencies?: Record<string, string>\n }\n if (!packageObj?.dependencies) {\n throw new Error('No package.json found in this project')\n }\n\n const payloadVersion = packageObj.dependencies?.payload\n if (!payloadVersion) {\n throw new Error('Payload is not installed in this project')\n }\n\n const packageManager = await getPackageManager({ projectDir })\n\n // Resolve the requested Payload version (dist-tag or explicit version)\n const latestPayloadVersion = await resolvePackageVersion({ packageName: 'payload', versionOrTag })\n\n if (payloadVersion === latestPayloadVersion) {\n return { message: `Payload v${payloadVersion} is already up to date.`, success: true }\n }\n\n // Update all existing Payload packages\n const payloadPackages = Object.keys(packageObj.dependencies).filter((dep) =>\n dep.startsWith('@payloadcms/'),\n )\n\n const packageNames = ['payload', ...payloadPackages]\n\n const packagesToUpdate = packageNames.map((pkg) => `${pkg}@${latestPayloadVersion}`)\n\n info(`Using ${packageManager}.\\n`)\n info(\n `Updating ${packagesToUpdate.length} Payload packages to v${latestPayloadVersion}...\\n\\n${packageNames.map((p) => ` - ${p}`).join('\\n')}`,\n )\n\n const { success: updateSuccess } = await installPackages({\n packageManager,\n packagesToInstall: packagesToUpdate,\n projectDir,\n })\n\n if (!updateSuccess) {\n throw new Error('Failed to update Payload packages')\n }\n info('Payload packages updated successfully.')\n\n info(`Updating Payload Next.js files...`)\n\n const templateFilesPath =\n process.env.JEST_WORKER_ID !== undefined\n ? path.resolve(dirname, '../../../../templates/blank')\n : path.resolve(dirname, '../..', 'dist/template')\n\n const templateSrcDir = path.resolve(templateFilesPath, 'src/app/(payload)')\n\n const payloadDirPath = path.resolve(\n projectDir,\n appDetails.isSrcDir ? 'src/app' : 'app',\n '(payload)',\n )\n\n // Rename a pre-migration `custom.scss` so the user's styles carry over to the `custom.css`\n // that the refreshed `layout.tsx` imports, and stay protected by the ignore pattern below.\n const legacyCustomStylesPath = path.resolve(payloadDirPath, 'custom.scss')\n const customCssPath = path.resolve(payloadDirPath, 'custom.css')\n\n if (fse.existsSync(legacyCustomStylesPath) && !fse.existsSync(customCssPath)) {\n fse.renameSync(legacyCustomStylesPath, customCssPath)\n info(\n 'Renamed `(payload)/custom.scss` to `custom.css`. If it contained Sass syntax (nesting, `$variables`, `@mixin`, etc.), convert it to plain CSS — it is no longer transpiled.',\n )\n }\n\n copyRecursiveSync(templateSrcDir, payloadDirPath, ['custom.css$']) // Do not overwrite user's custom.css\n\n return { message: 'Payload updated successfully.', success: true }\n}\n"],"names":["fse","fileURLToPath","path","filename","url","dirname","copyRecursiveSync","info","resolvePackageVersion","getPackageManager","installPackages","updatePayloadInProject","appDetails","versionOrTag","nextConfigPath","message","success","projectDir","packageObj","readJson","resolve","dependencies","Error","payloadVersion","payload","packageManager","latestPayloadVersion","packageName","payloadPackages","Object","keys","filter","dep","startsWith","packageNames","packagesToUpdate","map","pkg","length","p","join","updateSuccess","packagesToInstall","templateFilesPath","process","env","JEST_WORKER_ID","undefined","templateSrcDir","payloadDirPath","isSrcDir","legacyCustomStylesPath","customCssPath","existsSync","renameSync"],"mappings":"AAAA,OAAOA,SAAS,WAAU;AAC1B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AAEvB,MAAMC,WAAWF,cAAc,YAAYG,GAAG;AAC9C,MAAMC,UAAUH,KAAKG,OAAO,CAACF;AAI7B,SAASG,iBAAiB,QAAQ,kCAAiC;AACnE,SAASC,IAAI,QAAQ,kBAAiB;AACtC,SAASC,qBAAqB,QAAQ,oCAAmC;AACzE,SAASC,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,eAAe,QAAQ,wBAAuB;AAEvD,OAAO,eAAeC,uBACpBC,UAA0B,EAC1BC,YAAqB;IAErB,IAAI,CAACD,WAAWE,cAAc,EAAE;QAC9B,OAAO;YAAEC,SAAS;YAA2BC,SAAS;QAAM;IAC9D;IAEA,MAAMC,aAAaf,KAAKG,OA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