create-catalyst-app-internal 0.0.3-canary.33 → 0.0.3-canary.35
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/package.json +1 -1
- package/scripts/cli.cjs +108 -8
- package/templates/common/webpackConfig.js +1 -0
- package/templates/mcp-root/mcp/context.md +674 -0
- package/templates/mcp-root/mcp/mcp.js +36 -0
- package/templates/none-js/package.json +2 -2
- package/templates/none-ts/client/index.js +23 -0
- package/templates/none-ts/package.json +40 -0
- package/templates/none-ts/src/js/containers/App/index.js +16 -0
- package/templates/none-ts/src/js/routes/utils.js +42 -0
- package/templates/none-ts/tsconfig.json +13 -0
- package/templates/none-ts/types.d.ts +4 -0
- package/templates/redux-js/package.json +2 -2
- package/templates/redux-ts/client/index.js +28 -0
- package/templates/redux-ts/package.json +43 -0
- package/templates/redux-ts/src/js/containers/App/actions.js +17 -0
- package/templates/redux-ts/src/js/containers/App/index.js +16 -0
- package/templates/redux-ts/src/js/containers/App/reducer.js +19 -0
- package/templates/redux-ts/src/js/routes/utils.js +42 -0
- package/templates/redux-ts/src/js/store/index.js +28 -0
- package/templates/redux-ts/tsconfig.json +13 -0
- package/templates/redux-ts/types.d.ts +4 -0
- package/templates/rtk-js/package.json +2 -2
- package/templates/rtk-ts/client/index.js +28 -0
- package/templates/rtk-ts/package.json +43 -0
- package/templates/rtk-ts/src/js/containers/App/index.js +16 -0
- package/templates/rtk-ts/src/js/containers/App/reducer.js +18 -0
- package/templates/rtk-ts/src/js/routes/utils.js +42 -0
- package/templates/rtk-ts/src/js/store/index.js +28 -0
- package/templates/rtk-ts/tsconfig.json +13 -0
- package/templates/rtk-ts/types.d.ts +4 -0
- package/templates/tailwind/postcss.config.js +5 -0
- package/templates/tailwind/src/static/css/base/index.scss +2 -0
package/package.json
CHANGED
package/scripts/cli.cjs
CHANGED
|
@@ -17,6 +17,7 @@ const program = new Commander.Command()
|
|
|
17
17
|
.arguments("[folderName]")
|
|
18
18
|
.usage(`${green("[folderName]")} [options]`)
|
|
19
19
|
.action((name) => (projectName = name))
|
|
20
|
+
.addOption(new Option("-y, --yes [yes]", "Use default configuration"))
|
|
20
21
|
.addOption(
|
|
21
22
|
new Option(
|
|
22
23
|
"-s, --state-management [stateManagement]",
|
|
@@ -27,15 +28,39 @@ const program = new Commander.Command()
|
|
|
27
28
|
)
|
|
28
29
|
.action(async (folderName = null, cmd) => {
|
|
29
30
|
try {
|
|
31
|
+
let config = {
|
|
32
|
+
folderName,
|
|
33
|
+
language: null,
|
|
34
|
+
tailWindSupport: null,
|
|
35
|
+
description: null,
|
|
36
|
+
stateManagement: cmd.stateManagement,
|
|
37
|
+
mcpSupport: null,
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
if (process.argv.includes("new-route")) {
|
|
31
41
|
const createRoutePath = path.join(__dirname, "../codemod/new-route/index.js")
|
|
32
42
|
execSync(`node ${createRoutePath}`, { stdio: "inherit" })
|
|
33
43
|
return
|
|
34
44
|
}
|
|
35
45
|
|
|
46
|
+
console.log(cyan(`Using create-catalyst-app version ${bold(packageJson.version)}`))
|
|
47
|
+
|
|
36
48
|
// Use options provided through commander or prompt the user
|
|
37
49
|
validateOptions(cmd)
|
|
38
|
-
|
|
50
|
+
|
|
51
|
+
if (cmd.yes) {
|
|
52
|
+
console.log("Using default configuration.")
|
|
53
|
+
config = {
|
|
54
|
+
folderName: "my-app",
|
|
55
|
+
language: "js",
|
|
56
|
+
tailWindSupport: false,
|
|
57
|
+
description: "Default catalyst app",
|
|
58
|
+
stateManagement: "none",
|
|
59
|
+
mcpSupport: true,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const projectName = config.folderName || (await promptProjectName())
|
|
39
64
|
let isNameValid = validate(projectName)
|
|
40
65
|
if (!isNameValid.validForNewPackages) {
|
|
41
66
|
isNameValid?.warnings?.forEach?.((item) => console.log(red(item)))
|
|
@@ -47,9 +72,11 @@ const program = new Commander.Command()
|
|
|
47
72
|
console.log(red(`${projectName} already exists, try again.`))
|
|
48
73
|
process.exit(1)
|
|
49
74
|
}
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
75
|
+
const projectDescription = config.description || (await promptDescription())
|
|
76
|
+
const language = config.language || (await promptTypescript())
|
|
77
|
+
const tailWindSupport = config.tailWindSupport !== null || (await promptTailwind())
|
|
78
|
+
const stateManagement = config.stateManagement || (await promptStateManagement())
|
|
79
|
+
const mcpSupport = config.mcpSupport !== null || (await promptMcp())
|
|
53
80
|
|
|
54
81
|
// Define mapping of options to repository suffixes
|
|
55
82
|
const repositorySuffixes = {
|
|
@@ -65,7 +92,13 @@ const program = new Commander.Command()
|
|
|
65
92
|
|
|
66
93
|
const commonCodeDirectory = "package/templates/common"
|
|
67
94
|
const selectedTemplateCode = `package/templates/${repositorySuffixes[stateManagement]}-${repositorySuffixes[language]}`
|
|
95
|
+
const tailwindCodeDirectory = "package/templates/tailwind"
|
|
96
|
+
const mcpCodeDirectory = "package/templates/mcp-root"
|
|
97
|
+
|
|
68
98
|
const subDirectoriesToExtract = [commonCodeDirectory, selectedTemplateCode]
|
|
99
|
+
if (tailWindSupport) subDirectoriesToExtract.push(tailwindCodeDirectory)
|
|
100
|
+
if (mcpSupport) subDirectoriesToExtract.push(mcpCodeDirectory)
|
|
101
|
+
|
|
69
102
|
const extractionDestination = `/${projectName}/`
|
|
70
103
|
let tempDir
|
|
71
104
|
;(() => {
|
|
@@ -78,10 +111,27 @@ const program = new Commander.Command()
|
|
|
78
111
|
createGitignore(projectName)
|
|
79
112
|
|
|
80
113
|
execSync(
|
|
81
|
-
`cd ${projectName} && npm i && npm pkg set name=${projectName} ${projectDescription ? `description="${projectDescription}"` : ""} && git init --quiet
|
|
114
|
+
`cd ${projectName} && npm i && npm pkg set name=${projectName} ${projectDescription ? `description="${projectDescription}"` : ""} && git init --quiet`,
|
|
82
115
|
{ stdio: "inherit" }
|
|
83
116
|
)
|
|
84
117
|
|
|
118
|
+
if (tailWindSupport) {
|
|
119
|
+
execSync(`cd ${projectName} && npm i tailwindcss@4.1.4 @tailwindcss/postcss@4.1.4`, {
|
|
120
|
+
stdio: "inherit",
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (mcpSupport) {
|
|
125
|
+
execSync(`cd ${projectName} && npm i @modelcontextprotocol/sdk`, { stdio: "inherit" })
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
execSync(
|
|
129
|
+
`cd ${projectName} && git add . && git commit -m "initial commit from Create Catalyst App"`,
|
|
130
|
+
{
|
|
131
|
+
stdio: "inherit",
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
85
135
|
console.log(`\n${green(bold("Success!"))} created ${projectName} at ${projectPath}`)
|
|
86
136
|
console.log("Inside this directory, you can run the following commands.")
|
|
87
137
|
|
|
@@ -114,8 +164,8 @@ const program = new Commander.Command()
|
|
|
114
164
|
|
|
115
165
|
// to test locally, comment the upper execSync and uncomment this one.
|
|
116
166
|
// execSync(`npm pack --pack-destination=${tempDir} --silent`, {
|
|
117
|
-
//
|
|
118
|
-
// })
|
|
167
|
+
// cwd: process.cwd(),
|
|
168
|
+
// })
|
|
119
169
|
|
|
120
170
|
return tarballFilePath
|
|
121
171
|
} catch (error) {
|
|
@@ -150,13 +200,19 @@ const program = new Commander.Command()
|
|
|
150
200
|
if (entry.path.startsWith(selectedTemplateCode)) {
|
|
151
201
|
entry.path = entry.path.replace(selectedTemplateCode, extractionDestination)
|
|
152
202
|
}
|
|
203
|
+
if (entry.path.startsWith(tailwindCodeDirectory)) {
|
|
204
|
+
entry.path = entry.path.replace(tailwindCodeDirectory, extractionDestination)
|
|
205
|
+
}
|
|
206
|
+
if (entry.path.startsWith(mcpCodeDirectory)) {
|
|
207
|
+
entry.path = entry.path.replace(mcpCodeDirectory, extractionDestination)
|
|
208
|
+
}
|
|
153
209
|
},
|
|
154
210
|
})
|
|
155
211
|
} catch (e) {
|
|
156
212
|
console.log("An error occurred", e)
|
|
157
213
|
}
|
|
158
214
|
|
|
159
|
-
cyan(`Run cd ${projectName} && npm start to get started.`)
|
|
215
|
+
console.log(cyan(`Run cd ${projectName} && npm start to get started.`))
|
|
160
216
|
}
|
|
161
217
|
} catch (error) {
|
|
162
218
|
console.error(red("An error occurred:"), error.message)
|
|
@@ -218,6 +274,46 @@ async function promptDescription() {
|
|
|
218
274
|
} else return null
|
|
219
275
|
}
|
|
220
276
|
|
|
277
|
+
async function promptTypescript() {
|
|
278
|
+
const response = await prompts({
|
|
279
|
+
type: "select",
|
|
280
|
+
name: "typescript",
|
|
281
|
+
message: "Would you like to use TypeScript?",
|
|
282
|
+
choices: [
|
|
283
|
+
{ title: "Yes", value: "ts" },
|
|
284
|
+
{ title: "No", value: "js" },
|
|
285
|
+
],
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
return response.typescript
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
async function promptTailwind() {
|
|
292
|
+
const response = await prompts({
|
|
293
|
+
type: "select",
|
|
294
|
+
name: "tailwind",
|
|
295
|
+
message: "Would you like to use Tailwind CSS?",
|
|
296
|
+
choices: [
|
|
297
|
+
{ title: "Yes", value: true },
|
|
298
|
+
{ title: "No", value: false },
|
|
299
|
+
],
|
|
300
|
+
})
|
|
301
|
+
return response.tailwind
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function promptMcp() {
|
|
305
|
+
const response = await prompts({
|
|
306
|
+
type: "select",
|
|
307
|
+
name: "mcp",
|
|
308
|
+
message: "Would you like to setup an MCP server?",
|
|
309
|
+
choices: [
|
|
310
|
+
{ title: "Yes", value: true },
|
|
311
|
+
{ title: "No", value: false },
|
|
312
|
+
],
|
|
313
|
+
})
|
|
314
|
+
return response.mcp
|
|
315
|
+
}
|
|
316
|
+
|
|
221
317
|
function validateOptions(cmd) {
|
|
222
318
|
// Validate language option
|
|
223
319
|
if (cmd.lang && !["js", "ts"].includes(cmd.lang.toLowerCase())) {
|
|
@@ -228,6 +324,10 @@ function validateOptions(cmd) {
|
|
|
228
324
|
if (cmd.stateManagement && !["rtk", "redux", "none"].includes(cmd.stateManagement.toLowerCase())) {
|
|
229
325
|
throw new Error('Invalid state management option. Use "rtk", "redux", or "none".')
|
|
230
326
|
}
|
|
327
|
+
|
|
328
|
+
if (cmd.yes && typeof cmd.yes !== "boolean") {
|
|
329
|
+
throw new Error('Invalid option for "yes". Use "-y" or "--yes" to accept defaults.')
|
|
330
|
+
}
|
|
231
331
|
}
|
|
232
332
|
|
|
233
333
|
function deleteDirectory(dirPath) {
|