ui-thing 0.0.3 → 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 -19
- package/.prettierrc +12 -12
- package/CHANGELOG.md +32 -17
- package/README.md +69 -67
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- 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
package/src/commands/prettier.ts
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import prompts from "prompts";
|
|
3
|
-
|
|
4
|
-
import { addPrettierConfig } from "../utils/addPrettierConfig";
|
|
5
|
-
import { installPackages } from "../utils/installPackages";
|
|
6
|
-
import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
|
|
7
|
-
|
|
8
|
-
export const addPrettier = new Command()
|
|
9
|
-
.command("prettier")
|
|
10
|
-
.name("prettier")
|
|
11
|
-
.description("Add prettier to your project.")
|
|
12
|
-
.action(async () => {
|
|
13
|
-
const added = await addPrettierConfig(undefined, false);
|
|
14
|
-
if (!added) {
|
|
15
|
-
printFancyBoxMessage(
|
|
16
|
-
"Not Added",
|
|
17
|
-
{ title: "Prettier Not Added", borderColor: "red" },
|
|
18
|
-
`Prettier config was not added.`
|
|
19
|
-
);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const { pkgManager } = await prompts({
|
|
24
|
-
name: "pkgManager",
|
|
25
|
-
type: "select",
|
|
26
|
-
message: "Which package manager are you using?",
|
|
27
|
-
choices: [
|
|
28
|
-
{ title: "npm", value: "npm" },
|
|
29
|
-
{ title: "yarn", value: "yarn" },
|
|
30
|
-
{ title: "pnpm", value: "pnpm" },
|
|
31
|
-
{ title: "bun", value: "bun" },
|
|
32
|
-
],
|
|
33
|
-
});
|
|
34
|
-
if (!pkgManager) return process.exit(0);
|
|
35
|
-
|
|
36
|
-
// install prettier dep
|
|
37
|
-
await installPackages(pkgManager, undefined, [
|
|
38
|
-
"prettier",
|
|
39
|
-
"prettier-plugin-tailwindcss",
|
|
40
|
-
"@ianvs/prettier-plugin-sort-imports",
|
|
41
|
-
]);
|
|
42
|
-
printFancyBoxMessage(
|
|
43
|
-
"All Done!",
|
|
44
|
-
{ title: "Prettier Added" },
|
|
45
|
-
`A .prettierrc file has been added to your project and the code formatted. Enjoy!`
|
|
46
|
-
);
|
|
47
|
-
});
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import prompts from "prompts";
|
|
3
|
+
|
|
4
|
+
import { addPrettierConfig } from "../utils/addPrettierConfig";
|
|
5
|
+
import { installPackages } from "../utils/installPackages";
|
|
6
|
+
import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
|
|
7
|
+
|
|
8
|
+
export const addPrettier = new Command()
|
|
9
|
+
.command("prettier")
|
|
10
|
+
.name("prettier")
|
|
11
|
+
.description("Add prettier to your project.")
|
|
12
|
+
.action(async () => {
|
|
13
|
+
const added = await addPrettierConfig(undefined, false);
|
|
14
|
+
if (!added) {
|
|
15
|
+
printFancyBoxMessage(
|
|
16
|
+
"Not Added",
|
|
17
|
+
{ title: "Prettier Not Added", borderColor: "red" },
|
|
18
|
+
`Prettier config was not added.`
|
|
19
|
+
);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { pkgManager } = await prompts({
|
|
24
|
+
name: "pkgManager",
|
|
25
|
+
type: "select",
|
|
26
|
+
message: "Which package manager are you using?",
|
|
27
|
+
choices: [
|
|
28
|
+
{ title: "npm", value: "npm" },
|
|
29
|
+
{ title: "yarn", value: "yarn" },
|
|
30
|
+
{ title: "pnpm", value: "pnpm" },
|
|
31
|
+
{ title: "bun", value: "bun" },
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
if (!pkgManager) return process.exit(0);
|
|
35
|
+
|
|
36
|
+
// install prettier dep
|
|
37
|
+
await installPackages(pkgManager, undefined, [
|
|
38
|
+
"prettier",
|
|
39
|
+
"prettier-plugin-tailwindcss",
|
|
40
|
+
"@ianvs/prettier-plugin-sort-imports",
|
|
41
|
+
]);
|
|
42
|
+
printFancyBoxMessage(
|
|
43
|
+
"All Done!",
|
|
44
|
+
{ title: "Prettier Added" },
|
|
45
|
+
`A .prettierrc file has been added to your project and the code formatted. Enjoy!`
|
|
46
|
+
);
|
|
47
|
+
});
|
package/src/commands/theme.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { consola } from "consola";
|
|
3
|
-
import fse from "fs-extra";
|
|
4
|
-
import _ from "lodash";
|
|
5
|
-
import prompts from "prompts";
|
|
6
|
-
|
|
7
|
-
import { createCSS } from "../templates/css";
|
|
8
|
-
import { compareUIConfig } from "../utils/compareUIConfig";
|
|
9
|
-
import { getUIConfig } from "../utils/config";
|
|
10
|
-
import { CSS_THEME_OPTIONS } from "../utils/constants";
|
|
11
|
-
import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
|
|
12
|
-
|
|
13
|
-
export const theme = new Command()
|
|
14
|
-
.command("theme")
|
|
15
|
-
.name("theme")
|
|
16
|
-
.description("Add a new theme to your project.")
|
|
17
|
-
.action(async () => {
|
|
18
|
-
// Get ui config
|
|
19
|
-
let uiConfig = await getUIConfig();
|
|
20
|
-
let uiConfigIsCorrect = await compareUIConfig();
|
|
21
|
-
if (!uiConfigIsCorrect) {
|
|
22
|
-
uiConfig = await getUIConfig({ force: true });
|
|
23
|
-
}
|
|
24
|
-
if (_.isEmpty(uiConfig)) {
|
|
25
|
-
consola.info("Config file not set. Exiting...");
|
|
26
|
-
process.exit(0);
|
|
27
|
-
}
|
|
28
|
-
const { theme } = await prompts([
|
|
29
|
-
{
|
|
30
|
-
name: "theme",
|
|
31
|
-
type: "autocomplete",
|
|
32
|
-
message: "Which theme do you want to add?",
|
|
33
|
-
choices: CSS_THEME_OPTIONS,
|
|
34
|
-
},
|
|
35
|
-
]);
|
|
36
|
-
if (!theme) {
|
|
37
|
-
console.log("No theme selected. Exiting...");
|
|
38
|
-
return process.exit(0);
|
|
39
|
-
}
|
|
40
|
-
if (fse.existsSync(uiConfig.tailwindCSSLocation)) {
|
|
41
|
-
const { force } = await prompts([
|
|
42
|
-
{
|
|
43
|
-
name: "force",
|
|
44
|
-
type: "confirm",
|
|
45
|
-
message: "Do you want to overwrite your current css file?",
|
|
46
|
-
initial: true,
|
|
47
|
-
},
|
|
48
|
-
]);
|
|
49
|
-
if (!force) {
|
|
50
|
-
console.log("Exiting...");
|
|
51
|
-
return process.exit(0);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
fse.writeFileSync(uiConfig.tailwindCSSLocation, createCSS(theme.toUpperCase() as any), "utf-8");
|
|
55
|
-
|
|
56
|
-
printFancyBoxMessage(
|
|
57
|
-
`${_.capitalize(theme)}`,
|
|
58
|
-
{ title: "New Theme Added" },
|
|
59
|
-
`${_.capitalize(theme)} theme has been added to ${uiConfig.tailwindCSSLocation}`
|
|
60
|
-
);
|
|
61
|
-
});
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { consola } from "consola";
|
|
3
|
+
import fse from "fs-extra";
|
|
4
|
+
import _ from "lodash";
|
|
5
|
+
import prompts from "prompts";
|
|
6
|
+
|
|
7
|
+
import { createCSS } from "../templates/css";
|
|
8
|
+
import { compareUIConfig } from "../utils/compareUIConfig";
|
|
9
|
+
import { getUIConfig } from "../utils/config";
|
|
10
|
+
import { CSS_THEME_OPTIONS } from "../utils/constants";
|
|
11
|
+
import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
|
|
12
|
+
|
|
13
|
+
export const theme = new Command()
|
|
14
|
+
.command("theme")
|
|
15
|
+
.name("theme")
|
|
16
|
+
.description("Add a new theme to your project.")
|
|
17
|
+
.action(async () => {
|
|
18
|
+
// Get ui config
|
|
19
|
+
let uiConfig = await getUIConfig();
|
|
20
|
+
let uiConfigIsCorrect = await compareUIConfig();
|
|
21
|
+
if (!uiConfigIsCorrect) {
|
|
22
|
+
uiConfig = await getUIConfig({ force: true });
|
|
23
|
+
}
|
|
24
|
+
if (_.isEmpty(uiConfig)) {
|
|
25
|
+
consola.info("Config file not set. Exiting...");
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
const { theme } = await prompts([
|
|
29
|
+
{
|
|
30
|
+
name: "theme",
|
|
31
|
+
type: "autocomplete",
|
|
32
|
+
message: "Which theme do you want to add?",
|
|
33
|
+
choices: CSS_THEME_OPTIONS,
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
36
|
+
if (!theme) {
|
|
37
|
+
console.log("No theme selected. Exiting...");
|
|
38
|
+
return process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
if (fse.existsSync(uiConfig.tailwindCSSLocation)) {
|
|
41
|
+
const { force } = await prompts([
|
|
42
|
+
{
|
|
43
|
+
name: "force",
|
|
44
|
+
type: "confirm",
|
|
45
|
+
message: "Do you want to overwrite your current css file?",
|
|
46
|
+
initial: true,
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
49
|
+
if (!force) {
|
|
50
|
+
console.log("Exiting...");
|
|
51
|
+
return process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
fse.writeFileSync(uiConfig.tailwindCSSLocation, createCSS(theme.toUpperCase() as any), "utf-8");
|
|
55
|
+
|
|
56
|
+
printFancyBoxMessage(
|
|
57
|
+
`${_.capitalize(theme)}`,
|
|
58
|
+
{ title: "New Theme Added" },
|
|
59
|
+
`${_.capitalize(theme)} theme has been added to ${uiConfig.tailwindCSSLocation}`
|
|
60
|
+
);
|
|
61
|
+
});
|