ui-thing 0.0.3
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/.prettierignore +236 -0
- package/.prettierrc +12 -0
- package/CHANGELOG.md +26 -0
- package/README.md +67 -0
- package/dist/chunk-RARRDNKZ.js +24 -0
- package/dist/chunk-RARRDNKZ.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7896 -0
- package/dist/index.js.map +1 -0
- package/dist/prompt-3OFVH7AT.js +46 -0
- package/dist/prompt-3OFVH7AT.js.map +1 -0
- package/package.json +62 -0
- package/src/commands/add.ts +237 -0
- package/src/commands/init.ts +72 -0
- package/src/commands/prettier.ts +47 -0
- package/src/commands/theme.ts +61 -0
- package/src/comp.ts +2134 -0
- package/src/index.ts +30 -0
- package/src/templates/css.ts +641 -0
- package/src/templates/prettier.ts +16 -0
- package/src/templates/tailwind.ts +101 -0
- package/src/types.ts +13 -0
- package/src/utils/addPrettierConfig.ts +24 -0
- package/src/utils/compareUIConfig.ts +35 -0
- package/src/utils/config.ts +84 -0
- package/src/utils/constants.ts +36 -0
- package/src/utils/fileExists.ts +10 -0
- package/src/utils/installPackages.ts +28 -0
- package/src/utils/printFancyBoxMessage.ts +19 -0
- package/src/utils/promptForComponents.ts +17 -0
- package/src/utils/uiConfigPrompt.ts +73 -0
- package/src/utils/writeFile.ts +18 -0
- package/tsconfig.json +16 -0
- package/tsup.config.ts +12 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export const TAILWIND_CONFIG_JS = `const { fontFamily } = require("tailwindcss/defaultTheme");
|
|
2
|
+
|
|
3
|
+
/**@type {import('tailwindcss').Config} */
|
|
4
|
+
module.exports = {
|
|
5
|
+
darkMode: "class",
|
|
6
|
+
theme: {
|
|
7
|
+
extend: {
|
|
8
|
+
container: {
|
|
9
|
+
center: true,
|
|
10
|
+
padding: {
|
|
11
|
+
DEFAULT: "1rem",
|
|
12
|
+
sm: "2rem",
|
|
13
|
+
lg: "4rem",
|
|
14
|
+
},
|
|
15
|
+
screens: {
|
|
16
|
+
"2xl": "1440px",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
fontFamily: {
|
|
20
|
+
sans: ["Inter var", "Inter", ...fontFamily.sans],
|
|
21
|
+
},
|
|
22
|
+
borderRadius: {
|
|
23
|
+
lg: "var(--radius)",
|
|
24
|
+
md: "calc(var(--radius) - 2px)",
|
|
25
|
+
sm: "calc(var(--radius) - 4px)",
|
|
26
|
+
},
|
|
27
|
+
keyframes: {
|
|
28
|
+
"accordion-down": {
|
|
29
|
+
from: { height: "0px" },
|
|
30
|
+
to: { height: "var(--radix-accordion-content-height)" },
|
|
31
|
+
},
|
|
32
|
+
"accordion-up": {
|
|
33
|
+
from: { height: "var(--radix-accordion-content-height)" },
|
|
34
|
+
to: { height: "0px" },
|
|
35
|
+
},
|
|
36
|
+
fadeIn: {
|
|
37
|
+
from: { opacity: "0" },
|
|
38
|
+
to: { opacity: "1" },
|
|
39
|
+
},
|
|
40
|
+
fadeOut: {
|
|
41
|
+
from: { opacity: "1" },
|
|
42
|
+
to: { opacity: "0" },
|
|
43
|
+
},
|
|
44
|
+
"collapse-down": {
|
|
45
|
+
from: { height: "0px" },
|
|
46
|
+
to: { height: "var(--radix-collapsible-content-height)" },
|
|
47
|
+
},
|
|
48
|
+
"collapse-up": {
|
|
49
|
+
from: { height: "var(--radix-collapsible-content-height)" },
|
|
50
|
+
to: { height: "0px" },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
animation: {
|
|
54
|
+
"accordion-down": "accordion-down 0.2s ease-out",
|
|
55
|
+
"accordion-up": "accordion-up 0.2s ease-out",
|
|
56
|
+
fadeIn: "fadeIn 0.2s ease-out",
|
|
57
|
+
fadeOut: "fadeOut 0.2s ease-out",
|
|
58
|
+
"collapse-down": "collapse-down 0.2s ease-out",
|
|
59
|
+
"collapse-up": "collapse-up 0.2s ease-out",
|
|
60
|
+
},
|
|
61
|
+
colors: {
|
|
62
|
+
border: "hsl(var(--border))",
|
|
63
|
+
input: "hsl(var(--input))",
|
|
64
|
+
ring: "hsl(var(--ring))",
|
|
65
|
+
background: "hsl(var(--background))",
|
|
66
|
+
foreground: "hsl(var(--foreground))",
|
|
67
|
+
primary: {
|
|
68
|
+
DEFAULT: "hsl(var(--primary))",
|
|
69
|
+
foreground: "hsl(var(--primary-foreground))",
|
|
70
|
+
},
|
|
71
|
+
secondary: {
|
|
72
|
+
DEFAULT: "hsl(var(--secondary))",
|
|
73
|
+
foreground: "hsl(var(--secondary-foreground))",
|
|
74
|
+
},
|
|
75
|
+
destructive: {
|
|
76
|
+
DEFAULT: "hsl(var(--destructive))",
|
|
77
|
+
foreground: "hsl(var(--destructive-foreground))",
|
|
78
|
+
},
|
|
79
|
+
muted: {
|
|
80
|
+
DEFAULT: "hsl(var(--muted))",
|
|
81
|
+
foreground: "hsl(var(--muted-foreground))",
|
|
82
|
+
},
|
|
83
|
+
accent: {
|
|
84
|
+
DEFAULT: "hsl(var(--accent))",
|
|
85
|
+
foreground: "hsl(var(--accent-foreground))",
|
|
86
|
+
},
|
|
87
|
+
popover: {
|
|
88
|
+
DEFAULT: "hsl(var(--popover))",
|
|
89
|
+
foreground: "hsl(var(--popover-foreground))",
|
|
90
|
+
},
|
|
91
|
+
card: {
|
|
92
|
+
DEFAULT: "hsl(var(--card))",
|
|
93
|
+
foreground: "hsl(var(--card-foreground))",
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
plugins: [require("tailwindcss-animate")],
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
`;
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type UIConfig = {
|
|
2
|
+
theme: string;
|
|
3
|
+
tailwindCSSLocation: string;
|
|
4
|
+
tailwindConfigLocation: string;
|
|
5
|
+
componentsLocation: string;
|
|
6
|
+
composablesLocation: string;
|
|
7
|
+
utilsLocation: string;
|
|
8
|
+
force: boolean;
|
|
9
|
+
useDefaultFilename: boolean;
|
|
10
|
+
packageManager: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type InitOptions = { force?: boolean };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { $ } from "execa";
|
|
2
|
+
import fse from "fs-extra";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import prompts from "prompts";
|
|
5
|
+
|
|
6
|
+
import { PRETTIER_CONFIG } from "../templates/prettier";
|
|
7
|
+
|
|
8
|
+
export const addPrettierConfig = async (cwd = process.cwd(), format: boolean = true) => {
|
|
9
|
+
if (fse.existsSync(`${cwd}/.prettierrc`)) {
|
|
10
|
+
const res = await prompts({
|
|
11
|
+
name: "overwrite",
|
|
12
|
+
type: "confirm",
|
|
13
|
+
message: "A prettier config file already exists. Overwrite?",
|
|
14
|
+
initial: true,
|
|
15
|
+
});
|
|
16
|
+
if (!res.overwrite) return false;
|
|
17
|
+
}
|
|
18
|
+
await fse.writeFile(`${cwd}/.prettierrc`, PRETTIER_CONFIG, "utf-8");
|
|
19
|
+
if (!format) return true;
|
|
20
|
+
const spinner = ora("Formatting files with prettier...").start();
|
|
21
|
+
await $`npx prettier --write .`;
|
|
22
|
+
spinner.succeed("Files formatted with prettier");
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { UIConfig } from "../types";
|
|
2
|
+
import { getUIConfig } from "./config";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Compares the UI config with a temporary config to see if any properties are missing
|
|
6
|
+
* @returns {boolean} - Returns true if all properties are present
|
|
7
|
+
*/
|
|
8
|
+
export const compareUIConfig = async () => {
|
|
9
|
+
// Get ui config
|
|
10
|
+
let userConfig: UIConfig = await getUIConfig();
|
|
11
|
+
const tempConfig: UIConfig = {
|
|
12
|
+
theme: "string",
|
|
13
|
+
tailwindCSSLocation: "string",
|
|
14
|
+
tailwindConfigLocation: "string",
|
|
15
|
+
componentsLocation: "string",
|
|
16
|
+
composablesLocation: "string",
|
|
17
|
+
utilsLocation: "string",
|
|
18
|
+
force: true,
|
|
19
|
+
useDefaultFilename: true,
|
|
20
|
+
packageManager: "string",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const missingProperties: string[] = [];
|
|
24
|
+
|
|
25
|
+
for (const key of Object.keys(tempConfig)) {
|
|
26
|
+
if (userConfig[key as keyof UIConfig] === undefined) {
|
|
27
|
+
missingProperties.push(key);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (missingProperties.length > 0) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import { loadConfig } from "c12";
|
|
3
|
+
import fse from "fs-extra";
|
|
4
|
+
import kleur from "kleur";
|
|
5
|
+
import _ from "lodash";
|
|
6
|
+
import { loadFile, ProxifiedModule, writeFile } from "magicast";
|
|
7
|
+
import { addNuxtModule, getDefaultExportOptions } from "magicast/helpers";
|
|
8
|
+
import prompts from "prompts";
|
|
9
|
+
|
|
10
|
+
import { InitOptions, UIConfig } from "../types";
|
|
11
|
+
import { initPrompts } from "./uiConfigPrompt";
|
|
12
|
+
|
|
13
|
+
const currentDir = process.cwd();
|
|
14
|
+
const uiConfigFilename = "ui-thing.config.ts";
|
|
15
|
+
|
|
16
|
+
export const getNuxtConfig = async () => {
|
|
17
|
+
if (!fse.existsSync("nuxt.config.ts")) {
|
|
18
|
+
console.log(kleur.red(`No ${kleur.bgWhite(`nuxt.config.ts`)} file found. Exiting...`));
|
|
19
|
+
return process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
const nuxtConfig = await loadFile(join(currentDir, "nuxt.config.ts"));
|
|
22
|
+
const defaultExport = getDefaultExportOptions(nuxtConfig);
|
|
23
|
+
return { nuxtConfig, defaultExport };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getUIConfig = async (options?: InitOptions) => {
|
|
27
|
+
const configFileExists = fse.existsSync(uiConfigFilename);
|
|
28
|
+
let uiConfig: UIConfig = {} as UIConfig;
|
|
29
|
+
|
|
30
|
+
if (!configFileExists || options?.force) {
|
|
31
|
+
uiConfig = await initPrompts();
|
|
32
|
+
await fse.writeFile(uiConfigFilename, `export default ${JSON.stringify(uiConfig, null, 2)}`);
|
|
33
|
+
// Check if user chose pnpm as package manager
|
|
34
|
+
if (uiConfig.packageManager === "pnpm") {
|
|
35
|
+
// check if a .npmrc file exists
|
|
36
|
+
const npmrcExists = fse.existsSync(".npmrc");
|
|
37
|
+
// as the user if they want to create a .npmrc file
|
|
38
|
+
if (npmrcExists) {
|
|
39
|
+
const { confirmCreateNpmrc } = await prompts({
|
|
40
|
+
type: "confirm",
|
|
41
|
+
name: "confirmCreateNpmrc",
|
|
42
|
+
message: "A .npmrc file already exists. Do you want to overwrite it?",
|
|
43
|
+
initial: false,
|
|
44
|
+
});
|
|
45
|
+
if (confirmCreateNpmrc) {
|
|
46
|
+
await fse.writeFile(".npmrc", "shamefully-hoist=true\nstrict-peer-dependencies=false\n");
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
await fse.writeFile(".npmrc", "shamefully-hoist=true\nstrict-peer-dependencies=false\n");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
const data = await loadConfig({
|
|
54
|
+
configFile: uiConfigFilename.replace(".ts", ""),
|
|
55
|
+
});
|
|
56
|
+
uiConfig = data.config as UIConfig;
|
|
57
|
+
}
|
|
58
|
+
if (_.isEmpty(uiConfig)) {
|
|
59
|
+
await getUIConfig({ force: true });
|
|
60
|
+
}
|
|
61
|
+
createConfigPaths(uiConfig);
|
|
62
|
+
return uiConfig;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const createConfigPaths = (uiConfig: UIConfig) => {
|
|
66
|
+
// Esnure files exists
|
|
67
|
+
if (uiConfig.tailwindCSSLocation) fse.ensureFileSync(uiConfig.tailwindConfigLocation);
|
|
68
|
+
if (uiConfig.tailwindConfigLocation) fse.ensureFileSync(uiConfig.tailwindCSSLocation);
|
|
69
|
+
if (uiConfig.componentsLocation) fse.ensureDirSync(uiConfig.componentsLocation);
|
|
70
|
+
if (uiConfig.composablesLocation) fse.ensureDirSync(uiConfig.composablesLocation);
|
|
71
|
+
if (uiConfig.utilsLocation) fse.ensureDirSync(uiConfig.utilsLocation);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const addModuleToConfig = (cfg: ProxifiedModule, modules: string[] | string) => {
|
|
75
|
+
if (typeof modules === "string") {
|
|
76
|
+
modules = [modules];
|
|
77
|
+
}
|
|
78
|
+
modules.forEach((m) => addNuxtModule(cfg, m));
|
|
79
|
+
return cfg;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const updateConfig = async (cfg: ProxifiedModule, fileName = "nuxt.config.ts") => {
|
|
83
|
+
await writeFile(cfg.$ast, fileName);
|
|
84
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const INIT_DEPS = ["radix-vue", "tailwind-variants"];
|
|
2
|
+
export const INIT_DEV_DEPS = [
|
|
3
|
+
"typescript",
|
|
4
|
+
"tailwindcss-animate",
|
|
5
|
+
"nuxt-icon",
|
|
6
|
+
"nuxt-lodash",
|
|
7
|
+
"prettier-plugin-tailwindcss",
|
|
8
|
+
"prettier",
|
|
9
|
+
"@nuxtjs/tailwindcss",
|
|
10
|
+
"@nuxtjs/color-mode",
|
|
11
|
+
"@ianvs/prettier-plugin-sort-imports",
|
|
12
|
+
"@vueuse/nuxt",
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export const INIT_MODULES = [
|
|
16
|
+
"@nuxtjs/tailwindcss",
|
|
17
|
+
"@nuxtjs/color-mode",
|
|
18
|
+
"@vueuse/nuxt",
|
|
19
|
+
"nuxt-lodash",
|
|
20
|
+
"nuxt-icon",
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export const CSS_THEME_OPTIONS = [
|
|
24
|
+
{ title: "Zinc", value: "zinc" },
|
|
25
|
+
{ title: "Slate", value: "slate" },
|
|
26
|
+
{ title: "Stone", value: "stone" },
|
|
27
|
+
{ title: "Gray", value: "gray" },
|
|
28
|
+
{ title: "Neutral", value: "neutral" },
|
|
29
|
+
{ title: "Red", value: "red" },
|
|
30
|
+
{ title: "Rose", value: "rose" },
|
|
31
|
+
{ title: "Orange", value: "orange" },
|
|
32
|
+
{ title: "Green", value: "green" },
|
|
33
|
+
{ title: "Blue", value: "blue" },
|
|
34
|
+
{ title: "Yellow", value: "yellow" },
|
|
35
|
+
{ title: "Violet", value: "violet" },
|
|
36
|
+
];
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -0,0 +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 ask before overwriting files?",
|
|
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
|
+
};
|
|
@@ -0,0 +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
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +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
|
+
}
|