create-payload-app 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -56,7 +56,7 @@ var packages_1 = require("./packages");
|
|
56
56
|
/** Update payload config with necessary imports and adapters */
|
57
57
|
function configurePayloadConfig(args) {
|
58
58
|
return __awaiter(this, void 0, void 0, function () {
|
59
|
-
var packageJsonPath,
|
59
|
+
var packageJsonPath, packageObj_1, dbPackage_1, bundlerPackage, editorPackage, err_1, possiblePaths, payloadConfigPath_1, configContent, configLines_1, dbReplacement_1, bundlerReplacement_1, editorReplacement_1, dbConfigStartLineIndex_1, dbConfigEndLineIndex_1;
|
60
60
|
return __generator(this, function (_a) {
|
61
61
|
switch (_a.label) {
|
62
62
|
case 0:
|
@@ -69,15 +69,21 @@ function configurePayloadConfig(args) {
|
|
69
69
|
_a.trys.push([1, 4, , 5]);
|
70
70
|
return [4 /*yield*/, fs_extra_1.default.readJson(packageJsonPath)];
|
71
71
|
case 2:
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
packageObj_1 = _a.sent();
|
73
|
+
packageObj_1.dependencies['payload'] = '^2.0.0';
|
74
|
+
dbPackage_1 = packages_1.dbPackages[args.dbDetails.type];
|
75
75
|
bundlerPackage = packages_1.bundlerPackages['webpack'];
|
76
76
|
editorPackage = packages_1.editorPackages['slate'];
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
// Delete all other db adapters
|
78
|
+
Object.values(packages_1.dbPackages).forEach(function (p) {
|
79
|
+
if (p.packageName !== dbPackage_1.packageName) {
|
80
|
+
delete packageObj_1.dependencies[p.packageName];
|
81
|
+
}
|
82
|
+
});
|
83
|
+
packageObj_1.dependencies[dbPackage_1.packageName] = dbPackage_1.version;
|
84
|
+
packageObj_1.dependencies[bundlerPackage.packageName] = bundlerPackage.version;
|
85
|
+
packageObj_1.dependencies[editorPackage.packageName] = editorPackage.version;
|
86
|
+
return [4 /*yield*/, fs_extra_1.default.writeJson(packageJsonPath, packageObj_1, { spaces: 2 })];
|
81
87
|
case 3:
|
82
88
|
_a.sent();
|
83
89
|
return [3 /*break*/, 5];
|
@@ -161,6 +161,10 @@ describe('createProject', function () {
|
|
161
161
|
// Check deps
|
162
162
|
expect(packageJson.dependencies['payload']).toEqual('^2.0.0');
|
163
163
|
expect(packageJson.dependencies[dbReplacement.packageName]).toEqual(dbReplacement.version);
|
164
|
+
// Should only have one db adapter
|
165
|
+
expect(Object.keys(packageJson.dependencies).filter(function (n) {
|
166
|
+
return n.startsWith('@payloadcms/db-');
|
167
|
+
})).toHaveLength(1);
|
164
168
|
expect(packageJson.dependencies[bundlerReplacement.packageName]).toEqual(bundlerReplacement.version);
|
165
169
|
expect(packageJson.dependencies[editorReplacement.packageName]).toEqual(editorReplacement.version);
|
166
170
|
payloadConfigPath = path_1.default.resolve(projectDir, 'src/payload.config.ts');
|