@@ -3,8 +3,6 @@ import path from 'path';
3
3
import axios from 'axios' ;
4
4
import { fetchComponentContent , fetchStyleContent , fetchStyleFile , fetchTokenFile } from './github.js' ;
5
5
import { getDependencies } from './parser.js' ;
6
- import { createSpinner } from './spinner.js' ;
7
- import { info } from './logger.js' ;
8
6
9
7
async function detectProjectStructure ( ) {
10
8
// Check for Next.js app directory structure
@@ -36,32 +34,22 @@ export async function installComponent(componentName, targetDir = null) {
36
34
targetDir = await detectProjectStructure ( ) ;
37
35
}
38
36
39
- const spinner = createSpinner ( `Adding ${ componentName } ...` ) ;
40
-
41
37
try {
42
38
await fs . ensureDir ( targetDir ) ;
43
39
44
- // Show installation directory on first component
45
- if ( ! global . installPathShown ) {
46
- info ( ` Adding components in: ${ targetDir } ` ) ;
47
- global . installPathShown = true ;
48
- }
49
-
50
40
// If it's a SCSS file
51
41
if ( componentName . endsWith ( '.module.scss' ) ) {
52
42
const componentBaseName = componentName . replace ( '.module.scss' , '' ) ;
53
43
const styleContent = await fetchStyleContent ( componentBaseName ) ;
54
44
if ( styleContent ) {
55
45
await installFile ( componentName , styleContent , targetDir ) ;
56
- spinner . succeed ( `Added style: ${ componentName } ` ) ;
57
46
}
58
47
return ;
59
48
}
60
49
61
50
// Fetch and install the component
62
51
const content = await fetchComponentContent ( componentName ) ;
63
52
if ( ! content ) {
64
- spinner . succeed ( `Failed to fetch ${ componentName } ` ) ;
65
53
return ;
66
54
}
67
55
@@ -74,8 +62,6 @@ export async function installComponent(componentName, targetDir = null) {
74
62
await installFile ( `${ componentName } .module.scss` , styleContent , targetDir ) ;
75
63
}
76
64
77
- spinner . succeed ( `${ componentName } added` ) ;
78
-
79
65
// Install dependencies
80
66
const dependencies = await getDependencies ( content ) ;
81
67
for ( const dep of dependencies ) {
@@ -103,150 +89,113 @@ export async function installComponent(componentName, targetDir = null) {
103
89
// Install config.js file
104
90
await installConfigFile ( ) ;
105
91
} catch ( error ) {
106
- // Suppress error messages
92
+ throw error ;
107
93
}
108
94
}
109
95
110
96
async function createIconsFile ( ) {
111
97
const iconsFilePath = './once-ui/icons.ts' ;
112
98
const iconsContent = await fetchIconsContent ( ) ;
113
-
114
99
await installFile ( 'icons.ts' , iconsContent , './once-ui' ) ;
115
100
}
116
101
117
102
async function fetchIconsContent ( ) {
118
103
const GITHUB_ICONS_URL = 'https://raw.githubusercontent.com/once-ui-system/nextjs-starter/main/src/once-ui/icons.ts' ;
119
-
120
104
try {
121
105
const response = await axios . get ( GITHUB_ICONS_URL ) ;
122
106
return response . data ;
123
107
} catch ( err ) {
124
- return '' ; // Suppress error
108
+ return '' ;
125
109
}
126
110
}
127
111
128
112
async function installInterfacesAndTypes ( ) {
129
- const interfacesFilePath = './once-ui/interfaces.ts' ;
130
- const typesFilePath = './once-ui/types.ts' ;
131
-
132
113
const interfacesContent = await fetchInterfacesContent ( ) ;
133
114
const typesContent = await fetchTypesContent ( ) ;
134
-
135
115
await installFile ( 'interfaces.ts' , interfacesContent , './once-ui' ) ;
136
116
await installFile ( 'types.ts' , typesContent , './once-ui' ) ;
137
117
}
138
118
139
119
async function fetchInterfacesContent ( ) {
140
120
const GITHUB_INTERFACES_URL = 'https://raw.githubusercontent.com/once-ui-system/nextjs-starter/main/src/once-ui/interfaces.ts' ;
141
-
142
121
try {
143
122
const response = await axios . get ( GITHUB_INTERFACES_URL ) ;
144
123
return response . data ;
145
124
} catch ( err ) {
146
- return '' ; // Suppress error
125
+ return '' ;
147
126
}
148
127
}
149
128
150
129
async function fetchTypesContent ( ) {
151
130
const GITHUB_TYPES_URL = 'https://raw.githubusercontent.com/once-ui-system/nextjs-starter/main/src/once-ui/types.ts' ;
152
-
153
131
try {
154
132
const response = await axios . get ( GITHUB_TYPES_URL ) ;
155
133
return response . data ;
156
134
} catch ( err ) {
157
- return '' ; // Suppress error
135
+ return '' ;
158
136
}
159
137
}
160
138
161
139
async function installUseDebounce ( ) {
162
140
const hooksDir = './once-ui/hooks' ;
163
- await fs . ensureDir ( hooksDir ) ; // Create hooks directory if it doesn't exist
164
-
165
- const useDebounceFilePath = './once-ui/hooks/useDebounce.ts' ;
141
+ await fs . ensureDir ( hooksDir ) ;
166
142
const useDebounceContent = await fetchUseDebounceContent ( ) ;
167
-
168
143
await installFile ( 'useDebounce.ts' , useDebounceContent , hooksDir ) ;
169
144
}
170
145
171
146
async function fetchUseDebounceContent ( ) {
172
147
const GITHUB_USE_DEBOUNCE_URL = 'https://raw.githubusercontent.com/once-ui-system/nextjs-starter/main/src/once-ui/hooks/useDebounce.ts' ;
173
-
174
148
try {
175
149
const response = await axios . get ( GITHUB_USE_DEBOUNCE_URL ) ;
176
150
return response . data ;
177
151
} catch ( err ) {
178
- return '' ; // Suppress error
152
+ return '' ;
179
153
}
180
154
}
181
155
182
156
async function installConfigFile ( ) {
183
157
const resourcesDir = './once-ui/resources' ;
184
- await fs . ensureDir ( resourcesDir ) ; // Create resources directory if it doesn't exist
185
-
186
- const configFilePath = './once-ui/resources/config.js' ;
158
+ await fs . ensureDir ( resourcesDir ) ;
187
159
const configContent = await fetchConfigContent ( ) ;
188
-
189
160
await installFile ( 'config.js' , configContent , resourcesDir ) ;
190
161
}
191
162
192
163
async function fetchConfigContent ( ) {
193
164
const GITHUB_CONFIG_URL = 'https://raw.githubusercontent.com/once-ui-system/nextjs-starter/main/src/once-ui/resources/config.js' ;
194
-
195
165
try {
196
166
const response = await axios . get ( GITHUB_CONFIG_URL ) ;
197
167
return response . data ;
198
168
} catch ( err ) {
199
- return '' ; // Suppress error
169
+ return '' ;
200
170
}
201
171
}
202
172
203
173
async function installStylesAndTokens ( ) {
204
174
const stylesDir = './once-ui/styles' ;
205
175
const tokensDir = './once-ui/tokens' ;
206
176
207
- // Create directories for styles and tokens
208
177
await fs . ensureDir ( stylesDir ) ;
209
178
await fs . ensureDir ( tokensDir ) ;
210
179
211
- // List of styles to install
212
180
const styles = [
213
- 'background.scss' ,
214
- 'border.scss' ,
215
- 'breakpoints.scss' ,
216
- 'color.scss' ,
217
- 'display.scss' ,
218
- 'flex.scss' ,
219
- 'global.scss' ,
220
- 'grid.scss' ,
221
- 'index.scss' ,
222
- 'layout.scss' ,
223
- 'position.scss' ,
224
- 'shadow.scss' ,
225
- 'size.scss' ,
226
- 'spacing.scss' ,
227
- 'typography.scss' ,
181
+ 'background.scss' , 'border.scss' , 'breakpoints.scss' ,
182
+ 'color.scss' , 'display.scss' , 'flex.scss' , 'global.scss' ,
183
+ 'grid.scss' , 'index.scss' , 'layout.scss' , 'position.scss' ,
184
+ 'shadow.scss' , 'size.scss' , 'spacing.scss' , 'typography.scss' ,
228
185
'utilities.scss'
229
186
] ;
230
187
231
- // Install styles
232
188
for ( const style of styles ) {
233
189
const styleContent = await fetchStyleFile ( style ) ;
234
190
await installFile ( style , styleContent , stylesDir ) ;
235
191
}
236
192
237
- // List of tokens to install
238
193
const tokens = [
239
- 'border.scss' ,
240
- 'function.scss' ,
241
- 'index.scss' ,
242
- 'layout.scss' ,
243
- 'scheme.scss' ,
244
- 'shadow.scss' ,
245
- 'theme.scss' ,
246
- 'typography.scss'
194
+ 'border.scss' , 'function.scss' , 'index.scss' ,
195
+ 'layout.scss' , 'scheme.scss' , 'shadow.scss' ,
196
+ 'theme.scss' , 'typography.scss'
247
197
] ;
248
198
249
- // Install tokens
250
199
for ( const token of tokens ) {
251
200
const tokenContent = await fetchTokenFile ( token ) ;
252
201
await installFile ( token , tokenContent , tokensDir ) ;
0 commit comments