create-kyro 0.3.1 → 0.4.1
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/README.md +16 -13
- package/dist/index.js +67 -664
- package/package.json +1 -1
- package/src/generators/astro.ts +7 -70
- package/src/generators/config.ts +39 -40
- package/src/generators/files.ts +18 -509
- package/src/generators/packagejson.ts +6 -35
- package/src/index.ts +5 -5
- package/src/prompts.ts +1 -62
- package/test/generators.test.ts +13 -100
- package/test/validators.test.ts +0 -1
package/package.json
CHANGED
package/src/generators/astro.ts
CHANGED
|
@@ -1,82 +1,19 @@
|
|
|
1
1
|
import type { Answers } from "../prompts.js";
|
|
2
2
|
|
|
3
3
|
export function generateAstroConfig(answers: Answers): string {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (answers.styling === "tailwind") {
|
|
9
|
-
integrations.push(" react(),");
|
|
10
|
-
vitePlugins.push(" tailwindcss(),");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const adapter = answers.admin
|
|
14
|
-
? `
|
|
15
|
-
adapter: node({
|
|
16
|
-
mode: 'standalone'
|
|
17
|
-
}),`
|
|
18
|
-
: "";
|
|
19
|
-
|
|
20
|
-
const nativeExternals = `
|
|
21
|
-
ssr: {
|
|
22
|
-
external: [
|
|
23
|
-
'better-sqlite3',
|
|
24
|
-
'sharp',
|
|
25
|
-
'ssh2',
|
|
26
|
-
'cpu-features',
|
|
27
|
-
'ssh2-sftp-client',
|
|
28
|
-
'ioredis',
|
|
29
|
-
'nodemailer',
|
|
30
|
-
'jsonwebtoken',
|
|
31
|
-
'@mapbox/node-pre-gyp',
|
|
32
|
-
'mock-aws-s3',
|
|
33
|
-
'aws-sdk',
|
|
34
|
-
'nock',
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
optimizeDeps: {
|
|
38
|
-
exclude: [
|
|
39
|
-
'better-sqlite3',
|
|
40
|
-
'sharp',
|
|
41
|
-
'ssh2',
|
|
42
|
-
'cpu-features',
|
|
43
|
-
'ssh2-sftp-client',
|
|
44
|
-
'ioredis',
|
|
45
|
-
'nodemailer',
|
|
46
|
-
'jsonwebtoken',
|
|
47
|
-
'@mapbox/node-pre-gyp',
|
|
48
|
-
'mock-aws-s3',
|
|
49
|
-
'aws-sdk',
|
|
50
|
-
'nock',
|
|
51
|
-
],
|
|
52
|
-
},`;
|
|
53
|
-
|
|
54
|
-
const config = `import { defineConfig } from 'astro/config';
|
|
55
|
-
import node from '@astrojs/node';
|
|
56
|
-
${answers.styling === "tailwind" ? "import react from '@astrojs/react';\nimport tailwindcss from '@tailwindcss/vite';" : ""}
|
|
4
|
+
return `import { defineConfig } from 'astro/config';
|
|
5
|
+
import kyro from '@kyro-cms/core';
|
|
6
|
+
import { kyroAdmin } from '@kyro-cms/admin';
|
|
57
7
|
|
|
58
8
|
export default defineConfig({
|
|
59
|
-
output: 'server'
|
|
60
|
-
|
|
9
|
+
output: 'server',
|
|
61
10
|
integrations: [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
? `
|
|
66
|
-
vite: {
|
|
67
|
-
plugins: [
|
|
68
|
-
${vitePlugins.join("\n")}
|
|
69
|
-
],${nativeExternals}
|
|
70
|
-
},`
|
|
71
|
-
: `
|
|
72
|
-
vite: {${nativeExternals}
|
|
73
|
-
},`
|
|
74
|
-
}
|
|
11
|
+
kyro({ adminPath: '/admin', apiPath: '/api' }),
|
|
12
|
+
kyroAdmin({ basePath: '/admin', apiPath: '/api' }),
|
|
13
|
+
],
|
|
75
14
|
server: {
|
|
76
15
|
port: 4321,
|
|
77
16
|
host: true,
|
|
78
17
|
},
|
|
79
18
|
});`;
|
|
80
|
-
|
|
81
|
-
return config;
|
|
82
19
|
}
|
package/src/generators/config.ts
CHANGED
|
@@ -2,66 +2,57 @@ import type { Answers } from "../prompts.js";
|
|
|
2
2
|
|
|
3
3
|
export function generateKyroConfig(answers: Answers): string {
|
|
4
4
|
const imports: string[] = ["import { defineConfig } from '@kyro-cms/core';"];
|
|
5
|
-
const adapterLines: string[] = [];
|
|
6
5
|
|
|
7
6
|
if (answers.database === "sqlite") {
|
|
8
7
|
imports.push("import { createLocalAdapter } from '@kyro-cms/core';");
|
|
9
|
-
adapterLines.push(` adapter: createLocalAdapter({ path: './data.db' }),`);
|
|
10
8
|
} else if (answers.database === "postgres") {
|
|
11
9
|
imports.push("import { createDrizzleAdapter } from '@kyro-cms/core';");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
} else if (answers.database === "mongodb") {
|
|
11
|
+
imports.push("import { createMongoDBAdapter } from '@kyro-cms/core';");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const adapterLines: string[] = [];
|
|
15
|
+
if (answers.database === "sqlite") {
|
|
16
|
+
adapterLines.push(` adapter: createLocalAdapter({ path: './data.db' }),`);
|
|
17
|
+
} else if (answers.database === "postgres") {
|
|
17
18
|
adapterLines.push(` adapter: createDrizzleAdapter({`);
|
|
18
19
|
adapterLines.push(` connectionString: process.env.DATABASE_URL,`);
|
|
19
20
|
adapterLines.push(` }),`);
|
|
20
21
|
} else if (answers.database === "mongodb") {
|
|
21
|
-
imports.push("import { createMongoDBAdapter } from '@kyro-cms/core';");
|
|
22
22
|
adapterLines.push(` adapter: createMongoDBAdapter({`);
|
|
23
23
|
adapterLines.push(` connectionString: process.env.MONGODB_URI,`);
|
|
24
24
|
adapterLines.push(` }),`);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const apiConfig = [
|
|
28
|
-
" rest: true,",
|
|
29
|
-
" graphql: true,",
|
|
30
|
-
" trpc: true,",
|
|
31
|
-
" websocket: true,",
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
const features: string[] = [];
|
|
35
|
-
if (answers.auth) {
|
|
36
|
-
features.push(" auth: true,");
|
|
37
|
-
}
|
|
38
|
-
if (answers.versioning) {
|
|
39
|
-
features.push(" versioning: true,");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
27
|
let templateCollections = "";
|
|
43
28
|
let templateGlobals = "";
|
|
44
29
|
|
|
45
30
|
switch (answers.template) {
|
|
46
31
|
case "minimal":
|
|
47
32
|
templateCollections =
|
|
48
|
-
"import { minimalCollections } from '@kyro-cms/core';";
|
|
33
|
+
"import { minimalCollections } from '@kyro-cms/core/templates';";
|
|
34
|
+
templateGlobals =
|
|
35
|
+
"import { coreSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
49
36
|
break;
|
|
50
37
|
case "blog":
|
|
51
|
-
templateCollections = "import { blogCollections } from '@kyro-cms/core';";
|
|
38
|
+
templateCollections = "import { blogCollections } from '@kyro-cms/core/templates';";
|
|
39
|
+
templateGlobals =
|
|
40
|
+
"import { allSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
52
41
|
break;
|
|
53
42
|
case "ecommerce":
|
|
54
|
-
templateCollections =
|
|
55
|
-
|
|
43
|
+
templateCollections = "import { ecommerceCollections } from '@kyro-cms/core/templates';";
|
|
44
|
+
templateGlobals =
|
|
45
|
+
"import { allSettingsGlobals, ecommerceSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
56
46
|
break;
|
|
57
47
|
case "kitchen-sink":
|
|
58
|
-
templateCollections = `import { minimalCollections, blogCollections, ecommerceCollections, kitchenSinkCollections } from '@kyro-cms/core';`;
|
|
48
|
+
templateCollections = `import { minimalCollections, blogCollections, ecommerceCollections, kitchenSinkCollections } from '@kyro-cms/core/templates';`;
|
|
49
|
+
templateGlobals =
|
|
50
|
+
"import { allSettingsGlobals, ecommerceSettingsGlobals } from '@kyro-cms/core/templates';";
|
|
59
51
|
break;
|
|
60
52
|
}
|
|
61
53
|
|
|
62
|
-
if (templateCollections)
|
|
63
|
-
|
|
64
|
-
}
|
|
54
|
+
if (templateCollections) imports.push(templateCollections);
|
|
55
|
+
if (templateGlobals) imports.push(templateGlobals);
|
|
65
56
|
|
|
66
57
|
let collectionsConfig = "";
|
|
67
58
|
if (answers.template === "minimal") {
|
|
@@ -79,17 +70,25 @@ export function generateKyroConfig(answers: Answers): string {
|
|
|
79
70
|
],`;
|
|
80
71
|
}
|
|
81
72
|
|
|
82
|
-
|
|
73
|
+
let globalsConfig = "";
|
|
74
|
+
if (answers.template === "minimal") {
|
|
75
|
+
globalsConfig = ` globals: coreSettingsGlobals,`;
|
|
76
|
+
} else if (answers.template === "blog" || answers.template === "ecommerce") {
|
|
77
|
+
globalsConfig = answers.template === "ecommerce"
|
|
78
|
+
? ` globals: [...allSettingsGlobals, ...ecommerceSettingsGlobals],`
|
|
79
|
+
: ` globals: allSettingsGlobals,`;
|
|
80
|
+
} else if (answers.template === "kitchen-sink") {
|
|
81
|
+
globalsConfig = ` globals: [...allSettingsGlobals, ...ecommerceSettingsGlobals],`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return `${imports.join("\n")}
|
|
83
85
|
|
|
84
86
|
export default defineConfig({
|
|
85
87
|
name: '${answers.projectName}',
|
|
86
|
-
prefix: '/api'
|
|
87
|
-
${
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
},
|
|
88
|
+
prefix: '/api',
|
|
89
|
+
${adapterLines.join("\n")}
|
|
90
|
+
${collectionsConfig}
|
|
91
|
+
${globalsConfig}
|
|
92
|
+
auth: true,
|
|
92
93
|
});`;
|
|
93
|
-
|
|
94
|
-
return config;
|
|
95
94
|
}
|