sparesdev 0.0.7 → 0.0.8

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 (2) hide show
  1. package/core/init.js +126 -13
  2. package/package.json +1 -1
package/core/init.js CHANGED
@@ -2,6 +2,15 @@ import fs from "fs";
2
2
  import { execSync } from "child_process";
3
3
 
4
4
  function getMissingDependencies() {
5
+ const required = [
6
+ "react",
7
+ "react-dom",
8
+ "react-router-dom",
9
+ "clsx",
10
+ "tailwind-merge",
11
+ "class-variance-authority"
12
+ ];
13
+
5
14
  try {
6
15
  const pkg = JSON.parse(fs.readFileSync("package.json", "utf-8"));
7
16
 
@@ -10,15 +19,6 @@ function getMissingDependencies() {
10
19
  ...pkg.devDependencies
11
20
  };
12
21
 
13
- const required = [
14
- "react",
15
- "react-dom",
16
- "react-router-dom",
17
- "clsx",
18
- "tailwind-merge",
19
- "class-variance-authority"
20
- ];
21
-
22
22
  return required.filter(dep => !installed?.[dep]);
23
23
  } catch {
24
24
  return required;
@@ -35,7 +35,6 @@ function patchViteConfig() {
35
35
 
36
36
  let content = fs.readFileSync(viteConfigPath, "utf-8");
37
37
 
38
- // add import if missing
39
38
  if (!content.includes("@tailwindcss/vite")) {
40
39
  content = content.replace(
41
40
  /import react from ['"]@vitejs\/plugin-react['"]/,
@@ -43,7 +42,6 @@ function patchViteConfig() {
43
42
  );
44
43
  }
45
44
 
46
- // add plugin if missing
47
45
  if (!content.includes("tailwindcss()")) {
48
46
  content = content.replace(
49
47
  /plugins:\s*\[([^\]]*)\]/,
@@ -56,6 +54,117 @@ function patchViteConfig() {
56
54
  console.log("āœ… vite.config.ts updated with Tailwind");
57
55
  }
58
56
 
57
+ function ensureSrcFolder() {
58
+ if (!fs.existsSync("src")) {
59
+ fs.mkdirSync("src", { recursive: true });
60
+ console.log("šŸ“ Created src folder");
61
+ }
62
+ }
63
+
64
+ function createTokensCss() {
65
+ const tokensPath = "src/tokens.css";
66
+
67
+ if (fs.existsSync(tokensPath)) {
68
+ console.log("ā„¹ļø tokens.css already exists");
69
+ return;
70
+ }
71
+
72
+ const content = `@theme {
73
+
74
+ /* Screens */
75
+ --breakpoint-sm: 640px;
76
+ --breakpoint-md: 768px;
77
+ --breakpoint-lg: 1024px;
78
+
79
+ /* Fonts */
80
+ --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
81
+
82
+ /* Text */
83
+ --text-xs: 10px;
84
+ --text-sm: 12px;
85
+ --text-base: 14px;
86
+ --text-lg: 16px;
87
+ --text-xl: 17.5px;
88
+ --text-2xl: 21.88px;
89
+ --text-3xl: 27.34px;
90
+
91
+ /* Colors */
92
+ --color-background: 255 255 255;
93
+ --color-text: 0 0 0;
94
+
95
+ --color-black: #000000;
96
+ --color-white: #FFFFFF;
97
+ --color-neutral-100: #E6E6E6;
98
+ --color-neutral-500: #666666;
99
+ --color-neutral-900: #000000;
100
+
101
+ /* Border Radius */
102
+ --radius-sm: 4px;
103
+ --radius-base: 8px;
104
+ --radius-lg: 12px;
105
+ --radius-xl: 16px;
106
+ --radius-2xl: 24px;
107
+ --radius-full: 9999px;
108
+
109
+ /* Shadows */
110
+ --shadow-sm: 0 1px 3px -1px rgba(0, 0, 0, 0.16);
111
+ --shadow-md: 0 8px 16px -8px rgba(0, 0, 0, 0.16);
112
+
113
+ /* Spacing */
114
+ --spacing-1: 4px;
115
+ --spacing-2: 8px;
116
+ --spacing-4: 16px;
117
+ --spacing-6: 24px;
118
+ --spacing-8: 32px;
119
+ }
120
+ `;
121
+
122
+ fs.writeFileSync(tokensPath, content);
123
+ console.log("āœ… Created src/tokens.css");
124
+ }
125
+
126
+ function createIndexCss() {
127
+ const indexPath = "src/index.css";
128
+
129
+ const content = `@import "tailwindcss";
130
+ @import "./tokens.css";
131
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');
132
+
133
+ body {
134
+ background: rgb(var(--color-background));
135
+ color: rgb(var(--color-text));
136
+ font-feature-settings: "rlig" 1, "calt" 1;
137
+ font-family: var(--font-sans);
138
+ }
139
+
140
+ .hide-scrollbar {
141
+ -ms-overflow-style: none;
142
+ scrollbar-width: none;
143
+ }
144
+
145
+ .hide-scrollbar::-webkit-scrollbar {
146
+ display: none;
147
+ }
148
+ `;
149
+
150
+ if (!fs.existsSync(indexPath)) {
151
+ fs.writeFileSync(indexPath, content);
152
+ console.log("āœ… Created src/index.css");
153
+ return;
154
+ }
155
+
156
+ let existing = fs.readFileSync(indexPath, "utf-8");
157
+
158
+ if (!existing.includes('./tokens.css')) {
159
+ existing = `@import "./tokens.css";\n` + existing;
160
+
161
+ fs.writeFileSync(indexPath, existing);
162
+ console.log("āœ… Added tokens.css import to index.css");
163
+ } else {
164
+ console.log("ā„¹ļø index.css already configured");
165
+ }
166
+ }
167
+
59
168
  export async function init() {
60
169
  const config = {
61
170
  language: "typescript",
@@ -95,9 +204,13 @@ export async function init() {
95
204
  );
96
205
 
97
206
  patchViteConfig();
207
+ ensureSrcFolder();
208
+ createTokensCss();
209
+ createIndexCss();
98
210
 
99
- console.log("\nāœ… Setup completed successfully\n");
100
- } catch {
211
+ console.log("\nšŸŽ‰ SparesDev setup completed successfully\n");
212
+ } catch (error) {
101
213
  console.log("\nāŒ Installation failed");
214
+ console.error(error.message);
102
215
  }
103
216
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sparesdev",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "bin": {