create-payload-app 0.3.4 → 0.3.7-beta.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ var log_1 = require("./utils/log");
44
44
  return __generator(this, function (_a) {
45
45
  switch (_a.label) {
46
46
  case 0:
47
- trx = usage_1.init();
47
+ trx = (0, usage_1.init)();
48
48
  main = new main_1.Main();
49
49
  _a.label = 1;
50
50
  case 1:
@@ -55,11 +55,11 @@ var log_1 = require("./utils/log");
55
55
  return [3 /*break*/, 5];
56
56
  case 3:
57
57
  e_1 = _a.sent();
58
- usage_1.handleException(e_1);
59
- log_1.error("An error has occurred: " + (e_1 && e_1.message));
58
+ (0, usage_1.handleException)(e_1);
59
+ (0, log_1.error)("An error has occurred: ".concat(e_1 instanceof Error ? e_1.message : e_1));
60
60
  return [3 /*break*/, 5];
61
61
  case 4:
62
- trx.finish();
62
+ trx === null || trx === void 0 ? void 0 : trx.finish();
63
63
  return [7 /*endfinally*/];
64
64
  case 5: return [2 /*return*/];
65
65
  }
@@ -57,7 +57,7 @@ function createProjectDir(projectDir) {
57
57
  case 1:
58
58
  pathExists = _a.sent();
59
59
  if (pathExists) {
60
- log_1.error("The project directory '" + projectDir + "' already exists");
60
+ (0, log_1.error)("The project directory '".concat(projectDir, "' already exists"));
61
61
  process.exit(1);
62
62
  }
63
63
  return [4 /*yield*/, fs_extra_1.default.mkdir(projectDir)];
@@ -106,12 +106,12 @@ function getLatestPayloadVersion(betaFlag) {
106
106
  packageWithTag = 'payload';
107
107
  if (betaFlag)
108
108
  packageWithTag += '@beta';
109
- return [4 /*yield*/, execa_1.default("npm info " + packageWithTag + " version", [], {
109
+ return [4 /*yield*/, (0, execa_1.default)("npm info ".concat(packageWithTag, " version"), [], {
110
110
  shell: true,
111
111
  })];
112
112
  case 1:
113
113
  stdout = (_a.sent()).stdout;
114
- return [2 /*return*/, "^" + stdout];
114
+ return [2 /*return*/, "^".concat(stdout)];
115
115
  case 2:
116
116
  error_2 = _a.sent();
117
117
  return [2 /*return*/, false];
@@ -131,10 +131,10 @@ function updatePayloadVersion(projectDir, betaFlag) {
131
131
  case 1:
132
132
  payloadVersion = _a.sent();
133
133
  if (!payloadVersion) {
134
- log_1.warning('Error retrieving latest Payload version. Please update your package.json manually.');
134
+ (0, log_1.warning)('Error retrieving latest Payload version. Please update your package.json manually.');
135
135
  return [2 /*return*/];
136
136
  }
137
- usage_1.setTags({ payload_version: payloadVersion });
137
+ (0, usage_1.setTags)({ payload_version: payloadVersion });
138
138
  packageJsonPath = path_1.default.resolve(projectDir, 'package.json');
139
139
  _a.label = 2;
140
140
  case 2:
@@ -149,7 +149,7 @@ function updatePayloadVersion(projectDir, betaFlag) {
149
149
  return [3 /*break*/, 6];
150
150
  case 5:
151
151
  err_1 = _a.sent();
152
- log_1.warning('Unable to write Payload version to package.json. Please update your package.json manually.');
152
+ (0, log_1.warning)('Unable to write Payload version to package.json. Please update your package.json manually.');
153
153
  return [3 /*break*/, 6];
154
154
  case 6: return [2 /*return*/];
155
155
  }
@@ -165,10 +165,10 @@ function createProject(args, projectDir, template, packageManager) {
165
165
  case 0: return [4 /*yield*/, createProjectDir(projectDir)];
166
166
  case 1:
167
167
  _a.sent();
168
- templateDir = path_1.default.resolve(__dirname, "../templates/" + template.name);
169
- console.log("\n Creating a new Payload app in " + chalk_1.default.green(path_1.default.resolve(projectDir)) + "\n");
168
+ templateDir = path_1.default.resolve(__dirname, "../templates/".concat(template.name));
169
+ console.log("\n Creating a new Payload app in ".concat(chalk_1.default.green(path_1.default.resolve(projectDir)), "\n"));
170
170
  if (!(template.type === 'starter')) return [3 /*break*/, 3];
171
- emitter = degit_1.default(template.url);
171
+ emitter = (0, degit_1.default)(template.url);
172
172
  return [4 /*yield*/, emitter.clone(projectDir)];
173
173
  case 2:
174
174
  _a.sent();
@@ -178,16 +178,16 @@ function createProject(args, projectDir, template, packageManager) {
178
178
  return [4 /*yield*/, fs_extra_1.default.copy(templateDir, projectDir, { recursive: true })];
179
179
  case 4:
180
180
  _a.sent();
181
- log_1.success('Project directory created');
181
+ (0, log_1.success)('Project directory created');
182
182
  return [3 /*break*/, 6];
183
183
  case 5:
184
184
  err_2 = _a.sent();
185
185
  msg = 'Unable to copy template files. Please check template name or directory permissions.';
186
- log_1.error(msg);
186
+ (0, log_1.error)(msg);
187
187
  process.exit(1);
188
188
  return [3 /*break*/, 6];
189
189
  case 6:
190
- spinner = ora_1.default('Checking latest Payload version...').start();
190
+ spinner = (0, ora_1.default)('Checking latest Payload version...').start();
191
191
  return [4 /*yield*/, updatePayloadVersion(projectDir, args['--beta'])];
192
192
  case 7:
193
193
  _a.sent();
@@ -198,10 +198,10 @@ function createProject(args, projectDir, template, packageManager) {
198
198
  spinner.stop();
199
199
  spinner.clear();
200
200
  if (result) {
201
- log_1.success('Dependencies installed');
201
+ (0, log_1.success)('Dependencies installed');
202
202
  }
203
203
  else {
204
- log_1.error('Error installing dependencies');
204
+ (0, log_1.error)('Error installing dependencies');
205
205
  }
206
206
  return [2 /*return*/];
207
207
  }
@@ -46,10 +46,16 @@ describe('createProject', function () {
46
46
  var projectDir = path_1.default.resolve(__dirname, './tmp');
47
47
  beforeAll(function () {
48
48
  console.log = jest.fn();
49
- fs_extra_1.default.rmdirSync(projectDir, { recursive: true });
49
+ });
50
+ beforeEach(function () {
51
+ if (fs_extra_1.default.existsSync(projectDir)) {
52
+ fs_extra_1.default.rmdirSync(projectDir, { recursive: true });
53
+ }
50
54
  });
51
55
  afterEach(function () {
52
- fs_extra_1.default.rmdirSync(projectDir, { recursive: true });
56
+ if (fs_extra_1.default.existsSync(projectDir)) {
57
+ fs_extra_1.default.rmdirSync(projectDir, { recursive: true });
58
+ }
53
59
  });
54
60
  describe('#createProject', function () {
55
61
  var args = { _: ['project-name'], '--no-deps': true };
@@ -58,11 +64,11 @@ describe('createProject', function () {
58
64
  var expectedPayloadVersion, template, packageJsonPath, packageJson;
59
65
  return __generator(this, function (_a) {
60
66
  switch (_a.label) {
61
- case 0: return [4 /*yield*/, createProject_1.getLatestPayloadVersion()];
67
+ case 0: return [4 /*yield*/, (0, createProject_1.getLatestPayloadVersion)()];
62
68
  case 1:
63
69
  expectedPayloadVersion = _a.sent();
64
70
  template = { name: 'ts-todo', type: 'static' };
65
- return [4 /*yield*/, createProject_1.createProject(args, projectDir, template, packageManager)];
71
+ return [4 /*yield*/, (0, createProject_1.createProject)(args, projectDir, template, packageManager)];
66
72
  case 2:
67
73
  _a.sent();
68
74
  packageJsonPath = path_1.default.resolve(projectDir, 'package.json');
@@ -86,7 +92,7 @@ describe('createProject', function () {
86
92
  return [4 /*yield*/, fs_extra_1.default.writeJson(packageJsonPath, { dependencies: { payload: '0.0.1' } }, { spaces: 2 })];
87
93
  case 2:
88
94
  _a.sent();
89
- return [4 /*yield*/, createProject_1.updatePayloadVersion(projectDir)];
95
+ return [4 /*yield*/, (0, createProject_1.updatePayloadVersion)(projectDir)];
90
96
  case 3:
91
97
  _a.sent();
92
98
  return [4 /*yield*/, fs_extra_1.default.readJson(packageJsonPath)];
@@ -50,11 +50,11 @@ function getDatabaseConnection(args, projectName) {
50
50
  case 0:
51
51
  if (args['--db'])
52
52
  return [2 /*return*/, args['--db']];
53
- return [4 /*yield*/, prompts_1.default({
53
+ return [4 /*yield*/, (0, prompts_1.default)({
54
54
  type: 'text',
55
55
  name: 'value',
56
56
  message: 'Enter MongoDB connection',
57
- initial: "mongodb://localhost/" + slugify_1.default(projectName),
57
+ initial: "mongodb://localhost/".concat((0, slugify_1.default)(projectName)),
58
58
  validate: function (value) { return value.length; },
59
59
  }, {
60
60
  onCancel: function () {
@@ -49,7 +49,7 @@ function getPayloadSecret(args) {
49
49
  case 0:
50
50
  if (args['--secret'])
51
51
  return [2 /*return*/, args['--secret']];
52
- return [4 /*yield*/, prompts_1.default({
52
+ return [4 /*yield*/, (0, prompts_1.default)({
53
53
  type: 'password',
54
54
  name: 'value',
55
55
  message: 'Enter a long, complex string for Payload’s encryption key',
@@ -49,7 +49,7 @@ function parseLanguage(args) {
49
49
  case 0:
50
50
  if (args['--template'])
51
51
  return [2 /*return*/, args['--template']];
52
- return [4 /*yield*/, prompts_1.default({
52
+ return [4 /*yield*/, (0, prompts_1.default)({
53
53
  type: 'select',
54
54
  name: 'value',
55
55
  message: 'Choose language',
@@ -51,7 +51,7 @@ function parseProjectName(args) {
51
51
  return [2 /*return*/, args['--name']];
52
52
  if (args._[0])
53
53
  return [2 /*return*/, args._[0]];
54
- return [4 /*yield*/, prompts_1.default({
54
+ return [4 /*yield*/, (0, prompts_1.default)({
55
55
  type: 'text',
56
56
  name: 'value',
57
57
  message: 'Project name?',
@@ -53,18 +53,18 @@ function parseTemplate(args, validTemplates, language) {
53
53
  template_1 = validTemplates.find(function (template) { return template.name === templateName_1; });
54
54
  if (!template_1)
55
55
  throw new Error('Invalid template given');
56
- usage_1.setTags({ template: template_1.name });
56
+ (0, usage_1.setTags)({ template: template_1.name });
57
57
  return [2 /*return*/, template_1];
58
58
  }
59
59
  filteredTemplates = validTemplates
60
60
  .filter(function (d) { return d.name.startsWith(language); })
61
- .map(function (t) { return t.name.replace(language + "-", ''); });
62
- return [4 /*yield*/, prompts_1.default({
61
+ .map(function (t) { return t.name.replace("".concat(language, "-"), ''); });
62
+ return [4 /*yield*/, (0, prompts_1.default)({
63
63
  type: 'select',
64
64
  name: 'value',
65
65
  message: 'Choose project template',
66
66
  choices: filteredTemplates.map(function (p) {
67
- return { title: p, value: language + "-" + p };
67
+ return { title: p, value: "".concat(language, "-").concat(p) };
68
68
  }),
69
69
  validate: function (value) { return value.length; },
70
70
  }, {
@@ -79,7 +79,7 @@ function parseTemplate(args, validTemplates, language) {
79
79
  template = validTemplates.find(function (t) { return t.name === response.value; });
80
80
  if (!template)
81
81
  throw new Error('Template is undefined');
82
- usage_1.setTags({ template: template.name });
82
+ (0, usage_1.setTags)({ template: template.name });
83
83
  return [2 /*return*/, template];
84
84
  }
85
85
  });
@@ -52,8 +52,8 @@ function validateTemplate(templateName) {
52
52
  case 1:
53
53
  validTemplates = _a.sent();
54
54
  if (!validTemplates.map(function (t) { return t.name; }).includes(templateName)) {
55
- log_1.error("'" + templateName + "' is not a valid template.");
56
- log_1.info("Valid templates: " + validTemplates.join(', '));
55
+ (0, log_1.error)("'".concat(templateName, "' is not a valid template."));
56
+ (0, log_1.info)("Valid templates: ".concat(validTemplates.join(', ')));
57
57
  return [2 /*return*/, false];
58
58
  }
59
59
  return [2 /*return*/, true];
@@ -49,20 +49,22 @@ function writeEnvFile(projectName, databaseUri, payloadSecret) {
49
49
  return __generator(this, function (_a) {
50
50
  switch (_a.label) {
51
51
  case 0:
52
- content = "MONGODB_URI=" + databaseUri + "\nPAYLOAD_SECRET=" + payloadSecret;
52
+ content = "MONGODB_URI=".concat(databaseUri, "\nPAYLOAD_SECRET=").concat(payloadSecret);
53
53
  _a.label = 1;
54
54
  case 1:
55
55
  _a.trys.push([1, 3, , 4]);
56
- projectDir = "./" + slugify_1.default(projectName);
57
- return [4 /*yield*/, fs_extra_1.default.outputFile(projectDir + "/.env", content)];
56
+ projectDir = "./".concat((0, slugify_1.default)(projectName));
57
+ return [4 /*yield*/, fs_extra_1.default.outputFile("".concat(projectDir, "/.env"), content)];
58
58
  case 2:
59
59
  _a.sent();
60
- log_1.success('.env file created');
60
+ (0, log_1.success)('.env file created');
61
61
  return [3 /*break*/, 4];
62
62
  case 3:
63
63
  err_1 = _a.sent();
64
- log_1.error('Unable to write .env file');
65
- log_1.error(err_1);
64
+ (0, log_1.error)('Unable to write .env file');
65
+ if (err_1 instanceof Error) {
66
+ (0, log_1.error)(err_1.message);
67
+ }
66
68
  process.exit(1);
67
69
  return [3 /*break*/, 4];
68
70
  case 4: return [2 /*return*/];
package/dist/main.js CHANGED
@@ -56,7 +56,7 @@ var messages_1 = require("./utils/messages");
56
56
  var usage_1 = require("./utils/usage");
57
57
  var Main = /** @class */ (function () {
58
58
  function Main() {
59
- this.args = arg_1.default({
59
+ this.args = (0, arg_1.default)({
60
60
  '--help': Boolean,
61
61
  '--name': String,
62
62
  '--template': String,
@@ -80,7 +80,7 @@ var Main = /** @class */ (function () {
80
80
  _g.trys.push([0, 17, , 18]);
81
81
  if (!this.args['--help']) return [3 /*break*/, 2];
82
82
  _b = (_a = console).log;
83
- return [4 /*yield*/, messages_1.helpMessage()];
83
+ return [4 /*yield*/, (0, messages_1.helpMessage)()];
84
84
  case 1:
85
85
  _b.apply(_a, [_g.sent()]);
86
86
  process.exit(0);
@@ -88,52 +88,52 @@ var Main = /** @class */ (function () {
88
88
  case 2:
89
89
  templateArg = this.args['--template'];
90
90
  if (!templateArg) return [3 /*break*/, 5];
91
- return [4 /*yield*/, templates_1.validateTemplate(templateArg)];
91
+ return [4 /*yield*/, (0, templates_1.validateTemplate)(templateArg)];
92
92
  case 3:
93
93
  valid = _g.sent();
94
94
  if (!!valid) return [3 /*break*/, 5];
95
95
  _d = (_c = console).log;
96
- return [4 /*yield*/, messages_1.helpMessage()];
96
+ return [4 /*yield*/, (0, messages_1.helpMessage)()];
97
97
  case 4:
98
98
  _d.apply(_c, [_g.sent()]);
99
99
  process.exit(1);
100
100
  _g.label = 5;
101
101
  case 5:
102
102
  console.log(messages_1.welcomeMessage);
103
- return [4 /*yield*/, parseProjectName_1.parseProjectName(this.args)];
103
+ return [4 /*yield*/, (0, parseProjectName_1.parseProjectName)(this.args)];
104
104
  case 6:
105
105
  projectName = _g.sent();
106
- return [4 /*yield*/, parseLanguage_1.parseLanguage(this.args)];
106
+ return [4 /*yield*/, (0, parseLanguage_1.parseLanguage)(this.args)];
107
107
  case 7:
108
108
  language = _g.sent();
109
- return [4 /*yield*/, templates_1.getValidTemplates()];
109
+ return [4 /*yield*/, (0, templates_1.getValidTemplates)()];
110
110
  case 8:
111
111
  validTemplates = _g.sent();
112
- return [4 /*yield*/, parseTemplate_1.parseTemplate(this.args, validTemplates, language)];
112
+ return [4 /*yield*/, (0, parseTemplate_1.parseTemplate)(this.args, validTemplates, language)];
113
113
  case 9:
114
114
  template = _g.sent();
115
- return [4 /*yield*/, getDatabaseConnection_1.getDatabaseConnection(this.args, projectName)];
115
+ return [4 /*yield*/, (0, getDatabaseConnection_1.getDatabaseConnection)(this.args, projectName)];
116
116
  case 10:
117
117
  databaseUri = _g.sent();
118
- return [4 /*yield*/, getPayloadSecret_1.getPayloadSecret(this.args)];
118
+ return [4 /*yield*/, (0, getPayloadSecret_1.getPayloadSecret)(this.args)];
119
119
  case 11:
120
120
  payloadSecret = _g.sent();
121
- projectDir = "./" + slugify_1.default(projectName);
121
+ projectDir = "./".concat((0, slugify_1.default)(projectName));
122
122
  return [4 /*yield*/, getPackageManager(this.args)];
123
123
  case 12:
124
124
  packageManager = _g.sent();
125
125
  if (!!this.args['--dry-run']) return [3 /*break*/, 15];
126
- return [4 /*yield*/, createProject_1.createProject(this.args, projectDir, template, packageManager)];
126
+ return [4 /*yield*/, (0, createProject_1.createProject)(this.args, projectDir, template, packageManager)];
127
127
  case 13:
128
128
  _g.sent();
129
- return [4 /*yield*/, writeEnvFile_1.writeEnvFile(projectName, databaseUri, payloadSecret)];
129
+ return [4 /*yield*/, (0, writeEnvFile_1.writeEnvFile)(projectName, databaseUri, payloadSecret)];
130
130
  case 14:
131
131
  _g.sent();
132
132
  _g.label = 15;
133
133
  case 15:
134
- log_1.success('Payload project successfully created');
134
+ (0, log_1.success)('Payload project successfully created');
135
135
  _f = (_e = console).log;
136
- return [4 /*yield*/, messages_1.successMessage(projectDir, packageManager)];
136
+ return [4 /*yield*/, (0, messages_1.successMessage)(projectDir, packageManager)];
137
137
  case 16:
138
138
  _f.apply(_e, [_g.sent()]);
139
139
  return [3 /*break*/, 18];
@@ -160,7 +160,7 @@ function getPackageManager(args) {
160
160
  return [3 /*break*/, 4];
161
161
  case 1:
162
162
  _a.trys.push([1, 3, , 4]);
163
- return [4 /*yield*/, command_exists_1.default('yarn')];
163
+ return [4 /*yield*/, (0, command_exists_1.default)('yarn')];
164
164
  case 2:
165
165
  _a.sent();
166
166
  packageManager = 'yarn';
@@ -170,7 +170,7 @@ function getPackageManager(args) {
170
170
  packageManager = 'npm';
171
171
  return [3 /*break*/, 4];
172
172
  case 4:
173
- usage_1.setTags({ package_manager: packageManager });
173
+ (0, usage_1.setTags)({ package_manager: packageManager });
174
174
  return [2 /*return*/, packageManager];
175
175
  }
176
176
  });
@@ -13,6 +13,10 @@ app.get('/', (_, res) => {
13
13
  payload.init({
14
14
  secret: process.env.PAYLOAD_SECRET,
15
15
  mongoURL: process.env.MONGODB_URI,
16
+
17
+ // Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
18
+ // license: process.env.PAYLOAD_LICENSE_KEY,
19
+
16
20
  express: app,
17
21
  onInit: () => {
18
22
  payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
@@ -1,11 +1,3 @@
1
- const onlyNameIfPublic = ({ req: { user }, doc }) => {
2
- // Only return name if not logged in
3
- if (!user) {
4
- return { name: doc.name };
5
- }
6
- return doc;
7
- };
8
-
9
1
  const Users = {
10
2
  slug: 'users',
11
3
  auth: true,
@@ -15,9 +7,6 @@ const Users = {
15
7
  access: {
16
8
  read: () => true,
17
9
  },
18
- hooks: {
19
- beforeRead: [onlyNameIfPublic]
20
- },
21
10
  fields: [
22
11
  // Email added by default
23
12
  {
@@ -13,6 +13,10 @@ app.get('/', (_, res) => {
13
13
  payload.init({
14
14
  secret: process.env.PAYLOAD_SECRET,
15
15
  mongoURL: process.env.MONGODB_URI,
16
+
17
+ // Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
18
+ // license: process.env.PAYLOAD_LICENSE_KEY,
19
+
16
20
  express: app,
17
21
  onInit: () => {
18
22
  payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
@@ -13,6 +13,10 @@ app.get('/', (_, res) => {
13
13
  payload.init({
14
14
  secret: process.env.PAYLOAD_SECRET,
15
15
  mongoURL: process.env.MONGODB_URI,
16
+
17
+ // Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
18
+ // license: process.env.PAYLOAD_LICENSE_KEY,
19
+
16
20
  express: app,
17
21
  onInit: () => {
18
22
  payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
@@ -13,11 +13,15 @@ app.get('/', (_, res) => {
13
13
  payload.init({
14
14
  secret: process.env.PAYLOAD_SECRET,
15
15
  mongoURL: process.env.MONGODB_URI,
16
+
17
+ // Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
18
+ // license: process.env.PAYLOAD_LICENSE_KEY,
19
+
16
20
  express: app,
17
21
  onInit: () => {
18
- payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
22
+ payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
19
23
  },
20
- });
24
+ })
21
25
 
22
26
  // Add your own express routes here
23
27
 
@@ -1,14 +1,5 @@
1
- import { BeforeReadHook } from 'payload/dist/collections/config/types';
2
1
  import { CollectionConfig } from 'payload/types';
3
2
 
4
- const onlyNameIfPublic: BeforeReadHook = ({ req: { user }, doc }) => {
5
- // Only return name if not logged in
6
- if (!user) {
7
- return { name: doc.name };
8
- }
9
- return doc;
10
- };
11
-
12
3
  const Users: CollectionConfig = {
13
4
  slug: 'users',
14
5
  auth: true,
@@ -18,9 +9,6 @@ const Users: CollectionConfig = {
18
9
  access: {
19
10
  read: () => true,
20
11
  },
21
- hooks: {
22
- beforeRead: [onlyNameIfPublic]
23
- },
24
12
  fields: [
25
13
  // Email added by default
26
14
  {
@@ -13,11 +13,15 @@ app.get('/', (_, res) => {
13
13
  payload.init({
14
14
  secret: process.env.PAYLOAD_SECRET,
15
15
  mongoURL: process.env.MONGODB_URI,
16
+
17
+ // Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
18
+ // license: process.env.PAYLOAD_LICENSE_KEY,
19
+
16
20
  express: app,
17
21
  onInit: () => {
18
- payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
22
+ payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
19
23
  },
20
- });
24
+ })
21
25
 
22
26
  // Add your own express routes here
23
27
 
@@ -13,11 +13,15 @@ app.get('/', (_, res) => {
13
13
  payload.init({
14
14
  secret: process.env.PAYLOAD_SECRET,
15
15
  mongoURL: process.env.MONGODB_URI,
16
+
17
+ // Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
18
+ // license: process.env.PAYLOAD_LICENSE_KEY,
19
+
16
20
  express: app,
17
21
  onInit: () => {
18
- payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
22
+ payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
19
23
  },
20
- });
24
+ })
21
25
 
22
26
  // Add your own express routes here
23
27
 
@@ -51,23 +51,23 @@ var templates_1 = require("../lib/templates");
51
51
  var header = function (message) {
52
52
  return chalk_1.default.yellow(figures_1.default.star) + ' ' + chalk_1.default.bold(message);
53
53
  };
54
- exports.welcomeMessage = chalk_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n {green Welcome to Payload. Let's create a project! }\n"], ["\n {green Welcome to Payload. Let's create a project! }\n"])));
54
+ exports.welcomeMessage = (0, chalk_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n {green Welcome to Payload. Let's create a project! }\n"], ["\n {green Welcome to Payload. Let's create a project! }\n"])));
55
55
  function helpMessage() {
56
56
  return __awaiter(this, void 0, void 0, function () {
57
57
  var validTemplates;
58
58
  return __generator(this, function (_a) {
59
59
  switch (_a.label) {
60
- case 0: return [4 /*yield*/, templates_1.getValidTemplates()];
60
+ case 0: return [4 /*yield*/, (0, templates_1.getValidTemplates)()];
61
61
  case 1:
62
62
  validTemplates = _a.sent();
63
- return [2 /*return*/, chalk_1.default(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n {bold USAGE}\n\n {dim $} {bold npx create-payload-app}\n\n {bold OPTIONS}\n\n --name {underline my-payload-app} Set project name\n --template {underline template_name} Choose specific template\n\n {dim Available templates: ", "}\n\n --use-npm Use npm to install dependencies\n --no-deps Do not install any dependencies\n --help Show help\n"], ["\n {bold USAGE}\n\n {dim $} {bold npx create-payload-app}\n\n {bold OPTIONS}\n\n --name {underline my-payload-app} Set project name\n --template {underline template_name} Choose specific template\n\n {dim Available templates: ", "}\n\n --use-npm Use npm to install dependencies\n --no-deps Do not install any dependencies\n --help Show help\n"])), validTemplates.join(', '))];
63
+ return [2 /*return*/, (0, chalk_1.default)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n {bold USAGE}\n\n {dim $} {bold npx create-payload-app}\n\n {bold OPTIONS}\n\n --name {underline my-payload-app} Set project name\n --template {underline template_name} Choose specific template\n\n {dim Available templates: ", "}\n\n --use-npm Use npm to install dependencies\n --no-deps Do not install any dependencies\n --help Show help\n"], ["\n {bold USAGE}\n\n {dim $} {bold npx create-payload-app}\n\n {bold OPTIONS}\n\n --name {underline my-payload-app} Set project name\n --template {underline template_name} Choose specific template\n\n {dim Available templates: ", "}\n\n --use-npm Use npm to install dependencies\n --no-deps Do not install any dependencies\n --help Show help\n"])), validTemplates.map(function (t) { return t.name; }).join(', '))];
64
64
  }
65
65
  });
66
66
  });
67
67
  }
68
68
  exports.helpMessage = helpMessage;
69
69
  function successMessage(projectDir, packageManager) {
70
- return "\n " + header('Launch Application:') + "\n\n - cd " + projectDir + "\n - " + (packageManager === 'yarn' ? 'yarn' : 'npm run') + " dev\n\n " + header('Documentation:') + "\n\n - " + terminal_link_1.default('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload') + "\n - " + terminal_link_1.default('Configuration', 'https://payloadcms.com/docs/configuration/overview') + "\n\n";
70
+ return "\n ".concat(header('Launch Application:'), "\n\n - cd ").concat(projectDir, "\n - ").concat(packageManager === 'yarn' ? 'yarn' : 'npm run', " dev\n\n ").concat(header('Documentation:'), "\n\n - ").concat((0, terminal_link_1.default)('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload'), "\n - ").concat((0, terminal_link_1.default)('Configuration', 'https://payloadcms.com/docs/configuration/overview'), "\n\n");
71
71
  }
72
72
  exports.successMessage = successMessage;
73
73
  var templateObject_1, templateObject_2;
@@ -12,7 +12,11 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
14
  if (k2 === undefined) k2 = k;
15
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
16
20
  }) : (function(o, m, k, k2) {
17
21
  if (k2 === undefined) k2 = k;
18
22
  o[k2] = m[k];
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "bin"
19
19
  ],
20
20
  "dependencies": {
21
- "@sentry/node": "^6.3.3",
21
+ "@sentry/node": "^6.18.2",
22
22
  "@sindresorhus/slugify": "^1.1.0",
23
23
  "arg": "^5.0.0",
24
24
  "chalk": "^4.1.0",
@@ -31,7 +31,7 @@
31
31
  "prompts": "^2.4.0",
32
32
  "terminal-link": "^2.1.1"
33
33
  },
34
- "version": "0.3.4",
34
+ "version": "0.3.7-beta.0",
35
35
  "devDependencies": {
36
36
  "@types/command-exists": "^1.2.0",
37
37
  "@types/degit": "^2.8.3",
@@ -1,130 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- var __generator = (this && this.__generator) || function (thisArg, body) {
31
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
32
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
33
- function verb(n) { return function (v) { return step([n, v]); }; }
34
- function step(op) {
35
- if (f) throw new TypeError("Generator is already executing.");
36
- while (_) try {
37
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
38
- if (y = 0, t) op = [op[0] & 2, t.value];
39
- switch (op[0]) {
40
- case 0: case 1: t = op; break;
41
- case 4: _.label++; return { value: op[1], done: false };
42
- case 5: _.label++; y = op[1]; op = [0]; continue;
43
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
44
- default:
45
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
46
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
47
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
48
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
49
- if (t[2]) _.ops.pop();
50
- _.trys.pop(); continue;
51
- }
52
- op = body.call(thisArg, _);
53
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
54
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
55
- }
56
- };
57
- var __importDefault = (this && this.__importDefault) || function (mod) {
58
- return (mod && mod.__esModule) ? mod : { "default": mod };
59
- };
60
- Object.defineProperty(exports, "__esModule", { value: true });
61
- exports.createProjectFromGitHub = void 0;
62
- var node_fetch_1 = __importDefault(require("node-fetch"));
63
- var path_1 = __importDefault(require("path"));
64
- var fs_extra_1 = __importStar(require("fs-extra"));
65
- var stream_1 = require("stream");
66
- var util_1 = require("util");
67
- var streamPipeline = util_1.promisify(stream_1.pipeline);
68
- function createProjectFromGitHub(sha, remoteFilePath, dest) {
69
- return __awaiter(this, void 0, void 0, function () {
70
- var latestCommitSha, res, tree;
71
- var _this = this;
72
- return __generator(this, function (_a) {
73
- switch (_a.label) {
74
- case 0: return [4 /*yield*/, getLatestCommitSha()];
75
- case 1:
76
- latestCommitSha = _a.sent();
77
- return [4 /*yield*/, node_fetch_1.default("https://api.github.com/repos/payloadcms/payload/git/trees/" + latestCommitSha + "?recursive=1")];
78
- case 2:
79
- res = _a.sent();
80
- return [4 /*yield*/, res.json()];
81
- case 3:
82
- tree = (_a.sent()).tree;
83
- return [4 /*yield*/, Promise.all(tree.map(function (item) { return __awaiter(_this, void 0, void 0, function () {
84
- var destFile, fileDetails, fileContent;
85
- return __generator(this, function (_a) {
86
- switch (_a.label) {
87
- case 0:
88
- console.log(item.path);
89
- if (!(item.type === 'blob' && item.path.startsWith(remoteFilePath))) return [3 /*break*/, 5];
90
- destFile = path_1.default.join(dest, item.path.replace(remoteFilePath, ''));
91
- return [4 /*yield*/, fs_extra_1.default.ensureDir(path_1.default.dirname(destFile))];
92
- case 1:
93
- _a.sent();
94
- return [4 /*yield*/, node_fetch_1.default(item.url)];
95
- case 2: return [4 /*yield*/, (_a.sent()).json()];
96
- case 3:
97
- fileDetails = (_a.sent());
98
- fileContent = Buffer.from(fileDetails.content, 'base64').toString();
99
- return [4 /*yield*/, streamPipeline(fileContent, fs_extra_1.createWriteStream(destFile))];
100
- case 4:
101
- _a.sent();
102
- _a.label = 5;
103
- case 5: return [2 /*return*/];
104
- }
105
- });
106
- }); }))];
107
- case 4:
108
- _a.sent();
109
- return [2 /*return*/];
110
- }
111
- });
112
- });
113
- }
114
- exports.createProjectFromGitHub = createProjectFromGitHub;
115
- function getLatestCommitSha() {
116
- return __awaiter(this, void 0, void 0, function () {
117
- var res, commits;
118
- return __generator(this, function (_a) {
119
- switch (_a.label) {
120
- case 0: return [4 /*yield*/, node_fetch_1.default("https://api.github.com/repos/payloadcms/payload/commits")];
121
- case 1:
122
- res = _a.sent();
123
- return [4 /*yield*/, res.json()];
124
- case 2:
125
- commits = _a.sent();
126
- return [2 /*return*/, commits[0].sha];
127
- }
128
- });
129
- });
130
- }