@gilav21/shadcn-angular 0.0.4 → 0.0.6
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 +6 -2
- package/dist/commands/init.js +21 -7
- package/dist/index.js +1 -1
- package/dist/registry/index.js +8 -1
- package/package.json +1 -1
- package/src/commands/add.ts +7 -2
- package/src/commands/init.ts +23 -7
- package/src/index.ts +1 -1
- package/src/registry/index.ts +8 -1
package/dist/commands/add.js
CHANGED
|
@@ -55,7 +55,7 @@ export async function add(components, options) {
|
|
|
55
55
|
const config = await getConfig(cwd);
|
|
56
56
|
if (!config) {
|
|
57
57
|
console.log(chalk.red('Error: components.json not found.'));
|
|
58
|
-
console.log(chalk.dim('Run `npx shadcn-angular init` first.'));
|
|
58
|
+
console.log(chalk.dim('Run `npx @gilav21/shadcn-angular init` first.'));
|
|
59
59
|
process.exit(1);
|
|
60
60
|
}
|
|
61
61
|
// Get components to add
|
|
@@ -138,7 +138,11 @@ export async function add(components, options) {
|
|
|
138
138
|
for (const file of component.files) {
|
|
139
139
|
const targetPath = path.join(targetDir, file);
|
|
140
140
|
try {
|
|
141
|
-
|
|
141
|
+
let content = await fetchComponentContent(file, options);
|
|
142
|
+
// Transform imports
|
|
143
|
+
// Replace ../lib/utils (or similar relative paths) with the configured alias
|
|
144
|
+
const utilsAlias = config.aliases.utils;
|
|
145
|
+
content = content.replace(/(\.\.\/)+lib\/utils/g, utilsAlias);
|
|
142
146
|
await fs.ensureDir(path.dirname(targetPath));
|
|
143
147
|
await fs.writeFile(targetPath, content);
|
|
144
148
|
spinner.text = `Added ${file}`;
|
package/dist/commands/init.js
CHANGED
|
@@ -88,9 +88,9 @@ export async function init(options) {
|
|
|
88
88
|
cssVariables: true,
|
|
89
89
|
},
|
|
90
90
|
aliases: {
|
|
91
|
-
components: '@/
|
|
92
|
-
utils: '
|
|
93
|
-
ui: '
|
|
91
|
+
components: responses.componentsPath.replace('src/', '@/'), // Basic heuristic
|
|
92
|
+
utils: responses.utilsPath.replace('src/', '@/').replace('.ts', ''),
|
|
93
|
+
ui: responses.componentsPath.replace('src/', '@/'),
|
|
94
94
|
},
|
|
95
95
|
iconLibrary: 'lucide-angular',
|
|
96
96
|
};
|
|
@@ -101,9 +101,15 @@ export async function init(options) {
|
|
|
101
101
|
await fs.writeJson(componentsJsonPath, config, { spaces: 2 });
|
|
102
102
|
spinner.text = 'Created components.json';
|
|
103
103
|
// Create utils directory and file
|
|
104
|
-
|
|
104
|
+
// Resolve path from the config alias, assuming @/ maps to src/ logic for file creation if not provided directly
|
|
105
|
+
// But we have the 'responses' object from CLI prompt only in the else block above!
|
|
106
|
+
// So we should rely on config to reconstruct the path, or better yet, if we are in 'defaults' mode, check what config is.
|
|
107
|
+
// If config came from defaults, aliases are set.
|
|
108
|
+
// We can reverse-map alias to path: @/ -> src/
|
|
109
|
+
const utilsPathResolved = config.aliases.utils.replace('@/', 'src/');
|
|
110
|
+
const utilsDir = path.dirname(path.join(cwd, utilsPathResolved + '.ts')); // utils usually ends in path/to/utils
|
|
105
111
|
await fs.ensureDir(utilsDir);
|
|
106
|
-
await fs.writeFile(path.join(
|
|
112
|
+
await fs.writeFile(path.join(cwd, utilsPathResolved + '.ts'), getUtilsTemplate());
|
|
107
113
|
spinner.text = 'Created utils.ts';
|
|
108
114
|
// Create/update styles file
|
|
109
115
|
const stylesPath = path.join(cwd, config.tailwind.css);
|
|
@@ -115,7 +121,8 @@ export async function init(options) {
|
|
|
115
121
|
spinner.text = 'Updated styles with theme variables';
|
|
116
122
|
}
|
|
117
123
|
// Create components/ui directory
|
|
118
|
-
const
|
|
124
|
+
const uiPathResolved = config.aliases.ui.replace('@/', 'src/');
|
|
125
|
+
const uiDir = path.join(cwd, uiPathResolved);
|
|
119
126
|
await fs.ensureDir(uiDir);
|
|
120
127
|
spinner.text = 'Created components directory';
|
|
121
128
|
// Install dependencies
|
|
@@ -171,8 +178,15 @@ export async function init(options) {
|
|
|
171
178
|
}
|
|
172
179
|
spinner.succeed(chalk.green('Project initialized successfully!'));
|
|
173
180
|
console.log('\n' + chalk.bold('Next steps:'));
|
|
174
|
-
console.log(chalk.dim(' 1. Add components: ') + chalk.cyan('npx shadcn-angular add button'));
|
|
181
|
+
console.log(chalk.dim(' 1. Add components: ') + chalk.cyan('npx @gilav21/shadcn-angular add button'));
|
|
175
182
|
console.log(chalk.dim(' 2. Import and use in your templates'));
|
|
183
|
+
console.log(chalk.dim(' 3. Update your ') + chalk.bold('tsconfig.json') + chalk.dim(' paths:'));
|
|
184
|
+
console.log(chalk.dim(' "compilerOptions": {'));
|
|
185
|
+
console.log(chalk.dim(' "baseUrl": ".",'));
|
|
186
|
+
console.log(chalk.dim(' "paths": {'));
|
|
187
|
+
console.log(chalk.dim(' "@/*": ["./src/*"]'));
|
|
188
|
+
console.log(chalk.dim(' }'));
|
|
189
|
+
console.log(chalk.dim(' }'));
|
|
176
190
|
console.log('');
|
|
177
191
|
}
|
|
178
192
|
catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const program = new Command();
|
|
|
6
6
|
program
|
|
7
7
|
.name('shadcn-angular')
|
|
8
8
|
.description('CLI for adding shadcn-angular components to your Angular project')
|
|
9
|
-
.version('0.0.
|
|
9
|
+
.version('0.0.6');
|
|
10
10
|
program
|
|
11
11
|
.command('init')
|
|
12
12
|
.description('Initialize shadcn-angular in your project')
|
package/dist/registry/index.js
CHANGED
|
@@ -38,10 +38,12 @@ export const registry = {
|
|
|
38
38
|
'button-group': {
|
|
39
39
|
name: 'button-group',
|
|
40
40
|
files: ['button-group.component.ts'],
|
|
41
|
+
dependencies: ['button']
|
|
41
42
|
},
|
|
42
43
|
calendar: {
|
|
43
44
|
name: 'calendar',
|
|
44
|
-
files: ['calendar.component.ts'],
|
|
45
|
+
files: ['calendar.component.ts', 'calendar-locales.ts'],
|
|
46
|
+
dependencies: ['button', 'select'],
|
|
45
47
|
},
|
|
46
48
|
card: {
|
|
47
49
|
name: 'card',
|
|
@@ -213,4 +215,9 @@ export const registry = {
|
|
|
213
215
|
name: 'tooltip',
|
|
214
216
|
files: ['tooltip.component.ts'],
|
|
215
217
|
},
|
|
218
|
+
'speed-dial': {
|
|
219
|
+
name: 'speed-dial',
|
|
220
|
+
files: ['speed-dial.component.ts'],
|
|
221
|
+
dependencies: ['button']
|
|
222
|
+
},
|
|
216
223
|
};
|
package/package.json
CHANGED
package/src/commands/add.ts
CHANGED
|
@@ -70,7 +70,7 @@ export async function add(components: string[], options: AddOptions) {
|
|
|
70
70
|
const config = await getConfig(cwd);
|
|
71
71
|
if (!config) {
|
|
72
72
|
console.log(chalk.red('Error: components.json not found.'));
|
|
73
|
-
console.log(chalk.dim('Run `npx shadcn-angular init` first.'));
|
|
73
|
+
console.log(chalk.dim('Run `npx @gilav21/shadcn-angular init` first.'));
|
|
74
74
|
process.exit(1);
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -163,7 +163,12 @@ export async function add(components: string[], options: AddOptions) {
|
|
|
163
163
|
const targetPath = path.join(targetDir, file);
|
|
164
164
|
|
|
165
165
|
try {
|
|
166
|
-
|
|
166
|
+
let content = await fetchComponentContent(file, options);
|
|
167
|
+
|
|
168
|
+
// Transform imports
|
|
169
|
+
// Replace ../lib/utils (or similar relative paths) with the configured alias
|
|
170
|
+
const utilsAlias = config.aliases.utils;
|
|
171
|
+
content = content.replace(/(\.\.\/)+lib\/utils/g, utilsAlias);
|
|
167
172
|
await fs.ensureDir(path.dirname(targetPath));
|
|
168
173
|
await fs.writeFile(targetPath, content);
|
|
169
174
|
spinner.text = `Added ${file}`;
|
package/src/commands/init.ts
CHANGED
|
@@ -99,9 +99,9 @@ export async function init(options: InitOptions) {
|
|
|
99
99
|
cssVariables: true,
|
|
100
100
|
},
|
|
101
101
|
aliases: {
|
|
102
|
-
components: '@/
|
|
103
|
-
utils: '
|
|
104
|
-
ui: '
|
|
102
|
+
components: responses.componentsPath.replace('src/', '@/'), // Basic heuristic
|
|
103
|
+
utils: responses.utilsPath.replace('src/', '@/').replace('.ts', ''),
|
|
104
|
+
ui: responses.componentsPath.replace('src/', '@/'),
|
|
105
105
|
},
|
|
106
106
|
iconLibrary: 'lucide-angular',
|
|
107
107
|
};
|
|
@@ -115,9 +115,17 @@ export async function init(options: InitOptions) {
|
|
|
115
115
|
spinner.text = 'Created components.json';
|
|
116
116
|
|
|
117
117
|
// Create utils directory and file
|
|
118
|
-
|
|
118
|
+
// Resolve path from the config alias, assuming @/ maps to src/ logic for file creation if not provided directly
|
|
119
|
+
// But we have the 'responses' object from CLI prompt only in the else block above!
|
|
120
|
+
// So we should rely on config to reconstruct the path, or better yet, if we are in 'defaults' mode, check what config is.
|
|
121
|
+
// If config came from defaults, aliases are set.
|
|
122
|
+
// We can reverse-map alias to path: @/ -> src/
|
|
123
|
+
|
|
124
|
+
const utilsPathResolved = config.aliases.utils.replace('@/', 'src/');
|
|
125
|
+
const utilsDir = path.dirname(path.join(cwd, utilsPathResolved + '.ts')); // utils usually ends in path/to/utils
|
|
126
|
+
|
|
119
127
|
await fs.ensureDir(utilsDir);
|
|
120
|
-
await fs.writeFile(path.join(
|
|
128
|
+
await fs.writeFile(path.join(cwd, utilsPathResolved + '.ts'), getUtilsTemplate());
|
|
121
129
|
spinner.text = 'Created utils.ts';
|
|
122
130
|
|
|
123
131
|
// Create/update styles file
|
|
@@ -132,7 +140,8 @@ export async function init(options: InitOptions) {
|
|
|
132
140
|
}
|
|
133
141
|
|
|
134
142
|
// Create components/ui directory
|
|
135
|
-
const
|
|
143
|
+
const uiPathResolved = config.aliases.ui.replace('@/', 'src/');
|
|
144
|
+
const uiDir = path.join(cwd, uiPathResolved);
|
|
136
145
|
await fs.ensureDir(uiDir);
|
|
137
146
|
spinner.text = 'Created components directory';
|
|
138
147
|
|
|
@@ -190,8 +199,15 @@ export async function init(options: InitOptions) {
|
|
|
190
199
|
spinner.succeed(chalk.green('Project initialized successfully!'));
|
|
191
200
|
|
|
192
201
|
console.log('\n' + chalk.bold('Next steps:'));
|
|
193
|
-
console.log(chalk.dim(' 1. Add components: ') + chalk.cyan('npx shadcn-angular add button'));
|
|
202
|
+
console.log(chalk.dim(' 1. Add components: ') + chalk.cyan('npx @gilav21/shadcn-angular add button'));
|
|
194
203
|
console.log(chalk.dim(' 2. Import and use in your templates'));
|
|
204
|
+
console.log(chalk.dim(' 3. Update your ') + chalk.bold('tsconfig.json') + chalk.dim(' paths:'));
|
|
205
|
+
console.log(chalk.dim(' "compilerOptions": {'));
|
|
206
|
+
console.log(chalk.dim(' "baseUrl": ".",'));
|
|
207
|
+
console.log(chalk.dim(' "paths": {'));
|
|
208
|
+
console.log(chalk.dim(' "@/*": ["./src/*"]'));
|
|
209
|
+
console.log(chalk.dim(' }'));
|
|
210
|
+
console.log(chalk.dim(' }'));
|
|
195
211
|
console.log('');
|
|
196
212
|
|
|
197
213
|
} catch (error) {
|
package/src/index.ts
CHANGED
package/src/registry/index.ts
CHANGED
|
@@ -47,10 +47,12 @@ export const registry: Record<string, ComponentDefinition> = {
|
|
|
47
47
|
'button-group': {
|
|
48
48
|
name: 'button-group',
|
|
49
49
|
files: ['button-group.component.ts'],
|
|
50
|
+
dependencies: ['button']
|
|
50
51
|
},
|
|
51
52
|
calendar: {
|
|
52
53
|
name: 'calendar',
|
|
53
|
-
files: ['calendar.component.ts'],
|
|
54
|
+
files: ['calendar.component.ts', 'calendar-locales.ts'],
|
|
55
|
+
dependencies: ['button', 'select'],
|
|
54
56
|
},
|
|
55
57
|
card: {
|
|
56
58
|
name: 'card',
|
|
@@ -222,4 +224,9 @@ export const registry: Record<string, ComponentDefinition> = {
|
|
|
222
224
|
name: 'tooltip',
|
|
223
225
|
files: ['tooltip.component.ts'],
|
|
224
226
|
},
|
|
227
|
+
'speed-dial': {
|
|
228
|
+
name: 'speed-dial',
|
|
229
|
+
files: ['speed-dial.component.ts'],
|
|
230
|
+
dependencies: ['button']
|
|
231
|
+
},
|
|
225
232
|
};
|