Skip to content

Commit 2438c35

Browse files
authored
Merge pull request #3070 from gluestack/create/script
Create/script
2 parents a4128a4 + d5d0625 commit 2438c35

File tree

3 files changed

+519
-32
lines changed

3 files changed

+519
-32
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"private": true,
33
"dependencies": {
4+
"@clack/prompts": "^0.11.0",
45
"chokidar": "^4.0.3",
56
"solito": "^4.4.1",
67
"ts-node": "^10.9.2",
@@ -38,7 +39,8 @@
3839
"changeset:version": "changeset version",
3940
"release": "changeset publish",
4041
"changeset:status": "changeset status",
41-
"changeset:empty": "changeset --empty"
42+
"changeset:empty": "changeset --empty",
43+
"create:component": "tsx scripts/create.ts"
4244
},
4345
"devDependencies": {
4446
"@changesets/cli": "^2.29.5",
@@ -55,4 +57,4 @@
5557
"workspaces": [
5658
"packages/*"
5759
]
58-
}
60+
}
Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
const fs = require('fs');
22
const path = require('path');
33

4-
const components = [
5-
'accordion',
6-
'actionsheet',
7-
'alert',
8-
'alert-dialog',
9-
'avatar',
10-
'button',
11-
'checkbox',
12-
'fab',
13-
'form-control',
14-
'icon',
15-
'image',
16-
'input',
17-
'link',
18-
'menu',
19-
'modal',
20-
'overlay',
21-
'popover',
22-
'pressable',
23-
'progress',
24-
'radio',
25-
'select',
26-
'slider',
27-
'switch',
28-
'textarea',
29-
'toast',
30-
'tooltip'
31-
];
4+
// Dynamically get components from src directory
5+
const getComponents = () => {
6+
const srcPath = path.join(__dirname, '..', 'src');
7+
if (!fs.existsSync(srcPath)) {
8+
console.log('src directory not found');
9+
return [];
10+
}
11+
12+
return fs.readdirSync(srcPath, { withFileTypes: true })
13+
.filter(dirent => dirent.isDirectory())
14+
.map(dirent => dirent.name);
15+
};
3216

33-
const subdirs = ['creator', 'aria'];
17+
// Dynamically get subdirectories for a component
18+
const getSubdirs = (componentPath) => {
19+
if (!fs.existsSync(componentPath)) {
20+
return [];
21+
}
22+
23+
return fs.readdirSync(componentPath, { withFileTypes: true })
24+
.filter(dirent => dirent.isDirectory())
25+
.map(dirent => dirent.name);
26+
};
27+
28+
const components = getComponents();
29+
console.log('Found components:', components);
3430

3531
// Create barrel files for each component and subdir
3632
components.forEach(component => {
33+
const componentSrcPath = path.join(__dirname, '..', 'src', component);
34+
const subdirs = getSubdirs(componentSrcPath);
35+
36+
console.log(`Component ${component} has subdirs:`, subdirs);
37+
3738
subdirs.forEach(subdir => {
38-
const srcPath = path.join(__dirname, '..', 'src', component, subdir);
39+
const srcPath = path.join(componentSrcPath, subdir);
3940
const barrelPath = path.join(__dirname, '..', component, `${subdir}.ts`);
4041

4142
// Check if the source directory exists
@@ -49,6 +50,9 @@ components.forEach(component => {
4950
// Create barrel file
5051
const content = `export * from '../lib/esm/${component}/${subdir}';`;
5152
fs.writeFileSync(barrelPath, content);
53+
console.log(`Created barrel file: ${barrelPath}`);
5254
}
5355
});
5456
});
57+
58+
console.log('Barrel export generation completed!');

0 commit comments

Comments
 (0)