create-payload-app 1.0.0-beta.0 → 3.0.0-alpha.50

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +3 -3
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/configure-payload-config.d.ts +11 -0
  7. package/dist/lib/configure-payload-config.d.ts.map +1 -0
  8. package/dist/lib/configure-payload-config.js +15 -53
  9. package/dist/lib/configure-payload-config.js.map +1 -0
  10. package/dist/lib/create-project.d.ts +14 -0
  11. package/dist/lib/create-project.d.ts.map +1 -0
  12. package/dist/lib/create-project.js +84 -24
  13. package/dist/lib/create-project.js.map +1 -0
  14. package/dist/lib/create-project.spec.d.ts +2 -0
  15. package/dist/lib/create-project.spec.d.ts.map +1 -0
  16. package/dist/lib/create-project.spec.js +30 -75
  17. package/dist/lib/create-project.spec.js.map +1 -0
  18. package/dist/lib/generate-secret.d.ts +2 -0
  19. package/dist/lib/generate-secret.d.ts.map +1 -0
  20. package/dist/lib/generate-secret.js +1 -1
  21. package/dist/lib/generate-secret.js.map +1 -0
  22. package/dist/lib/init-next.d.ts +29 -0
  23. package/dist/lib/init-next.d.ts.map +1 -0
  24. package/dist/lib/init-next.js +285 -0
  25. package/dist/lib/init-next.js.map +1 -0
  26. package/dist/lib/packages.d.ts +9 -0
  27. package/dist/lib/packages.d.ts.map +1 -0
  28. package/dist/lib/packages.js +8 -52
  29. package/dist/lib/packages.js.map +1 -0
  30. package/dist/lib/parse-project-name.d.ts +3 -0
  31. package/dist/lib/parse-project-name.d.ts.map +1 -0
  32. package/dist/lib/parse-project-name.js +53 -12
  33. package/dist/lib/parse-project-name.js.map +1 -0
  34. package/dist/lib/parse-template.d.ts +3 -0
  35. package/dist/lib/parse-template.d.ts.map +1 -0
  36. package/dist/lib/parse-template.js +50 -20
  37. package/dist/lib/parse-template.js.map +1 -0
  38. package/dist/lib/select-db.d.ts +3 -0
  39. package/dist/lib/select-db.d.ts.map +1 -0
  40. package/dist/lib/select-db.js +72 -31
  41. package/dist/lib/select-db.js.map +1 -0
  42. package/dist/lib/templates.d.ts +4 -0
  43. package/dist/lib/templates.d.ts.map +1 -0
  44. package/dist/lib/templates.js +17 -11
  45. package/dist/lib/templates.js.map +1 -0
  46. package/dist/lib/wrap-next-config.d.ts +12 -0
  47. package/dist/lib/wrap-next-config.d.ts.map +1 -0
  48. package/dist/lib/wrap-next-config.js +110 -0
  49. package/dist/lib/wrap-next-config.js.map +1 -0
  50. package/dist/lib/wrap-next-config.spec.d.ts +2 -0
  51. package/dist/lib/wrap-next-config.spec.d.ts.map +1 -0
  52. package/dist/lib/wrap-next-config.spec.js +98 -0
  53. package/dist/lib/wrap-next-config.spec.js.map +1 -0
  54. package/dist/lib/write-env-file.d.ts +10 -0
  55. package/dist/lib/write-env-file.d.ts.map +1 -0
  56. package/dist/lib/write-env-file.js +9 -6
  57. package/dist/lib/write-env-file.js.map +1 -0
  58. package/dist/main.d.ts +7 -0
  59. package/dist/main.d.ts.map +1 -0
  60. package/dist/main.js +176 -60
  61. package/dist/main.js.map +1 -0
  62. package/dist/scripts/pack-template-files.d.ts +2 -0
  63. package/dist/scripts/pack-template-files.d.ts.map +1 -0
  64. package/dist/scripts/pack-template-files.js +43 -0
  65. package/dist/scripts/pack-template-files.js.map +1 -0
  66. package/dist/template/src/app/(payload)/admin/[[...segments]]/page.tsx +17 -0
  67. package/dist/template/src/app/(payload)/api/[...slug]/route.ts +9 -0
  68. package/dist/template/src/app/(payload)/api/graphql/route.ts +6 -0
  69. package/dist/template/src/app/(payload)/api/graphql-playground/route.ts +6 -0
  70. package/dist/template/src/app/(payload)/custom.scss +0 -0
  71. package/dist/template/src/app/(payload)/layout.tsx +16 -0
  72. package/dist/template/src/app/my-route/route.ts +14 -0
  73. package/dist/template/src/collections/Users.ts +13 -0
  74. package/dist/template/src/payload.config.ts +38 -0
  75. package/dist/types.d.ts +55 -0
  76. package/dist/types.d.ts.map +1 -0
  77. package/dist/types.js +1 -1
  78. package/dist/types.js.map +1 -0
  79. package/dist/utils/copy-recursive-sync.d.ts +5 -0
  80. package/dist/utils/copy-recursive-sync.d.ts.map +1 -0
  81. package/dist/utils/copy-recursive-sync.js +34 -0
  82. package/dist/utils/copy-recursive-sync.js.map +1 -0
  83. package/dist/utils/log.d.ts +6 -0
  84. package/dist/utils/log.d.ts.map +1 -0
  85. package/dist/utils/log.js +62 -15
  86. package/dist/utils/log.js.map +1 -0
  87. package/dist/utils/messages.d.ts +11 -0
  88. package/dist/utils/messages.d.ts.map +1 -0
  89. package/dist/utils/messages.js +47 -16
  90. package/dist/utils/messages.js.map +1 -0
  91. package/package.json +27 -10
@@ -10,16 +10,20 @@ Object.defineProperty(exports, "writeEnvFile", {
10
10
  });
11
11
  const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
12
12
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
- const _log = require("../utils/log");
13
+ const _log = require("../utils/log.js");
14
14
  function _interop_require_default(obj) {
15
15
  return obj && obj.__esModule ? obj : {
16
16
  default: obj
17
17
  };
18
18
  }
19
19
  async function writeEnvFile(args) {
20
- const { databaseUri, payloadSecret, projectDir, template } = args;
20
+ const { cliArgs, databaseUri, payloadSecret, projectDir, template } = args;
21
+ if (cliArgs['--dry-run']) {
22
+ (0, _log.debug)(`DRY RUN: .env file created`);
23
+ return;
24
+ }
21
25
  try {
22
- if (template.type === 'starter' && _fsextra.default.existsSync(_path.default.join(projectDir, '.env.example'))) {
26
+ if (template?.type === 'starter' && _fsextra.default.existsSync(_path.default.join(projectDir, '.env.example'))) {
23
27
  // Parse .env file into key/value pairs
24
28
  const envFile = await _fsextra.default.readFile(_path.default.join(projectDir, '.env.example'), 'utf8');
25
29
  const envWithValues = envFile.split('\n').filter((e)=>e).map((line)=>{
@@ -38,10 +42,9 @@ async function writeEnvFile(args) {
38
42
  // Write new .env file
39
43
  await _fsextra.default.writeFile(_path.default.join(projectDir, '.env'), envWithValues.join('\n'));
40
44
  } else {
41
- const content = `MONGODB_URI=${databaseUri}\nPAYLOAD_SECRET=${payloadSecret}`;
45
+ const content = `DATABASE_URI=${databaseUri}\nPAYLOAD_SECRET=${payloadSecret}`;
42
46
  await _fsextra.default.outputFile(`${projectDir}/.env`, content);
43
47
  }
44
- (0, _log.success)('.env file created');
45
48
  } catch (err) {
46
49
  (0, _log.error)('Unable to write .env file');
47
50
  if (err instanceof Error) {
@@ -51,4 +54,4 @@ async function writeEnvFile(args) {
51
54
  }
52
55
  }
53
56
 
54
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvd3JpdGUtZW52LWZpbGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGZzIGZyb20gJ2ZzLWV4dHJhJ1xuaW1wb3J0IHBhdGggZnJvbSAncGF0aCdcblxuaW1wb3J0IHR5cGUgeyBQcm9qZWN0VGVtcGxhdGUgfSBmcm9tICcuLi90eXBlcydcblxuaW1wb3J0IHsgZXJyb3IsIHN1Y2Nlc3MgfSBmcm9tICcuLi91dGlscy9sb2cnXG5cbi8qKiBQYXJzZSBhbmQgc3dhcCAuZW52LmV4YW1wbGUgdmFsdWVzIGFuZCB3cml0ZSAuZW52ICovXG5leHBvcnQgYXN5bmMgZnVuY3Rpb24gd3JpdGVFbnZGaWxlKGFyZ3M6IHtcbiAgZGF0YWJhc2VVcmk6IHN0cmluZ1xuICBwYXlsb2FkU2VjcmV0OiBzdHJpbmdcbiAgcHJvamVjdERpcjogc3RyaW5nXG4gIHRlbXBsYXRlOiBQcm9qZWN0VGVtcGxhdGVcbn0pOiBQcm9taXNlPHZvaWQ+IHtcbiAgY29uc3QgeyBkYXRhYmFzZVVyaSwgcGF5bG9hZFNlY3JldCwgcHJvamVjdERpciwgdGVtcGxhdGUgfSA9IGFyZ3NcbiAgdHJ5IHtcbiAgICBpZiAodGVtcGxhdGUudHlwZSA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NCQUFzQjtZQUN0QixNQUFNZixnQkFBRSxDQUFDZ0IsU0FBUyxDQUFDZCxhQUFJLENBQUNDLElBQUksQ0FBQ04sWUFBWSxTQUFTUyxjQUFjSCxJQUFJLENBQUM7UUFDdkUsT0FBTztZQUNMLE1BQU1jLFVBQVUsQ0FBQyxZQUFZLEVBQUV0QixZQUFZLGlCQUFpQixFQUFFQyxjQUFjLENBQUM7WUFDN0UsTUFBTUksZ0JBQUUsQ0FBQ2tCLFVBQVUsQ0FBQyxDQUFDLEVBQUVyQixXQUFXLEtBQUssQ0FBQyxFQUFFb0I7UUFDNUM7UUFFQUUsSUFBQUEsWUFBTyxFQUFDO0lBQ1YsRUFBRSxPQUFPQyxLQUFjO1FBQ3JCQyxJQUFBQSxVQUFLLEVBQUM7UUFDTixJQUFJRCxlQUFlRSxPQUFPO1lBQ3hCRCxJQUFBQSxVQUFLLEVBQUNELElBQUlHLE9BQU87UUFDbkI7UUFDQUMsUUFBUUMsSUFBSSxDQUFDO0lBQ2Y7QUFDRiJ9
57
+ //# sourceMappingURL=write-env-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/write-env-file.ts"],"sourcesContent":["import fs from 'fs-extra'\nimport path from 'path'\n\nimport type { CliArgs, ProjectTemplate } from '../types.js'\n\nimport { debug, error } from '../utils/log.js'\n\n/** Parse and swap .env.example values and write .env */\nexport async function writeEnvFile(args: {\n cliArgs: CliArgs\n databaseUri: string\n payloadSecret: string\n projectDir: string\n template?: ProjectTemplate\n}): Promise<void> {\n const { cliArgs, databaseUri, payloadSecret, projectDir, template } = args\n\n if (cliArgs['--dry-run']) {\n debug(`DRY RUN: .env file created`)\n return\n }\n\n try {\n if (template?.type === 'starter' && fs.existsSync(path.join(projectDir, '.env.example'))) {\n // Parse .env file into key/value pairs\n const envFile = await fs.readFile(path.join(projectDir, '.env.example'), 'utf8')\n const envWithValues: string[] = envFile\n .split('\\n')\n .filter((e) => e)\n .map((line) => {\n if (line.startsWith('#') || !line.includes('=')) return line\n\n const split = line.split('=')\n const key = split[0]\n let value = split[1]\n\n if (key === 'MONGODB_URI' || key === 'MONGO_URL' || key === 'DATABASE_URI') {\n value = databaseUri\n }\n if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') {\n value = payloadSecret\n }\n\n return `${key}=${value}`\n })\n\n // Write new .env file\n await fs.writeFile(path.join(projectDir, '.env'), envWithValues.join('\\n'))\n } else {\n const content = `DATABASE_URI=${databaseUri}\\nPAYLOAD_SECRET=${payloadSecret}`\n await fs.outputFile(`${projectDir}/.env`, content)\n }\n } catch (err: unknown) {\n error('Unable to write .env file')\n if (err instanceof Error) {\n error(err.message)\n }\n process.exit(1)\n }\n}\n"],"names":["writeEnvFile","args","cliArgs","databaseUri","payloadSecret","projectDir","template","debug","type","fs","existsSync","path","join","envFile","readFile","envWithValues","split","filter","e","map","line","startsWith","includes","key","value","writeFile","content","outputFile","err","error","Error","message","process","exit"],"mappings":";;;;+BAQsBA;;;eAAAA;;;gEARP;6DACE;qBAIY;;;;;;AAGtB,eAAeA,aAAaC,IAMlC;IACC,MAAM,EAAEC,OAAO,EAAEC,WAAW,EAAEC,aAAa,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGL;IAEtE,IAAIC,OAAO,CAAC,YAAY,EAAE;QACxBK,IAAAA,UAAK,EAAC,CAAC,0BAA0B,CAAC;QAClC;IACF;IAEA,IAAI;QACF,IAAID,UAAUE,SAAS,aAAaC,gBAAE,CAACC,UAAU,CAACC,aAAI,CAACC,IAAI,CAACP,YAAY,kBAAkB;YACxF,uCAAuC;YACvC,MAAMQ,UAAU,MAAMJ,gBAAE,CAACK,QAAQ,CAACH,aAAI,CAACC,IAAI,CAACP,YAAY,iBAAiB;YACzE,MAAMU,gBAA0BF,QAC7BG,KAAK,CAAC,MACNC,MAAM,CAAC,CAACC,IAAMA,GACdC,GAAG,CAAC,CAACC;gBACJ,IAAIA,KAAKC,UAAU,CAAC,QAAQ,CAACD,KAAKE,QAAQ,CAAC,MAAM,OAAOF;gBAExD,MAAMJ,QAAQI,KAAKJ,KAAK,CAAC;gBACzB,MAAMO,MAAMP,KAAK,CAAC,EAAE;gBACpB,IAAIQ,QAAQR,KAAK,CAAC,EAAE;gBAEpB,IAAIO,QAAQ,iBAAiBA,QAAQ,eAAeA,QAAQ,gBAAgB;oBAC1EC,QAAQrB;gBACV;gBACA,IAAIoB,QAAQ,oBAAoBA,QAAQ,sBAAsB;oBAC5DC,QAAQpB;gBACV;gBAEA,OAAO,CAAC,EAAEmB,IAAI,CAAC,EAAEC,MAAM,CAAC;YAC1B;YAEF,sBAAsB;YACtB,MAAMf,gBAAE,CAACgB,SAAS,CAACd,aAAI,CAACC,IAAI,CAACP,YAAY,SAASU,cAAcH,IAAI,CAAC;QACvE,OAAO;YACL,MAAMc,UAAU,CAAC,aAAa,EAAEvB,YAAY,iBAAiB,EAAEC,cAAc,CAAC;YAC9E,MAAMK,gBAAE,CAACkB,UAAU,CAAC,CAAC,EAAEtB,WAAW,KAAK,CAAC,EAAEqB;QAC5C;IACF,EAAE,OAAOE,KAAc;QACrBC,IAAAA,UAAK,EAAC;QACN,IAAID,eAAeE,OAAO;YACxBD,IAAAA,UAAK,EAACD,IAAIG,OAAO;QACnB;QACAC,QAAQC,IAAI,CAAC;IACf;AACF"}
package/dist/main.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { CliArgs } from './types.js';
2
+ export declare class Main {
3
+ args: CliArgs;
4
+ constructor();
5
+ init(): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,YAAY,CAAA;AAoBzD,qBAAa,IAAI;IACf,IAAI,EAAE,OAAO,CAAA;;IAwCP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CA4I5B"}
package/dist/main.js CHANGED
@@ -8,33 +8,86 @@ Object.defineProperty(exports, "Main", {
8
8
  return Main;
9
9
  }
10
10
  });
11
+ const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts"));
11
12
  const _slugify = /*#__PURE__*/ _interop_require_default(require("@sindresorhus/slugify"));
12
13
  const _arg = /*#__PURE__*/ _interop_require_default(require("arg"));
13
- const _commandexists = /*#__PURE__*/ _interop_require_default(require("command-exists"));
14
- const _createproject = require("./lib/create-project");
15
- const _generatesecret = require("./lib/generate-secret");
16
- const _parseprojectname = require("./lib/parse-project-name");
17
- const _parsetemplate = require("./lib/parse-template");
18
- const _selectdb = require("./lib/select-db");
19
- const _templates = require("./lib/templates");
20
- const _writeenvfile = require("./lib/write-env-file");
21
- const _log = require("./utils/log");
22
- const _messages = require("./utils/messages");
14
+ const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
15
+ const _detectpackagemanager = require("detect-package-manager");
16
+ const _figures = /*#__PURE__*/ _interop_require_default(require("figures"));
17
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
18
+ const _configurepayloadconfig = require("./lib/configure-payload-config.js");
19
+ const _createproject = require("./lib/create-project.js");
20
+ const _generatesecret = require("./lib/generate-secret.js");
21
+ const _initnext = require("./lib/init-next.js");
22
+ const _parseprojectname = require("./lib/parse-project-name.js");
23
+ const _parsetemplate = require("./lib/parse-template.js");
24
+ const _selectdb = require("./lib/select-db.js");
25
+ const _templates = require("./lib/templates.js");
26
+ const _writeenvfile = require("./lib/write-env-file.js");
27
+ const _log = require("./utils/log.js");
28
+ const _messages = require("./utils/messages.js");
23
29
  function _interop_require_default(obj) {
24
30
  return obj && obj.__esModule ? obj : {
25
31
  default: obj
26
32
  };
27
33
  }
34
+ function _getRequireWildcardCache(nodeInterop) {
35
+ if (typeof WeakMap !== "function") return null;
36
+ var cacheBabelInterop = new WeakMap();
37
+ var cacheNodeInterop = new WeakMap();
38
+ return (_getRequireWildcardCache = function(nodeInterop) {
39
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
40
+ })(nodeInterop);
41
+ }
42
+ function _interop_require_wildcard(obj, nodeInterop) {
43
+ if (!nodeInterop && obj && obj.__esModule) {
44
+ return obj;
45
+ }
46
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
47
+ return {
48
+ default: obj
49
+ };
50
+ }
51
+ var cache = _getRequireWildcardCache(nodeInterop);
52
+ if (cache && cache.has(obj)) {
53
+ return cache.get(obj);
54
+ }
55
+ var newObj = {
56
+ __proto__: null
57
+ };
58
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
59
+ for(var key in obj){
60
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
61
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
62
+ if (desc && (desc.get || desc.set)) {
63
+ Object.defineProperty(newObj, key, desc);
64
+ } else {
65
+ newObj[key] = obj[key];
66
+ }
67
+ }
68
+ }
69
+ newObj.default = obj;
70
+ if (cache) {
71
+ cache.set(obj, newObj);
72
+ }
73
+ return newObj;
74
+ }
28
75
  class Main {
29
76
  args;
30
77
  constructor(){
31
78
  // @ts-expect-error bad typings
32
79
  this.args = (0, _arg.default)({
33
80
  '--db': String,
81
+ '--db-accept-recommended': Boolean,
82
+ '--db-connection-string': String,
34
83
  '--help': Boolean,
84
+ '--local-template': String,
35
85
  '--name': String,
36
86
  '--secret': String,
37
87
  '--template': String,
88
+ '--template-branch': String,
89
+ // Next.js
90
+ '--init-next': Boolean,
38
91
  // Package manager
39
92
  '--no-deps': Boolean,
40
93
  '--use-npm': Boolean,
@@ -42,6 +95,7 @@ class Main {
42
95
  '--use-yarn': Boolean,
43
96
  // Flags
44
97
  '--beta': Boolean,
98
+ '--debug': Boolean,
45
99
  '--dry-run': Boolean,
46
100
  // Aliases
47
101
  '-d': '--db',
@@ -55,61 +109,128 @@ class Main {
55
109
  async init() {
56
110
  try {
57
111
  if (this.args['--help']) {
58
- console.log((0, _messages.helpMessage)());
112
+ (0, _messages.helpMessage)();
59
113
  process.exit(0);
60
114
  }
115
+ // eslint-disable-next-line no-console
116
+ console.log('\n');
117
+ _prompts.intro(_chalk.default.bgCyan(_chalk.default.black(' create-payload-app ')));
118
+ _prompts.note("Welcome to Payload. Let's create a project!");
119
+ // Detect if inside Next.js project
120
+ const nextAppDetails = await (0, _initnext.getNextAppDetails)(process.cwd());
121
+ const { hasTopLevelLayout, nextAppDir, nextConfigPath } = nextAppDetails;
122
+ if (nextConfigPath) {
123
+ this.args['--name'] = (0, _slugify.default)(_path.default.basename(_path.default.dirname(nextConfigPath)));
124
+ }
125
+ const projectName = await (0, _parseprojectname.parseProjectName)(this.args);
126
+ const projectDir = nextConfigPath ? _path.default.dirname(nextConfigPath) : _path.default.resolve(process.cwd(), (0, _slugify.default)(projectName));
127
+ const packageManager = await getPackageManager(this.args, projectDir);
128
+ if (nextConfigPath) {
129
+ _prompts.log.step(_chalk.default.bold(`${_chalk.default.bgBlack(` ${_figures.default.triangleUp} Next.js `)} project detected!`));
130
+ const proceed = await _prompts.confirm({
131
+ initialValue: true,
132
+ message: _chalk.default.bold(`Install ${_chalk.default.green('Payload')} in this project?`)
133
+ });
134
+ if (_prompts.isCancel(proceed) || !proceed) {
135
+ _prompts.outro((0, _messages.feedbackOutro)());
136
+ process.exit(0);
137
+ }
138
+ // Check for top-level layout.tsx
139
+ if (nextAppDir && hasTopLevelLayout) {
140
+ _prompts.log.warn((0, _messages.moveMessage)({
141
+ nextAppDir,
142
+ projectDir
143
+ }));
144
+ _prompts.outro((0, _messages.feedbackOutro)());
145
+ process.exit(0);
146
+ }
147
+ const dbDetails = await (0, _selectdb.selectDb)(this.args, projectName);
148
+ const result = await (0, _initnext.initNext)({
149
+ ...this.args,
150
+ dbType: dbDetails.type,
151
+ nextAppDetails,
152
+ packageManager,
153
+ projectDir
154
+ });
155
+ if (result.success === false) {
156
+ _prompts.outro((0, _messages.feedbackOutro)());
157
+ process.exit(1);
158
+ }
159
+ await (0, _configurepayloadconfig.configurePayloadConfig)({
160
+ dbDetails,
161
+ projectDirOrConfigPath: {
162
+ payloadConfigPath: result.payloadConfigPath
163
+ }
164
+ });
165
+ await (0, _writeenvfile.writeEnvFile)({
166
+ cliArgs: this.args,
167
+ databaseUri: dbDetails.dbUri,
168
+ payloadSecret: (0, _generatesecret.generateSecret)(),
169
+ projectDir
170
+ });
171
+ (0, _log.info)('Payload project successfully initialized!');
172
+ _prompts.note((0, _messages.successfulNextInit)(), _chalk.default.bgGreen(_chalk.default.black(' Documentation ')));
173
+ _prompts.outro((0, _messages.feedbackOutro)());
174
+ return;
175
+ }
61
176
  const templateArg = this.args['--template'];
62
177
  if (templateArg) {
63
178
  const valid = (0, _templates.validateTemplate)(templateArg);
64
179
  if (!valid) {
65
- console.log((0, _messages.helpMessage)());
180
+ (0, _messages.helpMessage)();
66
181
  process.exit(1);
67
182
  }
68
183
  }
69
- console.log(_messages.welcomeMessage);
70
- const projectName = await (0, _parseprojectname.parseProjectName)(this.args);
71
184
  const validTemplates = (0, _templates.getValidTemplates)();
72
185
  const template = await (0, _parsetemplate.parseTemplate)(this.args, validTemplates);
73
- const projectDir = projectName === '.' ? process.cwd() : `./${(0, _slugify.default)(projectName)}`;
74
- const packageManager = await getPackageManager(this.args);
75
- if (template.type !== 'plugin') {
76
- const dbDetails = await (0, _selectdb.selectDb)(this.args, projectName);
77
- const payloadSecret = (0, _generatesecret.generateSecret)();
78
- if (!this.args['--dry-run']) {
79
- await (0, _createproject.createProject)({
80
- cliArgs: this.args,
81
- dbDetails,
82
- packageManager,
83
- projectDir,
84
- projectName,
85
- template
86
- });
87
- await (0, _writeenvfile.writeEnvFile)({
88
- databaseUri: dbDetails.dbUri,
89
- payloadSecret,
90
- projectDir,
91
- template
92
- });
93
- }
94
- } else {
95
- if (!this.args['--dry-run']) {
96
- await (0, _createproject.createProject)({
97
- cliArgs: this.args,
98
- packageManager,
99
- projectDir,
100
- projectName,
101
- template
102
- });
103
- }
186
+ if (!template) {
187
+ _prompts.log.error('Invalid template given');
188
+ _prompts.outro((0, _messages.feedbackOutro)());
189
+ process.exit(1);
104
190
  }
105
- (0, _log.success)('Payload project successfully created');
106
- console.log((0, _messages.successMessage)(projectDir, packageManager));
107
- } catch (error) {
108
- console.log(error);
191
+ switch(template.type){
192
+ case 'starter':
193
+ {
194
+ const dbDetails = await (0, _selectdb.selectDb)(this.args, projectName);
195
+ const payloadSecret = (0, _generatesecret.generateSecret)();
196
+ await (0, _createproject.createProject)({
197
+ cliArgs: this.args,
198
+ dbDetails,
199
+ packageManager,
200
+ projectDir,
201
+ projectName,
202
+ template
203
+ });
204
+ await (0, _writeenvfile.writeEnvFile)({
205
+ cliArgs: this.args,
206
+ databaseUri: dbDetails.dbUri,
207
+ payloadSecret,
208
+ projectDir,
209
+ template
210
+ });
211
+ break;
212
+ }
213
+ case 'plugin':
214
+ {
215
+ await (0, _createproject.createProject)({
216
+ cliArgs: this.args,
217
+ packageManager,
218
+ projectDir,
219
+ projectName,
220
+ template
221
+ });
222
+ break;
223
+ }
224
+ }
225
+ (0, _log.info)('Payload project successfully created!');
226
+ _prompts.note((0, _messages.successMessage)(projectDir, packageManager), _chalk.default.bgGreen(_chalk.default.black(' Next Steps ')));
227
+ _prompts.outro((0, _messages.feedbackOutro)());
228
+ } catch (err) {
229
+ (0, _log.error)(err instanceof Error ? err.message : 'An error occurred');
109
230
  }
110
231
  }
111
232
  }
112
- async function getPackageManager(args) {
233
+ async function getPackageManager(args, projectDir) {
113
234
  let packageManager = 'npm';
114
235
  if (args['--use-npm']) {
115
236
  packageManager = 'npm';
@@ -118,17 +239,12 @@ async function getPackageManager(args) {
118
239
  } else if (args['--use-pnpm']) {
119
240
  packageManager = 'pnpm';
120
241
  } else {
121
- try {
122
- if (await (0, _commandexists.default)('yarn')) {
123
- packageManager = 'yarn';
124
- } else if (await (0, _commandexists.default)('pnpm')) {
125
- packageManager = 'pnpm';
126
- }
127
- } catch (error) {
128
- packageManager = 'npm';
129
- }
242
+ const detected = await (0, _detectpackagemanager.detect)({
243
+ cwd: projectDir
244
+ });
245
+ packageManager = detected || 'npm';
130
246
  }
131
247
  return packageManager;
132
248
  }
133
249
 
134
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9tYWluLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBzbHVnaWZ5IGZyb20gJ0BzaW5kcmVzb3JodXMvc2x1Z2lmeSdcbmltcG9ydCBhcmcgZnJvbSAnYXJnJ1xuaW1wb3J0IGNvbW1hbmRFeGlzdHMgZnJvbSAnY29tbWFuZC1leGlzdHMnXG5cbmltcG9ydCB0eXBlIHsgQ2xpQXJncywgUGFja2FnZU1hbmFnZXIgfSBmcm9tICcuL3R5cGVzJ1xuXG5pbXBvcnQgeyBjcmVhdGVQcm9qZWN0IH0gZnJvbSAnLi9saWIvY3JlYXRlLXByb2plY3QnXG5pbXBvcnQgeyBnZW5lcmF0ZVNlY3JldCB9IGZyb20gJy4vbGliL2dlbmVyYXRlLXNlY3JldCdcbmltcG9ydCB7IHBhcnNlUHJvamVjdE5hbWUgfSBmcm9tICcuL2xpYi9wYXJzZS1wcm9qZWN0LW5hbWUnXG5pbXBvcnQgeyBwYXJzZVRlbXBsYXRlIH0gZnJvbSAnLi9saWIvcGFyc2UtdGVtcGxhdGUnXG5pbXBvcnQgeyBzZWxlY3REYiB9IGZyb20gJy4vbGliL3NlbGVjdC1kYidcbmltcG9ydCB7IGdldFZhbGlkVGVtcGxhdGVzLCB2YWxpZGF0ZVRlbXBsYXRlIH0gZnJvbSAnLi9saWIvdGVtcGxhdGVzJ1xuaW1wb3J0IHsgd3JpdGVFbnZGaWxlIH0gZnJvbSAnLi9saWIvd3JpdGUtZW52LWZpbGUnXG5pbXBvcnQgeyBzdWNjZXNzIH0gZnJvbSAnLi91dGlscy9sb2cnXG5pbXBvcnQgeyBoZWxwTWVzc2FnZSwgc3VjY2Vzc01lc3NhZ2UsIHdlbGNvbWVNZXNzYWdlIH0gZnJvbSAnLi91dGlscy9tZXNzYWdlcydcblxuZXhwb3J0IGNsYXNzIE1haW4ge1xuICBhcmdzOiBDbGlBcmdzXG5cbiAgY29uc3RydWN0b3IoKSB7XG4gICAgLy8gQHRzLWV4cGVjdC1lcnJvciBiYWQgdHlwaW5nc1xuICAgIHRoaXMuYXJncyA9IGFyZyhcbiAgICAgIHtcbiAgICAgICAgJy0tZGInOiBTdHJpbmcsXG4gICAgICAgICctLWhlbHAnOiBCb29sZWFuLFxuICAgICAgICAnLS1uYW1lJzogU3RyaW5nLFxuICAgICAgICAnLS1zZWNyZXQnOiBTdHJpbmcsXG4gICAgICAgICctLXRlbXBsYXRlJzogU3RyaW5nLFxuXG4gICAgICAgIC8vIFBhY2thZ2UgbWFuYWdlclxuICAgICAgICAnLS1uby1kZXBzJzogQm9vbGVhbixcbiAgICAgICAgJy0tdXNlLW5wbSc6IEJvb2xlYW4sXG4gICAgICAgICctLXVzZS1wbnBtJzogQm9vbGVhbixcbiAgICAgICAgJy0tdXNlLXlhcm4nOiBCb29sZWFuLFxuXG4gICAgICAgIC8vIEZsYWdzXG4gICAgICAgICctLWJldGEnOiBCb29sZWFuLFxuICAgICAgICAnLS1kcnktcnVuJzogQm9vbGVhbixcblxuICAgICAgICAvLyBBbGlhc2VzXG4gICAgICAgICctZCc6ICctLWRiJyxcbiAgICAgICAgJy1oJzogJy0taGVscCcsXG4gICAgICAgICctbic6ICctLW5hbWUnLFxuICAgICAgICAnLXQnOiAnLS10ZW1wbGF0ZScsXG4gICAgICB9LFxuICAgICAgeyBwZXJtaXNzaXZlOiB0cnVlIH0sXG4gICAgKVxuICB9XG5cbiAgYXN5bmMgaW5pdCgpOiBQcm9taXNlPHZvaWQ+IHtcbiAgICB0cnkge1xuICAgICAgaWYgKHRoaXMuYXJnc1snLS1oZWxwJ10pIHtcbiAgICAgICAgY29uc29sZS5sb2coaGVscE1lc3NhZ2UoKSlcb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YgKCF0aGlzLmFyZ3NbJy0tZHJ5LXJ1biddKSB7XG4gICAgICAgICAgYXdhaXQgY3JlYXRlUHJvamVjdCh7XG4gICAgICAgICAgICBjbGlBcmdzOiB0aGlzLmFyZ3MsXG4gICAgICAgICAgICBkYkRldGFpbHMsXG4gICAgICAgICAgICBwYWNrYWdlTWFuYWdlcixcbiAgICAgICAgICAgIHByb2plY3REaXIsXG4gICAgICAgICAgICBwcm9qZWN0TmFtZSxcbiAgICAgICAgICAgIHRlbXBsYXRlLFxuICAgICAgICAgIH0pXG4gICAgICAgICAgYXdhaXQgd3JpdGVFbnZGaWxlKHtcbiAgICAgICAgICAgIGRhdGFiYXNlVXJpOiBkYkRldGFpbHMuZGJVcmksXG4gICAgICAgICAgICBwYXlsb2FkU2VjcmV0LFxuICAgICAgICAgICAgcHJvamVjdERpcixcbiAgICAgICAgICAgIHRlbXBsYXRlLFxuICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICghdGhpcy5hcmdzWyctLWRyeS1ydW4nXSkge1xuICAgICAgICAgIGF3YWl0IGNyZWF0ZVByb2plY3Qoe1xuICAgICAgICAgICAgY2xpQXJnczogdGhpcy5hcmdzLFxuICAgICAgICAgICAgcGFja2FnZU1hbmFnZXIsXG4gICAgICAgICAgICBwcm9qZWN0RGlyLFxuICAgICAgICAgICAgcHJvamVjdE5hbWUsXG4gICAgICAgICAgICB0ZW1wbGF0ZSxcbiAgICAgICAgICB9KVxuICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIHN1Y2Nlc3MoJ1BheWxvYWQgcHJvamVjdCBzdWNjZXNzZnVsbHkgY3JlYXRlZCcpXG4gICAgICBjb25zb2xlLmxvZyhzdWNjZXNzTWVzc2FnZShwcm9qZWN0RGlyLCBwYWNrYWdlTWFuYWdlcikpXG4gICAgfSBjYXRjaCAoZXJyb3I6IHVua25vd24pIHtcbiAgICAgIGNvbnNvbGUubG9nKGVycm9yKVxuIC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FPLElBQUksTUFBTWUsSUFBQUEsc0JBQWEsRUFBQyxTQUFTO2dCQUN0Q2YsaUJBQWlCO1lBQ25CO1FBQ0YsRUFBRSxPQUFPYyxPQUFnQjtZQUN2QmQsaUJBQWlCO1FBQ25CO0lBQ0Y7SUFDQSxPQUFPQTtBQUNUIn0=
250
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/main.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\nimport arg from 'arg'\nimport chalk from 'chalk'\n// @ts-expect-error no types\nimport { detect } from 'detect-package-manager'\nimport figures from 'figures'\nimport path from 'path'\n\nimport type { CliArgs, PackageManager } from './types.js'\n\nimport { configurePayloadConfig } from './lib/configure-payload-config.js'\nimport { createProject } from './lib/create-project.js'\nimport { generateSecret } from './lib/generate-secret.js'\nimport { getNextAppDetails, initNext } from './lib/init-next.js'\nimport { parseProjectName } from './lib/parse-project-name.js'\nimport { parseTemplate } from './lib/parse-template.js'\nimport { selectDb } from './lib/select-db.js'\nimport { getValidTemplates, validateTemplate } from './lib/templates.js'\nimport { writeEnvFile } from './lib/write-env-file.js'\nimport { error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successMessage,\n successfulNextInit,\n} from './utils/messages.js'\n\nexport class Main {\n args: CliArgs\n\n constructor() {\n // @ts-expect-error bad typings\n this.args = arg(\n {\n '--db': String,\n '--db-accept-recommended': Boolean,\n '--db-connection-string': String,\n '--help': Boolean,\n '--local-template': String,\n '--name': String,\n '--secret': String,\n '--template': String,\n '--template-branch': String,\n\n // Next.js\n '--init-next': Boolean, // TODO: Is this needed if we detect if inside Next.js project?\n\n // Package manager\n '--no-deps': Boolean,\n '--use-npm': Boolean,\n '--use-pnpm': Boolean,\n '--use-yarn': Boolean,\n\n // Flags\n '--beta': Boolean,\n '--debug': Boolean,\n '--dry-run': Boolean,\n\n // Aliases\n '-d': '--db',\n '-h': '--help',\n '-n': '--name',\n '-t': '--template',\n },\n { permissive: true },\n )\n }\n\n async init(): Promise<void> {\n try {\n if (this.args['--help']) {\n helpMessage()\n process.exit(0)\n }\n\n // eslint-disable-next-line no-console\n console.log('\\n')\n p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')))\n p.note(\"Welcome to Payload. Let's create a project!\")\n\n // Detect if inside Next.js project\n const nextAppDetails = await getNextAppDetails(process.cwd())\n const { hasTopLevelLayout, nextAppDir, nextConfigPath } = nextAppDetails\n\n if (nextConfigPath) {\n this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath)))\n }\n\n const projectName = await parseProjectName(this.args)\n const projectDir = nextConfigPath\n ? path.dirname(nextConfigPath)\n : path.resolve(process.cwd(), slugify(projectName))\n\n const packageManager = await getPackageManager(this.args, projectDir)\n\n if (nextConfigPath) {\n p.log.step(\n chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`),\n )\n\n const proceed = await p.confirm({\n initialValue: true,\n message: chalk.bold(`Install ${chalk.green('Payload')} in this project?`),\n })\n if (p.isCancel(proceed) || !proceed) {\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Check for top-level layout.tsx\n if (nextAppDir && hasTopLevelLayout) {\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const dbDetails = await selectDb(this.args, projectName)\n\n const result = await initNext({\n ...this.args,\n dbType: dbDetails.type,\n nextAppDetails,\n packageManager,\n projectDir,\n })\n\n if (result.success === false) {\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n await configurePayloadConfig({\n dbDetails,\n projectDirOrConfigPath: {\n payloadConfigPath: result.payloadConfigPath,\n },\n })\n\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret: generateSecret(),\n projectDir,\n })\n\n info('Payload project successfully initialized!')\n p.note(successfulNextInit(), chalk.bgGreen(chalk.black(' Documentation ')))\n p.outro(feedbackOutro())\n return\n }\n\n const templateArg = this.args['--template']\n if (templateArg) {\n const valid = validateTemplate(templateArg)\n if (!valid) {\n helpMessage()\n process.exit(1)\n }\n }\n\n const validTemplates = getValidTemplates()\n const template = await parseTemplate(this.args, validTemplates)\n if (!template) {\n p.log.error('Invalid template given')\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n switch (template.type) {\n case 'starter': {\n const dbDetails = await selectDb(this.args, projectName)\n const payloadSecret = generateSecret()\n await createProject({\n cliArgs: this.args,\n dbDetails,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret,\n projectDir,\n template,\n })\n break\n }\n case 'plugin': {\n await createProject({\n cliArgs: this.args,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n break\n }\n }\n\n info('Payload project successfully created!')\n p.note(successMessage(projectDir, packageManager), chalk.bgGreen(chalk.black(' Next Steps ')))\n p.outro(feedbackOutro())\n } catch (err: unknown) {\n error(err instanceof Error ? err.message : 'An error occurred')\n }\n }\n}\n\nasync function getPackageManager(args: CliArgs, projectDir: string): Promise<PackageManager> {\n let packageManager: PackageManager = 'npm'\n\n if (args['--use-npm']) {\n packageManager = 'npm'\n } else if (args['--use-yarn']) {\n packageManager = 'yarn'\n } else if (args['--use-pnpm']) {\n packageManager = 'pnpm'\n } else {\n const detected = await detect({ cwd: projectDir })\n packageManager = detected || 'npm'\n }\n return packageManager\n}\n"],"names":["Main","args","constructor","arg","String","Boolean","permissive","init","helpMessage","process","exit","console","log","p","intro","chalk","bgCyan","black","note","nextAppDetails","getNextAppDetails","cwd","hasTopLevelLayout","nextAppDir","nextConfigPath","slugify","path","basename","dirname","projectName","parseProjectName","projectDir","resolve","packageManager","getPackageManager","step","bold","bgBlack","figures","triangleUp","proceed","confirm","initialValue","message","green","isCancel","outro","feedbackOutro","warn","moveMessage","dbDetails","selectDb","result","initNext","dbType","type","success","configurePayloadConfig","projectDirOrConfigPath","payloadConfigPath","writeEnvFile","cliArgs","databaseUri","dbUri","payloadSecret","generateSecret","info","successfulNextInit","bgGreen","templateArg","valid","validateTemplate","validTemplates","getValidTemplates","template","parseTemplate","error","createProject","successMessage","err","Error","detected","detect"],"mappings":";;;;+BA6BaA;;;eAAAA;;;iEA7BM;gEACC;4DACJ;8DACE;sCAEK;gEACH;6DACH;wCAIsB;+BACT;gCACC;0BACa;kCACX;+BACH;0BACL;2BAC2B;8BACvB;qBACD;0BAOrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAMA;IACXC,KAAa;IAEbC,aAAc;QACZ,+BAA+B;QAC/B,IAAI,CAACD,IAAI,GAAGE,IAAAA,YAAG,EACb;YACE,QAAQC;YACR,2BAA2BC;YAC3B,0BAA0BD;YAC1B,UAAUC;YACV,oBAAoBD;YACpB,UAAUA;YACV,YAAYA;YACZ,cAAcA;YACd,qBAAqBA;YAErB,UAAU;YACV,eAAeC;YAEf,kBAAkB;YAClB,aAAaA;YACb,aAAaA;YACb,cAAcA;YACd,cAAcA;YAEd,QAAQ;YACR,UAAUA;YACV,WAAWA;YACX,aAAaA;YAEb,UAAU;YACV,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;QACR,GACA;YAAEC,YAAY;QAAK;IAEvB;IAEA,MAAMC,OAAsB;QAC1B,IAAI;YACF,IAAI,IAAI,CAACN,IAAI,CAAC,SAAS,EAAE;gBACvBO,IAAAA,qBAAW;gBACXC,QAAQC,IAAI,CAAC;YACf;YAEA,sCAAsC;YACtCC,QAAQC,GAAG,CAAC;YACZC,SAAEC,KAAK,CAACC,cAAK,CAACC,MAAM,CAACD,cAAK,CAACE,KAAK,CAAC;YACjCJ,SAAEK,IAAI,CAAC;YAEP,mCAAmC;YACnC,MAAMC,iBAAiB,MAAMC,IAAAA,2BAAiB,EAACX,QAAQY,GAAG;YAC1D,MAAM,EAAEC,iBAAiB,EAAEC,UAAU,EAAEC,cAAc,EAAE,G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ack-template-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pack-template-files.d.ts","sourceRoot":"","sources":["../../src/scripts/pack-template-files.ts"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
6
+ const _promises = /*#__PURE__*/ _interop_require_default(require("fs/promises"));
7
+ const _nodeurl = require("node:url");
8
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
9
+ function _interop_require_default(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
14
+ const filename = (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString());
15
+ const dirname = _path.default.dirname(filename);
16
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
17
+ main();
18
+ /**
19
+ * Copy the necessary template files from `templates/blank-3.0` to `dist/template`
20
+ *
21
+ * Eventually, this should be replaced with using tar.x to stream from the git repo
22
+ */ async function main() {
23
+ const root = _path.default.resolve(dirname, '../../../../');
24
+ const outputPath = _path.default.resolve(dirname, '../../dist/template');
25
+ const sourceTemplatePath = _path.default.resolve(root, 'templates/blank-3.0');
26
+ if (!_fs.default.existsSync(sourceTemplatePath)) {
27
+ throw new Error(`Source path does not exist: ${sourceTemplatePath}`);
28
+ }
29
+ if (!_fs.default.existsSync(outputPath)) {
30
+ _fs.default.mkdirSync(outputPath, {
31
+ recursive: true
32
+ });
33
+ }
34
+ // Copy the src directory from `templates/blank-3.0` to `dist`
35
+ const srcPath = _path.default.resolve(sourceTemplatePath, 'src');
36
+ const distSrcPath = _path.default.resolve(outputPath, 'src');
37
+ // Copy entire file structure from src to dist
38
+ await _promises.default.cp(srcPath, distSrcPath, {
39
+ recursive: true
40
+ });
41
+ }
42
+
43
+ //# sourceMappingURL=pack-template-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/scripts/pack-template-files.ts"],"sourcesContent":["import fs from 'fs'\nimport fsp from 'fs/promises'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\n// eslint-disable-next-line @typescript-eslint/no-floating-promises\nmain()\n\n/**\n * Copy the necessary template files from `templates/blank-3.0` to `dist/template`\n *\n * Eventually, this should be replaced with using tar.x to stream from the git repo\n */\n\nasync function main() {\n const root = path.resolve(dirname, '../../../../')\n const outputPath = path.resolve(dirname, '../../dist/template')\n const sourceTemplatePath = path.resolve(root, 'templates/blank-3.0')\n\n if (!fs.existsSync(sourceTemplatePath)) {\n throw new Error(`Source path does not exist: ${sourceTemplatePath}`)\n }\n\n if (!fs.existsSync(outputPath)) {\n fs.mkdirSync(outputPath, { recursive: true })\n }\n\n // Copy the src directory from `templates/blank-3.0` to `dist`\n const srcPath = path.resolve(sourceTemplatePath, 'src')\n const distSrcPath = path.resolve(outputPath, 'src')\n // Copy entire file structure from src to dist\n await fsp.cp(srcPath, distSrcPath, { recursive: true })\n}\n"],"names":["filename","fileURLToPath","dirname","path","main","root","resolve","outputPath","sourceTemplatePath","fs","existsSync","Error","mkdirSync","recursive","srcPath","distSrcPath","fsp","cp"],"mappings":";;;;2DAAe;iEACC;yBACc;6DACb;;;;;;AACjB,MAAMA,WAAWC,IAAAA,sBAAa,EAAC;AAC/B,MAAMC,UAAUC,aAAI,CAACD,OAAO,CAACF;AAE7B,mEAAmE;AACnEI;AAEA;;;;CAIC,GAED,eAAeA;IACb,MAAMC,OAAOF,aAAI,CAACG,OAAO,CAACJ,SAAS;IACnC,MAAMK,aAAaJ,aAAI,CAACG,OAAO,CAACJ,SAAS;IACzC,MAAMM,qBAAqBL,aAAI,CAACG,OAAO,CAACD,MAAM;IAE9C,IAAI,CAACI,WAAE,CAACC,UAAU,CAACF,qBAAqB;QACtC,MAAM,IAAIG,MAAM,CAAC,4BAA4B,EAAEH,mBAAmB,CAAC;IACrE;IAEA,IAAI,CAACC,WAAE,CAACC,UAAU,CAACH,aAAa;QAC9BE,WAAE,CAACG,SAAS,CAACL,YAAY;YAAEM,WAAW;QAAK;IAC7C;IAEA,8DAA8D;IAC9D,MAAMC,UAAUX,aAAI,CAACG,OAAO,CAACE,oBAAoB;IACjD,MAAMO,cAAcZ,aAAI,CAACG,OAAO,CAACC,YAAY;IAC7C,8CAA8C;IAC9C,MAAMS,iBAAG,CAACC,EAAE,CAACH,SAASC,aAAa;QAAEF,WAAW;IAAK;AACvD"}
@@ -0,0 +1,17 @@
1
+ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
+ import config from '@payload-config'
3
+ /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
4
+ import { RootPage } from '@payloadcms/next/views'
5
+
6
+ type Args = {
7
+ params: {
8
+ segments: string[]
9
+ }
10
+ searchParams: {
11
+ [key: string]: string | string[]
12
+ }
13
+ }
14
+
15
+ const Page = ({ params, searchParams }: Args) => RootPage({ config, params, searchParams })
16
+
17
+ export default Page
@@ -0,0 +1,9 @@
1
+ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
+ /* DO NOT MODIFY it because it could be re-written at any time. */
3
+ import config from '@payload-config'
4
+ import { REST_DELETE, REST_GET, REST_PATCH, REST_POST } from '@payloadcms/next/routes'
5
+
6
+ export const GET = REST_GET(config)
7
+ export const POST = REST_POST(config)
8
+ export const DELETE = REST_DELETE(config)
9
+ export const PATCH = REST_PATCH(config)
@@ -0,0 +1,6 @@
1
+ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
+ /* DO NOT MODIFY it because it could be re-written at any time. */
3
+ import config from '@payload-config'
4
+ import { GRAPHQL_POST } from '@payloadcms/next/routes'
5
+
6
+ export const POST = GRAPHQL_POST(config)
@@ -0,0 +1,6 @@
1
+ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
+ /* DO NOT MODIFY it because it could be re-written at any time. */
3
+ import config from '@payload-config'
4
+ import { GRAPHQL_PLAYGROUND_GET } from '@payloadcms/next/routes'
5
+
6
+ export const GET = GRAPHQL_PLAYGROUND_GET(config)
File without changes
@@ -0,0 +1,16 @@
1
+ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
+ import configPromise from '@payload-config'
3
+ import '@payloadcms/next/css'
4
+ import { RootLayout } from '@payloadcms/next/layouts'
5
+ /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
6
+ import React from 'react'
7
+
8
+ import './custom.scss'
9
+
10
+ type Args = {
11
+ children: React.ReactNode
12
+ }
13
+
14
+ const Layout = ({ children }: Args) => <RootLayout config={configPromise}>{children}</RootLayout>
15
+
16
+ export default Layout
@@ -0,0 +1,14 @@
1
+ import configPromise from '@payload-config'
2
+ import { getPayload } from 'payload'
3
+
4
+ export const GET = async () => {
5
+ const payload = await getPayload({
6
+ config: configPromise,
7
+ })
8
+
9
+ const data = await payload.find({
10
+ collection: 'users',
11
+ })
12
+
13
+ return Response.json(data)
14
+ }
@@ -0,0 +1,13 @@
1
+ import type { CollectionConfig } from 'payload/types'
2
+
3
+ export const Users: CollectionConfig = {
4
+ slug: 'users',
5
+ admin: {
6
+ useAsTitle: 'email',
7
+ },
8
+ auth: true,
9
+ fields: [
10
+ // Email added by default
11
+ // Add more fields as needed
12
+ ],
13
+ }
@@ -0,0 +1,38 @@
1
+ import { mongooseAdapter } from '@payloadcms/db-mongodb' // database-adapter-import
2
+ // import { payloadCloud } from '@payloadcms/plugin-cloud'
3
+ import { lexicalEditor } from '@payloadcms/richtext-lexical' // editor-import
4
+ import path from 'path'
5
+ import { buildConfig } from 'payload/config'
6
+ // import sharp from 'sharp'
7
+ import { fileURLToPath } from 'url'
8
+
9
+ import { Users } from './collections/Users'
10
+
11
+ const filename = fileURLToPath(import.meta.url)
12
+ const dirname = path.dirname(filename)
13
+
14
+ export default buildConfig({
15
+ admin: {
16
+ user: Users.slug,
17
+ },
18
+ collections: [Users],
19
+ editor: lexicalEditor({}),
20
+ // plugins: [payloadCloud()], // TODO: Re-enable when cloud supports 3.0
21
+ secret: process.env.PAYLOAD_SECRET || '',
22
+ typescript: {
23
+ outputFile: path.resolve(dirname, 'payload-types.ts'),
24
+ },
25
+ // database-adapter-config-start
26
+ db: mongooseAdapter({
27
+ url: process.env.DATABASE_URI || '',
28
+ }),
29
+ // database-adapter-config-end
30
+ // Sharp is now an optional dependency -
31
+ // if you want to resize images, crop, set focal point, etc.
32
+ // make sure to install it and pass it to the config.
33
+
34
+ // This is temporary - we may make an adapter pattern
35
+ // for this before reaching 3.0 stable
36
+
37
+ // sharp,
38
+ })