shadcn-extras 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Motion Primitives CLI
1
+ # Shadcn Extras CLI
2
2
 
3
3
  A command-line interface for easily adding beautiful, animated components to your React project.
4
4
 
@@ -7,14 +7,14 @@ A command-line interface for easily adding beautiful, animated components to you
7
7
  You can use the CLI directly with npx:
8
8
 
9
9
  ```bash
10
- npx motion-primitives <command>
10
+ npx shadcn-extras <command>
11
11
  ```
12
12
 
13
13
  Or install it globally:
14
14
 
15
15
  ```bash
16
- npm install -g motion-primitives
17
- motion-primitives <command>
16
+ npm install -g shadcn-extras
17
+ shadcn-extras <command>
18
18
  ```
19
19
 
20
20
  ## Usage
@@ -24,7 +24,7 @@ motion-primitives <command>
24
24
  To see all available animated components:
25
25
 
26
26
  ```bash
27
- npx motion-primitives list
27
+ npx shadcn-extras list
28
28
  ```
29
29
 
30
30
  This will display a list of all available components along with descriptions and required dependencies.
@@ -34,18 +34,18 @@ This will display a list of all available components along with descriptions and
34
34
  To add a specific component to your project:
35
35
 
36
36
  ```bash
37
- npx motion-primitives add <component-name>
37
+ npx shadcn-extras add <component-name>
38
38
  ```
39
39
 
40
40
  For example:
41
41
 
42
42
  ```bash
43
- npx motion-primitives add text-morph
43
+ npx shadcn-extras add text-morph
44
44
  ```
45
45
 
46
46
  This will:
47
47
 
48
- 1. Create a `components/motion-primitives` directory in your project (if it doesn't exist)
48
+ 1. Create a `components/shadcn-extras` directory in your project (if it doesn't exist)
49
49
  2. Download and add the component files
50
50
  3. Automatically install any required dependencies using your preferred package manager (npm, yarn, or pnpm)
51
51
 
@@ -60,7 +60,7 @@ Motion Primitives offers a variety of beautiful and performant animated componen
60
60
  - **Text Animations**: Text morphing, Text loops, Text scramble effects, Spinning text
61
61
  - **And many more!**
62
62
 
63
- For the complete list, run `npx motion-primitives list`.
63
+ For the complete list, run `npx shadcn-extras list`.
64
64
 
65
65
  ## Dependencies
66
66
 
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ function displayBanner() {
73
73
  console.log(`
74
74
  ┌────────────────────────────────────────────┐
75
75
  │ │
76
- Motion Primitives CLI
76
+ Shadcn Extras CLI
77
77
  │ │
78
78
  │ Beautiful, animated components │
79
79
  │ for your React projects │
@@ -84,22 +84,22 @@ function displayBanner() {
84
84
  `);
85
85
  }
86
86
  commander_1.program
87
- .name('motion-primitives')
87
+ .name('shadcn-extras')
88
88
  .description('CLI to add beautiful, animated components to your app')
89
89
  .version(packageJson.version);
90
90
  commander_1.program
91
91
  .command('add')
92
92
  .argument('<component>', 'The component to add (e.g., accordion, text-morph)')
93
- .description('Add a motion-primitives component to your project')
93
+ .description('Add a shadcn-extras component to your project')
94
94
  .action(async (component) => {
95
95
  const spinner = (0, ora_1.default)(`Adding ${component}...`).start();
96
96
  try {
97
- // Fetch the motion-primitives registry
97
+ // Fetch the shadcn-extras registry
98
98
  const motionPrimitivesRegistry = await fetchRegistry(MOTION_PRIMITIVES_REGISTRY_URL);
99
99
  const componentEntry = motionPrimitivesRegistry.items.find((item) => item.name === component);
100
100
  if (!componentEntry) {
101
- spinner.fail(`Component "${component}" not found in motion-primitives registry`);
102
- console.log('\nRun "npx motion-primitives list" to see all available components');
101
+ spinner.fail(`Component "${component}" not found in shadcn-extras registry`);
102
+ console.log('\nRun "npx shadcn-extras list" to see all available components');
103
103
  process.exit(1);
104
104
  }
105
105
  // Collect all files and dependencies
@@ -116,7 +116,7 @@ commander_1.program
116
116
  if (!(0, fs_1.existsSync)(TARGET_DIR)) {
117
117
  (0, fs_1.mkdirSync)(TARGET_DIR, { recursive: true });
118
118
  }
119
- // Write all files to components/motion-primitives/
119
+ // Write all files to components/shadcn-extras/
120
120
  for (const { path, content } of allFiles) {
121
121
  const filePath = (0, path_1.join)(TARGET_DIR, path);
122
122
  (0, fs_1.writeFileSync)(filePath, content);
@@ -135,7 +135,7 @@ commander_1.program
135
135
  .join('');
136
136
  console.log('\nExample usage:');
137
137
  console.log('```jsx');
138
- console.log(`import { ${pascalCaseName} } from '@/components/motion-primitives/${component}';`);
138
+ console.log(`import { ${pascalCaseName} } from '@/components/shadcn-extras/${component}';`);
139
139
  console.log('\n// Then in your JSX:');
140
140
  console.log(`<${pascalCaseName} />`);
141
141
  console.log('```');
@@ -152,11 +152,11 @@ commander_1.program
152
152
  });
153
153
  commander_1.program
154
154
  .command('list')
155
- .description('List all available motion-primitives components')
155
+ .description('List all available shadcn-extras components')
156
156
  .action(async () => {
157
157
  const spinner = (0, ora_1.default)('Fetching components...').start();
158
158
  try {
159
- // Fetch the motion-primitives registry
159
+ // Fetch the shadcn-extras registry
160
160
  const motionPrimitivesRegistry = await fetchRegistry(MOTION_PRIMITIVES_REGISTRY_URL);
161
161
  spinner.succeed(`Found ${motionPrimitivesRegistry.items.length} components`);
162
162
  console.log('\nAvailable components:');
@@ -172,7 +172,7 @@ commander_1.program
172
172
  console.log('');
173
173
  });
174
174
  console.log('\nTo add a component run:');
175
- console.log(' npx motion-primitives add <component-name>');
175
+ console.log(' npx shadcn-extras add <component-name>');
176
176
  }
177
177
  catch (error) {
178
178
  spinner.fail(`Error: ${error.message || error}`);
@@ -185,10 +185,10 @@ commander_1.program.action(() => {
185
185
  console.log('A tool for adding beautiful, animated components to your React app\n');
186
186
  console.log('Available commands:');
187
187
  console.log(' add <component> - Add a component to your project');
188
- console.log(' Example: npx motion-primitives add text-morph');
188
+ console.log(' Example: npx shadcn-extras add text-morph');
189
189
  console.log('\n list - List all available components');
190
- console.log(' Example: npx motion-primitives list');
190
+ console.log(' Example: npx shadcn-extras list');
191
191
  console.log('\n --help - Show help information');
192
- console.log('\nDocumentation: https://github.com/ibelick/motion-primitives');
192
+ console.log('\nDocumentation: https://github.com/nayanrdeveloper/shadcn-extras');
193
193
  });
194
194
  commander_1.program.parse(process.argv);
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "shadcn-extras",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "CLI to add shadcn-extras components to your app",
5
5
  "bin": {
6
6
  "shadcn-extras": "./dist/index.js"
7
7
  },
8
+ "files": [
9
+ "dist"
10
+ ],
8
11
  "type": "commonjs",
9
12
  "scripts": {
10
13
  "build": "tsc",
package/src/index.ts DELETED
@@ -1,258 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { program } from 'commander';
4
- import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
5
- import { join } from 'path';
6
- import ora from 'ora';
7
- import fetch from 'node-fetch';
8
- import { execSync } from 'child_process';
9
-
10
- // Read package.json for version info
11
- const packageJson = JSON.parse(
12
- readFileSync(join(__dirname, '..', 'package.json'), 'utf8')
13
- );
14
-
15
- const MOTION_PRIMITIVES_REGISTRY_URL =
16
- 'https://raw.githubusercontent.com/nayanrdeveloper/shadcn-extras/dev/public/c/registry.json';
17
- const MOTION_PRIMITIVES_BASE_URL =
18
- 'https://raw.githubusercontent.com/nayanrdeveloper/shadcn-extras/dev/';
19
- const TARGET_DIR = 'components/shadcn-extras';
20
-
21
- interface FileEntry {
22
- path: string;
23
- type: string;
24
- content?: string;
25
- }
26
-
27
- interface RegistryItem {
28
- name: string;
29
- title?: string;
30
- description?: string;
31
- dependencies?: string[];
32
- registryDependencies?: string[]; // Kept for reference, not used here
33
- files: FileEntry[];
34
- }
35
-
36
- interface Registry {
37
- items: RegistryItem[];
38
- }
39
-
40
- async function fetchRegistry(url: string): Promise<Registry> {
41
- const response = await fetch(url);
42
- if (!response.ok) {
43
- throw new Error(`Failed to fetch registry from ${url}: ${response.status}`);
44
- }
45
- return response.json();
46
- }
47
-
48
- async function fetchFile(url: string): Promise<string> {
49
- const response = await fetch(url);
50
- if (!response.ok) {
51
- throw new Error(`Failed to fetch file from ${url}: ${response.status}`);
52
- }
53
- return response.text();
54
- }
55
-
56
- // Detect package manager (npm, yarn, pnpm)
57
- function detectPackageManager(): string {
58
- try {
59
- // Check for yarn.lock or package-lock.json
60
- if (existsSync('yarn.lock')) {
61
- return 'yarn';
62
- } else if (existsSync('pnpm-lock.yaml')) {
63
- return 'pnpm';
64
- } else {
65
- return 'npm'; // Default to npm
66
- }
67
- } catch (error) {
68
- return 'npm'; // Default to npm on error
69
- }
70
- }
71
-
72
- // Install dependencies using detected package manager
73
- function installDependencies(dependencies: string[]): boolean {
74
- const packageManager = detectPackageManager();
75
- const spinner = ora('Installing dependencies...').start();
76
-
77
- try {
78
- const installCommand =
79
- packageManager === 'yarn'
80
- ? `yarn add ${dependencies.join(' ')}`
81
- : packageManager === 'pnpm'
82
- ? `pnpm add ${dependencies.join(' ')}`
83
- : `npm install ${dependencies.join(' ')}`;
84
-
85
- execSync(installCommand, { stdio: 'ignore' });
86
- spinner.succeed(
87
- `Dependencies installed successfully with ${packageManager}`
88
- );
89
- return true;
90
- } catch (error) {
91
- spinner.fail(`Failed to install dependencies: ${error}`);
92
- console.log('\nPlease install them manually:');
93
- console.log(
94
- `${packageManager === 'yarn' ? 'yarn add' : packageManager === 'pnpm' ? 'pnpm add' : 'npm install'} ${dependencies.join(' ')}`
95
- );
96
- return false;
97
- }
98
- }
99
-
100
- // Display the welcome banner
101
- function displayBanner() {
102
- console.log(`
103
- ┌────────────────────────────────────────────┐
104
- │ │
105
- │ Motion Primitives CLI │
106
- │ │
107
- │ Beautiful, animated components │
108
- │ for your React projects │
109
- │ │
110
- │ Version: ${packageJson.version} │
111
- │ │
112
- └────────────────────────────────────────────┘
113
- `);
114
- }
115
-
116
- program
117
- .name('motion-primitives')
118
- .description('CLI to add beautiful, animated components to your app')
119
- .version(packageJson.version);
120
-
121
- program
122
- .command('add')
123
- .argument('<component>', 'The component to add (e.g., accordion, text-morph)')
124
- .description('Add a motion-primitives component to your project')
125
- .action(async (component: string) => {
126
- const spinner = ora(`Adding ${component}...`).start();
127
-
128
- try {
129
- // Fetch the motion-primitives registry
130
- const motionPrimitivesRegistry = await fetchRegistry(
131
- MOTION_PRIMITIVES_REGISTRY_URL
132
- );
133
- const componentEntry = motionPrimitivesRegistry.items.find(
134
- (item) => item.name === component
135
- );
136
- if (!componentEntry) {
137
- spinner.fail(
138
- `Component "${component}" not found in motion-primitives registry`
139
- );
140
- console.log(
141
- '\nRun "npx motion-primitives list" to see all available components'
142
- );
143
- process.exit(1);
144
- }
145
-
146
- // Collect all files and dependencies
147
- const allFiles: { path: string; content: string }[] = [];
148
- const allDependencies: Set<string> = new Set(
149
- componentEntry.dependencies || []
150
- );
151
-
152
- // Process all files from registry.json
153
- for (const file of componentEntry.files) {
154
- const content =
155
- file.content ||
156
- (await fetchFile(`${MOTION_PRIMITIVES_BASE_URL}${file.path}`));
157
- const fileName = file.path.split('/').pop()!;
158
- allFiles.push({ path: fileName, content });
159
- }
160
-
161
- // Create target directory if it doesn't exist
162
- if (!existsSync(TARGET_DIR)) {
163
- mkdirSync(TARGET_DIR, { recursive: true });
164
- }
165
-
166
- // Write all files to components/motion-primitives/
167
- for (const { path, content } of allFiles) {
168
- const filePath = join(TARGET_DIR, path);
169
- writeFileSync(filePath, content);
170
- console.log(`✓ Added ${path} to ${filePath}`);
171
- }
172
-
173
- spinner.succeed(`Component "${component}" added successfully!`);
174
-
175
- // Install dependencies automatically
176
- const depsArray = Array.from(allDependencies);
177
- if (depsArray.length > 0) {
178
- const installSuccess = installDependencies(depsArray);
179
-
180
- // Add usage example
181
- if (componentEntry.title) {
182
- const pascalCaseName = component
183
- .split('-')
184
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
185
- .join('');
186
-
187
- console.log('\nExample usage:');
188
- console.log('```jsx');
189
- console.log(
190
- `import { ${pascalCaseName} } from '@/components/motion-primitives/${component}';`
191
- );
192
- console.log('\n// Then in your JSX:');
193
- console.log(`<${pascalCaseName} />`);
194
- console.log('```');
195
- }
196
- } else {
197
- console.log('No additional dependencies needed.');
198
- }
199
- } catch (error: any) {
200
- spinner.fail(`Error: ${error.message || error}`);
201
- process.exit(1);
202
- }
203
- });
204
-
205
- program
206
- .command('list')
207
- .description('List all available motion-primitives components')
208
- .action(async () => {
209
- const spinner = ora('Fetching components...').start();
210
-
211
- try {
212
- // Fetch the motion-primitives registry
213
- const motionPrimitivesRegistry = await fetchRegistry(
214
- MOTION_PRIMITIVES_REGISTRY_URL
215
- );
216
-
217
- spinner.succeed(
218
- `Found ${motionPrimitivesRegistry.items.length} components`
219
- );
220
-
221
- console.log('\nAvailable components:');
222
- console.log('====================\n');
223
-
224
- motionPrimitivesRegistry.items.forEach((item) => {
225
- console.log(`${item.name} - ${item.title}`);
226
- if (item.description) {
227
- console.log(` ${item.description}`);
228
- }
229
- if (item.dependencies && item.dependencies.length > 0) {
230
- console.log(` Dependencies: ${item.dependencies.join(', ')}`);
231
- }
232
- console.log('');
233
- });
234
-
235
- console.log('\nTo add a component run:');
236
- console.log(' npx motion-primitives add <component-name>');
237
- } catch (error: any) {
238
- spinner.fail(`Error: ${error.message || error}`);
239
- process.exit(1);
240
- }
241
- });
242
-
243
- // Add a default command if no command is provided
244
- program.action(() => {
245
- displayBanner();
246
- console.log(
247
- 'A tool for adding beautiful, animated components to your React app\n'
248
- );
249
- console.log('Available commands:');
250
- console.log(' add <component> - Add a component to your project');
251
- console.log(' Example: npx motion-primitives add text-morph');
252
- console.log('\n list - List all available components');
253
- console.log(' Example: npx motion-primitives list');
254
- console.log('\n --help - Show help information');
255
- console.log('\nDocumentation: https://github.com/ibelick/motion-primitives');
256
- });
257
-
258
- program.parse(process.argv);
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "CommonJS",
5
- "outDir": "./dist",
6
- "rootDir": "./src",
7
- "strict": true,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true
10
- },
11
- "include": ["src/**/*"],
12
- "exclude": ["node_modules"]
13
- }