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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-thing",
3
- "version": "0.0.10",
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",
@@ -5,15 +5,17 @@ import kleur from "kleur";
5
5
  import _ from "lodash";
6
6
  import prompts from "prompts";
7
7
 
8
- import allComponents from "../comp";
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: typeof allComponents = [];
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
@@ -22,6 +22,7 @@ export type Component = {
22
22
  files: Composable[];
23
23
  utils: Composable[];
24
24
  composables: Composable[];
25
+ plugins: Composable[];
25
26
  components?: string[];
26
27
  askValidator?: boolean;
27
28
  };
@@ -0,0 +1,8 @@
1
+ import axios from "axios";
2
+
3
+ import { Component } from "../types";
4
+
5
+ export const fetchComponents = async () => {
6
+ const { data } = await axios.get<Component[]>("https://ui-thing.behonbaker.com/api/components");
7
+ return data;
8
+ };
@@ -1,13 +1,19 @@
1
+ import ora from "ora";
1
2
  import prompts from "prompts";
2
3
 
3
- import allComponents from "../comp";
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";