create-payload-app 0.3.34 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/lib/create-project.js +33 -87
- package/dist/lib/create-project.test.js +37 -52
- package/dist/lib/templates.js +38 -71
- package/dist/lib/write-env-file.js +20 -15
- package/dist/main.js +14 -2
- package/dist/utils/messages.js +2 -1
- package/package.json +1 -1
- package/dist/lib/common-files/Dockerfile.template +0 -26
- package/dist/lib/common-files/README.template.md +0 -19
- package/dist/lib/common-files/docker-compose.template.yml +0 -35
- package/dist/lib/common-files/gitignore.template +0 -166
- package/dist/lib/common-files/nodemon.json +0 -4
- package/dist/lib/common-files/package.template.json +0 -30
- package/dist/lib/common-files/tsconfig.json +0 -34
- package/dist/lib/write-common-files.js +0 -124
- package/dist/templates/blank/src/collections/Examples.ts +0 -17
- package/dist/templates/blank/src/collections/Users.ts +0 -15
- package/dist/templates/blank/src/payload.config.ts +0 -22
- package/dist/templates/blank/src/server.ts +0 -28
- package/dist/templates/blog/src/collections/Categories.ts +0 -20
- package/dist/templates/blog/src/collections/Media.ts +0 -28
- package/dist/templates/blog/src/collections/Posts.ts +0 -62
- package/dist/templates/blog/src/collections/Tags.ts +0 -20
- package/dist/templates/blog/src/collections/Users.ts +0 -18
- package/dist/templates/blog/src/payload.config.ts +0 -21
- package/dist/templates/blog/src/server.ts +0 -28
- package/dist/templates/todo/src/collections/TodoLists.ts +0 -38
- package/dist/templates/todo/src/collections/Users.ts +0 -15
- package/dist/templates/todo/src/payload.config.ts +0 -18
- package/dist/templates/todo/src/server.ts +0 -28
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
40
40
|
};
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
42
|
-
exports.createProject = exports.
|
42
|
+
exports.createProject = exports.updatePackageJSONName = void 0;
|
43
43
|
var path_1 = __importDefault(require("path"));
|
44
44
|
var chalk_1 = __importDefault(require("chalk"));
|
45
45
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
@@ -47,7 +47,6 @@ var execa_1 = __importDefault(require("execa"));
|
|
47
47
|
var ora_1 = __importDefault(require("ora"));
|
48
48
|
var degit_1 = __importDefault(require("degit"));
|
49
49
|
var log_1 = require("../utils/log");
|
50
|
-
var write_common_files_1 = require("./write-common-files");
|
51
50
|
function createOrFindProjectDir(projectDir) {
|
52
51
|
return __awaiter(this, void 0, void 0, function () {
|
53
52
|
var pathExists;
|
@@ -66,13 +65,14 @@ function createOrFindProjectDir(projectDir) {
|
|
66
65
|
});
|
67
66
|
});
|
68
67
|
}
|
69
|
-
function installDeps(args
|
68
|
+
function installDeps(args) {
|
70
69
|
return __awaiter(this, void 0, void 0, function () {
|
71
|
-
var cmd, err_1;
|
70
|
+
var cliArgs, projectDir, packageManager, cmd, err_1;
|
72
71
|
return __generator(this, function (_a) {
|
73
72
|
switch (_a.label) {
|
74
73
|
case 0:
|
75
|
-
|
74
|
+
cliArgs = args.cliArgs, projectDir = args.projectDir, packageManager = args.packageManager;
|
75
|
+
if (cliArgs['--no-deps']) {
|
76
76
|
return [2 /*return*/, true];
|
77
77
|
}
|
78
78
|
cmd = packageManager === 'yarn' ? 'yarn' : 'npm install --legacy-peer-deps';
|
@@ -80,90 +80,57 @@ function installDeps(args, dir, packageManager) {
|
|
80
80
|
case 1:
|
81
81
|
_a.trys.push([1, 3, , 4]);
|
82
82
|
return [4 /*yield*/, execa_1.default.command(cmd, {
|
83
|
-
cwd: path_1.default.resolve(
|
83
|
+
cwd: path_1.default.resolve(projectDir),
|
84
84
|
})];
|
85
85
|
case 2:
|
86
86
|
_a.sent();
|
87
87
|
return [2 /*return*/, true];
|
88
88
|
case 3:
|
89
89
|
err_1 = _a.sent();
|
90
|
+
console.log({ err: err_1 });
|
90
91
|
return [2 /*return*/, false];
|
91
92
|
case 4: return [2 /*return*/];
|
92
93
|
}
|
93
94
|
});
|
94
95
|
});
|
95
96
|
}
|
96
|
-
function
|
97
|
-
if (betaFlag === void 0) { betaFlag = false; }
|
97
|
+
function updatePackageJSONName(args) {
|
98
98
|
return __awaiter(this, void 0, void 0, function () {
|
99
|
-
var
|
99
|
+
var projectName, projectDir, packageJsonPath, packageObj, err_2;
|
100
100
|
return __generator(this, function (_a) {
|
101
101
|
switch (_a.label) {
|
102
102
|
case 0:
|
103
|
-
|
104
|
-
packageWithTag = 'payload';
|
105
|
-
if (betaFlag)
|
106
|
-
packageWithTag += '@beta';
|
107
|
-
return [4 /*yield*/, (0, execa_1.default)("npm info ".concat(packageWithTag, " version"), [], {
|
108
|
-
shell: true,
|
109
|
-
})];
|
110
|
-
case 1:
|
111
|
-
stdout = (_a.sent()).stdout;
|
112
|
-
return [2 /*return*/, "^".concat(stdout)];
|
113
|
-
case 2:
|
114
|
-
err_2 = _a.sent();
|
115
|
-
if (err_2 instanceof Error) {
|
116
|
-
console.error(err_2.message);
|
117
|
-
console.error(err_2.stack);
|
118
|
-
}
|
119
|
-
return [2 /*return*/, false];
|
120
|
-
case 3: return [2 /*return*/];
|
121
|
-
}
|
122
|
-
});
|
123
|
-
});
|
124
|
-
}
|
125
|
-
exports.getLatestPayloadVersion = getLatestPayloadVersion;
|
126
|
-
function updatePayloadVersion(projectDir, betaFlag) {
|
127
|
-
if (betaFlag === void 0) { betaFlag = false; }
|
128
|
-
return __awaiter(this, void 0, void 0, function () {
|
129
|
-
var payloadVersion, packageJsonPath, packageObj, err_3;
|
130
|
-
return __generator(this, function (_a) {
|
131
|
-
switch (_a.label) {
|
132
|
-
case 0: return [4 /*yield*/, getLatestPayloadVersion(betaFlag)];
|
133
|
-
case 1:
|
134
|
-
payloadVersion = _a.sent();
|
135
|
-
if (!payloadVersion) {
|
136
|
-
(0, log_1.warning)('Error retrieving latest Payload version. Please update your package.json manually.');
|
137
|
-
return [2 /*return*/];
|
138
|
-
}
|
103
|
+
projectName = args.projectName, projectDir = args.projectDir;
|
139
104
|
packageJsonPath = path_1.default.resolve(projectDir, 'package.json');
|
140
|
-
_a.label =
|
141
|
-
case
|
142
|
-
_a.trys.push([
|
105
|
+
_a.label = 1;
|
106
|
+
case 1:
|
107
|
+
_a.trys.push([1, 4, , 5]);
|
143
108
|
return [4 /*yield*/, fs_extra_1.default.readJson(packageJsonPath)];
|
144
|
-
case
|
109
|
+
case 2:
|
145
110
|
packageObj = _a.sent();
|
146
|
-
packageObj.
|
111
|
+
packageObj.name = projectName;
|
147
112
|
return [4 /*yield*/, fs_extra_1.default.writeJson(packageJsonPath, packageObj, { spaces: 2 })];
|
148
|
-
case
|
113
|
+
case 3:
|
149
114
|
_a.sent();
|
150
|
-
return [3 /*break*/,
|
151
|
-
case
|
152
|
-
|
153
|
-
(0, log_1.warning)('Unable to
|
154
|
-
return [3 /*break*/,
|
155
|
-
case
|
115
|
+
return [3 /*break*/, 5];
|
116
|
+
case 4:
|
117
|
+
err_2 = _a.sent();
|
118
|
+
(0, log_1.warning)('Unable to update name in package.json');
|
119
|
+
return [3 /*break*/, 5];
|
120
|
+
case 5: return [2 /*return*/];
|
156
121
|
}
|
157
122
|
});
|
158
123
|
});
|
159
124
|
}
|
160
|
-
exports.
|
161
|
-
function createProject(args
|
125
|
+
exports.updatePackageJSONName = updatePackageJSONName;
|
126
|
+
function createProject(args) {
|
162
127
|
return __awaiter(this, void 0, void 0, function () {
|
163
|
-
var
|
128
|
+
var cliArgs, projectName, projectDir, template, packageManager, emitter, spinner, result;
|
164
129
|
return __generator(this, function (_a) {
|
165
130
|
switch (_a.label) {
|
166
|
-
case 0:
|
131
|
+
case 0:
|
132
|
+
cliArgs = args.cliArgs, projectName = args.projectName, projectDir = args.projectDir, template = args.template, packageManager = args.packageManager;
|
133
|
+
return [4 /*yield*/, createOrFindProjectDir(projectDir)];
|
167
134
|
case 1:
|
168
135
|
_a.sent();
|
169
136
|
console.log("\n Creating project in ".concat(chalk_1.default.green(path_1.default.resolve(projectDir)), "\n"));
|
@@ -172,36 +139,15 @@ function createProject(args, projectDir, template, packageManager) {
|
|
172
139
|
return [4 /*yield*/, emitter.clone(projectDir)];
|
173
140
|
case 2:
|
174
141
|
_a.sent();
|
175
|
-
|
142
|
+
_a.label = 3;
|
176
143
|
case 3:
|
177
|
-
_a.trys.push([3, 6, , 7]);
|
178
|
-
templateDir = path_1.default.resolve(__dirname, "../templates/".concat(template.directory));
|
179
|
-
return [4 /*yield*/, fs_extra_1.default.copy(templateDir, projectDir, { recursive: true })];
|
180
|
-
case 4:
|
181
|
-
_a.sent();
|
182
|
-
return [4 /*yield*/, (0, write_common_files_1.writeCommonFiles)(projectDir, template, packageManager)];
|
183
|
-
case 5:
|
184
|
-
_a.sent();
|
185
|
-
(0, log_1.success)('Project directory created');
|
186
|
-
return [3 /*break*/, 7];
|
187
|
-
case 6:
|
188
|
-
err_4 = _a.sent();
|
189
|
-
msg = 'Unable to copy template files. Please check template name or directory permissions.';
|
190
|
-
(0, log_1.error)(msg);
|
191
|
-
console.error({ err: err_4 });
|
192
|
-
process.exit(1);
|
193
|
-
return [3 /*break*/, 7];
|
194
|
-
case 7:
|
195
144
|
spinner = (0, ora_1.default)('Checking latest Payload version...').start();
|
196
|
-
|
197
|
-
|
198
|
-
case 8:
|
145
|
+
return [4 /*yield*/, updatePackageJSONName({ projectName: projectName, projectDir: projectDir })];
|
146
|
+
case 4:
|
199
147
|
_a.sent();
|
200
|
-
_a.label = 9;
|
201
|
-
case 9:
|
202
148
|
spinner.text = 'Installing dependencies...';
|
203
|
-
return [4 /*yield*/, installDeps(
|
204
|
-
case
|
149
|
+
return [4 /*yield*/, installDeps({ cliArgs: cliArgs, projectDir: projectDir, packageManager: packageManager })];
|
150
|
+
case 5:
|
205
151
|
result = _a.sent();
|
206
152
|
spinner.stop();
|
207
153
|
spinner.clear();
|
@@ -61,78 +61,63 @@ describe('createProject', function () {
|
|
61
61
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
62
62
|
var args = { _: ['project-name'], '--no-deps': true };
|
63
63
|
var packageManager = 'yarn';
|
64
|
-
it('creates
|
65
|
-
var
|
64
|
+
it('creates starter project', function () { return __awaiter(void 0, void 0, void 0, function () {
|
65
|
+
var projectName, template, packageJsonPath, packageJson;
|
66
66
|
return __generator(this, function (_a) {
|
67
67
|
switch (_a.label) {
|
68
|
-
case 0:
|
69
|
-
|
70
|
-
expectedPayloadVersion = _a.sent();
|
71
|
-
templateName = 'todo';
|
68
|
+
case 0:
|
69
|
+
projectName = 'starter-project';
|
72
70
|
template = {
|
73
|
-
name:
|
74
|
-
type: '
|
75
|
-
|
71
|
+
name: 'blank',
|
72
|
+
type: 'starter',
|
73
|
+
url: 'https://github.com/payloadcms/payload/templates/blank',
|
74
|
+
description: 'Blank Template',
|
76
75
|
};
|
77
|
-
return [4 /*yield*/, (0, create_project_1.createProject)(
|
78
|
-
|
76
|
+
return [4 /*yield*/, (0, create_project_1.createProject)({
|
77
|
+
cliArgs: args,
|
78
|
+
projectName: projectName,
|
79
|
+
projectDir: projectDir,
|
80
|
+
template: template,
|
81
|
+
packageManager: packageManager,
|
82
|
+
})];
|
83
|
+
case 1:
|
79
84
|
_a.sent();
|
80
85
|
packageJsonPath = path_1.default.resolve(projectDir, 'package.json');
|
81
86
|
packageJson = fs_extra_1.default.readJsonSync(packageJsonPath);
|
82
|
-
expect(packageJson.dependencies.payload).toBe(expectedPayloadVersion);
|
83
87
|
// Check package name and description
|
84
|
-
expect(packageJson.name).toEqual(
|
85
|
-
expect(packageJson.description).toContain(templateName);
|
86
|
-
// Check all common files are create
|
87
|
-
assertProjectFileExists('.gitignore');
|
88
|
-
assertProjectFileExists('nodemon.json');
|
89
|
-
assertProjectFileExists('README.md');
|
90
|
-
assertProjectFileExists('tsconfig.json');
|
91
|
-
assertProjectFileExists('docker-compose.yml');
|
88
|
+
expect(packageJson.name).toEqual(projectName);
|
92
89
|
return [2 /*return*/];
|
93
90
|
}
|
94
91
|
});
|
95
92
|
}); });
|
96
|
-
|
97
|
-
|
98
|
-
it('updates payload version in package.json', function () { return __awaiter(void 0, void 0, void 0, function () {
|
99
|
-
var packageJsonPath, modified;
|
93
|
+
it('creates plugin template', function () { return __awaiter(void 0, void 0, void 0, function () {
|
94
|
+
var projectName, template, packageJsonPath, packageJson;
|
100
95
|
return __generator(this, function (_a) {
|
101
96
|
switch (_a.label) {
|
102
97
|
case 0:
|
103
|
-
|
104
|
-
|
98
|
+
projectName = 'plugin';
|
99
|
+
template = {
|
100
|
+
name: 'plugin',
|
101
|
+
type: 'plugin',
|
102
|
+
url: 'https://github.com/payloadcms/payload-plugin-template',
|
103
|
+
description: 'Template for creating a Payload plugin',
|
104
|
+
};
|
105
|
+
return [4 /*yield*/, (0, create_project_1.createProject)({
|
106
|
+
cliArgs: args,
|
107
|
+
projectName: projectName,
|
108
|
+
projectDir: projectDir,
|
109
|
+
template: template,
|
110
|
+
packageManager: packageManager,
|
111
|
+
})];
|
105
112
|
case 1:
|
106
113
|
_a.sent();
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
case 3:
|
112
|
-
_a.sent();
|
113
|
-
return [4 /*yield*/, fs_extra_1.default.readJson(packageJsonPath)];
|
114
|
-
case 4:
|
115
|
-
modified = _a.sent();
|
116
|
-
expect(modified.dependencies.payload).not.toBe('0.0.1');
|
114
|
+
packageJsonPath = path_1.default.resolve(projectDir, 'package.json');
|
115
|
+
packageJson = fs_extra_1.default.readJsonSync(packageJsonPath);
|
116
|
+
// Check package name and description
|
117
|
+
expect(packageJson.name).toEqual(projectName);
|
117
118
|
return [2 /*return*/];
|
118
119
|
}
|
119
120
|
});
|
120
121
|
}); });
|
121
122
|
});
|
122
123
|
});
|
123
|
-
function assertProjectFileExists(fileName) {
|
124
|
-
return __awaiter(this, void 0, void 0, function () {
|
125
|
-
var filePath, _a;
|
126
|
-
return __generator(this, function (_b) {
|
127
|
-
switch (_b.label) {
|
128
|
-
case 0:
|
129
|
-
filePath = path_1.default.resolve(projectDir, fileName);
|
130
|
-
_a = expect;
|
131
|
-
return [4 /*yield*/, fs_extra_1.default.pathExists(filePath)];
|
132
|
-
case 1:
|
133
|
-
_a.apply(void 0, [_b.sent()]).toBe(true);
|
134
|
-
return [2 /*return*/];
|
135
|
-
}
|
136
|
-
});
|
137
|
-
});
|
138
|
-
}
|
package/dist/lib/templates.js
CHANGED
@@ -35,15 +35,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
36
|
}
|
37
37
|
};
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
40
|
-
if (ar || !(i in from)) {
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
42
|
-
ar[i] = from[i];
|
43
|
-
}
|
44
|
-
}
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
46
|
-
};
|
47
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
48
39
|
exports.getValidTemplates = exports.validateTemplate = void 0;
|
49
40
|
var log_1 = require("../utils/log");
|
@@ -68,69 +59,45 @@ function validateTemplate(templateName) {
|
|
68
59
|
exports.validateTemplate = validateTemplate;
|
69
60
|
function getValidTemplates() {
|
70
61
|
return __awaiter(this, void 0, void 0, function () {
|
71
|
-
var templates, starters, pluginTemplates;
|
72
62
|
return __generator(this, function (_a) {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
},
|
112
|
-
{
|
113
|
-
name: 'cloud-template-website',
|
114
|
-
type: 'starter',
|
115
|
-
url: 'https://github.com/payloadcms/template-website',
|
116
|
-
description: 'Website template for Payload Cloud',
|
117
|
-
},
|
118
|
-
{
|
119
|
-
name: 'cloud-template-ecommerce',
|
120
|
-
type: 'starter',
|
121
|
-
url: 'https://github.com/payloadcms/template-ecommerce',
|
122
|
-
description: 'E-commerce template for Payload Cloud',
|
123
|
-
},
|
124
|
-
];
|
125
|
-
pluginTemplates = [
|
126
|
-
{
|
127
|
-
name: 'plugin',
|
128
|
-
type: 'plugin',
|
129
|
-
url: 'https://github.com/payloadcms/payload-plugin-template',
|
130
|
-
description: 'Template for creating a Payload plugin',
|
131
|
-
},
|
132
|
-
];
|
133
|
-
return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], templates, true), starters, true), pluginTemplates, true)];
|
63
|
+
return [2 /*return*/, [
|
64
|
+
{
|
65
|
+
name: 'blank',
|
66
|
+
type: 'starter',
|
67
|
+
url: 'https://github.com/payloadcms/payload/templates/blank',
|
68
|
+
description: 'Blank Template',
|
69
|
+
},
|
70
|
+
{
|
71
|
+
name: 'website',
|
72
|
+
type: 'starter',
|
73
|
+
url: 'https://github.com/payloadcms/payload/templates/website',
|
74
|
+
description: 'Website Template',
|
75
|
+
},
|
76
|
+
{
|
77
|
+
name: 'ecommerce',
|
78
|
+
type: 'starter',
|
79
|
+
url: 'https://github.com/payloadcms/payload/templates/ecommerce',
|
80
|
+
description: 'E-commerce Template',
|
81
|
+
},
|
82
|
+
{
|
83
|
+
name: 'plugin',
|
84
|
+
type: 'plugin',
|
85
|
+
url: 'https://github.com/payloadcms/payload-plugin-template',
|
86
|
+
description: 'Template for creating a Payload plugin',
|
87
|
+
},
|
88
|
+
{
|
89
|
+
name: 'payload-demo',
|
90
|
+
type: 'starter',
|
91
|
+
url: 'https://github.com/payloadcms/public-demo',
|
92
|
+
description: 'Payload demo site at https://demo.payloadcms.com',
|
93
|
+
},
|
94
|
+
{
|
95
|
+
name: 'payload-website',
|
96
|
+
type: 'starter',
|
97
|
+
url: 'https://github.com/payloadcms/website-cms',
|
98
|
+
description: 'Payload website CMS at https://payloadcms.com',
|
99
|
+
},
|
100
|
+
]];
|
134
101
|
});
|
135
102
|
});
|
136
103
|
}
|
@@ -43,9 +43,10 @@ exports.writeEnvFile = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
44
44
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
45
45
|
var log_1 = require("../utils/log");
|
46
|
+
/** Parse and swap .env.example values and write .env */
|
46
47
|
function writeEnvFile(args) {
|
47
48
|
return __awaiter(this, void 0, void 0, function () {
|
48
|
-
var databaseUri, payloadSecret, template, projectDir, envFile,
|
49
|
+
var databaseUri, payloadSecret, template, projectDir, envFile, envWithValues, content, err_1;
|
49
50
|
return __generator(this, function (_a) {
|
50
51
|
switch (_a.label) {
|
51
52
|
case 0:
|
@@ -58,25 +59,29 @@ function writeEnvFile(args) {
|
|
58
59
|
return [4 /*yield*/, fs_extra_1.default.readFile(path_1.default.join(projectDir, '.env.example'), 'utf8')];
|
59
60
|
case 2:
|
60
61
|
envFile = _a.sent();
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
envWithValues = envFile
|
63
|
+
.split('\n')
|
64
|
+
.filter(function (e) { return e; })
|
65
|
+
.map(function (line) {
|
66
|
+
if (line.startsWith('#') || !line.includes('='))
|
67
|
+
return line;
|
68
|
+
var split = line.split('=');
|
69
|
+
var key = split[0];
|
70
|
+
var value = split[1];
|
71
|
+
if (key === 'MONGODB_URI' || key === 'MONGO_URL') {
|
72
|
+
value = databaseUri;
|
69
73
|
}
|
70
|
-
if (
|
71
|
-
|
74
|
+
if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') {
|
75
|
+
value = payloadSecret;
|
72
76
|
}
|
73
|
-
return
|
77
|
+
return "".concat(key, "=").concat(value);
|
74
78
|
});
|
75
|
-
|
76
|
-
return [4 /*yield*/, fs_extra_1.default.writeFile(path_1.default.join(projectDir, '.env'),
|
79
|
+
// Write new .env file
|
80
|
+
return [4 /*yield*/, fs_extra_1.default.writeFile(path_1.default.join(projectDir, '.env'), envWithValues.join('\n'))];
|
77
81
|
case 3:
|
82
|
+
// Write new .env file
|
78
83
|
_a.sent();
|
79
|
-
|
84
|
+
_a.label = 4;
|
80
85
|
case 4:
|
81
86
|
content = "MONGODB_URI=".concat(databaseUri, "\nPAYLOAD_SECRET=").concat(payloadSecret);
|
82
87
|
return [4 /*yield*/, fs_extra_1.default.outputFile("".concat(projectDir, "/.env"), content)];
|
package/dist/main.js
CHANGED
@@ -120,7 +120,13 @@ var Main = /** @class */ (function () {
|
|
120
120
|
case 11:
|
121
121
|
payloadSecret = _e.sent();
|
122
122
|
if (!!this.args['--dry-run']) return [3 /*break*/, 14];
|
123
|
-
return [4 /*yield*/, (0, create_project_1.createProject)(
|
123
|
+
return [4 /*yield*/, (0, create_project_1.createProject)({
|
124
|
+
cliArgs: this.args,
|
125
|
+
projectName: projectName,
|
126
|
+
projectDir: projectDir,
|
127
|
+
template: template,
|
128
|
+
packageManager: packageManager,
|
129
|
+
})];
|
124
130
|
case 12:
|
125
131
|
_e.sent();
|
126
132
|
return [4 /*yield*/, (0, write_env_file_1.writeEnvFile)({
|
@@ -135,7 +141,13 @@ var Main = /** @class */ (function () {
|
|
135
141
|
case 14: return [3 /*break*/, 17];
|
136
142
|
case 15:
|
137
143
|
if (!!this.args['--dry-run']) return [3 /*break*/, 17];
|
138
|
-
return [4 /*yield*/, (0, create_project_1.createProject)(
|
144
|
+
return [4 /*yield*/, (0, create_project_1.createProject)({
|
145
|
+
cliArgs: this.args,
|
146
|
+
projectName: projectName,
|
147
|
+
projectDir: projectDir,
|
148
|
+
template: template,
|
149
|
+
packageManager: packageManager,
|
150
|
+
})];
|
139
151
|
case 16:
|
140
152
|
_e.sent();
|
141
153
|
_e.label = 17;
|
package/dist/utils/messages.js
CHANGED
@@ -48,6 +48,7 @@ var chalk_1 = __importDefault(require("chalk"));
|
|
48
48
|
var figures_1 = __importDefault(require("figures"));
|
49
49
|
var terminal_link_1 = __importDefault(require("terminal-link"));
|
50
50
|
var templates_1 = require("../lib/templates");
|
51
|
+
var path_1 = __importDefault(require("path"));
|
51
52
|
var header = function (message) {
|
52
53
|
return "".concat(chalk_1.default.yellow(figures_1.default.star), " ").concat(chalk_1.default.bold(message));
|
53
54
|
};
|
@@ -73,7 +74,7 @@ function formatTemplates(templates) {
|
|
73
74
|
.join("\n".concat(spacer)));
|
74
75
|
}
|
75
76
|
function successMessage(projectDir, packageManager) {
|
76
|
-
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(createTerminalLink('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload'), "\n - ").concat(createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview'), "\n\n");
|
77
|
+
return "\n ".concat(header('Launch Application:'), "\n\n - cd ").concat(projectDir, "\n - ").concat(packageManager === 'yarn' ? 'yarn' : 'npm run', " dev or follow directions in ").concat(createTerminalLink('README.md', "file://".concat(path_1.default.resolve(projectDir, 'README.md'))), "\n\n ").concat(header('Documentation:'), "\n\n - ").concat(createTerminalLink('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload'), "\n - ").concat(createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview'), "\n\n");
|
77
78
|
}
|
78
79
|
exports.successMessage = successMessage;
|
79
80
|
// Create terminalLink with fallback for unsupported terminals
|
package/package.json
CHANGED
@@ -1,26 +0,0 @@
|
|
1
|
-
FROM node:18.8-alpine as base
|
2
|
-
|
3
|
-
FROM base as builder
|
4
|
-
|
5
|
-
WORKDIR /home/node/app
|
6
|
-
COPY package*.json ./
|
7
|
-
|
8
|
-
COPY . .
|
9
|
-
RUN {{installCmd}}
|
10
|
-
RUN {{buildCmd}}
|
11
|
-
|
12
|
-
FROM base as runtime
|
13
|
-
|
14
|
-
ENV NODE_ENV=production
|
15
|
-
ENV PAYLOAD_CONFIG_PATH=dist/payload.config.js
|
16
|
-
|
17
|
-
WORKDIR /home/node/app
|
18
|
-
COPY package*.json ./
|
19
|
-
|
20
|
-
RUN {{installCmd}} --production
|
21
|
-
COPY --from=builder /home/node/app/dist ./dist
|
22
|
-
COPY --from=builder /home/node/app/build ./build
|
23
|
-
|
24
|
-
EXPOSE 3000
|
25
|
-
|
26
|
-
CMD ["node", "dist/server.js"]
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# {{projectName}}
|
2
|
-
|
3
|
-
This project was created using create-payload-app using the {{templateName}} template.
|
4
|
-
|
5
|
-
## How to Use
|
6
|
-
|
7
|
-
`yarn dev` will start up your application and reload on any changes.
|
8
|
-
|
9
|
-
### Docker
|
10
|
-
|
11
|
-
If you have docker and docker-compose installed, you can run `docker-compose up`
|
12
|
-
|
13
|
-
To build the docker image, run `docker build -t my-tag .`
|
14
|
-
|
15
|
-
Ensure you are passing all needed environment variables when starting up your container via `--env-file` or setting them with your deployment.
|
16
|
-
|
17
|
-
The 3 typical env vars will be `MONGODB_URI`, `PAYLOAD_SECRET`, and `PAYLOAD_CONFIG_PATH`
|
18
|
-
|
19
|
-
`docker run --env-file .env -p 3000:3000 my-tag`
|
@@ -1,35 +0,0 @@
|
|
1
|
-
version: '3'
|
2
|
-
|
3
|
-
services:
|
4
|
-
|
5
|
-
payload:
|
6
|
-
image: node:18-alpine
|
7
|
-
ports:
|
8
|
-
- "3000:3000"
|
9
|
-
volumes:
|
10
|
-
- .:/home/node/app
|
11
|
-
- node_modules:/home/node/app/node_modules
|
12
|
-
working_dir: /home/node/app/
|
13
|
-
command: sh -c "{{installCmd}} && {{devCmd}}"
|
14
|
-
depends_on:
|
15
|
-
- mongo
|
16
|
-
environment:
|
17
|
-
MONGODB_URI: mongodb://mongo:27017/payload
|
18
|
-
PORT: 3000
|
19
|
-
NODE_ENV: development
|
20
|
-
PAYLOAD_SECRET: TESTING
|
21
|
-
|
22
|
-
mongo:
|
23
|
-
image: mongo:latest
|
24
|
-
ports:
|
25
|
-
- "27017:27017"
|
26
|
-
command:
|
27
|
-
- --storageEngine=wiredTiger
|
28
|
-
volumes:
|
29
|
-
- data:/data/db
|
30
|
-
logging:
|
31
|
-
driver: none
|
32
|
-
|
33
|
-
volumes:
|
34
|
-
data:
|
35
|
-
node_modules:
|