@tioelvis/next-template 2.4.8 → 3.0.0

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.
Files changed (132) hide show
  1. package/README.md +42 -42
  2. package/package.json +44 -92
  3. package/src/actions/configure-package-json.js +32 -0
  4. package/src/actions/init-project.js +40 -0
  5. package/src/actions/init-shadcn-ui.js +48 -0
  6. package/src/actions/init-theme.js +28 -0
  7. package/src/actions/init-tioelvis-components.js +42 -0
  8. package/src/actions/install-main-packages.js +51 -0
  9. package/src/constants.js +234 -97
  10. package/src/lib/exception.js +9 -0
  11. package/src/lib/utils.js +55 -0
  12. package/src/main.js +158 -229
  13. package/src/template/eslint.config.mjs +15 -13
  14. package/src/template/postcss.config.mjs +3 -1
  15. package/src/template/src/app/globals.css +0 -122
  16. package/src/template/src/app/layout.tsx +7 -15
  17. package/src/template/src/app/page.tsx +6 -2
  18. package/src/template/tsconfig.json +9 -2
  19. package/src/themes/blue.css +141 -0
  20. package/src/themes/default.css +141 -0
  21. package/src/themes/green.css +141 -0
  22. package/src/themes/orange.css +141 -0
  23. package/src/themes/red.css +141 -0
  24. package/src/themes/rose.css +141 -0
  25. package/src/themes/violet.css +141 -0
  26. package/src/themes/yellow.css +141 -0
  27. package/src/tioelvis-components/max-width-wrapper.tsx +21 -0
  28. package/src/app/components/ui/accordion.json +0 -6
  29. package/src/app/components/ui/accordion.tsx +0 -64
  30. package/src/app/components/ui/alert-dialog.json +0 -6
  31. package/src/app/components/ui/alert-dialog.tsx +0 -157
  32. package/src/app/components/ui/alert.json +0 -6
  33. package/src/app/components/ui/alert.tsx +0 -66
  34. package/src/app/components/ui/aspect-ratio.json +0 -6
  35. package/src/app/components/ui/aspect-ratio.tsx +0 -11
  36. package/src/app/components/ui/avatar.json +0 -6
  37. package/src/app/components/ui/avatar.tsx +0 -53
  38. package/src/app/components/ui/badge.json +0 -6
  39. package/src/app/components/ui/badge.tsx +0 -46
  40. package/src/app/components/ui/breadcrumb.json +0 -6
  41. package/src/app/components/ui/breadcrumb.tsx +0 -107
  42. package/src/app/components/ui/button.json +0 -6
  43. package/src/app/components/ui/button.tsx +0 -58
  44. package/src/app/components/ui/calendar.json +0 -6
  45. package/src/app/components/ui/calendar.tsx +0 -213
  46. package/src/app/components/ui/card.json +0 -6
  47. package/src/app/components/ui/card.tsx +0 -92
  48. package/src/app/components/ui/carousel.json +0 -6
  49. package/src/app/components/ui/carousel.tsx +0 -236
  50. package/src/app/components/ui/chart.json +0 -6
  51. package/src/app/components/ui/chart.tsx +0 -347
  52. package/src/app/components/ui/checkbox.json +0 -6
  53. package/src/app/components/ui/checkbox.tsx +0 -30
  54. package/src/app/components/ui/collapsible.json +0 -6
  55. package/src/app/components/ui/collapsible.tsx +0 -33
  56. package/src/app/components/ui/command.json +0 -6
  57. package/src/app/components/ui/command.tsx +0 -182
  58. package/src/app/components/ui/context-menu.json +0 -6
  59. package/src/app/components/ui/context-menu.tsx +0 -249
  60. package/src/app/components/ui/dialog.json +0 -6
  61. package/src/app/components/ui/dialog.tsx +0 -141
  62. package/src/app/components/ui/drawer.json +0 -6
  63. package/src/app/components/ui/drawer.tsx +0 -134
  64. package/src/app/components/ui/dropdown-menu.json +0 -6
  65. package/src/app/components/ui/dropdown-menu.tsx +0 -256
  66. package/src/app/components/ui/form.json +0 -12
  67. package/src/app/components/ui/form.tsx +0 -167
  68. package/src/app/components/ui/hover-card.json +0 -6
  69. package/src/app/components/ui/hover-card.tsx +0 -49
  70. package/src/app/components/ui/input-otp.json +0 -6
  71. package/src/app/components/ui/input-otp.tsx +0 -76
  72. package/src/app/components/ui/input.json +0 -6
  73. package/src/app/components/ui/input.tsx +0 -21
  74. package/src/app/components/ui/label.json +0 -6
  75. package/src/app/components/ui/label.tsx +0 -24
  76. package/src/app/components/ui/menubar.json +0 -6
  77. package/src/app/components/ui/menubar.tsx +0 -273
  78. package/src/app/components/ui/navigation-menu.json +0 -6
  79. package/src/app/components/ui/navigation-menu.tsx +0 -164
  80. package/src/app/components/ui/pagination.json +0 -6
  81. package/src/app/components/ui/pagination.tsx +0 -124
  82. package/src/app/components/ui/popover.json +0 -6
  83. package/src/app/components/ui/popover.tsx +0 -55
  84. package/src/app/components/ui/progress.json +0 -6
  85. package/src/app/components/ui/progress.tsx +0 -30
  86. package/src/app/components/ui/radio-group.json +0 -6
  87. package/src/app/components/ui/radio-group.tsx +0 -43
  88. package/src/app/components/ui/resizable.json +0 -6
  89. package/src/app/components/ui/resizable.tsx +0 -55
  90. package/src/app/components/ui/scroll-area.json +0 -6
  91. package/src/app/components/ui/scroll-area.tsx +0 -55
  92. package/src/app/components/ui/select.json +0 -6
  93. package/src/app/components/ui/select.tsx +0 -179
  94. package/src/app/components/ui/separator.json +0 -6
  95. package/src/app/components/ui/separator.tsx +0 -28
  96. package/src/app/components/ui/sheet.json +0 -6
  97. package/src/app/components/ui/sheet.tsx +0 -145
  98. package/src/app/components/ui/sidebar.json +0 -6
  99. package/src/app/components/ui/sidebar.tsx +0 -718
  100. package/src/app/components/ui/skeleton.json +0 -6
  101. package/src/app/components/ui/skeleton.tsx +0 -13
  102. package/src/app/components/ui/slider.json +0 -6
  103. package/src/app/components/ui/slider.tsx +0 -61
  104. package/src/app/components/ui/sonner.json +0 -6
  105. package/src/app/components/ui/sonner.tsx +0 -25
  106. package/src/app/components/ui/switch.json +0 -6
  107. package/src/app/components/ui/switch.tsx +0 -30
  108. package/src/app/components/ui/table.json +0 -6
  109. package/src/app/components/ui/table.tsx +0 -115
  110. package/src/app/components/ui/tabs.json +0 -6
  111. package/src/app/components/ui/tabs.tsx +0 -66
  112. package/src/app/components/ui/textarea.json +0 -6
  113. package/src/app/components/ui/textarea.tsx +0 -18
  114. package/src/app/components/ui/toggle-group.json +0 -6
  115. package/src/app/components/ui/toggle-group.tsx +0 -71
  116. package/src/app/components/ui/toggle.json +0 -6
  117. package/src/app/components/ui/toggle.tsx +0 -47
  118. package/src/app/components/ui/tooltip.json +0 -6
  119. package/src/app/components/ui/tooltip.tsx +0 -60
  120. package/src/app/hooks/use-mobile.ts +0 -21
  121. package/src/app/lib/utils.ts +0 -6
  122. package/src/app/tsconfig.json +0 -27
  123. package/src/template/components.json +0 -21
  124. package/src/template/next-env.d.ts +0 -5
  125. package/src/template/public/.gitkeep +0 -0
  126. package/src/template/src/lib/axios.ts +0 -39
  127. package/src/template/src/lib/constants.ts +0 -1
  128. package/src/template/src/lib/utils.ts +0 -6
  129. package/src/template/src/providers/query.provider.tsx +0 -12
  130. package/src/template/src/providers/theme.provider.tsx +0 -8
  131. package/src/utils.js +0 -113
  132. /package/src/template/{src/app → public}/favicon.ico +0 -0
package/README.md CHANGED
@@ -1,42 +1,42 @@
1
- # UI Project Generator
2
-
3
- A **command-line tool** to scaffold a modern **Next.js + TailwindCSS** project with optional prebuilt UI components and hooks — inspired by [shadcn/ui](https://ui.shadcn.com/).
4
-
5
- > ⚠️ This tool does **not** aim to replace or take credit for [shadcn/ui]. It is simply a utility for convenience and faster setup in personal and internal projects. All UI components are sourced directly from shadcn.
6
-
7
- ---
8
-
9
- ## 🔌 React Query Included
10
-
11
- React Query ([`@tanstack/react-query`](https://tanstack.com/query/latest)) is pre-configured for efficient and scalable data fetching:
12
-
13
- - ✅ Includes a `QueryClient` setup in `src/providers/query-provider.tsx`
14
- - ✅ Wraps the application with `QueryClientProvider` (already wired in your layout)
15
- - ✅ Enables usage of `useQuery`, `useMutation`, and other React Query hooks out of the box
16
-
17
- ## ✨ Features
18
-
19
- - 🔧 Choose a **project name** and **package manager** (`npm` or `pnpm`)
20
- - 🎨 Select UI components to include (e.g., Accordion, Alert, Button)
21
- - ⚡ Automatically sets up:
22
- - A **Next.js + TailwindCSS** project
23
- - Preselected **UI components** and **hooks**
24
- - Project structure under `src/` (with `components/ui`, `hooks`, `lib`, etc.)
25
- - **React Query** integration with [`@tanstack/react-query`](https://tanstack.com/query/latest)
26
- - All required dependencies and devDependencies
27
-
28
- ---
29
-
30
- ## 🛠️ Usage
31
-
32
- Using npm:
33
-
34
- ```bash
35
- npx @tioelvis/next-template
36
- ```
37
-
38
- Using pnpm:
39
-
40
- ```bash
41
- pnpx @tioelvis/next-template
42
- ```
1
+ # UI Project Generator
2
+
3
+ A **command-line tool** to scaffold a modern **Next.js + TailwindCSS** project with optional prebuilt UI components and hooks — inspired by [shadcn/ui](https://ui.shadcn.com/).
4
+
5
+ > ⚠️ This tool does **not** aim to replace or take credit for [shadcn/ui]. It is simply a utility for convenience and faster setup in personal and internal projects. All UI components are sourced directly from shadcn.
6
+
7
+ ---
8
+
9
+ ## 🔌 React Query Included
10
+
11
+ React Query ([`@tanstack/react-query`](https://tanstack.com/query/latest)) is pre-configured for efficient and scalable data fetching:
12
+
13
+ - ✅ Includes a `QueryClient` setup in `src/providers/query-provider.tsx`
14
+ - ✅ Wraps the application with `QueryClientProvider` (already wired in your layout)
15
+ - ✅ Enables usage of `useQuery`, `useMutation`, and other React Query hooks out of the box
16
+
17
+ ## ✨ Features
18
+
19
+ - 🔧 Choose a **project name** and **package manager** (`npm` or `pnpm`)
20
+ - 🎨 Select UI components to include (e.g., Accordion, Alert, Button)
21
+ - ⚡ Automatically sets up:
22
+ - A **Next.js + TailwindCSS** project
23
+ - Preselected **UI components** and **hooks**
24
+ - Project structure under `src/` (with `components/ui`, `hooks`, `lib`, etc.)
25
+ - **React Query** integration with [`@tanstack/react-query`](https://tanstack.com/query/latest)
26
+ - All required dependencies and devDependencies
27
+
28
+ ---
29
+
30
+ ## 🛠️ Usage
31
+
32
+ Using npm:
33
+
34
+ ```bash
35
+ npx @tioelvis/next-template
36
+ ```
37
+
38
+ Using pnpm:
39
+
40
+ ```bash
41
+ pnpx @tioelvis/next-template
42
+ ```
package/package.json CHANGED
@@ -1,92 +1,44 @@
1
- {
2
- "name": "@tioelvis/next-template",
3
- "version": "2.4.8",
4
- "description": "CLI to scaffold a Next.js + Tailwind project using shadcn/ui components",
5
- "type": "module",
6
- "bin": {
7
- "next-template": "./src/main.js"
8
- },
9
- "keywords": [
10
- "cli",
11
- "nextjs",
12
- "shadcn",
13
- "tailwind",
14
- "ui",
15
- "project-generator",
16
- "scaffolding"
17
- ],
18
- "author": {
19
- "name": "Ti0Elvis",
20
- "email": "elvis.veramijares@gmail.com"
21
- },
22
- "license": "MIT",
23
- "repository": {
24
- "type": "git",
25
- "url": "https://github.com/Ti0Elvis/next-template"
26
- },
27
- "dependencies": {
28
- "chalk": "^5.4.1",
29
- "prompts": "^2.4.2"
30
- },
31
- "devDependencies": {
32
- "@eslint/eslintrc": "^3.3.1",
33
- "@hookform/resolvers": "^5.2.0",
34
- "@radix-ui/react-accordion": "^1.2.11",
35
- "@radix-ui/react-alert-dialog": "^1.1.14",
36
- "@radix-ui/react-aspect-ratio": "^1.1.7",
37
- "@radix-ui/react-avatar": "^1.1.10",
38
- "@radix-ui/react-checkbox": "^1.3.2",
39
- "@radix-ui/react-collapsible": "^1.1.11",
40
- "@radix-ui/react-context-menu": "^2.2.15",
41
- "@radix-ui/react-dialog": "^1.1.14",
42
- "@radix-ui/react-dropdown-menu": "^2.1.15",
43
- "@radix-ui/react-hover-card": "^1.1.14",
44
- "@radix-ui/react-label": "^2.1.7",
45
- "@radix-ui/react-menubar": "^1.1.15",
46
- "@radix-ui/react-navigation-menu": "^1.2.13",
47
- "@radix-ui/react-popover": "^1.1.14",
48
- "@radix-ui/react-progress": "^1.1.7",
49
- "@radix-ui/react-radio-group": "^1.3.7",
50
- "@radix-ui/react-scroll-area": "^1.2.9",
51
- "@radix-ui/react-select": "^2.2.5",
52
- "@radix-ui/react-separator": "^1.1.7",
53
- "@radix-ui/react-slider": "^1.3.5",
54
- "@radix-ui/react-slot": "^1.2.3",
55
- "@radix-ui/react-switch": "^1.2.5",
56
- "@radix-ui/react-tabs": "^1.1.12",
57
- "@radix-ui/react-toggle": "^1.1.9",
58
- "@radix-ui/react-toggle-group": "^1.1.10",
59
- "@radix-ui/react-tooltip": "^1.2.7",
60
- "@tailwindcss/postcss": "^4.1.11",
61
- "@tanstack/react-query": "^5.83.0",
62
- "@types/node": "^24.1.0",
63
- "@types/react": "^19.1.8",
64
- "@types/react-dom": "^19.1.6",
65
- "axios": "^1.11.0",
66
- "class-variance-authority": "^0.7.1",
67
- "clsx": "^2.1.1",
68
- "cmdk": "^1.1.1",
69
- "cookies-next": "^6.1.0",
70
- "date-fns": "^4.1.0",
71
- "embla-carousel-react": "^8.6.0",
72
- "eslint": "^9.32.0",
73
- "eslint-config-next": "^15.4.4",
74
- "input-otp": "^1.4.2",
75
- "lucide-react": "^0.532.0",
76
- "next": "^15.4.4",
77
- "next-themes": "^0.4.6",
78
- "react": "^19.1.0",
79
- "react-day-picker": "^9.8.1",
80
- "react-dom": "^19.1.0",
81
- "react-hook-form": "^7.61.1",
82
- "react-resizable-panels": "^3.0.3",
83
- "recharts": "^2.15.4",
84
- "sonner": "^2.0.6",
85
- "tailwind-merge": "^3.3.1",
86
- "tailwindcss": "^4.1.11",
87
- "tw-animate-css": "^1.3.6",
88
- "typescript": "^5.8.3",
89
- "vaul": "^1.1.2",
90
- "zod": "^4.0.13"
91
- }
92
- }
1
+ {
2
+ "name": "@tioelvis/next-template",
3
+ "version": "3.0.0",
4
+ "description": "Interactive CLI to scaffold a Next.js project with customizable presets and configurations.",
5
+ "type": "module",
6
+ "bin": {
7
+ "next-template": "./src/main.js"
8
+ },
9
+ "keywords": [
10
+ "cli",
11
+ "nextjs",
12
+ "ui",
13
+ "scaffolding"
14
+ ],
15
+ "author": {
16
+ "name": "TioElvis",
17
+ "email": "elvis.veramijares@gmail.com"
18
+ },
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/TioElvis/next-template"
23
+ },
24
+ "dependencies": {
25
+ "chalk": "^5.6.2",
26
+ "ora": "^9.0.0",
27
+ "prompts": "^2.4.2"
28
+ },
29
+ "devDependencies": {
30
+ "@tailwindcss/postcss": "^4.1.18",
31
+ "@tanstack/react-query": "^5.90.12",
32
+ "@types/node": "^25.0.3",
33
+ "@types/prompts": "^2.4.9",
34
+ "@types/react": "^19.2.7",
35
+ "@types/react-dom": "^19.2.3",
36
+ "eslint": "^9.39.2",
37
+ "eslint-config-next": "^16.1.0",
38
+ "next": "^16.1.0",
39
+ "react": "^19.2.3",
40
+ "react-dom": "^19.2.3",
41
+ "tailwindcss": "^4.1.18",
42
+ "typescript": "^5.9.3"
43
+ }
44
+ }
@@ -0,0 +1,32 @@
1
+ import ora from "ora";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { context } from "../constants.js";
5
+
6
+ export function configurePackageJSON() {
7
+ const spinner = ora("Configuring package.json...").start();
8
+
9
+ const packageJSON = {
10
+ name: context.projectName,
11
+ version: "1.0.0",
12
+ private: true,
13
+ scripts: {
14
+ dev: "next dev",
15
+ build: "next build",
16
+ start: "next start",
17
+ lint: "next lint",
18
+ },
19
+ };
20
+
21
+ const packageJSONPath = path.join(context.dest, "package.json");
22
+
23
+ try {
24
+ fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, 2));
25
+ spinner.succeed("package.json configured successfully.");
26
+ } catch (error) {
27
+ spinner.fail("Failed to configure package.json.");
28
+ throw new Exception(`Could not configure package.json: ${error.message}`, {
29
+ deleteDest: true,
30
+ });
31
+ }
32
+ }
@@ -0,0 +1,40 @@
1
+ import ora from "ora";
2
+ import fs from "node:fs";
3
+ import { Exception } from "../lib/exception.js";
4
+ import { context, TEMPLATE_FOLDER_PATH } from "../constants.js";
5
+
6
+ function copyTemplateFiles() {
7
+ const spinner = ora("Copying template files to project folder...").start();
8
+
9
+ try {
10
+ fs.cpSync(TEMPLATE_FOLDER_PATH, context.dest, { recursive: true });
11
+ spinner.succeed("Template files copied successfully.");
12
+ } catch (error) {
13
+ spinner.fail("Failed to copy template files.");
14
+ throw new Exception(`Could not copy template files: ${error.message}`, {
15
+ deleteDest: true,
16
+ });
17
+ }
18
+ }
19
+
20
+ export function initProject() {
21
+ const spinner = ora(`Creating "${context.projectName}" folder... `).start();
22
+
23
+ if (fs.existsSync(context.dest)) {
24
+ spinner.fail("Failed to create project folder.");
25
+
26
+ throw new Exception(
27
+ `Directory ${context.projectName} already exists. Choose a different project name.`
28
+ );
29
+ }
30
+
31
+ try {
32
+ fs.mkdirSync(context.dest, { recursive: true });
33
+ spinner.succeed(`Created "${context.projectName}" folder.`);
34
+ } catch (error) {
35
+ spinner.fail("Failed to create project folder.");
36
+ throw new Exception(`Could not create project folder: ${error.message}`);
37
+ }
38
+
39
+ copyTemplateFiles();
40
+ }
@@ -0,0 +1,48 @@
1
+ import ora from "ora";
2
+ import { context } from "../constants.js";
3
+ import { runCommand } from "../lib/utils.js";
4
+ import { Exception } from "../lib/exception.js";
5
+
6
+ async function installComponents(components) {
7
+ const spinner = ora("Installing shadcn/ui components...").start();
8
+
9
+ try {
10
+ for (const component of components) {
11
+ await runCommand(
12
+ "npx",
13
+ ["shadcn@latest", "add", component],
14
+ context.dest
15
+ );
16
+ }
17
+
18
+ spinner.succeed("shadcn/ui components installed.");
19
+ } catch (error) {
20
+ spinner.fail("Failed to install shadcn/ui components.");
21
+ throw new Exception("Failed to install shadcn/ui components.", {
22
+ deleteDest: false,
23
+ });
24
+ }
25
+ }
26
+
27
+ export async function initShadcnUI(components) {
28
+ const spinner = ora("Installing shadcn/ui...").start();
29
+
30
+ try {
31
+ await runCommand(
32
+ "npx",
33
+ ["shadcn@latest", "init", "--base-color", "neutral"],
34
+ context.dest
35
+ );
36
+
37
+ spinner.succeed("shadcn/ui installed");
38
+ } catch (error) {
39
+ spinner.fail("Failed to install shadcn/ui.");
40
+ throw new Exception("Failed to install shadcn/ui.", {
41
+ deleteDest: false,
42
+ });
43
+ }
44
+
45
+ if (components.length > 0) {
46
+ await installComponents(components);
47
+ }
48
+ }
@@ -0,0 +1,28 @@
1
+ import ora from "ora";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { Exception } from "../lib/exception.js";
5
+ import { context, THEME_FOLDER_PATH } from "../constants.js";
6
+
7
+ export function initThemeColor(themeColor) {
8
+ const spinner = ora("Setting up theme color...").start();
9
+
10
+ const themeFilePath = path.join(THEME_FOLDER_PATH, `${themeColor}.css`);
11
+
12
+ try {
13
+ if (!themeColor || !fs.existsSync(themeFilePath)) {
14
+ throw new Error("Invalid theme color selected.");
15
+ }
16
+
17
+ fs.copyFileSync(
18
+ themeFilePath,
19
+ path.join(context.dest, "src/app/globals.css")
20
+ );
21
+ spinner.succeed("Theme color set up successfully.");
22
+ } catch (error) {
23
+ spinner.fail("Failed to set up theme color.");
24
+ throw new Exception(`Could not set up theme color: ${error.message}`, {
25
+ deleteDest: true,
26
+ });
27
+ }
28
+ }
@@ -0,0 +1,42 @@
1
+ import ora from "ora";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { Exception } from "../lib/exception.js";
5
+ import { context, TIOELVIS_COMPONENTS_FOLDER_PATH } from "../constants.js";
6
+
7
+ export function initTioElvisComponents(components) {
8
+ const spinner = ora("Setting up TioElvis components...").start();
9
+
10
+ try {
11
+ if (!components || components.length === 0) {
12
+ spinner.info("No TioElvis components selected. Skipping...");
13
+ return;
14
+ }
15
+
16
+ components.forEach((component) => {
17
+ const componentFilePath = path.join(
18
+ TIOELVIS_COMPONENTS_FOLDER_PATH,
19
+ `${component}.tsx`
20
+ );
21
+
22
+ if (!fs.existsSync(componentFilePath)) {
23
+ throw new Error(`Component file for ${component} does not exist.`);
24
+ }
25
+
26
+ fs.copyFileSync(
27
+ componentFilePath,
28
+ path.join(context.dest, "src/components", `${component}.tsx`)
29
+ );
30
+ });
31
+
32
+ spinner.succeed("TioElvis components set up successfully.");
33
+ } catch (error) {
34
+ spinner.fail("Failed to set up TioElvis components.");
35
+ throw new Exception(
36
+ `Could not set up TioElvis components: ${error.message}`,
37
+ {
38
+ deleteDest: true,
39
+ }
40
+ );
41
+ }
42
+ }
@@ -0,0 +1,51 @@
1
+ import ora from "ora";
2
+ import {
3
+ context,
4
+ MAIN_DEPENDENCIES,
5
+ MAIN_DEV_DEPENDENCIES,
6
+ } from "../constants.js";
7
+ import { runCommand } from "../lib/utils.js";
8
+ import { Exception } from "../lib/exception.js";
9
+
10
+ export async function installMainPackages() {
11
+ const spinner = ora("Installing main packages...").start();
12
+
13
+ try {
14
+ if (context.packageManager === "npm") {
15
+ await runCommand("npm", ["install", ...MAIN_DEPENDENCIES], context.dest);
16
+ await runCommand(
17
+ "npm",
18
+ ["install", "--save-dev", ...MAIN_DEV_DEPENDENCIES],
19
+ context.dest
20
+ );
21
+ }
22
+
23
+ if (context.packageManager === "yarn") {
24
+ await runCommand("yarn", ["add", ...MAIN_DEPENDENCIES], context.dest);
25
+ await runCommand(
26
+ "yarn",
27
+ ["add", "--dev", ...MAIN_DEV_DEPENDENCIES],
28
+ context.dest
29
+ );
30
+ }
31
+
32
+ if (context.packageManager === "pnpm") {
33
+ await runCommand("pnpm", ["add", ...MAIN_DEPENDENCIES], context.dest);
34
+ await runCommand(
35
+ "pnpm",
36
+ ["add", "--save-dev", ...MAIN_DEV_DEPENDENCIES],
37
+ context.dest
38
+ );
39
+ }
40
+
41
+ spinner.succeed("Main packages installed successfully.");
42
+ } catch (error) {
43
+ spinner.fail("Failed to install main packages.");
44
+ throw new Exception(
45
+ `Could not install main packages: ${error?.message ?? error}`,
46
+ {
47
+ deleteDest: true,
48
+ }
49
+ );
50
+ }
51
+ }