Skip to content

Commit d4b9187

Browse files
authored
Merge pull request #3081 from gluestack/feat/delete-logic
fix the delete scripts
2 parents 19f1848 + 830d521 commit d4b9187

File tree

6 files changed

+116
-61
lines changed

6 files changed

+116
-61
lines changed

apps/kitchen-sink/components.json renamed to apps/kitchen-sink/constants/sidebar.json

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,18 @@
118118
{
119119
"title": "Heading",
120120
"path": "/ui/docs/components/heading",
121-
"tags": ["rsc"],
121+
"tags": [
122+
"rsc"
123+
],
122124
"url": "https://i.imgur.com/iLgtAcF.png",
123125
"darkUrl": "https://i.imgur.com/or5K0UG.png"
124126
},
125127
{
126128
"title": "Text",
127129
"path": "/ui/docs/components/text",
128-
"tags": ["rsc"],
130+
"tags": [
131+
"rsc"
132+
],
129133
"url": "https://i.imgur.com/vp6ui7d.png",
130134
"darkUrl": "https://i.imgur.com/XMZvanC.png"
131135
}
@@ -138,14 +142,18 @@
138142
{
139143
"title": "Box",
140144
"path": "/ui/docs/components/box",
141-
"tags": ["rsc"],
145+
"tags": [
146+
"rsc"
147+
],
142148
"url": "https://i.imgur.com/3rXWRNQ.png",
143149
"darkUrl": "https://i.imgur.com/nA1FGmN.png"
144150
},
145151
{
146152
"title": "Center",
147153
"path": "/ui/docs/components/center",
148-
"tags": ["rsc"],
154+
"tags": [
155+
"rsc"
156+
],
149157
"url": "https://i.imgur.com/fN5RCAV.png",
150158
"darkUrl": "https://i.imgur.com/gmV2Fil.png"
151159
},
@@ -158,21 +166,28 @@
158166
{
159167
"title": "HStack",
160168
"path": "/ui/docs/components/hstack",
161-
"tags": ["rsc"],
169+
"tags": [
170+
"rsc"
171+
],
162172
"url": "https://i.imgur.com/zMeYQ2r.png",
163173
"darkUrl": "https://i.imgur.com/sxWxT2s.png"
164174
},
165175
{
166176
"title": "VStack",
167177
"path": "/ui/docs/components/vstack",
168-
"tags": ["rsc"],
178+
"tags": [
179+
"rsc"
180+
],
169181
"url": "https://i.imgur.com/d7QcAkw.png",
170182
"darkUrl": "https://i.imgur.com/2ivkRp7.png"
171183
},
172184
{
173185
"title": "Grid",
174186
"path": "/ui/docs/components/grid",
175-
"tags": ["alpha", "rsc"],
187+
"tags": [
188+
"alpha",
189+
"rsc"
190+
],
176191
"url": "https://i.imgur.com/xS7rIHh.png",
177192
"darkUrl": "https://i.imgur.com/r6HtWus.png"
178193
}
@@ -221,14 +236,18 @@
221236
{
222237
"title": "Card",
223238
"path": "/ui/docs/components/card",
224-
"tags": ["rsc"],
239+
"tags": [
240+
"rsc"
241+
],
225242
"url": "https://i.imgur.com/At8sHdO.png",
226243
"darkUrl": "https://i.imgur.com/g37yBPg.png"
227244
},
228245
{
229246
"title": "Table",
230247
"path": "/ui/docs/components/table",
231-
"tags": ["alpha"],
248+
"tags": [
249+
"alpha"
250+
],
232251
"url": "https://i.imgur.com/xS7rIHh.png",
233252
"darkUrl": "https://i.imgur.com/r6HtWus.png"
234253
}
@@ -373,7 +392,9 @@
373392
{
374393
"title": "BottomSheet",
375394
"path": "/ui/docs/components/bottomsheet",
376-
"tags": ["alpha"]
395+
"tags": [
396+
"alpha"
397+
]
377398
}
378399
]
379400
},
@@ -396,7 +417,9 @@
396417
{
397418
"title": "Icon",
398419
"path": "/ui/docs/components/icon",
399-
"tags": ["rsc"],
420+
"tags": [
421+
"rsc"
422+
],
400423
"url": "https://i.imgur.com/wrq05q6.png",
401424
"darkUrl": "https://i.imgur.com/sCURs3s.png"
402425
}
@@ -415,7 +438,10 @@
415438
{
416439
"title": "Skeleton",
417440
"path": "/ui/docs/components/skeleton",
418-
"tags": ["alpha", "rsc"],
441+
"tags": [
442+
"alpha",
443+
"rsc"
444+
],
419445
"url": "https://i.imgur.com/c65rk9I.png",
420446
"darkUrl": "https://i.imgur.com/AGl2kYx.png"
421447
}
@@ -547,4 +573,4 @@
547573
}
548574
]
549575
}
550-
}
576+
}
Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import components from '../components.json';
1+
import components from '../constants/sidebar.json';
22
import {
33
getNestedComponents,
44
type NestedComponents,
@@ -8,25 +8,3 @@ export function getAllComponents(): NestedComponents {
88
return getNestedComponents(components);
99
}
1010

11-
// Example usage:
12-
/*
13-
const components = getAllComponents();
14-
// This will return an array of objects like:
15-
[
16-
{
17-
category: "Typography",
18-
components: [
19-
{ name: "Heading", path: "/ui/docs/components/heading", tags: ["rsc"] },
20-
{ name: "Text", path: "/ui/docs/components/text", tags: ["rsc"] }
21-
]
22-
},
23-
{
24-
category: "Layout",
25-
components: [
26-
{ name: "Box", path: "/ui/docs/components/box", tags: ["rsc"] },
27-
// ... other layout components
28-
]
29-
},
30-
// ... other categories
31-
]
32-
*/

scripts/mappers/kitchen-sink/docsOperations.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@ import path from 'path';
22
import * as fileOps from '../utils/fileOperations';
33
import * as templateGen from './templateGenerator';
44

5-
export const copyComponentsDocs = (component: string) => {
5+
export const copyComponentsDocs = (component: string, event: string) => {
66
const sourcePath = path.resolve('src/components/ui');
77
const kitchenSinkPath = path.resolve('apps/kitchen-sink/app/components');
88

9+
if (event === 'removed') {
10+
const destPath = path.join(kitchenSinkPath, component);
11+
if (!fileOps.pathExists(destPath)) {
12+
console.log(`No docs found for ${component} ${destPath}`);
13+
return;
14+
}
15+
fileOps.deletePath(destPath);
16+
console.log(`Docs for ${component} removed`);
17+
return;
18+
}
19+
920
try {
1021
// Find docs files in the component folder
1122
const componentDocsPath = path.join(sourcePath, component, 'docs');

scripts/mappers/kitchen-sink/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as docsOperations from './docsOperations';
33
export default {
44
component: function (component: string, event = 'added') {
55
componentOperations.copyComponent(component, event);
6-
docsOperations.copyComponentsDocs(component);
6+
docsOperations.copyComponentsDocs(component, event);
77
},
88
nonComponent: function (path: string) {
99
// componentOperations.processNonComponentFile(path);

scripts/mappers/website/componentOperations.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,31 @@ export const copyComponent = (component: string, event: string = 'added') => {
1818
};
1919

2020
export const deleteComponentDocs = (component: string) => {
21-
const websitePath = path.resolve('apps/website/app/ui/docs/components');
22-
const componentDocsPath = path.join(websitePath, component);
23-
24-
try {
25-
if (fileOps.pathExists(componentDocsPath)) {
26-
fileOps.deletePath(componentDocsPath);
27-
console.log(`🗑️ Deleted component docs: ${component}`);
21+
const paths = [
22+
{
23+
path: path.join(path.resolve('apps/website/app/ui/docs/components'), component),
24+
label: 'component docs'
25+
},
26+
{
27+
path: path.join(path.resolve('apps/website/components/page-components/all-components'), component),
28+
label: 'component example'
29+
},
30+
{
31+
path: path.join(path.resolve('apps/website/components/ui'), component),
32+
label: 'component'
2833
}
29-
} catch (error) {
30-
console.error(`❌ Error deleting component docs ${component}:`, error);
31-
}
34+
];
35+
36+
paths.forEach(({ path: componentPath, label }) => {
37+
try {
38+
if (fileOps.pathExists(componentPath)) {
39+
fileOps.deletePath(componentPath);
40+
console.log(`🗑️ Deleted ${label}: ${component}`);
41+
}
42+
} catch (error) {
43+
console.error(`❌ Error deleting ${label} ${component}:`, error);
44+
}
45+
});
3246
};
3347

3448
export const processSidebarFile = (filePath: string) => {

src/sidebar.json

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,18 @@
118118
{
119119
"title": "Heading",
120120
"path": "/ui/docs/components/heading",
121-
"tags": ["rsc"],
121+
"tags": [
122+
"rsc"
123+
],
122124
"url": "https://i.imgur.com/iLgtAcF.png",
123125
"darkUrl": "https://i.imgur.com/or5K0UG.png"
124126
},
125127
{
126128
"title": "Text",
127129
"path": "/ui/docs/components/text",
128-
"tags": ["rsc"],
130+
"tags": [
131+
"rsc"
132+
],
129133
"url": "https://i.imgur.com/vp6ui7d.png",
130134
"darkUrl": "https://i.imgur.com/XMZvanC.png"
131135
}
@@ -138,14 +142,18 @@
138142
{
139143
"title": "Box",
140144
"path": "/ui/docs/components/box",
141-
"tags": ["rsc"],
145+
"tags": [
146+
"rsc"
147+
],
142148
"url": "https://i.imgur.com/3rXWRNQ.png",
143149
"darkUrl": "https://i.imgur.com/nA1FGmN.png"
144150
},
145151
{
146152
"title": "Center",
147153
"path": "/ui/docs/components/center",
148-
"tags": ["rsc"],
154+
"tags": [
155+
"rsc"
156+
],
149157
"url": "https://i.imgur.com/fN5RCAV.png",
150158
"darkUrl": "https://i.imgur.com/gmV2Fil.png"
151159
},
@@ -158,21 +166,28 @@
158166
{
159167
"title": "HStack",
160168
"path": "/ui/docs/components/hstack",
161-
"tags": ["rsc"],
169+
"tags": [
170+
"rsc"
171+
],
162172
"url": "https://i.imgur.com/zMeYQ2r.png",
163173
"darkUrl": "https://i.imgur.com/sxWxT2s.png"
164174
},
165175
{
166176
"title": "VStack",
167177
"path": "/ui/docs/components/vstack",
168-
"tags": ["rsc"],
178+
"tags": [
179+
"rsc"
180+
],
169181
"url": "https://i.imgur.com/d7QcAkw.png",
170182
"darkUrl": "https://i.imgur.com/2ivkRp7.png"
171183
},
172184
{
173185
"title": "Grid",
174186
"path": "/ui/docs/components/grid",
175-
"tags": ["alpha", "rsc"],
187+
"tags": [
188+
"alpha",
189+
"rsc"
190+
],
176191
"url": "https://i.imgur.com/xS7rIHh.png",
177192
"darkUrl": "https://i.imgur.com/r6HtWus.png"
178193
}
@@ -221,14 +236,18 @@
221236
{
222237
"title": "Card",
223238
"path": "/ui/docs/components/card",
224-
"tags": ["rsc"],
239+
"tags": [
240+
"rsc"
241+
],
225242
"url": "https://i.imgur.com/At8sHdO.png",
226243
"darkUrl": "https://i.imgur.com/g37yBPg.png"
227244
},
228245
{
229246
"title": "Table",
230247
"path": "/ui/docs/components/table",
231-
"tags": ["alpha"],
248+
"tags": [
249+
"alpha"
250+
],
232251
"url": "https://i.imgur.com/xS7rIHh.png",
233252
"darkUrl": "https://i.imgur.com/r6HtWus.png"
234253
}
@@ -373,7 +392,9 @@
373392
{
374393
"title": "BottomSheet",
375394
"path": "/ui/docs/components/bottomsheet",
376-
"tags": ["alpha"]
395+
"tags": [
396+
"alpha"
397+
]
377398
}
378399
]
379400
},
@@ -396,7 +417,9 @@
396417
{
397418
"title": "Icon",
398419
"path": "/ui/docs/components/icon",
399-
"tags": ["rsc"],
420+
"tags": [
421+
"rsc"
422+
],
400423
"url": "https://i.imgur.com/wrq05q6.png",
401424
"darkUrl": "https://i.imgur.com/sCURs3s.png"
402425
}
@@ -415,7 +438,10 @@
415438
{
416439
"title": "Skeleton",
417440
"path": "/ui/docs/components/skeleton",
418-
"tags": ["alpha", "rsc"],
441+
"tags": [
442+
"alpha",
443+
"rsc"
444+
],
419445
"url": "https://i.imgur.com/c65rk9I.png",
420446
"darkUrl": "https://i.imgur.com/AGl2kYx.png"
421447
}
@@ -547,4 +573,4 @@
547573
}
548574
]
549575
}
550-
}
576+
}

0 commit comments

Comments
 (0)