tailjng 0.0.13 → 0.0.15

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.
Files changed (87) hide show
  1. package/cli/component-manager.js +45 -0
  2. package/cli/dependency-manager.js +52 -0
  3. package/cli/file-operations.js +88 -0
  4. package/cli/index.js +51 -0
  5. package/cli/settings/colors.js +17 -0
  6. package/cli/settings/components-list.js +87 -0
  7. package/cli/settings/header-generator.js +42 -0
  8. package/cli/settings/path-utils.js +50 -0
  9. package/cli/settings/prompt-utils.js +37 -0
  10. package/cli/settings/tailwind-check.js +21 -0
  11. package/fesm2022/tailjng.mjs +903 -25
  12. package/fesm2022/tailjng.mjs.map +1 -1
  13. package/lib/config/tailjng-config.token.d.ts +3 -0
  14. package/lib/interfaces/alert/dialog-alert.interface.d.ts +52 -0
  15. package/lib/interfaces/alert/toast-alert.interface.d.ts +52 -0
  16. package/lib/interfaces/config.interface.d.ts +5 -0
  17. package/lib/interfaces/crud/api-response.d.ts +29 -0
  18. package/lib/interfaces/crud/crud.interface.d.ts +103 -0
  19. package/lib/services/alert/dialog-alert.service.d.ts +24 -0
  20. package/lib/services/alert/toast-alert.service.d.ts +26 -0
  21. package/lib/services/crud/converter-crud.service.d.ts +41 -0
  22. package/lib/services/crud/generic-crud.service.d.ts +81 -0
  23. package/lib/services/http/error-handler-http.service.d.ts +26 -0
  24. package/lib/services/http/params-http.service.d.ts +13 -0
  25. package/lib/services/static/icons.service.d.ts +31 -0
  26. package/lib/services/transformer/calendar.service.d.ts +71 -0
  27. package/package.json +5 -3
  28. package/public-api.d.ts +10 -3
  29. package/src/lib/components/alert/dialog-alert/dialog-alert.component.css +0 -0
  30. package/src/lib/components/alert/dialog-alert/dialog-alert.component.html +72 -0
  31. package/src/lib/components/alert/dialog-alert/dialog-alert.component.ts +66 -0
  32. package/src/lib/components/alert/toast-alert/toast-alert.component.css +5 -0
  33. package/src/lib/components/alert/toast-alert/toast-alert.component.html +76 -0
  34. package/src/lib/components/alert/toast-alert/toast-alert.component.ts +87 -0
  35. package/src/lib/components/button/button.component.css +0 -0
  36. package/src/lib/components/button/button.component.html +36 -0
  37. package/src/lib/components/button/button.component.ts +95 -0
  38. package/src/lib/components/checkbox/input-checkbox/input-checkbox.component.css +0 -0
  39. package/src/lib/components/checkbox/input-checkbox/input-checkbox.component.html +23 -0
  40. package/src/lib/components/checkbox/input-checkbox/input-checkbox.component.ts +44 -0
  41. package/src/lib/components/checkbox/switch-checkbox/switch-checkbox.component.css +0 -0
  42. package/src/lib/components/checkbox/switch-checkbox/switch-checkbox.component.html +26 -0
  43. package/src/lib/components/checkbox/switch-checkbox/switch-checkbox.component.ts +29 -0
  44. package/src/lib/components/color/colors.service.ts +109 -0
  45. package/src/lib/components/dialog/dialog.component.css +8 -0
  46. package/src/lib/components/dialog/dialog.component.html +57 -0
  47. package/src/lib/components/dialog/dialog.component.ts +179 -0
  48. package/src/lib/components/image/viewer-image/viewer-image.component.css +4 -0
  49. package/src/lib/components/image/viewer-image/viewer-image.component.html +75 -0
  50. package/src/lib/components/image/viewer-image/viewer-image.component.ts +131 -0
  51. package/src/lib/components/input/file-input/file-input.component.css +0 -0
  52. package/src/lib/components/input/file-input/file-input.component.html +49 -0
  53. package/src/lib/components/input/file-input/file-input.component.ts +218 -0
  54. package/src/lib/components/input/input/input.component.css +0 -0
  55. package/src/lib/components/input/input/input.component.html +24 -0
  56. package/src/lib/components/input/input/input.component.ts +78 -0
  57. package/src/lib/components/input/range-input/range-input.component.css +0 -0
  58. package/src/lib/components/input/range-input/range-input.component.html +64 -0
  59. package/src/lib/components/input/range-input/range-input.component.ts +78 -0
  60. package/src/lib/components/input/textarea-input/textarea-input.component.css +0 -0
  61. package/src/lib/components/input/textarea-input/textarea-input.component.html +21 -0
  62. package/src/lib/components/input/textarea-input/textarea-input.component.ts +75 -0
  63. package/src/lib/components/label/label.component.html +1 -1
  64. package/src/lib/components/label/label.component.ts +1 -1
  65. package/src/lib/components/mode-toggle/mode-toggle.component.css +0 -0
  66. package/src/lib/components/mode-toggle/mode-toggle.component.html +8 -0
  67. package/src/lib/components/mode-toggle/mode-toggle.component.ts +61 -0
  68. package/src/lib/components/progress-bar/progress-bar.component.css +0 -0
  69. package/src/lib/components/progress-bar/progress-bar.component.html +22 -0
  70. package/src/lib/components/progress-bar/progress-bar.component.ts +20 -0
  71. package/src/lib/components/select/dropdown/dropdown.component.css +0 -0
  72. package/src/lib/components/select/dropdown/dropdown.component.html +95 -0
  73. package/src/lib/components/select/dropdown/dropdown.component.ts +562 -0
  74. package/src/lib/components/select/multi-dropdown/multi-dropdown.component.css +0 -0
  75. package/src/lib/components/select/multi-dropdown/multi-dropdown.component.html +87 -0
  76. package/src/lib/components/select/multi-dropdown/multi-dropdown.component.ts +315 -0
  77. package/src/lib/components/select/multi-table/multi-table.component.css +0 -0
  78. package/src/lib/components/select/multi-table/multi-table.component.html +83 -0
  79. package/src/lib/components/select/multi-table/multi-table.component.ts +230 -0
  80. package/src/lib/components/toggle-radio/toggle-radio.component.css +0 -0
  81. package/src/lib/components/toggle-radio/toggle-radio.component.html +51 -0
  82. package/src/lib/components/toggle-radio/toggle-radio.component.ts +203 -0
  83. package/src/styles.css +126 -0
  84. package/cli/tailjng.js +0 -105
  85. package/lib/services/icons.service.d.ts +0 -9
  86. package/lib/tailjng.component.d.ts +0 -5
  87. package/lib/tailjng.service.d.ts +0 -6
@@ -0,0 +1,45 @@
1
+ const fs = require("fs")
2
+ const path = require("path")
3
+ const { copyComponentFiles } = require("./file-operations")
4
+ const { installDependencies } = require("./dependency-manager")
5
+ const { COLORS } = require("./settings/colors")
6
+
7
+ async function addComponent(componentName, componentList) {
8
+ const componentData = componentList[componentName]
9
+ if (!componentData) {
10
+ console.error(
11
+ `${COLORS.red}[tailjng CLI] ERROR: Component "${componentName}" not found in the component list.${COLORS.reset}`,
12
+ )
13
+ process.exit(1)
14
+ }
15
+
16
+ console.log(`${COLORS.blue}[tailjng CLI] Adding component: ${componentName}${COLORS.reset}`)
17
+
18
+ // Create a Set to track already processed components
19
+ const installedComponents = new Set()
20
+
21
+ // Install dependencies first to ensure they are available before the main component
22
+ await installDependencies(componentData.dependencies, componentList, installedComponents)
23
+
24
+ // Check if the main component was already processed as a dependency
25
+ if (!installedComponents.has(componentName)) {
26
+ // Copy the main component files to the project
27
+ const wasInstalled = await copyComponentFiles(componentName, componentData.path, false)
28
+
29
+ if (wasInstalled) {
30
+ console.log(
31
+ `${COLORS.greenBright}[tailjng CLI] ✔ Component "${componentName}" installed successfully.${COLORS.reset}`,
32
+ )
33
+ } else {
34
+ console.log(
35
+ `${COLORS.yellow}[tailjng CLI] Component "${componentName}" installation was cancelled by user.${COLORS.reset}`,
36
+ )
37
+ }
38
+ } else {
39
+ console.log(
40
+ `${COLORS.dim}[tailjng CLI] Main component "${componentName}" was already processed as a dependency.${COLORS.reset}`,
41
+ )
42
+ }
43
+ }
44
+
45
+ module.exports = { addComponent }
@@ -0,0 +1,52 @@
1
+ const { copyComponentFiles } = require("./file-operations")
2
+ const { COLORS } = require("./settings/colors")
3
+
4
+ async function installDependencies(dependencies = [], componentList, installedComponents = new Set()) {
5
+ if (dependencies.length === 0) {
6
+ console.log(`${COLORS.dim}[tailjng CLI] No dependencies to install.${COLORS.reset}`)
7
+ return
8
+ }
9
+
10
+ for (const dep of dependencies) {
11
+ // Avoid infinite loops by checking if the component was already processed
12
+ if (installedComponents.has(dep)) {
13
+ console.log(`${COLORS.dim}[tailjng CLI] Component "${dep}" already processed, skipping.${COLORS.reset}`)
14
+ continue
15
+ }
16
+
17
+ const depComponentData = componentList[dep]
18
+ if (!depComponentData) {
19
+ console.error(
20
+ `${COLORS.red}[tailjng CLI] ERROR: Dependency component "${dep}" not found in the component list.${COLORS.reset}`,
21
+ )
22
+ process.exit(1)
23
+ }
24
+
25
+ console.log(`${COLORS.magenta}[tailjng CLI] Installing dependency component: ${dep}${COLORS.reset}`)
26
+
27
+ // Mark as processed before installing to avoid infinite loops
28
+ installedComponents.add(dep)
29
+
30
+ // Install recursively the dependencies of this dependency
31
+ if (depComponentData.dependencies && depComponentData.dependencies.length > 0) {
32
+ await installDependencies(depComponentData.dependencies, componentList, installedComponents)
33
+ }
34
+
35
+ // Copy the dependent component files
36
+ try {
37
+ const wasInstalled = await copyComponentFiles(dep, depComponentData.path, true)
38
+
39
+ if (wasInstalled) {
40
+ console.log(`${COLORS.green}[tailjng CLI] Successfully installed dependency: ${dep}${COLORS.reset}`)
41
+ } else {
42
+ console.log(`${COLORS.dim}[tailjng CLI] Dependency "${dep}" was skipped by user choice.${COLORS.reset}`)
43
+ }
44
+ } catch (err) {
45
+ console.error(`${COLORS.red}[tailjng CLI] Failed to install dependency component: ${dep}${COLORS.reset}`)
46
+ console.error(`${COLORS.red}[tailjng CLI] Error details:${COLORS.reset}`, err)
47
+ process.exit(1)
48
+ }
49
+ }
50
+ }
51
+
52
+ module.exports = { installDependencies }
@@ -0,0 +1,88 @@
1
+ const fs = require("fs")
2
+ const path = require("path")
3
+ const { COLORS } = require("./settings/colors")
4
+ const { generateHeaderComment } = require("./settings/header-generator")
5
+ const { askOverwrite } = require("./settings/prompt-utils")
6
+ const { buildTargetPath, parseComponentPath } = require("./settings/path-utils")
7
+
8
+ async function copyComponentFiles(componentName, componentPath, isDependency = false) {
9
+ // Detect the root directory where node_modules is located
10
+ let currentDir = process.cwd()
11
+ // Up to the root directory where node_modules is located
12
+ while (!fs.existsSync(path.join(currentDir, "node_modules"))) {
13
+ currentDir = path.dirname(currentDir)
14
+ if (currentDir === path.dirname(currentDir)) {
15
+ console.error(`${COLORS.red}[tailjng CLI] ERROR: node_modules not found in project root.${COLORS.reset}`)
16
+ process.exit(1)
17
+ }
18
+ }
19
+
20
+ // Now currentDir points to the root directory where node_modules is located
21
+ const nodeModulesPath = path.join(currentDir, "node_modules", "tailjng", componentPath)
22
+ const projectRoot = process.cwd()
23
+
24
+ // Use the new function to build the target path while maintaining the folder structure
25
+ const targetPath = buildTargetPath(projectRoot, componentName, componentPath)
26
+ const pathInfo = parseComponentPath(componentPath)
27
+
28
+ // Check if the component exists in the correct path
29
+ if (!fs.existsSync(nodeModulesPath)) {
30
+ console.error(
31
+ `${COLORS.red}[tailjng CLI] ERROR: Component path "${nodeModulesPath}" does not exist.${COLORS.reset}`,
32
+ )
33
+ process.exit(1)
34
+ }
35
+
36
+ // Check if the target path already exists
37
+ if (fs.existsSync(targetPath)) {
38
+ const relativeTargetPath = path.relative(projectRoot, targetPath)
39
+ const shouldOverwrite = await askOverwrite(componentName, relativeTargetPath, isDependency)
40
+
41
+ if (!shouldOverwrite) {
42
+ console.log(`${COLORS.dim}[tailjng CLI] Skipping "${componentName}" - keeping existing version.${COLORS.reset}`)
43
+ return false // Return false to indicate that it was not installed
44
+ }
45
+
46
+ // If decided to overwrite, remove the existing directory
47
+ console.log(`${COLORS.yellow}[tailjng CLI] Removing existing "${componentName}" to overwrite...${COLORS.reset}`)
48
+ fs.rmSync(targetPath, { recursive: true, force: true })
49
+ }
50
+
51
+ const componentType = isDependency ? "dependency component" : "component"
52
+ const relativeTargetPath = path.relative(projectRoot, targetPath)
53
+
54
+ // See if the component has subfolders
55
+ if (pathInfo.hasSubfolders) {
56
+ console.log(
57
+ `${COLORS.blue}[tailjng CLI] Copying ${componentType} "${componentName}" (${pathInfo.fullSubPath}) → ${relativeTargetPath}${COLORS.reset}`,
58
+ )
59
+ } else {
60
+ console.log(
61
+ `${COLORS.blue}[tailjng CLI] Copying ${componentType} "${componentName}" → ${relativeTargetPath}${COLORS.reset}`,
62
+ )
63
+ }
64
+
65
+ // Create the target directory structure
66
+ fs.mkdirSync(targetPath, { recursive: true })
67
+
68
+ const files = fs.readdirSync(nodeModulesPath)
69
+ files.forEach((file) => {
70
+ const srcFile = path.join(nodeModulesPath, file)
71
+ const destFile = path.join(targetPath, file)
72
+ let content = fs.readFileSync(srcFile, "utf8")
73
+
74
+ // Add header comment to the content
75
+ const headerComment = generateHeaderComment(file)
76
+ content = headerComment + "\n\n" + content
77
+
78
+ // Here you can add more processing logic if needed
79
+ // For example, replace imports, etc.
80
+
81
+ fs.writeFileSync(destFile, content)
82
+ console.log(`${COLORS.green}[tailjng CLI] Copied file: ${file}${COLORS.reset}`)
83
+ })
84
+
85
+ return true // Return true to indicate that it was installed successfully
86
+ }
87
+
88
+ module.exports = { copyComponentFiles }
package/cli/index.js ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { checkTailwindInstalled } = require("./settings/tailwind-check")
4
+ const { addComponent } = require("./component-manager")
5
+ const { getComponentList } = require("./settings/components-list")
6
+ const { COLORS } = require("./settings/colors")
7
+
8
+ const args = process.argv.slice(2)
9
+ const command = args[0]
10
+
11
+ async function main() {
12
+ if (command === "add") {
13
+ const componentName = args[1]
14
+ if (!componentName) {
15
+ console.error(`${COLORS.red}[tailjng CLI] ERROR: Please specify a component name.${COLORS.reset}`)
16
+ console.log(`${COLORS.cyan}Usage: npx tailjng add <componentName>${COLORS.reset}`)
17
+ process.exit(1)
18
+ }
19
+ checkTailwindInstalled()
20
+ await addComponent(componentName, getComponentList())
21
+ } else if (command === "list") {
22
+ showComponentList()
23
+ } else {
24
+ console.log(`${COLORS.cyan}Usage:
25
+ npx tailjng add <componentName> Add a component to your project
26
+ npx tailjng list List all available components${COLORS.reset}`)
27
+ }
28
+ }
29
+
30
+ function showComponentList() {
31
+ const componentList = getComponentList()
32
+ if (Object.keys(componentList).length === 0) {
33
+ console.log(`${COLORS.yellow}[tailjng CLI] No components available.${COLORS.reset}`)
34
+ return
35
+ }
36
+
37
+ console.log(`${COLORS.cyan}[tailjng CLI] Available components:${COLORS.reset}`)
38
+ for (const component in componentList) {
39
+ const dependencies =
40
+ componentList[component].dependencies.length > 0 ? componentList[component].dependencies.join(", ") : "None"
41
+ console.log(
42
+ `${COLORS.green}- ${component}${COLORS.reset} ${COLORS.dim}(Dependencies: ${dependencies})${COLORS.reset}`,
43
+ )
44
+ }
45
+ }
46
+
47
+ // Execute the main function
48
+ main().catch((error) => {
49
+ console.error(`${COLORS.red}[tailjng CLI] Unexpected error:${COLORS.reset}`, error)
50
+ process.exit(1)
51
+ })
@@ -0,0 +1,17 @@
1
+ // Color helpers
2
+ const COLORS = {
3
+ reset: "\x1b[0m",
4
+ bright: "\x1b[1m",
5
+ dim: "\x1b[2m",
6
+ underscore: "\x1b[4m",
7
+ red: "\x1b[31m",
8
+ green: "\x1b[32m",
9
+ yellow: "\x1b[33m",
10
+ blue: "\x1b[34m",
11
+ magenta: "\x1b[35m",
12
+ cyan: "\x1b[36m",
13
+ white: "\x1b[37m",
14
+ greenBright: "\x1b[92m",
15
+ }
16
+
17
+ module.exports = { COLORS }
@@ -0,0 +1,87 @@
1
+ function getComponentList() {
2
+ return {
3
+ 'mode-toggle': {
4
+ path: "src/lib/components/mode-toggle",
5
+ dependencies: [],
6
+ },
7
+ color: {
8
+ path: "src/lib/components/color",
9
+ dependencies: [],
10
+ },
11
+ tooltip: {
12
+ path: "src/lib/components/tooltip",
13
+ dependencies: [],
14
+ },
15
+ label: {
16
+ path: "src/lib/components/label",
17
+ dependencies: ["tooltip"],
18
+ },
19
+ 'toggle-radio': {
20
+ path: "src/lib/components/toggle-radio",
21
+ dependencies: [],
22
+ },
23
+ button: {
24
+ path: "src/lib/components/button",
25
+ dependencies: ["tooltip", "color"],
26
+ },
27
+ 'input-checkbox': {
28
+ path: "src/lib/components/checkbox/input-checkbox",
29
+ dependencies: ["color"],
30
+ },
31
+ 'switch-checkbox': {
32
+ path: "src/lib/components/checkbox/switch-checkbox",
33
+ dependencies: ["color"],
34
+ },
35
+ 'alert-dialog': {
36
+ path: "src/lib/components/alert/dialog-alert",
37
+ dependencies: ["button", "color"],
38
+ },
39
+ 'alert-toast': {
40
+ path: "src/lib/components/alert/toast-alert",
41
+ dependencies: ["button", "color"],
42
+ },
43
+ 'progress-bar': {
44
+ path: "src/lib/components/progress-bar",
45
+ dependencies: [],
46
+ },
47
+ 'viewer-image': {
48
+ path: "src/lib/components/image/viewer-image",
49
+ dependencies: ["button"],
50
+ },
51
+ dialog: {
52
+ path: "src/lib/components/dialog",
53
+ dependencies: [],
54
+ },
55
+ 'input-file': {
56
+ path: "src/lib/components/input/file-input",
57
+ dependencies: [],
58
+ },
59
+ 'input-textarea': {
60
+ path: "src/lib/components/input/textarea-input",
61
+ dependencies: [],
62
+ },
63
+ 'input-range': {
64
+ path: "src/lib/components/input/range-input",
65
+ dependencies: [],
66
+ },
67
+ input: {
68
+ path: "src/lib/components/input/input",
69
+ dependencies: [],
70
+ },
71
+ 'select-multi-table': {
72
+ path: "src/lib/components/select/multi-table",
73
+ dependencies: ["button"],
74
+ },
75
+ 'select-multi-dropdown': {
76
+ path: "src/lib/components/select/multi-dropdown",
77
+ dependencies: [],
78
+ },
79
+ 'select-dropdown': {
80
+ path: "src/lib/components/select/dropdown",
81
+ dependencies: [],
82
+ },
83
+ // Add more components as needed
84
+ }
85
+ }
86
+
87
+ module.exports = { getComponentList }
@@ -0,0 +1,42 @@
1
+ const path = require("path")
2
+
3
+ function generateHeaderComment(fileName) {
4
+ const headerContent = `===============================================
5
+ Component and Function Library - tailjNg
6
+ ===============================================
7
+ Description:
8
+ This library is designed to provide a set of reusable components and optimized functions
9
+ to facilitate the development of user interfaces and data management in web applications.
10
+ It includes tools to improve the developer experience and user interaction.
11
+
12
+ Purpose:
13
+ - Create modular and customizable components.
14
+ - Improve front-end development efficiency through reusable tools.
15
+ - Provide scalable solutions that are easy to integrate with existing applications.
16
+
17
+ Usage:
18
+ To access full functionality, simply import the necessary modules and use the
19
+ components according to your use case. Be sure to review the official documentation for detailed examples
20
+ on implementation and customization.
21
+
22
+ Authors:
23
+ Armando Josue Velasquez Delgado - Lead Developer
24
+
25
+ License:
26
+ This project is licensed under the BSD 3-Clause - see the LICENSE file for more details.
27
+
28
+ Version: 0.0.15
29
+ Creation Date: 2025-01-04
30
+ ===============================================`
31
+
32
+ const ext = path.extname(fileName).toLowerCase()
33
+ if (ext === ".ts" || ext === ".js" || ext === ".css" || ext === ".scss") {
34
+ return `/*\n${headerContent}\n*/`
35
+ } else if (ext === ".html") {
36
+ return `<!--\n${headerContent}\n-->`
37
+ } else {
38
+ return `/*\n${headerContent}\n*/`
39
+ }
40
+ }
41
+
42
+ module.exports = { generateHeaderComment }
@@ -0,0 +1,50 @@
1
+ const path = require("path")
2
+
3
+ /**
4
+ * Extracts folder structure information from the component path
5
+ * @param {string} componentPath - Path del componente (ej: "src/lib/components/alert/dialog-alert")
6
+ * @returns {object} - Information about the folder structure
7
+ */
8
+ function parseComponentPath(componentPath) {
9
+
10
+ // Remove the base prefix "src/lib/components/"
11
+ const basePath = "src/lib/components/"
12
+ const relativePath = componentPath.replace(basePath, "")
13
+
14
+ // Split the path into parts
15
+ const pathParts = relativePath.split("/")
16
+
17
+ // The last element is the component name
18
+ const componentFolder = pathParts[pathParts.length - 1]
19
+
20
+ // All except the last element are subfolders
21
+ const subfolders = pathParts.slice(0, -1)
22
+
23
+ return {
24
+ componentFolder,
25
+ subfolders,
26
+ hasSubfolders: subfolders.length > 0,
27
+ fullSubPath: subfolders.join("/"),
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Make sure to keep the folder structure
33
+ * @param {string} projectRoot - Project root directory
34
+ * @param {string} componentName - Component name
35
+ * @param {string} componentPath - Original component path
36
+ * @returns {string} - Full target path
37
+ */
38
+ function buildTargetPath(projectRoot, componentName, componentPath) {
39
+ const pathInfo = parseComponentPath(componentPath)
40
+
41
+ if (pathInfo.hasSubfolders) {
42
+ // If it has subfolders, keep the structure
43
+ return path.join(projectRoot, "src", "app", "tailjng", pathInfo.fullSubPath, componentName)
44
+ } else {
45
+ // If it doesn't have subfolders, use the original structure
46
+ return path.join(projectRoot, "src", "app", "tailjng", componentName)
47
+ }
48
+ }
49
+
50
+ module.exports = { parseComponentPath, buildTargetPath }
@@ -0,0 +1,37 @@
1
+ const readline = require("readline")
2
+ const { COLORS } = require("./colors")
3
+
4
+ function createReadlineInterface() {
5
+ return readline.createInterface({
6
+ input: process.stdin,
7
+ output: process.stdout,
8
+ })
9
+ }
10
+
11
+ function askQuestion(question) {
12
+ return new Promise((resolve) => {
13
+ const rl = createReadlineInterface()
14
+ rl.question(question, (answer) => {
15
+ rl.close()
16
+ resolve(answer.toLowerCase().trim())
17
+ })
18
+ })
19
+ }
20
+
21
+ async function askOverwrite(componentName, targetPath, isDependency = false) {
22
+ const componentType = isDependency ? "dependency component" : "component"
23
+
24
+ console.log(
25
+ `${COLORS.yellow}⚠ [tailjng CLI] WARNING: ${componentType} "${componentName}" already exists!${COLORS.reset}`,
26
+ )
27
+ console.log(`${COLORS.dim} Path: ${targetPath}${COLORS.reset}`)
28
+ console.log(
29
+ `${COLORS.yellow} This component may have been modified. Overwriting will replace your changes.${COLORS.reset}`,
30
+ )
31
+
32
+ const answer = await askQuestion(`${COLORS.cyan} Do you want to overwrite it? (y/N): ${COLORS.reset}`)
33
+
34
+ return answer === "y" || answer === "yes"
35
+ }
36
+
37
+ module.exports = { askOverwrite }
@@ -0,0 +1,21 @@
1
+ const { COLORS } = require("./colors")
2
+
3
+ function checkTailwindInstalled() {
4
+ try {
5
+ require.resolve("tailwindcss")
6
+ console.log(`${COLORS.green}[tailjng CLI] TailwindCSS is installed.${COLORS.reset}`)
7
+ } catch (e) {
8
+ console.warn(`${COLORS.yellow}
9
+ [tailjng CLI] WARNING:
10
+ ------------------------------------------------------------
11
+ TailwindCSS is not installed in your project.
12
+ Please install it to ensure styles work properly:
13
+ npm install tailwindcss
14
+ And generate the config:
15
+ npx tailwindcss init
16
+ ------------------------------------------------------------
17
+ ${COLORS.reset}`)
18
+ }
19
+ }
20
+
21
+ module.exports = { checkTailwindInstalled }