ui-thing 0.0.29 → 0.0.30
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/CHANGELOG.md +13 -0
- package/dist/index.js +66 -66
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/add.ts +18 -11
- package/src/commands/init.ts +1 -0
- package/src/types.ts +1 -1
- package/src/utils/config.ts +17 -1
- package/src/utils/promptForComponents.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui-thing",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"description": "CLI used to add Nuxt 3 components to a project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"boxen": "^7.1.1",
|
|
46
46
|
"build": "^0.1.4",
|
|
47
47
|
"c12": "^1.9.0",
|
|
48
|
-
"commander": "^
|
|
48
|
+
"commander": "^12.0.0",
|
|
49
49
|
"defu": "^6.1.4",
|
|
50
50
|
"execa": "^8.0.1",
|
|
51
51
|
"figlet": "^1.7.0",
|
package/src/commands/add.ts
CHANGED
|
@@ -30,8 +30,9 @@ export const add = new Command()
|
|
|
30
30
|
.name("add")
|
|
31
31
|
.command("add")
|
|
32
32
|
.description("Add a list of components to your project.")
|
|
33
|
+
.option("-a --all", "Add all components to your project.", false)
|
|
33
34
|
.argument("[componentNames...]", "Components that you want to add.")
|
|
34
|
-
.action(async (components: Array<string
|
|
35
|
+
.action(async (components: Array<string>, options: { all?: boolean }) => {
|
|
35
36
|
// Get nuxt config
|
|
36
37
|
const cfg = await getNuxtConfig();
|
|
37
38
|
// Get ui config
|
|
@@ -48,7 +49,7 @@ export const add = new Command()
|
|
|
48
49
|
let componentNames = components;
|
|
49
50
|
// if no components are passed, prompt the user to select components
|
|
50
51
|
if (componentNames.length === 0) {
|
|
51
|
-
const response = await promptUserForComponents();
|
|
52
|
+
const response = await promptUserForComponents(options.all);
|
|
52
53
|
if ((response && response.length === 0) || !response) {
|
|
53
54
|
consola.info("No components selected. Exiting...");
|
|
54
55
|
process.exit(0);
|
|
@@ -277,16 +278,22 @@ export const add = new Command()
|
|
|
277
278
|
|
|
278
279
|
// check if the foundDeps & foundDevDeps lists are not empty, ask the user to install them
|
|
279
280
|
if (foundDeps.length > 0 || foundDevDeps.length > 0) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
name: "confirmInstall",
|
|
283
|
-
message: `Do you want to install the following packages: ${kleur.cyan(
|
|
284
|
-
foundDeps.join(", ")
|
|
285
|
-
)} ${kleur.cyan(foundDevDeps.join(", "))}`,
|
|
286
|
-
initial: true,
|
|
287
|
-
});
|
|
288
|
-
if (confirmInstall) {
|
|
281
|
+
// if the all option was passed, install the packages without asking
|
|
282
|
+
if (options.all) {
|
|
289
283
|
await installPackages(uiConfig.packageManager, foundDeps, foundDevDeps);
|
|
284
|
+
} else {
|
|
285
|
+
// Ask the user to install the packages
|
|
286
|
+
const { confirmInstall } = await prompts({
|
|
287
|
+
type: "confirm",
|
|
288
|
+
name: "confirmInstall",
|
|
289
|
+
message: `Do you want to install the following packages: ${kleur.cyan(
|
|
290
|
+
foundDeps.join(", ")
|
|
291
|
+
)} ${kleur.cyan(foundDevDeps.join(", "))}`,
|
|
292
|
+
initial: true,
|
|
293
|
+
});
|
|
294
|
+
if (confirmInstall) {
|
|
295
|
+
await installPackages(uiConfig.packageManager, foundDeps, foundDevDeps);
|
|
296
|
+
}
|
|
290
297
|
}
|
|
291
298
|
}
|
|
292
299
|
|
package/src/commands/init.ts
CHANGED
|
@@ -19,6 +19,7 @@ export const init = new Command()
|
|
|
19
19
|
"Initialize UI Thing in your Nuxt3 project. This will: 1. Create a tailwind.config.js file 2. Update your nuxt.config.ts file 3. Add the necessary dependencies 4. Create a ui-thing.config.ts file with the default configuration"
|
|
20
20
|
)
|
|
21
21
|
.option("-f --force", "Overwrite config file if it exists.", false)
|
|
22
|
+
.option("-y --yes", "Skip prompts and use default values.", false)
|
|
22
23
|
.action(async (options: InitOptions) => {
|
|
23
24
|
// Get nuxt config
|
|
24
25
|
const cfg = await getNuxtConfig();
|
package/src/types.ts
CHANGED
package/src/utils/config.ts
CHANGED
|
@@ -12,6 +12,17 @@ import { initPrompts } from "./uiConfigPrompt";
|
|
|
12
12
|
|
|
13
13
|
const currentDir = process.cwd();
|
|
14
14
|
const uiConfigFilename = "ui-thing.config.ts";
|
|
15
|
+
const defaultConfig = {
|
|
16
|
+
theme: "zinc",
|
|
17
|
+
tailwindCSSLocation: "assets/css/tailwind.css",
|
|
18
|
+
tailwindConfigLocation: "tailwind.config.js",
|
|
19
|
+
componentsLocation: "components/Ui",
|
|
20
|
+
composablesLocation: "composables",
|
|
21
|
+
utilsLocation: "utils",
|
|
22
|
+
force: true,
|
|
23
|
+
useDefaultFilename: true,
|
|
24
|
+
packageManager: "npm",
|
|
25
|
+
};
|
|
15
26
|
|
|
16
27
|
export const getNuxtConfig = async () => {
|
|
17
28
|
if (!fse.existsSync("nuxt.config.ts")) {
|
|
@@ -28,7 +39,12 @@ export const getUIConfig = async (options?: InitOptions) => {
|
|
|
28
39
|
let uiConfig: UIConfig = {} as UIConfig;
|
|
29
40
|
|
|
30
41
|
if (!configFileExists || options?.force) {
|
|
31
|
-
|
|
42
|
+
// if option yes is passed, use default values
|
|
43
|
+
if (options?.yes) {
|
|
44
|
+
uiConfig = defaultConfig;
|
|
45
|
+
} else {
|
|
46
|
+
uiConfig = await initPrompts();
|
|
47
|
+
}
|
|
32
48
|
await fse.writeFile(uiConfigFilename, `export default ${JSON.stringify(uiConfig, null, 2)}`);
|
|
33
49
|
// Check if user chose pnpm as package manager
|
|
34
50
|
if (uiConfig.packageManager === "pnpm") {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import ora from "ora";
|
|
2
1
|
import prompts from "prompts";
|
|
3
2
|
|
|
4
3
|
import allComponents from "../comps";
|
|
5
4
|
import { Component } from "../types";
|
|
6
5
|
|
|
7
|
-
export const promptUserForComponents = async (): Promise<string[]> => {
|
|
6
|
+
export const promptUserForComponents = async (all?: boolean): Promise<string[]> => {
|
|
7
|
+
// If all is true, return all components
|
|
8
|
+
if (all) return allComponents.map((c: Component) => c.value);
|
|
8
9
|
const { components } = await prompts({
|
|
9
10
|
type: "autocompleteMultiselect",
|
|
10
11
|
name: "components",
|