kmod-cli 1.4.10 → 1.4.12
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 +61 -2
- package/bin/gen-components.js +2 -0
- package/bin/gen-readme-name-key.js +39 -0
- package/bin/index.js +46 -0
- package/components.json +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,8 +38,67 @@ npx kumod add --all # add all component
|
|
|
38
38
|
npx kumod add button # add button component
|
|
39
39
|
#...any other command
|
|
40
40
|
```
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
## Components
|
|
42
|
+
|
|
43
|
+
- access-denied
|
|
44
|
+
- breadcumb
|
|
45
|
+
- count-down
|
|
46
|
+
- count-input
|
|
47
|
+
- button
|
|
48
|
+
- calendar
|
|
49
|
+
- date-input
|
|
50
|
+
- date-range-picker
|
|
51
|
+
- label
|
|
52
|
+
- popover
|
|
53
|
+
- select
|
|
54
|
+
- switch
|
|
55
|
+
- datetime-picker
|
|
56
|
+
- input
|
|
57
|
+
- period-input
|
|
58
|
+
- time-picker-input
|
|
59
|
+
- time-picker-utils
|
|
60
|
+
- time-picker
|
|
61
|
+
- gradient-outline
|
|
62
|
+
- gradient-svg
|
|
63
|
+
- grid-layout
|
|
64
|
+
- hydrate-guard
|
|
65
|
+
- image
|
|
66
|
+
- loader-slash-gradient
|
|
67
|
+
- masonry-gallery
|
|
68
|
+
- modal
|
|
69
|
+
- multi-select
|
|
70
|
+
- non-hydration
|
|
71
|
+
- portal
|
|
72
|
+
- segments-circle
|
|
73
|
+
- single-select
|
|
74
|
+
- stroke-circle
|
|
75
|
+
- column-table
|
|
76
|
+
- data-table
|
|
77
|
+
- readme
|
|
78
|
+
- table
|
|
79
|
+
- text-hover-effect
|
|
80
|
+
- timout-loader
|
|
81
|
+
- toast
|
|
82
|
+
- config
|
|
83
|
+
- feature-config
|
|
84
|
+
- keys
|
|
85
|
+
- api-service
|
|
86
|
+
- calculate
|
|
87
|
+
- idb
|
|
88
|
+
- lib
|
|
89
|
+
- storage
|
|
90
|
+
- fade-on-scroll
|
|
91
|
+
- safe-action
|
|
92
|
+
- spam-guard
|
|
93
|
+
- utils
|
|
94
|
+
- feature-guard
|
|
95
|
+
- refine-provider
|
|
96
|
+
- query
|
|
97
|
+
- color-by-text
|
|
98
|
+
- stripe-effect
|
|
99
|
+
- kookies
|
|
100
|
+
- hash-aes
|
|
101
|
+
- simple-validate
|
|
43
102
|
## Contributing
|
|
44
103
|
|
|
45
104
|
Contributions are welcome! Please open issues or pull requests.
|
package/bin/gen-components.js
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
|
|
8
|
+
const readmePath = path.join(__dirname, '../README.md');
|
|
9
|
+
const componentsPath = path.join(__dirname, '../components.json');
|
|
10
|
+
|
|
11
|
+
// đọc components.json
|
|
12
|
+
const componentsConfig = JSON.parse(
|
|
13
|
+
fs.readFileSync(componentsPath, 'utf8')
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// build list
|
|
17
|
+
const componentList = Object.keys(componentsConfig)
|
|
18
|
+
.map((k) => `- ${k}`)
|
|
19
|
+
.join('\n');
|
|
20
|
+
|
|
21
|
+
// đọc README
|
|
22
|
+
const readmeContent = fs.readFileSync(readmePath, 'utf8');
|
|
23
|
+
|
|
24
|
+
// regex tìm block ## Components
|
|
25
|
+
const regex = /## Components[\s\S]*?(?=\n## |\n?$)/;
|
|
26
|
+
|
|
27
|
+
if (!regex.test(readmeContent)) {
|
|
28
|
+
throw new Error('Không tìm thấy heading "## Components" trong README.md');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const newReadme = readmeContent.replace(
|
|
32
|
+
regex,
|
|
33
|
+
`## Components\n\n${componentList}`
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// ghi lại README
|
|
37
|
+
fs.writeFileSync(readmePath, newReadme);
|
|
38
|
+
|
|
39
|
+
console.log('✅ Updated README.md');
|
package/bin/index.js
CHANGED
|
@@ -142,6 +142,41 @@ async function addComponents() {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
async function addComponentsByName(names) {
|
|
146
|
+
const collectedDeps = { deps: [], devDeps: [] };
|
|
147
|
+
|
|
148
|
+
for (const name of names) {
|
|
149
|
+
await copyComponent(name, collectedDeps);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
collectedDeps.deps = [...new Set(collectedDeps.deps)];
|
|
153
|
+
collectedDeps.devDeps = [...new Set(collectedDeps.devDeps)];
|
|
154
|
+
|
|
155
|
+
if (collectedDeps.deps.length || collectedDeps.devDeps.length) {
|
|
156
|
+
console.log(`⚠️ Missing packages detected:`);
|
|
157
|
+
|
|
158
|
+
if (collectedDeps.deps.length)
|
|
159
|
+
console.log(" - deps:", collectedDeps.deps.join(", "));
|
|
160
|
+
if (collectedDeps.devDeps.length)
|
|
161
|
+
console.log(" - devDeps:", collectedDeps.devDeps.join(", "));
|
|
162
|
+
|
|
163
|
+
const { confirm } = await inquirer.prompt([
|
|
164
|
+
{
|
|
165
|
+
type: "confirm",
|
|
166
|
+
name: "confirm",
|
|
167
|
+
message: "Install all missing packages now?",
|
|
168
|
+
default: true,
|
|
169
|
+
},
|
|
170
|
+
]);
|
|
171
|
+
|
|
172
|
+
if (confirm) {
|
|
173
|
+
if (collectedDeps.deps.length) installDeps(collectedDeps.deps, false);
|
|
174
|
+
if (collectedDeps.devDeps.length) installDeps(collectedDeps.devDeps, true);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
145
180
|
// ====================== CLI Commands ======================
|
|
146
181
|
program
|
|
147
182
|
.name("kumod")
|
|
@@ -149,5 +184,16 @@ program
|
|
|
149
184
|
.version("1.0.0");
|
|
150
185
|
|
|
151
186
|
program.command("add").description("Select components to add").action(addComponents);
|
|
187
|
+
program
|
|
188
|
+
.command("add [components...]")
|
|
189
|
+
.description("Add components by name or select interactively")
|
|
190
|
+
.action(async (components) => {
|
|
191
|
+
if (components.length > 0) {
|
|
192
|
+
await addComponentsByName(components);
|
|
193
|
+
} else {
|
|
194
|
+
await addComponents();
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
152
198
|
|
|
153
199
|
program.parse(process.argv);
|
package/components.json
CHANGED