ui-thing 0.0.4 → 0.0.5
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/.github/workflows/main.yml +19 -0
- package/.prettierrc +12 -12
- package/CHANGELOG.md +32 -129
- package/README.md +69 -69
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
- package/src/commands/add.ts +237 -237
- package/src/commands/init.ts +72 -72
- package/src/commands/prettier.ts +47 -47
- package/src/commands/theme.ts +61 -61
- package/src/comp.ts +2134 -2134
- package/src/index.ts +30 -30
- package/src/templates/css.ts +641 -641
- package/src/templates/prettier.ts +16 -16
- package/src/templates/tailwind.ts +101 -101
- package/src/types.ts +13 -13
- package/src/utils/addPrettierConfig.ts +24 -24
- package/src/utils/compareUIConfig.ts +35 -35
- package/src/utils/config.ts +84 -84
- package/src/utils/constants.ts +36 -36
- package/src/utils/fileExists.ts +10 -10
- package/src/utils/installPackages.ts +28 -28
- package/src/utils/printFancyBoxMessage.ts +19 -19
- package/src/utils/promptForComponents.ts +17 -17
- package/src/utils/uiConfigPrompt.ts +73 -73
- package/src/utils/writeFile.ts +18 -18
- package/tsconfig.json +16 -16
- package/tsup.config.ts +12 -12
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { execa } from "execa";
|
|
2
|
-
import _ from "lodash";
|
|
3
|
-
import ora from "ora";
|
|
4
|
-
|
|
5
|
-
export const installPackages = async (
|
|
6
|
-
packageManager: string,
|
|
7
|
-
deps?: string[] | string,
|
|
8
|
-
devDeps?: string | string[]
|
|
9
|
-
) => {
|
|
10
|
-
if (typeof deps === "string") {
|
|
11
|
-
deps = [deps];
|
|
12
|
-
}
|
|
13
|
-
if (typeof devDeps === "string") {
|
|
14
|
-
devDeps = [devDeps];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const depsSpinner = ora("Installing dependencies...").start();
|
|
18
|
-
if (!_.isUndefined(deps) && !_.isEmpty(deps)) {
|
|
19
|
-
await execa(packageManager, [packageManager === "yarn" ? "add" : "install", ...deps]);
|
|
20
|
-
}
|
|
21
|
-
depsSpinner.text = "Installing dev dependencies...";
|
|
22
|
-
if (!_.isUndefined(devDeps) && !_.isEmpty(devDeps)) {
|
|
23
|
-
await execa(packageManager, [packageManager === "yarn" ? "add" : "install", "-D", ...devDeps]);
|
|
24
|
-
}
|
|
25
|
-
await execa(packageManager, ["run", "postinstall"]);
|
|
26
|
-
|
|
27
|
-
depsSpinner.succeed("Installed dependencies!");
|
|
28
|
-
};
|
|
1
|
+
import { execa } from "execa";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
|
|
5
|
+
export const installPackages = async (
|
|
6
|
+
packageManager: string,
|
|
7
|
+
deps?: string[] | string,
|
|
8
|
+
devDeps?: string | string[]
|
|
9
|
+
) => {
|
|
10
|
+
if (typeof deps === "string") {
|
|
11
|
+
deps = [deps];
|
|
12
|
+
}
|
|
13
|
+
if (typeof devDeps === "string") {
|
|
14
|
+
devDeps = [devDeps];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const depsSpinner = ora("Installing dependencies...").start();
|
|
18
|
+
if (!_.isUndefined(deps) && !_.isEmpty(deps)) {
|
|
19
|
+
await execa(packageManager, [packageManager === "yarn" ? "add" : "install", ...deps]);
|
|
20
|
+
}
|
|
21
|
+
depsSpinner.text = "Installing dev dependencies...";
|
|
22
|
+
if (!_.isUndefined(devDeps) && !_.isEmpty(devDeps)) {
|
|
23
|
+
await execa(packageManager, [packageManager === "yarn" ? "add" : "install", "-D", ...devDeps]);
|
|
24
|
+
}
|
|
25
|
+
await execa(packageManager, ["run", "postinstall"]);
|
|
26
|
+
|
|
27
|
+
depsSpinner.succeed("Installed dependencies!");
|
|
28
|
+
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import boxen from "boxen";
|
|
2
|
-
import figlet from "figlet";
|
|
3
|
-
import type { Options } from "boxen";
|
|
4
|
-
|
|
5
|
-
export const printFancyBoxMessage = (title: string, boxOptions?: Options, description?: string) => {
|
|
6
|
-
console.log("\n");
|
|
7
|
-
console.log(
|
|
8
|
-
boxen(figlet.textSync(title), {
|
|
9
|
-
borderColor: "greenBright",
|
|
10
|
-
padding: 1,
|
|
11
|
-
borderStyle: "round",
|
|
12
|
-
titleAlignment: "center",
|
|
13
|
-
...boxOptions,
|
|
14
|
-
})
|
|
15
|
-
);
|
|
16
|
-
if (description) {
|
|
17
|
-
console.log(`\n${description}`);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
1
|
+
import boxen from "boxen";
|
|
2
|
+
import figlet from "figlet";
|
|
3
|
+
import type { Options } from "boxen";
|
|
4
|
+
|
|
5
|
+
export const printFancyBoxMessage = (title: string, boxOptions?: Options, description?: string) => {
|
|
6
|
+
console.log("\n");
|
|
7
|
+
console.log(
|
|
8
|
+
boxen(figlet.textSync(title), {
|
|
9
|
+
borderColor: "greenBright",
|
|
10
|
+
padding: 1,
|
|
11
|
+
borderStyle: "round",
|
|
12
|
+
titleAlignment: "center",
|
|
13
|
+
...boxOptions,
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
if (description) {
|
|
17
|
+
console.log(`\n${description}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import prompts from "prompts";
|
|
2
|
-
|
|
3
|
-
import allComponents from "../comp";
|
|
4
|
-
|
|
5
|
-
export const promptUserForComponents = async (): Promise<string[]> => {
|
|
6
|
-
const { components } = await prompts({
|
|
7
|
-
type: "autocompleteMultiselect",
|
|
8
|
-
name: "components",
|
|
9
|
-
message: "Select the components you want to add",
|
|
10
|
-
choices: allComponents.map((c) => ({ title: c.name, value: c.value })),
|
|
11
|
-
onRender(kleur) {
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
this.msg = kleur.bgCyan(" Choose components ") + " Select the components you want to add";
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
return components;
|
|
17
|
-
};
|
|
1
|
+
import prompts from "prompts";
|
|
2
|
+
|
|
3
|
+
import allComponents from "../comp";
|
|
4
|
+
|
|
5
|
+
export const promptUserForComponents = async (): Promise<string[]> => {
|
|
6
|
+
const { components } = await prompts({
|
|
7
|
+
type: "autocompleteMultiselect",
|
|
8
|
+
name: "components",
|
|
9
|
+
message: "Select the components you want to add",
|
|
10
|
+
choices: allComponents.map((c) => ({ title: c.name, value: c.value })),
|
|
11
|
+
onRender(kleur) {
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
this.msg = kleur.bgCyan(" Choose components ") + " Select the components you want to add";
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return components;
|
|
17
|
+
};
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import kleur from "kleur";
|
|
2
|
-
import prompts from "prompts";
|
|
3
|
-
|
|
4
|
-
import { CSS_THEME_OPTIONS } from "./constants";
|
|
5
|
-
|
|
6
|
-
export const initPrompts = async () => {
|
|
7
|
-
const response = await prompts([
|
|
8
|
-
{
|
|
9
|
-
name: "theme",
|
|
10
|
-
type: "autocomplete",
|
|
11
|
-
message: "Which theme do you want to start with?",
|
|
12
|
-
choices: CSS_THEME_OPTIONS,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: "tailwindCSSLocation",
|
|
16
|
-
type: "text",
|
|
17
|
-
message: "Where is your tailwind.css file located?",
|
|
18
|
-
initial: "assets/css/tailwind.css",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
name: "tailwindConfigLocation",
|
|
22
|
-
type: "text",
|
|
23
|
-
message: "Where is your tailwind.config file located?",
|
|
24
|
-
initial: "tailwind.config.js",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: "componentsLocation",
|
|
28
|
-
type: "text",
|
|
29
|
-
message: "Where should your components be stored?",
|
|
30
|
-
initial: "components/UI",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "composablesLocation",
|
|
34
|
-
type: "text",
|
|
35
|
-
message: "Where should your composables be stored?",
|
|
36
|
-
initial: "composables",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "utilsLocation",
|
|
40
|
-
type: "text",
|
|
41
|
-
message: "Where should your utils be stored?",
|
|
42
|
-
initial: "utils",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "force",
|
|
46
|
-
type: "confirm",
|
|
47
|
-
message: "Should we just replace component files if they already exist?",
|
|
48
|
-
initial: true,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "useDefaultFilename",
|
|
52
|
-
type: "confirm",
|
|
53
|
-
message: "Would you like to use the default filename when adding components?",
|
|
54
|
-
initial: true,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: "packageManager",
|
|
58
|
-
type: "select",
|
|
59
|
-
message: "Which package manager do you use?",
|
|
60
|
-
choices: [
|
|
61
|
-
{ title: "NPM", value: "npm" },
|
|
62
|
-
{ title: "Yarn", value: "yarn" },
|
|
63
|
-
{ title: "PNPM", value: "pnpm" },
|
|
64
|
-
{ title: "Bun", value: "bun" },
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
]);
|
|
68
|
-
if (!response || Object.keys(response).length < 9) {
|
|
69
|
-
console.log(kleur.red("Incomplete configuration submitted. Exiting..."));
|
|
70
|
-
return process.exit(0);
|
|
71
|
-
}
|
|
72
|
-
return response;
|
|
73
|
-
};
|
|
1
|
+
import kleur from "kleur";
|
|
2
|
+
import prompts from "prompts";
|
|
3
|
+
|
|
4
|
+
import { CSS_THEME_OPTIONS } from "./constants";
|
|
5
|
+
|
|
6
|
+
export const initPrompts = async () => {
|
|
7
|
+
const response = await prompts([
|
|
8
|
+
{
|
|
9
|
+
name: "theme",
|
|
10
|
+
type: "autocomplete",
|
|
11
|
+
message: "Which theme do you want to start with?",
|
|
12
|
+
choices: CSS_THEME_OPTIONS,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "tailwindCSSLocation",
|
|
16
|
+
type: "text",
|
|
17
|
+
message: "Where is your tailwind.css file located?",
|
|
18
|
+
initial: "assets/css/tailwind.css",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "tailwindConfigLocation",
|
|
22
|
+
type: "text",
|
|
23
|
+
message: "Where is your tailwind.config file located?",
|
|
24
|
+
initial: "tailwind.config.js",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "componentsLocation",
|
|
28
|
+
type: "text",
|
|
29
|
+
message: "Where should your components be stored?",
|
|
30
|
+
initial: "components/UI",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "composablesLocation",
|
|
34
|
+
type: "text",
|
|
35
|
+
message: "Where should your composables be stored?",
|
|
36
|
+
initial: "composables",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "utilsLocation",
|
|
40
|
+
type: "text",
|
|
41
|
+
message: "Where should your utils be stored?",
|
|
42
|
+
initial: "utils",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "force",
|
|
46
|
+
type: "confirm",
|
|
47
|
+
message: "Should we just replace component files if they already exist?",
|
|
48
|
+
initial: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "useDefaultFilename",
|
|
52
|
+
type: "confirm",
|
|
53
|
+
message: "Would you like to use the default filename when adding components?",
|
|
54
|
+
initial: true,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "packageManager",
|
|
58
|
+
type: "select",
|
|
59
|
+
message: "Which package manager do you use?",
|
|
60
|
+
choices: [
|
|
61
|
+
{ title: "NPM", value: "npm" },
|
|
62
|
+
{ title: "Yarn", value: "yarn" },
|
|
63
|
+
{ title: "PNPM", value: "pnpm" },
|
|
64
|
+
{ title: "Bun", value: "bun" },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
]);
|
|
68
|
+
if (!response || Object.keys(response).length < 9) {
|
|
69
|
+
console.log(kleur.red("Incomplete configuration submitted. Exiting..."));
|
|
70
|
+
return process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
return response;
|
|
73
|
+
};
|
package/src/utils/writeFile.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
import { fileExists } from "./fileExists";
|
|
5
|
-
|
|
6
|
-
export const writeFile = async (filePath: string, fileContent: string) => {
|
|
7
|
-
// check if the file exists
|
|
8
|
-
const exists = await fileExists(filePath);
|
|
9
|
-
// if it doesn't, create it
|
|
10
|
-
if (!exists) {
|
|
11
|
-
// if it doesn't, create it
|
|
12
|
-
const folderPath = path.dirname(filePath);
|
|
13
|
-
if (!fs.existsSync(folderPath)) {
|
|
14
|
-
fs.mkdirSync(folderPath, { recursive: true });
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
fs.writeFileSync(filePath, fileContent);
|
|
18
|
-
};
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { fileExists } from "./fileExists";
|
|
5
|
+
|
|
6
|
+
export const writeFile = async (filePath: string, fileContent: string) => {
|
|
7
|
+
// check if the file exists
|
|
8
|
+
const exists = await fileExists(filePath);
|
|
9
|
+
// if it doesn't, create it
|
|
10
|
+
if (!exists) {
|
|
11
|
+
// if it doesn't, create it
|
|
12
|
+
const folderPath = path.dirname(filePath);
|
|
13
|
+
if (!fs.existsSync(folderPath)) {
|
|
14
|
+
fs.mkdirSync(folderPath, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
fs.writeFileSync(filePath, fileContent);
|
|
18
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": ["src/**/*"],
|
|
3
|
-
"exclude": ["node_modules", "**/*.spec.ts", "dist"],
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"target": "ESNext",
|
|
6
|
-
"module": "commonjs",
|
|
7
|
-
"outDir": "dist",
|
|
8
|
-
"rootDir": "src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"sourceMap": true,
|
|
14
|
-
"allowSyntheticDefaultImports": true
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"include": ["src/**/*"],
|
|
3
|
+
"exclude": ["node_modules", "**/*.spec.ts", "dist"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"rootDir": "src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"allowSyntheticDefaultImports": true
|
|
15
|
+
}
|
|
16
|
+
}
|
package/tsup.config.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
sourcemap: true,
|
|
5
|
-
entry: ["src/index.ts"],
|
|
6
|
-
dts: true,
|
|
7
|
-
clean: true,
|
|
8
|
-
format: ["esm"],
|
|
9
|
-
minify: true,
|
|
10
|
-
target: "esnext",
|
|
11
|
-
outDir: "dist",
|
|
12
|
-
});
|
|
1
|
+
import { defineConfig } from "tsup";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
sourcemap: true,
|
|
5
|
+
entry: ["src/index.ts"],
|
|
6
|
+
dts: true,
|
|
7
|
+
clean: true,
|
|
8
|
+
format: ["esm"],
|
|
9
|
+
minify: true,
|
|
10
|
+
target: "esnext",
|
|
11
|
+
outDir: "dist",
|
|
12
|
+
});
|