@gilav21/shadcn-angular 0.0.1 → 0.0.2
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.
- package/dist/commands/add.js +17 -7
- package/package.json +1 -1
- package/src/commands/add.ts +15 -7
package/dist/commands/add.js
CHANGED
|
@@ -9,7 +9,7 @@ import { registry } from '../registry/index.js';
|
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
10
|
const __dirname = path.dirname(__filename);
|
|
11
11
|
// Base URL for the component registry (GitHub raw content)
|
|
12
|
-
const REGISTRY_BASE_URL = 'https://raw.githubusercontent.com/gilav21/shadcn-angular/
|
|
12
|
+
const REGISTRY_BASE_URL = 'https://raw.githubusercontent.com/gilav21/shadcn-angular/master/packages/components/ui';
|
|
13
13
|
// Components source directory (relative to CLI dist folder) for local dev
|
|
14
14
|
function getLocalComponentsDir() {
|
|
15
15
|
// From dist/commands/add.js -> packages/components/ui
|
|
@@ -129,10 +129,12 @@ export async function add(components, options) {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
const spinner = ora('Installing components...').start();
|
|
132
|
+
let successCount = 0;
|
|
132
133
|
try {
|
|
133
134
|
await fs.ensureDir(targetDir);
|
|
134
135
|
for (const name of allComponents) {
|
|
135
136
|
const component = registry[name];
|
|
137
|
+
let componentSuccess = true;
|
|
136
138
|
for (const file of component.files) {
|
|
137
139
|
const targetPath = path.join(targetDir, file);
|
|
138
140
|
try {
|
|
@@ -143,15 +145,23 @@ export async function add(components, options) {
|
|
|
143
145
|
}
|
|
144
146
|
catch (err) {
|
|
145
147
|
spinner.warn(`Could not add ${file}: ${err.message}`);
|
|
148
|
+
componentSuccess = false;
|
|
146
149
|
}
|
|
147
150
|
}
|
|
151
|
+
if (componentSuccess)
|
|
152
|
+
successCount++;
|
|
153
|
+
}
|
|
154
|
+
if (successCount > 0) {
|
|
155
|
+
spinner.succeed(chalk.green(`Added ${successCount} component(s)`));
|
|
156
|
+
console.log('\n' + chalk.dim('Components added:'));
|
|
157
|
+
allComponents.forEach(name => {
|
|
158
|
+
console.log(chalk.dim(' - ') + chalk.cyan(name));
|
|
159
|
+
});
|
|
160
|
+
console.log('');
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
spinner.fail(chalk.red('Failed to add any components.'));
|
|
148
164
|
}
|
|
149
|
-
spinner.succeed(chalk.green(`Added ${allComponents.size} component(s)`));
|
|
150
|
-
console.log('\n' + chalk.dim('Components added:'));
|
|
151
|
-
allComponents.forEach(name => {
|
|
152
|
-
console.log(chalk.dim(' - ') + chalk.cyan(name));
|
|
153
|
-
});
|
|
154
|
-
console.log('');
|
|
155
165
|
}
|
|
156
166
|
catch (error) {
|
|
157
167
|
spinner.fail('Failed to add components');
|
package/package.json
CHANGED
package/src/commands/add.ts
CHANGED
|
@@ -11,7 +11,7 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
11
11
|
const __dirname = path.dirname(__filename);
|
|
12
12
|
|
|
13
13
|
// Base URL for the component registry (GitHub raw content)
|
|
14
|
-
const REGISTRY_BASE_URL = 'https://raw.githubusercontent.com/gilav21/shadcn-angular/
|
|
14
|
+
const REGISTRY_BASE_URL = 'https://raw.githubusercontent.com/gilav21/shadcn-angular/master/packages/components/ui';
|
|
15
15
|
|
|
16
16
|
// Components source directory (relative to CLI dist folder) for local dev
|
|
17
17
|
function getLocalComponentsDir(): string | null {
|
|
@@ -150,12 +150,14 @@ export async function add(components: string[], options: AddOptions) {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
const spinner = ora('Installing components...').start();
|
|
153
|
+
let successCount = 0;
|
|
153
154
|
|
|
154
155
|
try {
|
|
155
156
|
await fs.ensureDir(targetDir);
|
|
156
157
|
|
|
157
158
|
for (const name of allComponents) {
|
|
158
159
|
const component = registry[name];
|
|
160
|
+
let componentSuccess = true;
|
|
159
161
|
|
|
160
162
|
for (const file of component.files) {
|
|
161
163
|
const targetPath = path.join(targetDir, file);
|
|
@@ -167,17 +169,23 @@ export async function add(components: string[], options: AddOptions) {
|
|
|
167
169
|
spinner.text = `Added ${file}`;
|
|
168
170
|
} catch (err: any) {
|
|
169
171
|
spinner.warn(`Could not add ${file}: ${err.message}`);
|
|
172
|
+
componentSuccess = false;
|
|
170
173
|
}
|
|
171
174
|
}
|
|
175
|
+
if (componentSuccess) successCount++;
|
|
172
176
|
}
|
|
173
177
|
|
|
174
|
-
|
|
178
|
+
if (successCount > 0) {
|
|
179
|
+
spinner.succeed(chalk.green(`Added ${successCount} component(s)`));
|
|
175
180
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
console.log('\n' + chalk.dim('Components added:'));
|
|
182
|
+
allComponents.forEach(name => {
|
|
183
|
+
console.log(chalk.dim(' - ') + chalk.cyan(name));
|
|
184
|
+
});
|
|
185
|
+
console.log('');
|
|
186
|
+
} else {
|
|
187
|
+
spinner.fail(chalk.red('Failed to add any components.'));
|
|
188
|
+
}
|
|
181
189
|
|
|
182
190
|
} catch (error) {
|
|
183
191
|
spinner.fail('Failed to add components');
|