create-keystone-app 10.0.3 → 11.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/cli.js +1 -1
- package/dist/create-keystone-app.d.ts +2 -0
- package/dist/{create-keystone-app.esm.js → create-keystone-app.js} +13 -57
- package/package.json +11 -14
- package/starter/README.md +17 -8
- package/starter/_gitignore +1 -0
- package/starter/auth.ts +0 -13
- package/starter/keystone.ts +37 -3
- package/starter/package.json +11 -4
- package/starter/prisma.config.ts +11 -0
- package/starter/schema.ts +6 -11
- package/dist/create-keystone-app.cjs.d.ts +0 -2
- package/dist/create-keystone-app.cjs.dev.js +0 -132
- package/dist/create-keystone-app.cjs.js +0 -7
- package/dist/create-keystone-app.cjs.prod.js +0 -132
package/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import '
|
|
2
|
+
import 'create-keystone-app'
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLWtleXN0b25lLWFwcC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -1,50 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import
|
|
4
|
+
import { styleText } from 'node:util';
|
|
5
5
|
import enquirer from 'enquirer';
|
|
6
|
-
import execa from 'execa';
|
|
7
6
|
import getPackageJson from 'package-json';
|
|
8
7
|
import meow from 'meow';
|
|
9
|
-
import ora from 'ora';
|
|
10
|
-
|
|
11
|
-
var thisPackage = {
|
|
12
|
-
name: "create-keystone-app",
|
|
13
|
-
version: "10.0.3",
|
|
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
8
|
|
|
47
9
|
async function checkVersion() {
|
|
10
|
+
const thisPackage = JSON.parse(await fs.readFile(new URL('../package.json', import.meta.url), 'utf-8'));
|
|
48
11
|
const {
|
|
49
12
|
version: upstream
|
|
50
13
|
} = await getPackageJson('create-keystone-app');
|
|
@@ -57,7 +20,9 @@ const starterDir = path.normalize(`${__dirname}/../starter`);
|
|
|
57
20
|
const cli = meow(`
|
|
58
21
|
Usage
|
|
59
22
|
$ create-keystone-app [directory]
|
|
60
|
-
|
|
23
|
+
`, {
|
|
24
|
+
importMeta: import.meta
|
|
25
|
+
});
|
|
61
26
|
async function normalizeArgs() {
|
|
62
27
|
let directory = cli.input[0];
|
|
63
28
|
if (!directory) {
|
|
@@ -77,36 +42,27 @@ async function normalizeArgs() {
|
|
|
77
42
|
}
|
|
78
43
|
(async (_process$env$npm_conf, _process$env$npm_conf2) => {
|
|
79
44
|
process.stdout.write('\n');
|
|
80
|
-
console.log(`✨ You're about to generate a project using ${
|
|
45
|
+
console.log(`✨ You're about to generate a project using ${styleText('bold', 'Keystone 6')} packages.`);
|
|
81
46
|
await checkVersion();
|
|
82
47
|
const normalizedArgs = await normalizeArgs();
|
|
83
48
|
const nextCwd = normalizedArgs.directory;
|
|
84
49
|
await fs.mkdir(nextCwd);
|
|
85
|
-
await Promise.all(['_gitignore', 'schema.ts', 'package.json', 'tsconfig.json', 'keystone.ts', 'auth.ts', 'README.md'].map(filename => fs.copyFile(path.join(starterDir, filename), path.join(normalizedArgs.directory, filename.replace(/^_/, '.')))));
|
|
50
|
+
await Promise.all(['_gitignore', 'schema.ts', 'package.json', 'prisma.config.ts', 'tsconfig.json', 'keystone.ts', 'auth.ts', 'README.md'].map(filename => fs.copyFile(path.join(starterDir, filename), path.join(normalizedArgs.directory, filename.replace(/^_/, '.')))));
|
|
86
51
|
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
52
|
const relativeProjectDir = path.relative(process.cwd(), normalizedArgs.directory);
|
|
98
53
|
process.stdout.write('\n');
|
|
99
|
-
console.log(`🎉 Keystone created a starter project in: ${
|
|
54
|
+
console.log(`🎉 Keystone created a starter project in: ${styleText('bold', relativeProjectDir)}
|
|
100
55
|
|
|
101
|
-
${
|
|
56
|
+
${styleText('bold', 'To install dependencies and launch your app, run:')}
|
|
102
57
|
|
|
103
58
|
- cd ${relativeProjectDir}
|
|
59
|
+
- ${packageManager} install
|
|
104
60
|
- ${packageManager} run dev
|
|
105
61
|
|
|
106
|
-
${
|
|
62
|
+
${styleText('bold', 'Next steps:')}
|
|
107
63
|
|
|
108
|
-
- Read ${
|
|
109
|
-
- Edit ${
|
|
64
|
+
- Read ${styleText('bold', `${relativeProjectDir}${path.sep}README.md`)} for additional getting started details.
|
|
65
|
+
- Edit ${styleText('bold', `${relativeProjectDir}${path.sep}keystone.ts`)} to customize your app.
|
|
110
66
|
- Star Keystone on GitHub (https://github.com/keystonejs/keystone)
|
|
111
67
|
`);
|
|
112
68
|
})().catch(err => {
|
package/package.json
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-keystone-app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/keystonejs/keystone/tree/main/packages/create"
|
|
9
|
+
},
|
|
10
10
|
"exports": {
|
|
11
|
-
".":
|
|
12
|
-
"module": "./dist/create-keystone-app.esm.js",
|
|
13
|
-
"default": "./dist/create-keystone-app.cjs.js"
|
|
14
|
-
},
|
|
11
|
+
".": "./dist/create-keystone-app.js",
|
|
15
12
|
"./package.json": "./package.json"
|
|
16
13
|
},
|
|
17
14
|
"preconstruct": {
|
|
@@ -20,16 +17,16 @@
|
|
|
20
17
|
]
|
|
21
18
|
},
|
|
22
19
|
"dependencies": {
|
|
23
|
-
"chalk": "^4.1.2",
|
|
24
20
|
"enquirer": "^2.4.1",
|
|
25
|
-
"
|
|
26
|
-
"meow": "^9.0.0",
|
|
27
|
-
"ora": "^8.0.1",
|
|
21
|
+
"meow": "^14.1.0",
|
|
28
22
|
"package-json": "^10.0.0"
|
|
29
23
|
},
|
|
30
24
|
"files": [
|
|
31
25
|
"dist",
|
|
32
26
|
"starter",
|
|
33
27
|
"cli.js"
|
|
34
|
-
]
|
|
28
|
+
],
|
|
29
|
+
"bin": {
|
|
30
|
+
"create-keystone-app": "./cli.js"
|
|
31
|
+
}
|
|
35
32
|
}
|
package/starter/README.md
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Welcome to Keystone!
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Install dependencies and start Keystone:
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
+
npm install
|
|
8
9
|
npm run dev
|
|
9
10
|
```
|
|
10
11
|
|
|
@@ -12,7 +13,7 @@ To view the config for your new app, look at [./keystone.ts](./keystone.ts)
|
|
|
12
13
|
|
|
13
14
|
This project starter is designed to give you a sense of the power Keystone can offer you, and show off some of its main features. It's also a pretty simple setup if you want to build out from it.
|
|
14
15
|
|
|
15
|
-
We recommend you use this alongside our [getting started
|
|
16
|
+
We recommend you use this alongside our [getting started guide](https://keystonejs.com/docs/getting-started), which will walk you through what you get as part of this starter.
|
|
16
17
|
|
|
17
18
|
If you want an overview of all the features Keystone offers, check out our [features](https://keystonejs.com/why-keystone#features) page.
|
|
18
19
|
|
|
@@ -20,20 +21,28 @@ If you want an overview of all the features Keystone offers, check out our [feat
|
|
|
20
21
|
|
|
21
22
|
### Changing the database
|
|
22
23
|
|
|
23
|
-
We've set you up with an [SQLite database](https://keystonejs.com/docs/
|
|
24
|
+
We've set you up with an [SQLite database](https://keystonejs.com/docs/config/config#sqlite) for ease of use. To switch to PostgreSQL, install its Prisma adapter and driver:
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
```shell
|
|
27
|
+
npm install @prisma/adapter-pg pg
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Import `PrismaPg` and replace the `db` property in [./keystone.ts](./keystone.ts):
|
|
26
31
|
|
|
27
32
|
```typescript
|
|
33
|
+
import { PrismaPg } from '@prisma/adapter-pg'
|
|
34
|
+
|
|
28
35
|
db: {
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
provider: 'postgresql',
|
|
37
|
+
prismaClientOptions: () => ({
|
|
38
|
+
adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL! }),
|
|
39
|
+
}),
|
|
31
40
|
}
|
|
32
41
|
```
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
Also change the `datasource.url` in [./prisma.config.ts](./prisma.config.ts) to `process.env.DATABASE_URL`. The Prisma CLI reads its connection URL from that file for migrations, while Keystone's runtime uses the adapter configured above.
|
|
35
44
|
|
|
36
|
-
For more on database configuration,
|
|
45
|
+
For more on database configuration, see the [database configuration docs](https://keystonejs.com/docs/config/config#db).
|
|
37
46
|
|
|
38
47
|
### Auth
|
|
39
48
|
|
package/starter/_gitignore
CHANGED
package/starter/auth.ts
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
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 'node:crypto'
|
|
19
18
|
import { createAuth } from '@keystone-6/auth'
|
|
20
19
|
|
|
21
20
|
// see https://keystonejs.com/docs/apis/session for the session docs
|
|
@@ -31,18 +30,6 @@ const { withAuth } = createAuth({
|
|
|
31
30
|
// you can find out more at https://keystonejs.com/docs/guides/auth-and-access-control
|
|
32
31
|
sessionData: 'name createdAt',
|
|
33
32
|
secretField: 'password',
|
|
34
|
-
|
|
35
|
-
// WARNING: remove initFirstItem functionality in production
|
|
36
|
-
// see https://keystonejs.com/docs/config/auth#init-first-item for more
|
|
37
|
-
initFirstItem: {
|
|
38
|
-
// if there are no items in the database, by configuring this field
|
|
39
|
-
// you are asking the Keystone AdminUI to create a new user
|
|
40
|
-
// providing inputs for these fields
|
|
41
|
-
fields: ['name', 'email', 'password'],
|
|
42
|
-
|
|
43
|
-
// it uses context.sudo() to do this, which bypasses any access control you might have
|
|
44
|
-
// you shouldn't use this in production
|
|
45
|
-
},
|
|
46
33
|
})
|
|
47
34
|
|
|
48
35
|
// statelessSessions uses cookies for session tracking
|
package/starter/keystone.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3'
|
|
1
2
|
// Welcome to Keystone!
|
|
2
3
|
//
|
|
3
4
|
// This file is what Keystone uses as the entry-point to your headless backend
|
|
@@ -8,11 +9,11 @@
|
|
|
8
9
|
import { config } from '@keystone-6/core'
|
|
9
10
|
|
|
10
11
|
// to keep this file tidy, we define our schema in a different file
|
|
11
|
-
import { lists } from './schema'
|
|
12
|
+
import { lists } from './schema.ts'
|
|
12
13
|
|
|
13
14
|
// authentication is configured separately here too, but you might move this elsewhere
|
|
14
15
|
// when you write your list-level access control functions, as they typically rely on session data
|
|
15
|
-
import { withAuth, session } from './auth'
|
|
16
|
+
import { withAuth, session } from './auth.ts'
|
|
16
17
|
|
|
17
18
|
export default withAuth(
|
|
18
19
|
config({
|
|
@@ -21,7 +22,40 @@ export default withAuth(
|
|
|
21
22
|
// for more information on what database might be appropriate for you
|
|
22
23
|
// see https://keystonejs.com/docs/guides/choosing-a-database#title
|
|
23
24
|
provider: 'sqlite',
|
|
24
|
-
|
|
25
|
+
prismaClientOptions: () => ({
|
|
26
|
+
adapter: new PrismaBetterSqlite3({ url: 'file:./keystone.db' }),
|
|
27
|
+
}),
|
|
28
|
+
async onConnect(context) {
|
|
29
|
+
// this creates an initial user if none exist so you can log in for development
|
|
30
|
+
// WARNING: do not use this in production
|
|
31
|
+
;(async () => {
|
|
32
|
+
const sudoContext = context.sudo()
|
|
33
|
+
if ((await sudoContext.db.User.count()) !== 0) return
|
|
34
|
+
|
|
35
|
+
const password = crypto.getRandomValues(new Uint8Array(16)).toHex()
|
|
36
|
+
await sudoContext.db.User.createOne({
|
|
37
|
+
data: { name: 'admin', email: 'admin@example.com', password },
|
|
38
|
+
})
|
|
39
|
+
console.log(`Created initial user: admin@example.com / ${password}`)
|
|
40
|
+
})().catch(error => console.error('Failed to create initial user:', error))
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
apolloConfig: {
|
|
44
|
+
plugins: [
|
|
45
|
+
{
|
|
46
|
+
async requestDidStart(requestContext) {
|
|
47
|
+
console.log(
|
|
48
|
+
'graphql operation',
|
|
49
|
+
requestContext.request.operationName ?? '(unnamed operation)'
|
|
50
|
+
)
|
|
51
|
+
return {
|
|
52
|
+
async didEncounterErrors(requestContext) {
|
|
53
|
+
console.error(...requestContext.errors)
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
25
59
|
},
|
|
26
60
|
lists,
|
|
27
61
|
session,
|
package/starter/package.json
CHANGED
|
@@ -8,9 +8,16 @@
|
|
|
8
8
|
"build": "keystone build"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@keystone-6/auth": "^
|
|
12
|
-
"@keystone-6/core": "^
|
|
13
|
-
"@keystone-6/fields-document": "^
|
|
14
|
-
"
|
|
11
|
+
"@keystone-6/auth": "^10.0.0",
|
|
12
|
+
"@keystone-6/core": "^8.0.0",
|
|
13
|
+
"@keystone-6/fields-document": "^11.0.0",
|
|
14
|
+
"@prisma/adapter-better-sqlite3": "^7.9.0",
|
|
15
|
+
"@prisma/client": "^7.9.0",
|
|
16
|
+
"next": "^16.2.10",
|
|
17
|
+
"react": "^19.2.4",
|
|
18
|
+
"react-dom": "^19.2.4",
|
|
19
|
+
"prisma": "^7.9.0",
|
|
20
|
+
"typescript": "^6.0.0",
|
|
21
|
+
"better-sqlite3": "^12.6.0"
|
|
15
22
|
}
|
|
16
23
|
}
|
package/starter/schema.ts
CHANGED
|
@@ -10,21 +10,15 @@ 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
|
|
13
|
-
import {
|
|
14
|
-
text,
|
|
15
|
-
relationship,
|
|
16
|
-
password,
|
|
17
|
-
timestamp,
|
|
18
|
-
select,
|
|
19
|
-
} from '@keystone-6/core/fields'
|
|
13
|
+
import { text, relationship, password, timestamp, select } from '@keystone-6/core/fields'
|
|
20
14
|
|
|
21
15
|
// the document field is a more complicated field, so it has it's own package
|
|
22
16
|
import { document } from '@keystone-6/fields-document'
|
|
23
17
|
// if you want to make your own fields, see https://keystonejs.com/docs/guides/custom-fields
|
|
24
18
|
|
|
25
19
|
// when using Typescript, you can refine your types to a stricter subset by importing
|
|
26
|
-
// the generated types from '
|
|
27
|
-
import {
|
|
20
|
+
// the generated types from './generated/keystone/types'
|
|
21
|
+
import type { Lists } from './generated/keystone/types'
|
|
28
22
|
|
|
29
23
|
export const lists = {
|
|
30
24
|
User: list({
|
|
@@ -130,13 +124,14 @@ export const lists = {
|
|
|
130
124
|
Tag: list({
|
|
131
125
|
// WARNING
|
|
132
126
|
// for this starter project, anyone can create, query, update and delete anything
|
|
127
|
+
//
|
|
133
128
|
// if you want to prevent random people on the internet from accessing your data,
|
|
134
129
|
// you can find out more at https://keystonejs.com/docs/guides/auth-and-access-control
|
|
135
130
|
access: allowAll,
|
|
136
131
|
|
|
137
|
-
//
|
|
132
|
+
// dont show this list in the AdminUI
|
|
138
133
|
ui: {
|
|
139
|
-
|
|
134
|
+
hideNavigation: true,
|
|
140
135
|
},
|
|
141
136
|
|
|
142
137
|
// this is the fields for our Tag list
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export * from "./declarations/src/index.js";
|
|
2
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLWtleXN0b25lLWFwcC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
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');
|
|
7
|
-
var enquirer = require('enquirer');
|
|
8
|
-
var execa = require('execa');
|
|
9
|
-
var getPackageJson = require('package-json');
|
|
10
|
-
var meow = require('meow');
|
|
11
|
-
var ora = require('ora');
|
|
12
|
-
|
|
13
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
16
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
17
|
-
var c__default = /*#__PURE__*/_interopDefault(c);
|
|
18
|
-
var enquirer__default = /*#__PURE__*/_interopDefault(enquirer);
|
|
19
|
-
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
20
|
-
var getPackageJson__default = /*#__PURE__*/_interopDefault(getPackageJson);
|
|
21
|
-
var meow__default = /*#__PURE__*/_interopDefault(meow);
|
|
22
|
-
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
23
|
-
|
|
24
|
-
var thisPackage = {
|
|
25
|
-
name: "create-keystone-app",
|
|
26
|
-
version: "10.0.3",
|
|
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
|
-
},
|
|
45
|
-
dependencies: {
|
|
46
|
-
chalk: "^4.1.2",
|
|
47
|
-
enquirer: "^2.4.1",
|
|
48
|
-
execa: "^5.1.1",
|
|
49
|
-
meow: "^9.0.0",
|
|
50
|
-
ora: "^8.0.1",
|
|
51
|
-
"package-json": "^10.0.0"
|
|
52
|
-
},
|
|
53
|
-
files: [
|
|
54
|
-
"dist",
|
|
55
|
-
"starter",
|
|
56
|
-
"cli.js"
|
|
57
|
-
]
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
async function checkVersion() {
|
|
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}`);
|
|
66
|
-
}
|
|
67
|
-
class UserError extends Error {}
|
|
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.tagName.toUpperCase() === 'SCRIPT' && 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`);
|
|
70
|
-
const cli = meow__default["default"](`
|
|
71
|
-
Usage
|
|
72
|
-
$ create-keystone-app [directory]
|
|
73
|
-
`);
|
|
74
|
-
async function normalizeArgs() {
|
|
75
|
-
let directory = cli.input[0];
|
|
76
|
-
if (!directory) {
|
|
77
|
-
({
|
|
78
|
-
directory
|
|
79
|
-
} = await enquirer__default["default"].prompt({
|
|
80
|
-
type: 'input',
|
|
81
|
-
name: 'directory',
|
|
82
|
-
message: 'What directory should create-keystone-app generate your app into?',
|
|
83
|
-
validate: x => !!x
|
|
84
|
-
}));
|
|
85
|
-
process.stdout.write('\n');
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
directory: path__default["default"].resolve(directory)
|
|
89
|
-
};
|
|
90
|
-
}
|
|
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', '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();
|
|
101
|
-
try {
|
|
102
|
-
await execa__default["default"](packageManager, ['install'], {
|
|
103
|
-
cwd: nextCwd
|
|
104
|
-
});
|
|
105
|
-
spinner.succeed(`Installed dependencies with ${packageManager}.`);
|
|
106
|
-
} catch (err) {
|
|
107
|
-
spinner.fail(`Failed to install with ${packageManager}.`);
|
|
108
|
-
throw err;
|
|
109
|
-
}
|
|
110
|
-
const relativeProjectDir = path__default["default"].relative(process.cwd(), normalizedArgs.directory);
|
|
111
|
-
process.stdout.write('\n');
|
|
112
|
-
console.log(`🎉 Keystone created a starter project in: ${c__default["default"].bold(relativeProjectDir)}
|
|
113
|
-
|
|
114
|
-
${c__default["default"].bold('To launch your app, run:')}
|
|
115
|
-
|
|
116
|
-
- cd ${relativeProjectDir}
|
|
117
|
-
- ${packageManager} run dev
|
|
118
|
-
|
|
119
|
-
${c__default["default"].bold('Next steps:')}
|
|
120
|
-
|
|
121
|
-
- Read ${c__default["default"].bold(`${relativeProjectDir}${path__default["default"].sep}README.md`)} for additional getting started details.
|
|
122
|
-
- Edit ${c__default["default"].bold(`${relativeProjectDir}${path__default["default"].sep}keystone.ts`)} to customize your app.
|
|
123
|
-
- Star Keystone on GitHub (https://github.com/keystonejs/keystone)
|
|
124
|
-
`);
|
|
125
|
-
})().catch(err => {
|
|
126
|
-
if (err instanceof UserError) {
|
|
127
|
-
console.error(err.message);
|
|
128
|
-
} else {
|
|
129
|
-
console.error(err);
|
|
130
|
-
}
|
|
131
|
-
process.exit(1);
|
|
132
|
-
});
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
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');
|
|
7
|
-
var enquirer = require('enquirer');
|
|
8
|
-
var execa = require('execa');
|
|
9
|
-
var getPackageJson = require('package-json');
|
|
10
|
-
var meow = require('meow');
|
|
11
|
-
var ora = require('ora');
|
|
12
|
-
|
|
13
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
16
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
17
|
-
var c__default = /*#__PURE__*/_interopDefault(c);
|
|
18
|
-
var enquirer__default = /*#__PURE__*/_interopDefault(enquirer);
|
|
19
|
-
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
20
|
-
var getPackageJson__default = /*#__PURE__*/_interopDefault(getPackageJson);
|
|
21
|
-
var meow__default = /*#__PURE__*/_interopDefault(meow);
|
|
22
|
-
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
23
|
-
|
|
24
|
-
var thisPackage = {
|
|
25
|
-
name: "create-keystone-app",
|
|
26
|
-
version: "10.0.3",
|
|
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
|
-
},
|
|
45
|
-
dependencies: {
|
|
46
|
-
chalk: "^4.1.2",
|
|
47
|
-
enquirer: "^2.4.1",
|
|
48
|
-
execa: "^5.1.1",
|
|
49
|
-
meow: "^9.0.0",
|
|
50
|
-
ora: "^8.0.1",
|
|
51
|
-
"package-json": "^10.0.0"
|
|
52
|
-
},
|
|
53
|
-
files: [
|
|
54
|
-
"dist",
|
|
55
|
-
"starter",
|
|
56
|
-
"cli.js"
|
|
57
|
-
]
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
async function checkVersion() {
|
|
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}`);
|
|
66
|
-
}
|
|
67
|
-
class UserError extends Error {}
|
|
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.tagName.toUpperCase() === 'SCRIPT' && 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`);
|
|
70
|
-
const cli = meow__default["default"](`
|
|
71
|
-
Usage
|
|
72
|
-
$ create-keystone-app [directory]
|
|
73
|
-
`);
|
|
74
|
-
async function normalizeArgs() {
|
|
75
|
-
let directory = cli.input[0];
|
|
76
|
-
if (!directory) {
|
|
77
|
-
({
|
|
78
|
-
directory
|
|
79
|
-
} = await enquirer__default["default"].prompt({
|
|
80
|
-
type: 'input',
|
|
81
|
-
name: 'directory',
|
|
82
|
-
message: 'What directory should create-keystone-app generate your app into?',
|
|
83
|
-
validate: x => !!x
|
|
84
|
-
}));
|
|
85
|
-
process.stdout.write('\n');
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
directory: path__default["default"].resolve(directory)
|
|
89
|
-
};
|
|
90
|
-
}
|
|
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', '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();
|
|
101
|
-
try {
|
|
102
|
-
await execa__default["default"](packageManager, ['install'], {
|
|
103
|
-
cwd: nextCwd
|
|
104
|
-
});
|
|
105
|
-
spinner.succeed(`Installed dependencies with ${packageManager}.`);
|
|
106
|
-
} catch (err) {
|
|
107
|
-
spinner.fail(`Failed to install with ${packageManager}.`);
|
|
108
|
-
throw err;
|
|
109
|
-
}
|
|
110
|
-
const relativeProjectDir = path__default["default"].relative(process.cwd(), normalizedArgs.directory);
|
|
111
|
-
process.stdout.write('\n');
|
|
112
|
-
console.log(`🎉 Keystone created a starter project in: ${c__default["default"].bold(relativeProjectDir)}
|
|
113
|
-
|
|
114
|
-
${c__default["default"].bold('To launch your app, run:')}
|
|
115
|
-
|
|
116
|
-
- cd ${relativeProjectDir}
|
|
117
|
-
- ${packageManager} run dev
|
|
118
|
-
|
|
119
|
-
${c__default["default"].bold('Next steps:')}
|
|
120
|
-
|
|
121
|
-
- Read ${c__default["default"].bold(`${relativeProjectDir}${path__default["default"].sep}README.md`)} for additional getting started details.
|
|
122
|
-
- Edit ${c__default["default"].bold(`${relativeProjectDir}${path__default["default"].sep}keystone.ts`)} to customize your app.
|
|
123
|
-
- Star Keystone on GitHub (https://github.com/keystonejs/keystone)
|
|
124
|
-
`);
|
|
125
|
-
})().catch(err => {
|
|
126
|
-
if (err instanceof UserError) {
|
|
127
|
-
console.error(err.message);
|
|
128
|
-
} else {
|
|
129
|
-
console.error(err);
|
|
130
|
-
}
|
|
131
|
-
process.exit(1);
|
|
132
|
-
});
|