create-catalyst-app 0.0.1-beta.16 → 0.0.1-beta.18
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 +42 -1
- package/templates/none-js/package.json +1 -1
- package/templates/none-ts/package.json +1 -1
- package/templates/redux-js/package.json +1 -1
- package/templates/redux-ts/package.json +1 -1
- package/templates/rtk-js/package.json +1 -1
- package/templates/rtk-ts/package.json +1 -1
- 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
|
@@ -33,6 +33,8 @@ const program = new Commander.Command()
|
|
|
33
33
|
return
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
console.log(cyan(`Using create-catalyst-app version ${bold(packageJson.version)}`))
|
|
37
|
+
|
|
36
38
|
// Use options provided through commander or prompt the user
|
|
37
39
|
validateOptions(cmd)
|
|
38
40
|
const projectName = folderName || (await promptProjectName())
|
|
@@ -47,8 +49,9 @@ const program = new Commander.Command()
|
|
|
47
49
|
console.log(red(`${projectName} already exists, try again.`))
|
|
48
50
|
process.exit(1)
|
|
49
51
|
}
|
|
50
|
-
const language = await promptTypescript()
|
|
51
52
|
const projectDescription = await promptDescription()
|
|
53
|
+
const language = await promptTypescript()
|
|
54
|
+
const tailWindSupport = await promptTailwind()
|
|
52
55
|
const stateManagement = cmd.stateManagement || (await promptStateManagement())
|
|
53
56
|
|
|
54
57
|
// Define mapping of options to repository suffixes
|
|
@@ -65,7 +68,11 @@ const program = new Commander.Command()
|
|
|
65
68
|
|
|
66
69
|
const commonCodeDirectory = "package/templates/common"
|
|
67
70
|
const selectedTemplateCode = `package/templates/${repositorySuffixes[stateManagement]}-${repositorySuffixes[language]}`
|
|
71
|
+
const tailwindCodeDirectory = "package/templates/tailwind"
|
|
72
|
+
|
|
68
73
|
const subDirectoriesToExtract = [commonCodeDirectory, selectedTemplateCode]
|
|
74
|
+
if (tailWindSupport) subDirectoriesToExtract.push(tailwindCodeDirectory)
|
|
75
|
+
|
|
69
76
|
const extractionDestination = `/${projectName}/`
|
|
70
77
|
let tempDir
|
|
71
78
|
;(() => {
|
|
@@ -77,6 +84,8 @@ const program = new Commander.Command()
|
|
|
77
84
|
extractSubdirectory(packageFilePath)
|
|
78
85
|
createGitignore(projectName)
|
|
79
86
|
|
|
87
|
+
if (tailWindSupport) setupTailwind(projectName)
|
|
88
|
+
|
|
80
89
|
execSync(
|
|
81
90
|
`cd ${projectName} && npm i && npm pkg set name=${projectName} ${projectDescription ? `description="${projectDescription}"` : ""} && git init --quiet && git add . && git commit -m "initial commit from Create Catalyst App"`,
|
|
82
91
|
{ stdio: "inherit" }
|
|
@@ -150,6 +159,9 @@ const program = new Commander.Command()
|
|
|
150
159
|
if (entry.path.startsWith(selectedTemplateCode)) {
|
|
151
160
|
entry.path = entry.path.replace(selectedTemplateCode, extractionDestination)
|
|
152
161
|
}
|
|
162
|
+
if (entry.path.startsWith(tailwindCodeDirectory)) {
|
|
163
|
+
entry.path = entry.path.replace(tailwindCodeDirectory, extractionDestination)
|
|
164
|
+
}
|
|
153
165
|
},
|
|
154
166
|
})
|
|
155
167
|
} catch (e) {
|
|
@@ -232,6 +244,35 @@ async function promptTypescript() {
|
|
|
232
244
|
return response.typescript
|
|
233
245
|
}
|
|
234
246
|
|
|
247
|
+
async function promptTailwind() {
|
|
248
|
+
const response = await prompts({
|
|
249
|
+
type: "select",
|
|
250
|
+
name: "tailwind",
|
|
251
|
+
message: "Would you like to use Tailwind CSS?",
|
|
252
|
+
choices: [
|
|
253
|
+
{ title: "Yes", value: true },
|
|
254
|
+
{ title: "No", value: false },
|
|
255
|
+
],
|
|
256
|
+
})
|
|
257
|
+
return response.tailwind
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async function setupTailwind(projectName) {
|
|
261
|
+
try {
|
|
262
|
+
const packageJsonPath = path.join(process.cwd(), projectName, "package.json")
|
|
263
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"))
|
|
264
|
+
packageJson.dependencies = {
|
|
265
|
+
...(packageJson.dependencies || {}),
|
|
266
|
+
tailwindcss: "^4.1.4",
|
|
267
|
+
"@tailwindcss/postcss": "^4.1.4",
|
|
268
|
+
}
|
|
269
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
|
|
270
|
+
} catch (error) {
|
|
271
|
+
console.log("Error while setting up tailwind:", error)
|
|
272
|
+
process.exit(1)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
235
276
|
function validateOptions(cmd) {
|
|
236
277
|
// Validate language option
|
|
237
278
|
if (cmd.lang && !["js", "ts"].includes(cmd.lang.toLowerCase())) {
|