create-keystone-app 9.0.1 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Thinkmill Labs Pty Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # create-keystone-app
2
+
3
+ <br>
4
+ <p>Keystone helps you build faster and scale further than any other CMS or App Framework. Describe your schema, and get a powerful GraphQL API & beautiful Management UI for your content and data.</p>
5
+ <p>No boilerplate or bootstrapping – just elegant APIs to help you ship the code that matters without sacrificing the flexibility or power of a bespoke back-end.
6
+ </p>
7
+
8
+ For help with this package join the conversation in [Slack](https://community.keystonejs.com/), or on [GitHub](https://github.com/keystonejs/keystone/).
9
+
10
+ Visit <https://keystonejs.com/> for docs, and [follow @keystonejs on Twitter](https://twitter.com/keystonejs) for the latest updates.
package/cli.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import './dist/create-keystone-app.esm.js'
@@ -0,0 +1,2 @@
1
+ export * from "./declarations/src/index";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLWtleXN0b25lLWFwcC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
@@ -1,102 +1,76 @@
1
1
  'use strict';
2
2
 
3
- var fs = require('fs-extra');
4
- var path = require('path');
5
- var meow = require('meow');
3
+ var fs = require('node:fs/promises');
4
+ var path = require('node:path');
5
+ var node_url = require('node:url');
6
+ var c = require('chalk');
6
7
  var enquirer = require('enquirer');
7
8
  var execa = require('execa');
8
- var ora = require('ora');
9
9
  var getPackageJson = require('package-json');
10
- var semver = require('semver');
11
- var c = require('chalk');
12
- var terminalLink = require('terminal-link');
10
+ var meow = require('meow');
11
+ var ora = require('ora');
13
12
 
14
13
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
14
 
16
- function _interopNamespace(e) {
17
- if (e && e.__esModule) return e;
18
- var n = Object.create(null);
19
- if (e) {
20
- Object.keys(e).forEach(function (k) {
21
- if (k !== 'default') {
22
- var d = Object.getOwnPropertyDescriptor(e, k);
23
- Object.defineProperty(n, k, d.get ? d : {
24
- enumerable: true,
25
- get: function () { return e[k]; }
26
- });
27
- }
28
- });
29
- }
30
- n["default"] = e;
31
- return Object.freeze(n);
32
- }
33
-
34
15
  var fs__default = /*#__PURE__*/_interopDefault(fs);
35
16
  var path__default = /*#__PURE__*/_interopDefault(path);
36
- var meow__default = /*#__PURE__*/_interopDefault(meow);
17
+ var c__default = /*#__PURE__*/_interopDefault(c);
37
18
  var enquirer__default = /*#__PURE__*/_interopDefault(enquirer);
38
19
  var execa__default = /*#__PURE__*/_interopDefault(execa);
39
- var ora__default = /*#__PURE__*/_interopDefault(ora);
40
20
  var getPackageJson__default = /*#__PURE__*/_interopDefault(getPackageJson);
41
- var semver__namespace = /*#__PURE__*/_interopNamespace(semver);
42
- var c__default = /*#__PURE__*/_interopDefault(c);
43
- var terminalLink__default = /*#__PURE__*/_interopDefault(terminalLink);
21
+ var meow__default = /*#__PURE__*/_interopDefault(meow);
22
+ var ora__default = /*#__PURE__*/_interopDefault(ora);
44
23
 
45
- var currentPkgJson = {
24
+ var thisPackage = {
46
25
  name: "create-keystone-app",
47
- version: "9.0.1",
48
- main: "dist/create-keystone-app.cjs.js",
49
- files: [
50
- "dist",
51
- "starter",
52
- "!dist/**/*.d.ts",
53
- "!starter/node_modules"
54
- ],
55
- bin: "./bin.js",
26
+ version: "10.0.0",
56
27
  license: "MIT",
28
+ type: "module",
29
+ main: "dist/create-keystone-app.cjs.js",
30
+ module: "dist/create-keystone-app.esm.js",
31
+ repository: "https://github.com/keystonejs/keystone/tree/main/packages/create",
32
+ bin: "./cli.js",
33
+ exports: {
34
+ ".": {
35
+ module: "./dist/create-keystone-app.esm.js",
36
+ "default": "./dist/create-keystone-app.cjs.js"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ preconstruct: {
41
+ entrypoints: [
42
+ "index.ts"
43
+ ]
44
+ },
57
45
  dependencies: {
58
- "@babel/runtime": "^7.18.9",
59
46
  chalk: "^4.1.2",
60
- enquirer: "^2.3.6",
47
+ enquirer: "^2.4.1",
61
48
  execa: "^5.1.1",
62
- "fs-extra": "^10.1.0",
63
49
  meow: "^9.0.0",
64
- ora: "^5.4.1",
65
- "package-json": "^7.0.0",
66
- semver: "^7.3.7",
67
- "terminal-link": "^2.1.1"
68
- }
50
+ ora: "^8.0.1",
51
+ "package-json": "^10.0.0"
52
+ },
53
+ files: [
54
+ "dist",
55
+ "starter",
56
+ "cli.js"
57
+ ]
69
58
  };
70
59
 
71
60
  async function checkVersion() {
72
- try {
73
- const {
74
- version
75
- } = await getPackageJson__default["default"]('create-keystone-app');
76
- if (typeof version !== 'string') {
77
- throw new Error('version from package metadata was expected to be a string but was not');
78
- }
79
- if (semver__namespace.lt(currentPkgJson.version, version)) {
80
- console.error(`⚠️ You're running an old version of create-keystone-app, please update to ${version}`);
81
- }
82
- } catch (err) {
83
- console.error('A problem occurred fetching the latest version of create-keystone-app');
84
- console.error(err);
85
- }
61
+ const {
62
+ version: upstream
63
+ } = await getPackageJson__default["default"]('create-keystone-app');
64
+ if (upstream === thisPackage.version) return;
65
+ console.error(`⚠️ You're running an old version of create-keystone-app, please update to ${upstream}`);
86
66
  }
87
-
88
67
  class UserError extends Error {}
89
-
90
- const starterDir = path__default["default"].normalize(`${__dirname}/../starter`);
68
+ const __dirname$1 = path__default["default"].dirname(node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('dist/create-keystone-app.cjs.dev.js', document.baseURI).href))));
69
+ const starterDir = path__default["default"].normalize(`${__dirname$1}/../starter`);
91
70
  const cli = meow__default["default"](`
92
71
  Usage
93
72
  $ create-keystone-app [directory]
94
73
  `);
95
- const versionInfo = () => {
96
- process.stdout.write('\n');
97
- console.log(`✨ You're about to generate a project using ${c__default["default"].bold('Keystone 6')} packages.
98
- `);
99
- };
100
74
  async function normalizeArgs() {
101
75
  let directory = cli.input[0];
102
76
  if (!directory) {
@@ -114,42 +88,25 @@ async function normalizeArgs() {
114
88
  directory: path__default["default"].resolve(directory)
115
89
  };
116
90
  }
117
- const installDeps = async cwd => {
118
- const spinner = ora__default["default"]('Installing dependencies with yarn. This may take a few minutes.').start();
91
+ (async (_process$env$npm_conf, _process$env$npm_conf2) => {
92
+ process.stdout.write('\n');
93
+ console.log(`✨ You're about to generate a project using ${c__default["default"].bold('Keystone 6')} packages.`);
94
+ await checkVersion();
95
+ const normalizedArgs = await normalizeArgs();
96
+ const nextCwd = normalizedArgs.directory;
97
+ await fs__default["default"].mkdir(nextCwd);
98
+ await Promise.all(['_gitignore', 'schema.ts', 'package.json', 'tsconfig.json', 'schema.graphql', 'schema.prisma', 'keystone.ts', 'auth.ts', 'README.md'].map(filename => fs__default["default"].copyFile(path__default["default"].join(starterDir, filename), path__default["default"].join(normalizedArgs.directory, filename.replace(/^_/, '.')))));
99
+ const [packageManager] = (_process$env$npm_conf = (_process$env$npm_conf2 = process.env.npm_config_user_agent) === null || _process$env$npm_conf2 === void 0 ? void 0 : _process$env$npm_conf2.split('/', 1)) !== null && _process$env$npm_conf !== void 0 ? _process$env$npm_conf : ['npm'];
100
+ const spinner = ora__default["default"](`Installing dependencies with ${packageManager}. This may take a few minutes.`).start();
119
101
  try {
120
- await execa__default["default"]('yarn', ['install'], {
121
- cwd
102
+ await execa__default["default"](packageManager, ['install'], {
103
+ cwd: nextCwd
122
104
  });
123
- spinner.succeed('Installed dependencies with yarn.');
124
- return 'yarn';
125
- } catch (_err) {
126
- let err = _err;
127
- if (err.failed) {
128
- process.stdout.write('\n');
129
- spinner.warn('Failed to install with yarn.');
130
- spinner.start('Installing dependencies with npm. This may take a few minutes.');
131
- try {
132
- await execa__default["default"]('npm', ['install'], {
133
- cwd
134
- });
135
- spinner.succeed('Installed dependencies with npm.');
136
- } catch (npmErr) {
137
- spinner.fail('Failed to install with npm.');
138
- throw npmErr;
139
- }
140
- process.stdout.write('\n');
141
- return 'npm';
142
- }
105
+ spinner.succeed(`Installed dependencies with ${packageManager}.`);
106
+ } catch (err) {
107
+ spinner.fail(`Failed to install with ${packageManager}.`);
143
108
  throw err;
144
109
  }
145
- };
146
- (async () => {
147
- versionInfo();
148
- await checkVersion();
149
- const normalizedArgs = await normalizeArgs();
150
- await fs__default["default"].mkdir(normalizedArgs.directory);
151
- await Promise.all([...['_gitignore', 'schema.ts', 'package.json', 'tsconfig.json', 'schema.graphql', 'schema.prisma', 'keystone.ts', 'auth.ts', 'README.md'].map(filename => fs__default["default"].copyFile(path__default["default"].join(starterDir, filename), path__default["default"].join(normalizedArgs.directory, filename.replace(/^_/, '.'))))]);
152
- const packageManager = await installDeps(normalizedArgs.directory);
153
110
  const relativeProjectDir = path__default["default"].relative(process.cwd(), normalizedArgs.directory);
154
111
  process.stdout.write('\n');
155
112
  console.log(`🎉 Keystone created a starter project in: ${c__default["default"].bold(relativeProjectDir)}
@@ -157,16 +114,14 @@ const installDeps = async cwd => {
157
114
  ${c__default["default"].bold('To launch your app, run:')}
158
115
 
159
116
  - cd ${relativeProjectDir}
160
- - ${packageManager === 'yarn' ? 'yarn' : 'npm run'} dev
117
+ - ${packageManager} run dev
161
118
 
162
119
  ${c__default["default"].bold('Next steps:')}
163
120
 
164
121
  - Read ${c__default["default"].bold(`${relativeProjectDir}${path__default["default"].sep}README.md`)} for additional getting started details.
165
122
  - Edit ${c__default["default"].bold(`${relativeProjectDir}${path__default["default"].sep}keystone.ts`)} to customize your app.
166
- - ${terminalLink__default["default"]('Open the Admin UI', 'http://localhost:3000')}
167
- - ${terminalLink__default["default"]('Open the Graphql API', 'http://localhost:3000/api/graphql')}
168
- - ${terminalLink__default["default"]('Read the docs', 'https://next.keystonejs.com')}
169
- - ${terminalLink__default["default"]('Star Keystone on GitHub', 'https://github.com/keystonejs/keystone')}
123
+ - Star Keystone on GitHub (https://github.com/keystonejs/keystone)
124
+ )}
170
125
  `);
171
126
  })().catch(err => {
172
127
  if (err instanceof UserError) {
@@ -1,102 +1,76 @@
1
1
  'use strict';
2
2
 
3
- var fs = require('fs-extra');
4
- var path = require('path');
5
- var meow = require('meow');
3
+ var fs = require('node:fs/promises');
4
+ var path = require('node:path');
5
+ var node_url = require('node:url');
6
+ var c = require('chalk');
6
7
  var enquirer = require('enquirer');
7
8
  var execa = require('execa');
8
- var ora = require('ora');
9
9
  var getPackageJson = require('package-json');
10
- var semver = require('semver');
11
- var c = require('chalk');
12
- var terminalLink = require('terminal-link');
10
+ var meow = require('meow');
11
+ var ora = require('ora');
13
12
 
14
13
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
14
 
16
- function _interopNamespace(e) {
17
- if (e && e.__esModule) return e;
18
- var n = Object.create(null);
19
- if (e) {
20
- Object.keys(e).forEach(function (k) {
21
- if (k !== 'default') {
22
- var d = Object.getOwnPropertyDescriptor(e, k);
23
- Object.defineProperty(n, k, d.get ? d : {
24
- enumerable: true,
25
- get: function () { return e[k]; }
26
- });
27
- }
28
- });
29
- }
30
- n["default"] = e;
31
- return Object.freeze(n);
32
- }
33
-
34
15
  var fs__default = /*#__PURE__*/_interopDefault(fs);
35
16
  var path__default = /*#__PURE__*/_interopDefault(path);
36
- var meow__default = /*#__PURE__*/_interopDefault(meow);
17
+ var c__default = /*#__PURE__*/_interopDefault(c);
37
18
  var enquirer__default = /*#__PURE__*/_interopDefault(enquirer);
38
19
  var execa__default = /*#__PURE__*/_interopDefault(execa);
39
- var ora__default = /*#__PURE__*/_interopDefault(ora);
40
20
  var getPackageJson__default = /*#__PURE__*/_interopDefault(getPackageJson);
41
- var semver__namespace = /*#__PURE__*/_interopNamespace(semver);
42
- var c__default = /*#__PURE__*/_interopDefault(c);
43
- var terminalLink__default = /*#__PURE__*/_interopDefault(terminalLink);
21
+ var meow__default = /*#__PURE__*/_interopDefault(meow);
22
+ var ora__default = /*#__PURE__*/_interopDefault(ora);
44
23
 
45
- var currentPkgJson = {
24
+ var thisPackage = {
46
25
  name: "create-keystone-app",
47
- version: "9.0.1",
48
- main: "dist/create-keystone-app.cjs.js",
49
- files: [
50
- "dist",
51
- "starter",
52
- "!dist/**/*.d.ts",
53
- "!starter/node_modules"
54
- ],
55
- bin: "./bin.js",
26
+ version: "10.0.0",
56
27
  license: "MIT",
28
+ type: "module",
29
+ main: "dist/create-keystone-app.cjs.js",
30
+ module: "dist/create-keystone-app.esm.js",
31
+ repository: "https://github.com/keystonejs/keystone/tree/main/packages/create",
32
+ bin: "./cli.js",
33
+ exports: {
34
+ ".": {
35
+ module: "./dist/create-keystone-app.esm.js",
36
+ "default": "./dist/create-keystone-app.cjs.js"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ preconstruct: {
41
+ entrypoints: [
42
+ "index.ts"
43
+ ]
44
+ },
57
45
  dependencies: {
58
- "@babel/runtime": "^7.18.9",
59
46
  chalk: "^4.1.2",
60
- enquirer: "^2.3.6",
47
+ enquirer: "^2.4.1",
61
48
  execa: "^5.1.1",
62
- "fs-extra": "^10.1.0",
63
49
  meow: "^9.0.0",
64
- ora: "^5.4.1",
65
- "package-json": "^7.0.0",
66
- semver: "^7.3.7",
67
- "terminal-link": "^2.1.1"
68
- }
50
+ ora: "^8.0.1",
51
+ "package-json": "^10.0.0"
52
+ },
53
+ files: [
54
+ "dist",
55
+ "starter",
56
+ "cli.js"
57
+ ]
69
58
  };
70
59
 
71
60
  async function checkVersion() {
72
- try {
73
- const {
74
- version
75
- } = await getPackageJson__default["default"]('create-keystone-app');
76
- if (typeof version !== 'string') {
77
- throw new Error('version from package metadata was expected to be a string but was not');
78
- }
79
- if (semver__namespace.lt(currentPkgJson.version, version)) {
80
- console.error(`⚠️ You're running an old version of create-keystone-app, please update to ${version}`);
81
- }
82
- } catch (err) {
83
- console.error('A problem occurred fetching the latest version of create-keystone-app');
84
- console.error(err);
85
- }
61
+ const {
62
+ version: upstream
63
+ } = await getPackageJson__default["default"]('create-keystone-app');
64
+ if (upstream === thisPackage.version) return;
65
+ console.error(`⚠️ You're running an old version of create-keystone-app, please update to ${upstream}`);
86
66
  }
87
-
88
67
  class UserError extends Error {}
89
-
90
- const starterDir = path__default["default"].normalize(`${__dirname}/../starter`);
68
+ const __dirname$1 = path__default["default"].dirname(node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('dist/create-keystone-app.cjs.prod.js', document.baseURI).href))));
69
+ const starterDir = path__default["default"].normalize(`${__dirname$1}/../starter`);
91
70
  const cli = meow__default["default"](`
92
71
  Usage
93
72
  $ create-keystone-app [directory]
94
73
  `);
95
- const versionInfo = () => {
96
- process.stdout.write('\n');
97
- console.log(`✨ You're about to generate a project using ${c__default["default"].bold('Keystone 6')} packages.
98
- `);
99
- };
100
74
  async function normalizeArgs() {
101
75
  let directory = cli.input[0];
102
76
  if (!directory) {
@@ -114,42 +88,25 @@ async function normalizeArgs() {
114
88
  directory: path__default["default"].resolve(directory)
115
89
  };
116
90
  }
117
- const installDeps = async cwd => {
118
- const spinner = ora__default["default"]('Installing dependencies with yarn. This may take a few minutes.').start();
91
+ (async (_process$env$npm_conf, _process$env$npm_conf2) => {
92
+ process.stdout.write('\n');
93
+ console.log(`✨ You're about to generate a project using ${c__default["default"].bold('Keystone 6')} packages.`);
94
+ await checkVersion();
95
+ const normalizedArgs = await normalizeArgs();
96
+ const nextCwd = normalizedArgs.directory;
97
+ await fs__default["default"].mkdir(nextCwd);
98
+ await Promise.all(['_gitignore', 'schema.ts', 'package.json', 'tsconfig.json', 'schema.graphql', 'schema.prisma', 'keystone.ts', 'auth.ts', 'README.md'].map(filename => fs__default["default"].copyFile(path__default["default"].join(starterDir, filename), path__default["default"].join(normalizedArgs.directory, filename.replace(/^_/, '.')))));
99
+ const [packageManager] = (_process$env$npm_conf = (_process$env$npm_conf2 = process.env.npm_config_user_agent) === null || _process$env$npm_conf2 === void 0 ? void 0 : _process$env$npm_conf2.split('/', 1)) !== null && _process$env$npm_conf !== void 0 ? _process$env$npm_conf : ['npm'];
100
+ const spinner = ora__default["default"](`Installing dependencies with ${packageManager}. This may take a few minutes.`).start();
119
101
  try {
120
- await execa__default["default"]('yarn', ['install'], {
121
- cwd
102
+ await execa__default["default"](packageManager, ['install'], {
103
+ cwd: nextCwd
122
104
  });
123
- spinner.succeed('Installed dependencies with yarn.');
124
- return 'yarn';
125
- } catch (_err) {
126
- let err = _err;
127
- if (err.failed) {
128
- process.stdout.write('\n');
129
- spinner.warn('Failed to install with yarn.');
130
- spinner.start('Installing dependencies with npm. This may take a few minutes.');
131
- try {
132
- await execa__default["default"]('npm', ['install'], {
133
- cwd
134
- });
135
- spinner.succeed('Installed dependencies with npm.');
136
- } catch (npmErr) {
137
- spinner.fail('Failed to install with npm.');
138
- throw npmErr;
139
- }
140
- process.stdout.write('\n');
141
- return 'npm';
142
- }
105
+ spinner.succeed(`Installed dependencies with ${packageManager}.`);
106
+ } catch (err) {
107
+ spinner.fail(`Failed to install with ${packageManager}.`);
143
108
  throw err;
144
109
  }
145
- };
146
- (async () => {
147
- versionInfo();
148
- await checkVersion();
149
- const normalizedArgs = await normalizeArgs();
150
- await fs__default["default"].mkdir(normalizedArgs.directory);
151
- await Promise.all([...['_gitignore', 'schema.ts', 'package.json', 'tsconfig.json', 'schema.graphql', 'schema.prisma', 'keystone.ts', 'auth.ts', 'README.md'].map(filename => fs__default["default"].copyFile(path__default["default"].join(starterDir, filename), path__default["default"].join(normalizedArgs.directory, filename.replace(/^_/, '.'))))]);
152
- const packageManager = await installDeps(normalizedArgs.directory);
153
110
  const relativeProjectDir = path__default["default"].relative(process.cwd(), normalizedArgs.directory);
154
111
  process.stdout.write('\n');
155
112
  console.log(`🎉 Keystone created a starter project in: ${c__default["default"].bold(relativeProjectDir)}
@@ -157,16 +114,14 @@ const installDeps = async cwd => {
157
114
  ${c__default["default"].bold('To launch your app, run:')}
158
115
 
159
116
  - cd ${relativeProjectDir}
160
- - ${packageManager === 'yarn' ? 'yarn' : 'npm run'} dev
117
+ - ${packageManager} run dev
161
118
 
162
119
  ${c__default["default"].bold('Next steps:')}
163
120
 
164
121
  - Read ${c__default["default"].bold(`${relativeProjectDir}${path__default["default"].sep}README.md`)} for additional getting started details.
165
122
  - Edit ${c__default["default"].bold(`${relativeProjectDir}${path__default["default"].sep}keystone.ts`)} to customize your app.
166
- - ${terminalLink__default["default"]('Open the Admin UI', 'http://localhost:3000')}
167
- - ${terminalLink__default["default"]('Open the Graphql API', 'http://localhost:3000/api/graphql')}
168
- - ${terminalLink__default["default"]('Read the docs', 'https://next.keystonejs.com')}
169
- - ${terminalLink__default["default"]('Star Keystone on GitHub', 'https://github.com/keystonejs/keystone')}
123
+ - Star Keystone on GitHub (https://github.com/keystonejs/keystone)
124
+ )}
170
125
  `);
171
126
  })().catch(err => {
172
127
  if (err instanceof UserError) {
@@ -0,0 +1,120 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import c from 'chalk';
5
+ import enquirer from 'enquirer';
6
+ import execa from 'execa';
7
+ import getPackageJson from 'package-json';
8
+ import meow from 'meow';
9
+ import ora from 'ora';
10
+
11
+ var thisPackage = {
12
+ name: "create-keystone-app",
13
+ version: "10.0.0",
14
+ license: "MIT",
15
+ type: "module",
16
+ main: "dist/create-keystone-app.cjs.js",
17
+ module: "dist/create-keystone-app.esm.js",
18
+ repository: "https://github.com/keystonejs/keystone/tree/main/packages/create",
19
+ bin: "./cli.js",
20
+ exports: {
21
+ ".": {
22
+ module: "./dist/create-keystone-app.esm.js",
23
+ "default": "./dist/create-keystone-app.cjs.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ preconstruct: {
28
+ entrypoints: [
29
+ "index.ts"
30
+ ]
31
+ },
32
+ dependencies: {
33
+ chalk: "^4.1.2",
34
+ enquirer: "^2.4.1",
35
+ execa: "^5.1.1",
36
+ meow: "^9.0.0",
37
+ ora: "^8.0.1",
38
+ "package-json": "^10.0.0"
39
+ },
40
+ files: [
41
+ "dist",
42
+ "starter",
43
+ "cli.js"
44
+ ]
45
+ };
46
+
47
+ async function checkVersion() {
48
+ const {
49
+ version: upstream
50
+ } = await getPackageJson('create-keystone-app');
51
+ if (upstream === thisPackage.version) return;
52
+ console.error(`⚠️ You're running an old version of create-keystone-app, please update to ${upstream}`);
53
+ }
54
+ class UserError extends Error {}
55
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
56
+ const starterDir = path.normalize(`${__dirname}/../starter`);
57
+ const cli = meow(`
58
+ Usage
59
+ $ create-keystone-app [directory]
60
+ `);
61
+ async function normalizeArgs() {
62
+ let directory = cli.input[0];
63
+ if (!directory) {
64
+ ({
65
+ directory
66
+ } = await enquirer.prompt({
67
+ type: 'input',
68
+ name: 'directory',
69
+ message: 'What directory should create-keystone-app generate your app into?',
70
+ validate: x => !!x
71
+ }));
72
+ process.stdout.write('\n');
73
+ }
74
+ return {
75
+ directory: path.resolve(directory)
76
+ };
77
+ }
78
+ (async (_process$env$npm_conf, _process$env$npm_conf2) => {
79
+ process.stdout.write('\n');
80
+ console.log(`✨ You're about to generate a project using ${c.bold('Keystone 6')} packages.`);
81
+ await checkVersion();
82
+ const normalizedArgs = await normalizeArgs();
83
+ const nextCwd = normalizedArgs.directory;
84
+ await fs.mkdir(nextCwd);
85
+ await Promise.all(['_gitignore', 'schema.ts', 'package.json', 'tsconfig.json', 'schema.graphql', 'schema.prisma', 'keystone.ts', 'auth.ts', 'README.md'].map(filename => fs.copyFile(path.join(starterDir, filename), path.join(normalizedArgs.directory, filename.replace(/^_/, '.')))));
86
+ const [packageManager] = (_process$env$npm_conf = (_process$env$npm_conf2 = process.env.npm_config_user_agent) === null || _process$env$npm_conf2 === void 0 ? void 0 : _process$env$npm_conf2.split('/', 1)) !== null && _process$env$npm_conf !== void 0 ? _process$env$npm_conf : ['npm'];
87
+ const spinner = ora(`Installing dependencies with ${packageManager}. This may take a few minutes.`).start();
88
+ try {
89
+ await execa(packageManager, ['install'], {
90
+ cwd: nextCwd
91
+ });
92
+ spinner.succeed(`Installed dependencies with ${packageManager}.`);
93
+ } catch (err) {
94
+ spinner.fail(`Failed to install with ${packageManager}.`);
95
+ throw err;
96
+ }
97
+ const relativeProjectDir = path.relative(process.cwd(), normalizedArgs.directory);
98
+ process.stdout.write('\n');
99
+ console.log(`🎉 Keystone created a starter project in: ${c.bold(relativeProjectDir)}
100
+
101
+ ${c.bold('To launch your app, run:')}
102
+
103
+ - cd ${relativeProjectDir}
104
+ - ${packageManager} run dev
105
+
106
+ ${c.bold('Next steps:')}
107
+
108
+ - Read ${c.bold(`${relativeProjectDir}${path.sep}README.md`)} for additional getting started details.
109
+ - Edit ${c.bold(`${relativeProjectDir}${path.sep}keystone.ts`)} to customize your app.
110
+ - Star Keystone on GitHub (https://github.com/keystonejs/keystone)
111
+ )}
112
+ `);
113
+ })().catch(err => {
114
+ if (err instanceof UserError) {
115
+ console.error(err.message);
116
+ } else {
117
+ console.error(err);
118
+ }
119
+ process.exit(1);
120
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,25 +1,35 @@
1
1
  {
2
2
  "name": "create-keystone-app",
3
- "version": "9.0.1",
4
- "main": "dist/create-keystone-app.cjs.js",
5
- "files": [
6
- "dist",
7
- "starter",
8
- "!dist/**/*.d.ts",
9
- "!starter/node_modules"
10
- ],
11
- "bin": "./bin.js",
3
+ "version": "10.0.0",
12
4
  "license": "MIT",
5
+ "type": "module",
6
+ "main": "dist/create-keystone-app.cjs.js",
7
+ "module": "dist/create-keystone-app.esm.js",
8
+ "repository": "https://github.com/keystonejs/keystone/tree/main/packages/create",
9
+ "bin": "./cli.js",
10
+ "exports": {
11
+ ".": {
12
+ "module": "./dist/create-keystone-app.esm.js",
13
+ "default": "./dist/create-keystone-app.cjs.js"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "preconstruct": {
18
+ "entrypoints": [
19
+ "index.ts"
20
+ ]
21
+ },
13
22
  "dependencies": {
14
- "@babel/runtime": "^7.18.9",
15
23
  "chalk": "^4.1.2",
16
- "enquirer": "^2.3.6",
24
+ "enquirer": "^2.4.1",
17
25
  "execa": "^5.1.1",
18
- "fs-extra": "^10.1.0",
19
26
  "meow": "^9.0.0",
20
- "ora": "^5.4.1",
21
- "package-json": "^7.0.0",
22
- "semver": "^7.3.7",
23
- "terminal-link": "^2.1.1"
24
- }
25
- }
27
+ "ora": "^8.0.1",
28
+ "package-json": "^10.0.0"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "starter",
33
+ "cli.js"
34
+ ]
35
+ }
package/starter/README.md CHANGED
@@ -5,7 +5,7 @@ Welcome to Keystone!
5
5
  Run
6
6
 
7
7
  ```
8
- yarn dev
8
+ npm run dev
9
9
  ```
10
10
 
11
11
  To view the config for your new app, look at [./keystone.ts](./keystone.ts)
@@ -1,4 +1,4 @@
1
1
  node_modules
2
- .keystone/admin
2
+ .keystone/
3
3
  keystone.db
4
- *.log
4
+ *.log
package/starter/auth.ts CHANGED
@@ -15,17 +15,17 @@
15
15
  // If you want to learn more about how our out-of-the-box authentication works, please
16
16
  // read https://keystonejs.com/docs/apis/auth#authentication-api
17
17
 
18
- import { randomBytes } from 'crypto';
19
- import { createAuth } from '@keystone-6/auth';
18
+ import { randomBytes } from 'node:crypto'
19
+ import { createAuth } from '@keystone-6/auth'
20
20
 
21
21
  // see https://keystonejs.com/docs/apis/session for the session docs
22
- import { statelessSessions } from '@keystone-6/core/session';
22
+ import { statelessSessions } from '@keystone-6/core/session'
23
23
 
24
24
  // for a stateless session, a SESSION_SECRET should always be provided
25
25
  // especially in production (statelessSessions will throw if SESSION_SECRET is undefined)
26
- let sessionSecret = process.env.SESSION_SECRET;
26
+ let sessionSecret = process.env.SESSION_SECRET
27
27
  if (!sessionSecret && process.env.NODE_ENV !== 'production') {
28
- sessionSecret = randomBytes(32).toString('hex');
28
+ sessionSecret = randomBytes(32).toString('hex')
29
29
  }
30
30
 
31
31
  // withAuth is a function we can use to wrap our base configuration
@@ -50,17 +50,17 @@ const { withAuth } = createAuth({
50
50
  // it uses context.sudo() to do this, which bypasses any access control you might have
51
51
  // you shouldn't use this in production
52
52
  },
53
- });
53
+ })
54
54
 
55
55
  // statelessSessions uses cookies for session tracking
56
56
  // these cookies have an expiry, in seconds
57
57
  // we use an expiry of 30 days for this starter
58
- const sessionMaxAge = 60 * 60 * 24 * 30;
58
+ const sessionMaxAge = 60 * 60 * 24 * 30
59
59
 
60
60
  // you can find out more at https://keystonejs.com/docs/apis/session#session-api
61
61
  const session = statelessSessions({
62
62
  maxAge: sessionMaxAge,
63
63
  secret: sessionSecret!,
64
- });
64
+ })
65
65
 
66
- export { withAuth, session };
66
+ export { withAuth, session }
@@ -5,14 +5,14 @@
5
5
  // Keystone imports the default export of this file, expecting a Keystone configuration object
6
6
  // you can find out more at https://keystonejs.com/docs/apis/config
7
7
 
8
- import { config } from '@keystone-6/core';
8
+ import { config } from '@keystone-6/core'
9
9
 
10
10
  // to keep this file tidy, we define our schema in a different file
11
- import { lists } from './schema';
11
+ import { lists } from './schema'
12
12
 
13
13
  // authentication is configured separately here too, but you might move this elsewhere
14
14
  // when you write your list-level access control functions, as they typically rely on session data
15
- import { withAuth, session } from './auth';
15
+ import { withAuth, session } from './auth'
16
16
 
17
17
  export default withAuth(
18
18
  config({
@@ -26,4 +26,4 @@ export default withAuth(
26
26
  lists,
27
27
  session,
28
28
  })
29
- );
29
+ )
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keystone-app",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "keystone dev",
@@ -9,9 +9,9 @@
9
9
  "postinstall": "keystone build --no-ui --frozen"
10
10
  },
11
11
  "dependencies": {
12
- "@keystone-6/auth": "^7.0.0",
13
- "@keystone-6/core": "^5.0.0",
14
- "@keystone-6/fields-document": "^7.0.0",
15
- "typescript": "^4.9.5"
12
+ "@keystone-6/auth": "^8.0.0",
13
+ "@keystone-6/core": "^6.0.0",
14
+ "@keystone-6/fields-document": "^9.0.0",
15
+ "typescript": "^5.5.0"
16
16
  }
17
17
  }
package/starter/schema.ts CHANGED
@@ -5,8 +5,8 @@
5
5
  // If you want to learn more about how lists are configured, please read
6
6
  // - https://keystonejs.com/docs/config/lists
7
7
 
8
- import { list } from '@keystone-6/core';
9
- import { allowAll } from '@keystone-6/core/access';
8
+ import { list } from '@keystone-6/core'
9
+ import { allowAll } from '@keystone-6/core/access'
10
10
 
11
11
  // see https://keystonejs.com/docs/fields/overview for the full list of fields
12
12
  // this is a few common fields for an example
@@ -16,17 +16,17 @@ import {
16
16
  password,
17
17
  timestamp,
18
18
  select,
19
- } from '@keystone-6/core/fields';
19
+ } from '@keystone-6/core/fields'
20
20
 
21
21
  // the document field is a more complicated field, so it has it's own package
22
- import { document } from '@keystone-6/fields-document';
22
+ import { document } from '@keystone-6/fields-document'
23
23
  // if you want to make your own fields, see https://keystonejs.com/docs/guides/custom-fields
24
24
 
25
25
  // when using Typescript, you can refine your types to a stricter subset by importing
26
26
  // the generated types from '.keystone/types'
27
- import type { Lists } from '.keystone/types';
27
+ import { type Lists } from '.keystone/types'
28
28
 
29
- export const lists: Lists = {
29
+ export const lists = {
30
30
  User: list({
31
31
  // WARNING
32
32
  // for this starter project, anyone can create, query, update and delete anything
@@ -146,4 +146,4 @@ export const lists: Lists = {
146
146
  posts: relationship({ ref: 'Post.tags', many: true }),
147
147
  },
148
148
  }),
149
- };
149
+ } satisfies Lists
package/bin.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- require('.');
@@ -1,186 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // keystone.ts
21
- var keystone_exports = {};
22
- __export(keystone_exports, {
23
- default: () => keystone_default
24
- });
25
- module.exports = __toCommonJS(keystone_exports);
26
- var import_core2 = require("@keystone-6/core");
27
-
28
- // schema.ts
29
- var import_core = require("@keystone-6/core");
30
- var import_access = require("@keystone-6/core/access");
31
- var import_fields = require("@keystone-6/core/fields");
32
- var import_fields_document = require("@keystone-6/fields-document");
33
- var lists = {
34
- User: (0, import_core.list)({
35
- // WARNING
36
- // for this starter project, anyone can create, query, update and delete anything
37
- // if you want to prevent random people on the internet from accessing your data,
38
- // you can find out more at https://keystonejs.com/docs/guides/auth-and-access-control
39
- access: import_access.allowAll,
40
- // this is the fields for our User list
41
- fields: {
42
- // by adding isRequired, we enforce that every User should have a name
43
- // if no name is provided, an error will be displayed
44
- name: (0, import_fields.text)({ validation: { isRequired: true } }),
45
- email: (0, import_fields.text)({
46
- validation: { isRequired: true },
47
- // by adding isIndexed: 'unique', we're saying that no user can have the same
48
- // email as another user - this may or may not be a good idea for your project
49
- isIndexed: "unique"
50
- }),
51
- password: (0, import_fields.password)({ validation: { isRequired: true } }),
52
- // we can use this field to see what Posts this User has authored
53
- // more on that in the Post list below
54
- posts: (0, import_fields.relationship)({ ref: "Post.author", many: true }),
55
- createdAt: (0, import_fields.timestamp)({
56
- // this sets the timestamp to Date.now() when the user is first created
57
- defaultValue: { kind: "now" }
58
- })
59
- }
60
- }),
61
- Post: (0, import_core.list)({
62
- // WARNING
63
- // for this starter project, anyone can create, query, update and delete anything
64
- // if you want to prevent random people on the internet from accessing your data,
65
- // you can find out more at https://keystonejs.com/docs/guides/auth-and-access-control
66
- access: import_access.allowAll,
67
- // this is the fields for our Post list
68
- fields: {
69
- title: (0, import_fields.text)({ validation: { isRequired: true } }),
70
- // the document field can be used for making rich editable content
71
- // you can find out more at https://keystonejs.com/docs/guides/document-fields
72
- content: (0, import_fields_document.document)({
73
- formatting: true,
74
- layouts: [
75
- [1, 1],
76
- [1, 1, 1],
77
- [2, 1],
78
- [1, 2],
79
- [1, 2, 1]
80
- ],
81
- links: true,
82
- dividers: true
83
- }),
84
- // with this field, you can set a User as the author for a Post
85
- author: (0, import_fields.relationship)({
86
- // we could have used 'User', but then the relationship would only be 1-way
87
- ref: "User.posts",
88
- // this is some customisations for changing how this will look in the AdminUI
89
- ui: {
90
- displayMode: "cards",
91
- cardFields: ["name", "email"],
92
- inlineEdit: { fields: ["name", "email"] },
93
- linkToItem: true,
94
- inlineConnect: true
95
- },
96
- // a Post can only have one author
97
- // this is the default, but we show it here for verbosity
98
- many: false
99
- }),
100
- // with this field, you can add some Tags to Posts
101
- tags: (0, import_fields.relationship)({
102
- // we could have used 'Tag', but then the relationship would only be 1-way
103
- ref: "Tag.posts",
104
- // a Post can have many Tags, not just one
105
- many: true,
106
- // this is some customisations for changing how this will look in the AdminUI
107
- ui: {
108
- displayMode: "cards",
109
- cardFields: ["name"],
110
- inlineEdit: { fields: ["name"] },
111
- linkToItem: true,
112
- inlineConnect: true,
113
- inlineCreate: { fields: ["name"] }
114
- }
115
- })
116
- }
117
- }),
118
- // this last list is our Tag list, it only has a name field for now
119
- Tag: (0, import_core.list)({
120
- // WARNING
121
- // for this starter project, anyone can create, query, update and delete anything
122
- // if you want to prevent random people on the internet from accessing your data,
123
- // you can find out more at https://keystonejs.com/docs/guides/auth-and-access-control
124
- access: import_access.allowAll,
125
- // setting this to isHidden for the user interface prevents this list being visible in the Admin UI
126
- ui: {
127
- isHidden: true
128
- },
129
- // this is the fields for our Tag list
130
- fields: {
131
- name: (0, import_fields.text)(),
132
- // this can be helpful to find out all the Posts associated with a Tag
133
- posts: (0, import_fields.relationship)({ ref: "Post.tags", many: true })
134
- }
135
- })
136
- };
137
-
138
- // auth.ts
139
- var import_crypto = require("crypto");
140
- var import_auth = require("@keystone-6/auth");
141
- var import_session = require("@keystone-6/core/session");
142
- var sessionSecret = process.env.SESSION_SECRET;
143
- if (!sessionSecret && process.env.NODE_ENV !== "production") {
144
- sessionSecret = (0, import_crypto.randomBytes)(32).toString("hex");
145
- }
146
- var { withAuth } = (0, import_auth.createAuth)({
147
- listKey: "User",
148
- identityField: "email",
149
- // this is a GraphQL query fragment for fetching what data will be attached to a context.session
150
- // this can be helpful for when you are writing your access control functions
151
- // you can find out more at https://keystonejs.com/docs/guides/auth-and-access-control
152
- sessionData: "name createdAt",
153
- secretField: "password",
154
- // WARNING: remove initFirstItem functionality in production
155
- // see https://keystonejs.com/docs/config/auth#init-first-item for more
156
- initFirstItem: {
157
- // if there are no items in the database, by configuring this field
158
- // you are asking the Keystone AdminUI to create a new user
159
- // providing inputs for these fields
160
- fields: ["name", "email", "password"]
161
- // it uses context.sudo() to do this, which bypasses any access control you might have
162
- // you shouldn't use this in production
163
- }
164
- });
165
- var sessionMaxAge = 60 * 60 * 24 * 30;
166
- var session = (0, import_session.statelessSessions)({
167
- maxAge: sessionMaxAge,
168
- secret: sessionSecret
169
- });
170
-
171
- // keystone.ts
172
- var keystone_default = withAuth(
173
- (0, import_core2.config)({
174
- db: {
175
- // we're using sqlite for the fastest startup experience
176
- // for more information on what database might be appropriate for you
177
- // see https://keystonejs.com/docs/guides/choosing-a-database#title
178
- provider: "sqlite",
179
- url: "file:./keystone.db"
180
- },
181
- lists,
182
- session
183
- })
184
- );
185
- // Annotate the CommonJS export names for ESM import in node:
186
- 0 && (module.exports = {});
@@ -1,17 +0,0 @@
1
- # keystone-app
2
-
3
- ## 1.0.2
4
-
5
- ### Patch Changes
6
-
7
- - [`3b4360a`](https://github.com/keystonejs/create-keystone-app/commit/3b4360a114f00094e40fdc89dd4c82e1456b9ae5) Thanks [@dcousens](https://github.com/dcousens)! - Fix graphql@^15.8.0 and next@12.2.4 as pseudo-peer dependencies until next `@keystone-6/core` release
8
-
9
- ## 1.0.1
10
-
11
- ### Patch Changes
12
-
13
- - [#278](https://github.com/keystonejs/create-keystone-app/pull/278) [`26f9a79`](https://github.com/keystonejs/create-keystone-app/commit/26f9a79ef913915bac85657884f85ff7e4da46c2) Thanks [@Noviny](https://github.com/Noviny)! - Improve schema options for linking authors to posts:
14
- - Add `inlineConnect: true` to the post's relationship to users
15
- - Remove authors from being inline-creatable
16
-
17
- * [#319](https://github.com/keystonejs/create-keystone-app/pull/319) [`94a859e`](https://github.com/keystonejs/create-keystone-app/commit/94a859e43123d2f348d5e21551d59bd7e257aa81) Thanks [@Achisingh](https://github.com/Achisingh)! - Fix dependencies and update schemas for the latest `keystone-6` release