ui-thing 0.0.10 → 0.0.11
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 +21 -0
- package/dist/index.js +114 -8422
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/commands/add.ts +6 -2
- package/src/types.ts +1 -0
- package/src/utils/fetchComponents.ts +8 -0
- package/src/utils/promptForComponents.ts +8 -2
- package/src/comp.ts +0 -2287
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui-thing",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "CLI used to add Nuxt 3 components to a project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"axios": "^1.6.2",
|
|
43
44
|
"boxen": "^7.1.1",
|
|
44
45
|
"build": "^0.1.4",
|
|
45
46
|
"c12": "^1.5.1",
|
package/src/commands/add.ts
CHANGED
|
@@ -5,15 +5,17 @@ import kleur from "kleur";
|
|
|
5
5
|
import _ from "lodash";
|
|
6
6
|
import prompts from "prompts";
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import { Component } from "../types";
|
|
9
9
|
import { compareUIConfig } from "../utils/compareUIConfig";
|
|
10
10
|
import { addModuleToConfig, getNuxtConfig, getUIConfig, updateConfig } from "../utils/config";
|
|
11
|
+
import { fetchComponents } from "../utils/fetchComponents";
|
|
11
12
|
import { fileExists } from "../utils/fileExists";
|
|
12
13
|
import { installPackages } from "../utils/installPackages";
|
|
13
14
|
import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
|
|
14
15
|
import { promptUserForComponents } from "../utils/promptForComponents";
|
|
15
16
|
import { writeFile } from "../utils/writeFile";
|
|
16
17
|
|
|
18
|
+
let allComponents: Component[] = [];
|
|
17
19
|
const currentDirectory = process.cwd();
|
|
18
20
|
|
|
19
21
|
const findComponent = (name: string) => {
|
|
@@ -41,6 +43,8 @@ export const add = new Command()
|
|
|
41
43
|
consola.info("Config file not set. Exiting...");
|
|
42
44
|
process.exit(0);
|
|
43
45
|
}
|
|
46
|
+
// get components from API
|
|
47
|
+
allComponents = await fetchComponents();
|
|
44
48
|
|
|
45
49
|
let componentNames = components;
|
|
46
50
|
// if no components are passed, prompt the user to select components
|
|
@@ -65,7 +69,7 @@ export const add = new Command()
|
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
// store the components that are found
|
|
68
|
-
let found:
|
|
72
|
+
let found: Component[] = [];
|
|
69
73
|
componentNames.forEach((c) => {
|
|
70
74
|
if (findComponent(c)) {
|
|
71
75
|
found.push(findComponent(c)!);
|
package/src/types.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import ora from "ora";
|
|
1
2
|
import prompts from "prompts";
|
|
2
3
|
|
|
3
|
-
import
|
|
4
|
+
import { Component } from "../types";
|
|
5
|
+
import { fetchComponents } from "./fetchComponents";
|
|
4
6
|
|
|
5
7
|
export const promptUserForComponents = async (): Promise<string[]> => {
|
|
8
|
+
// get comps from API
|
|
9
|
+
const compsSpinner = ora("Fetching components...").start();
|
|
10
|
+
const allComponents = await fetchComponents();
|
|
11
|
+
compsSpinner.succeed("Fetched components");
|
|
6
12
|
const { components } = await prompts({
|
|
7
13
|
type: "autocompleteMultiselect",
|
|
8
14
|
name: "components",
|
|
9
15
|
message: "Select the components you want to add",
|
|
10
|
-
choices: allComponents.map((c) => ({ title: c.name, value: c.value })),
|
|
16
|
+
choices: allComponents.map((c: Component) => ({ title: c.name, value: c.value })),
|
|
11
17
|
onRender(kleur) {
|
|
12
18
|
// @ts-ignore
|
|
13
19
|
this.msg = kleur.bgCyan(" Choose components ") + " Select the components you want to add";
|