create-payload-app 0.5.0 → 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, packageObj, dbPackage, bundlerPackage, editorPackage, err_1, possiblePaths, payloadConfigPath_1, configContent, configLines_1, dbReplacement_1, bundlerReplacement_1, editorReplacement_1, dbConfigStartLineIndex_1, dbConfigEndLineIndex_1;
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
- packageObj = _a.sent();
73
- packageObj.dependencies['payload'] = 'latest';
74
- dbPackage = packages_1.dbPackages[args.dbDetails.type];
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
- packageObj.dependencies[dbPackage.packageName] = 'latest';
78
- packageObj.dependencies[bundlerPackage.packageName] = 'latest';
79
- packageObj.dependencies[editorPackage.packageName] = 'latest';
80
- return [4 /*yield*/, fs_extra_1.default.writeJson(packageJsonPath, packageObj, { spaces: 2 })];
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];
@@ -129,7 +129,7 @@ describe('createProject', function () {
129
129
  ['mongodb', 'webpack'],
130
130
  ['postgres', 'webpack'],
131
131
  ])('update config and deps: %s, %s', function (db, bundler) { return __awaiter(void 0, void 0, void 0, function () {
132
- var projectName, template, dbReplacement, bundlerReplacement, packageJsonPath, packageJson, payloadConfigPath, content;
132
+ var projectName, template, dbReplacement, bundlerReplacement, editorReplacement, packageJsonPath, packageJson, payloadConfigPath, content;
133
133
  return __generator(this, function (_a) {
134
134
  switch (_a.label) {
135
135
  case 0:
@@ -155,11 +155,18 @@ describe('createProject', function () {
155
155
  _a.sent();
156
156
  dbReplacement = packages_1.dbPackages[db];
157
157
  bundlerReplacement = packages_1.bundlerPackages[bundler];
158
+ editorReplacement = packages_1.editorPackages['slate'];
158
159
  packageJsonPath = path_1.default.resolve(projectDir, 'package.json');
159
160
  packageJson = fs_extra_1.default.readJsonSync(packageJsonPath);
160
161
  // Check deps
161
- expect(packageJson.dependencies[dbReplacement.packageName]).toBeDefined();
162
- expect(packageJson.dependencies[bundlerReplacement.packageName]).toBeDefined();
162
+ expect(packageJson.dependencies['payload']).toEqual('^2.0.0');
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);
168
+ expect(packageJson.dependencies[bundlerReplacement.packageName]).toEqual(bundlerReplacement.version);
169
+ expect(packageJson.dependencies[editorReplacement.packageName]).toEqual(editorReplacement.version);
163
170
  payloadConfigPath = path_1.default.resolve(projectDir, 'src/payload.config.ts');
164
171
  content = fs_extra_1.default.readFileSync(payloadConfigPath, 'utf-8');
165
172
  // Check payload.config.ts
@@ -178,4 +185,8 @@ describe('createProject', function () {
178
185
  }); });
179
186
  });
180
187
  });
188
+ describe('Templates', function () {
189
+ it.todo('Verify that all templates are valid');
190
+ // Loop through all templates.ts that should have replacement comments, and verify that they are present
191
+ });
181
192
  });
@@ -10,6 +10,7 @@ var mongodbReplacement = {
10
10
  ' url: process.env.DATABASE_URI,',
11
11
  ' }),',
12
12
  ],
13
+ version: '^1.0.0',
13
14
  };
14
15
  var postgresReplacement = {
15
16
  packageName: '@payloadcms/db-postgres',
@@ -21,6 +22,7 @@ var postgresReplacement = {
21
22
  ' },',
22
23
  ' }),',
23
24
  ],
25
+ version: '^0.x', // up to, not including 1.0.0
24
26
  };
25
27
  exports.dbPackages = {
26
28
  mongodb: mongodbReplacement,
@@ -31,11 +33,13 @@ var webpackReplacement = {
31
33
  importReplacement: "import { webpackBundler } from '@payloadcms/bundler-webpack'",
32
34
  // Replacement of line containing `// bundler-config`
33
35
  configReplacement: ' bundler: webpackBundler(),',
36
+ version: '^1.0.0',
34
37
  };
35
38
  var viteReplacement = {
36
39
  packageName: '@payloadcms/bundler-vite',
37
40
  importReplacement: "import { viteBundler } from '@payloadcms/bundler-vite'",
38
41
  configReplacement: ' bundler: viteBundler(),',
42
+ version: '^0.x', // up to, not including 1.0.0
39
43
  };
40
44
  exports.bundlerPackages = {
41
45
  webpack: webpackReplacement,
@@ -46,10 +50,12 @@ exports.editorPackages = {
46
50
  packageName: '@payloadcms/richtext-slate',
47
51
  importReplacement: "import { slateEditor } from '@payloadcms/richtext-slate'",
48
52
  configReplacement: ' editor: slateEditor({}),',
53
+ version: '^1.0.0',
49
54
  },
50
55
  lexical: {
51
56
  packageName: '@payloadcms/richtext-lexical',
52
57
  importReplacement: "import { lexicalEditor } from '@payloadcms/richtext-lexical'",
53
58
  configReplacement: ' editor: lexicalEditor({}),',
59
+ version: '^0.x', // up to, not including 1.0.0
54
60
  },
55
61
  };
package/package.json CHANGED
@@ -37,7 +37,7 @@
37
37
  "prompts": "^2.4.2",
38
38
  "terminal-link": "^2.1.1"
39
39
  },
40
- "version": "0.5.0",
40
+ "version": "0.5.2",
41
41
  "devDependencies": {
42
42
  "@types/command-exists": "^1.2.0",
43
43
  "@types/degit": "^2.8.3",