grg-kit-cli 0.2.0 ā 0.3.1
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 +97 -167
- package/bin/grg.js +25 -32
- package/commands/add.js +59 -101
- package/commands/init.js +150 -19
- package/commands/list.js +26 -58
- package/commands/llm-prompts.js +706 -0
- package/config/resources.js +15 -11
- package/package.json +6 -7
- package/scripts/README.md +4 -4
- package/scripts/generate-resources.js +14 -14
- package/commands/interactive.js +0 -223
- package/commands/metadata.js +0 -122
package/README.md
CHANGED
|
@@ -1,69 +1,59 @@
|
|
|
1
1
|
# grg-kit-cli
|
|
2
2
|
|
|
3
|
-
CLI tool for
|
|
3
|
+
CLI tool for initializing Angular projects with GRG Kit and adding blocks.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
pnpm install -g grg-kit-cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
#
|
|
15
|
-
grg
|
|
16
|
-
# or
|
|
17
|
-
grg interactive
|
|
18
|
-
grg i
|
|
19
|
-
|
|
20
|
-
# Or use direct commands
|
|
21
|
-
grg init # Initialize with theme
|
|
22
|
-
grg add theme:claude # Add specific resources
|
|
23
|
-
grg list # Browse available resources
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Commands
|
|
14
|
+
# Initialize a new Angular project with GRG Kit
|
|
15
|
+
grg init my-app
|
|
27
16
|
|
|
28
|
-
|
|
17
|
+
# Initialize with a specific theme
|
|
18
|
+
grg init my-app --theme claude
|
|
29
19
|
|
|
30
|
-
|
|
20
|
+
# Add blocks (inside project directory)
|
|
21
|
+
cd my-app
|
|
22
|
+
grg add block --auth
|
|
23
|
+
grg add block --shell
|
|
24
|
+
grg add block --all
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
grg
|
|
34
|
-
grg
|
|
35
|
-
grg
|
|
26
|
+
# List available resources
|
|
27
|
+
grg list
|
|
28
|
+
grg list blocks
|
|
29
|
+
grg list themes
|
|
36
30
|
```
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
- Presents a simple menu to choose actions
|
|
40
|
-
- Browse resources with descriptions
|
|
41
|
-
- Select multiple examples at once
|
|
42
|
-
- Minimal surface area, focused experience
|
|
43
|
-
|
|
44
|
-
**Perfect for:**
|
|
45
|
-
- First-time users
|
|
46
|
-
- Exploring available resources
|
|
47
|
-
- Quick resource selection
|
|
32
|
+
## Commands
|
|
48
33
|
|
|
49
|
-
### `grg init
|
|
34
|
+
### `grg init <project-name>`
|
|
50
35
|
|
|
51
|
-
|
|
36
|
+
Create a new Angular project with GRG Kit fully configured. One command to set up everything.
|
|
52
37
|
|
|
53
38
|
```bash
|
|
54
|
-
grg init [options]
|
|
39
|
+
grg init <project-name> [options]
|
|
55
40
|
|
|
56
41
|
Options:
|
|
57
42
|
-t, --theme <name> Theme to install (default: "grg-theme")
|
|
58
43
|
|
|
59
44
|
Examples:
|
|
60
|
-
grg init
|
|
61
|
-
grg init --theme claude
|
|
62
|
-
grg init -t modern-minimal
|
|
45
|
+
grg init my-app
|
|
46
|
+
grg init my-app --theme claude
|
|
47
|
+
grg init dashboard -t modern-minimal
|
|
63
48
|
```
|
|
64
49
|
|
|
65
50
|
**What it does:**
|
|
66
|
-
- Creates
|
|
51
|
+
- Creates Angular project with CSS styling
|
|
52
|
+
- Installs Tailwind CSS v4 (`tailwindcss @tailwindcss/postcss postcss`)
|
|
53
|
+
- Creates `.postcssrc.json` with PostCSS configuration
|
|
54
|
+
- Installs and configures Spartan-NG CLI
|
|
55
|
+
- Runs `ng g @spartan-ng/cli:ui all` to install all Spartan-NG UI components
|
|
56
|
+
- Downloads 56+ Spartan-NG examples to `libs/examples`
|
|
67
57
|
- Downloads the selected theme
|
|
68
58
|
- Updates `src/styles.css` with theme import
|
|
69
59
|
|
|
@@ -75,187 +65,127 @@ Examples:
|
|
|
75
65
|
- `amber-minimal` - Warm amber accents
|
|
76
66
|
- `mocks` - Theme for mockups and prototypes
|
|
77
67
|
|
|
78
|
-
### `grg add
|
|
68
|
+
### `grg add block`
|
|
79
69
|
|
|
80
|
-
Add
|
|
70
|
+
Add blocks to your project.
|
|
81
71
|
|
|
82
72
|
```bash
|
|
83
|
-
grg add
|
|
73
|
+
grg add block [options]
|
|
84
74
|
|
|
85
75
|
Options:
|
|
76
|
+
--all Add all blocks
|
|
77
|
+
--auth Add authentication block (login, signup, forgot password)
|
|
78
|
+
--shell Add app shell block (sidebar, header, content area)
|
|
79
|
+
--settings Add settings block (settings page with sidebar navigation)
|
|
86
80
|
-o, --output <path> Custom output directory
|
|
87
81
|
|
|
88
82
|
Examples:
|
|
89
|
-
grg add
|
|
90
|
-
grg add
|
|
91
|
-
grg add
|
|
92
|
-
grg add examples:button
|
|
93
|
-
grg add examples:all
|
|
83
|
+
grg add block --auth
|
|
84
|
+
grg add block --shell --settings
|
|
85
|
+
grg add block --all
|
|
94
86
|
```
|
|
95
87
|
|
|
96
|
-
**Resource format:** `<category>:<name>`
|
|
97
|
-
|
|
98
|
-
**Categories:**
|
|
99
|
-
- `theme` - Pre-built theme files
|
|
100
|
-
- `component` - Reusable components
|
|
101
|
-
- `layout` - Page layouts
|
|
102
|
-
- `examples` - Spartan-NG component examples
|
|
103
|
-
|
|
104
88
|
### `grg list [category]`
|
|
105
89
|
|
|
106
|
-
List available
|
|
90
|
+
List available blocks and themes.
|
|
107
91
|
|
|
108
92
|
```bash
|
|
109
93
|
grg list [category]
|
|
110
94
|
|
|
111
95
|
Examples:
|
|
112
|
-
grg list # Show
|
|
96
|
+
grg list # Show overview
|
|
97
|
+
grg list blocks # List all blocks
|
|
113
98
|
grg list themes # List all themes
|
|
114
|
-
grg list components
|
|
115
|
-
grg list layouts
|
|
116
|
-
grg list examples
|
|
117
99
|
```
|
|
118
100
|
|
|
119
|
-
### `grg
|
|
101
|
+
### `grg llm-prompts`
|
|
120
102
|
|
|
121
|
-
|
|
103
|
+
Generate LLM-specific prompts and rules for AI assistants (Windsurf, Cursor, etc.).
|
|
122
104
|
|
|
123
105
|
```bash
|
|
124
|
-
grg
|
|
106
|
+
grg llm-prompts [options]
|
|
125
107
|
|
|
126
108
|
Options:
|
|
127
|
-
-
|
|
109
|
+
-o, --output <path> Output directory for rules (default: ".windsurf/rules")
|
|
128
110
|
|
|
129
111
|
Examples:
|
|
130
|
-
grg
|
|
131
|
-
grg
|
|
112
|
+
grg llm-prompts
|
|
113
|
+
grg llm-prompts --output .cursor/rules
|
|
132
114
|
```
|
|
133
115
|
|
|
134
|
-
**Purpose:**
|
|
135
|
-
This command outputs structured JSON/YAML metadata that can be consumed by:
|
|
136
|
-
- MCP (Model Context Protocol) servers
|
|
137
|
-
- LLMs for automated resource discovery
|
|
138
|
-
- CI/CD pipelines
|
|
139
|
-
- Documentation generators
|
|
140
|
-
|
|
141
116
|
## MCP Server Integration
|
|
142
117
|
|
|
143
|
-
|
|
118
|
+
For AI assistants to automatically discover and use GRG Kit resources:
|
|
144
119
|
|
|
145
|
-
1.
|
|
146
|
-
2. **Understand command usage** - Syntax, options, examples
|
|
147
|
-
3. **Execute commands automatically** - Based on user intent
|
|
148
|
-
4. **Provide contextual help** - Descriptions, tags, dependencies
|
|
120
|
+
### 1. Install the MCP Server
|
|
149
121
|
|
|
150
|
-
|
|
122
|
+
```bash
|
|
123
|
+
pnpm install -g @grg-kit/mcp-server
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 2. Configure Your AI Assistant
|
|
127
|
+
|
|
128
|
+
**Windsurf** (`~/.codeium/windsurf/mcp_config.json`):
|
|
151
129
|
|
|
152
130
|
```json
|
|
153
131
|
{
|
|
154
|
-
"
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
"commands": [
|
|
158
|
-
{
|
|
159
|
-
"name": "init",
|
|
160
|
-
"description": "Initialize GRG Kit in your Angular project",
|
|
161
|
-
"usage": "grg init [options]",
|
|
162
|
-
"options": [...],
|
|
163
|
-
"examples": [...],
|
|
164
|
-
"effects": [...]
|
|
132
|
+
"mcpServers": {
|
|
133
|
+
"grg-kit": {
|
|
134
|
+
"command": "grg-mcp-server"
|
|
165
135
|
}
|
|
166
|
-
],
|
|
167
|
-
"resources": {
|
|
168
|
-
"themes": [...],
|
|
169
|
-
"components": [...],
|
|
170
|
-
"layouts": [...],
|
|
171
|
-
"examples": {...}
|
|
172
136
|
}
|
|
173
137
|
}
|
|
174
138
|
```
|
|
175
139
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
### Initialize a new project
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
# Initialize with default theme
|
|
182
|
-
grg init
|
|
183
|
-
|
|
184
|
-
# Initialize with Claude theme
|
|
185
|
-
grg init --theme claude
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Add resources
|
|
189
|
-
|
|
190
|
-
```bash
|
|
191
|
-
# Add a different theme
|
|
192
|
-
grg add theme:modern-minimal
|
|
193
|
-
|
|
194
|
-
# Add a component
|
|
195
|
-
grg add component:stepper
|
|
196
|
-
|
|
197
|
-
# Add a layout
|
|
198
|
-
grg add layout:dashboard
|
|
199
|
-
|
|
200
|
-
# Add all Spartan-NG examples
|
|
201
|
-
grg add examples:all
|
|
202
|
-
|
|
203
|
-
# Add specific component examples
|
|
204
|
-
grg add examples:button
|
|
205
|
-
grg add examples:dialog
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
### Browse resources
|
|
209
|
-
|
|
210
|
-
```bash
|
|
211
|
-
# See all categories
|
|
212
|
-
grg list
|
|
213
|
-
|
|
214
|
-
# See all themes
|
|
215
|
-
grg list themes
|
|
140
|
+
**Cursor** (`~/.cursor/mcp_config.json`):
|
|
216
141
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
grg
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"mcpServers": {
|
|
145
|
+
"grg-kit": {
|
|
146
|
+
"command": "grg-mcp-server"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
222
150
|
```
|
|
223
151
|
|
|
224
|
-
|
|
152
|
+
### 3. Generate AI Rules
|
|
225
153
|
|
|
226
|
-
### Before (with degit):
|
|
227
154
|
```bash
|
|
228
|
-
|
|
229
|
-
|
|
155
|
+
cd your-angular-project
|
|
156
|
+
grg llm-prompts
|
|
230
157
|
```
|
|
231
158
|
|
|
232
|
-
###
|
|
233
|
-
```bash
|
|
234
|
-
grg add theme:grg-theme
|
|
235
|
-
grg add examples:all
|
|
236
|
-
```
|
|
159
|
+
### 4. Restart Your IDE
|
|
237
160
|
|
|
238
|
-
**
|
|
239
|
-
- ā
|
|
240
|
-
- ā
|
|
241
|
-
- ā
|
|
242
|
-
- ā
|
|
243
|
-
- ā
MCP server integration
|
|
244
|
-
- ā
Structured metadata for LLMs
|
|
161
|
+
**What this enables:**
|
|
162
|
+
- ā
AI automatically searches GRG Kit before writing custom code
|
|
163
|
+
- ā
AI knows about themes, components, blocks, and examples
|
|
164
|
+
- ā
AI follows GRG Kit design system patterns
|
|
165
|
+
- ā
AI can install blocks directly via MCP tools
|
|
245
166
|
|
|
246
|
-
##
|
|
167
|
+
## Quick Reference
|
|
247
168
|
|
|
248
169
|
```bash
|
|
249
|
-
#
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
#
|
|
256
|
-
grg --
|
|
257
|
-
grg
|
|
258
|
-
grg
|
|
170
|
+
# Initialize project
|
|
171
|
+
grg init my-app # Default theme
|
|
172
|
+
grg init my-app --theme claude # Custom theme
|
|
173
|
+
|
|
174
|
+
# Add blocks (inside project directory)
|
|
175
|
+
cd my-app
|
|
176
|
+
grg add block --auth # Auth pages
|
|
177
|
+
grg add block --shell # App shell
|
|
178
|
+
grg add block --settings # Settings page
|
|
179
|
+
grg add block --auth --shell # Multiple blocks
|
|
180
|
+
grg add block --all # All blocks
|
|
181
|
+
|
|
182
|
+
# List resources
|
|
183
|
+
grg list # Overview
|
|
184
|
+
grg list blocks # Available blocks
|
|
185
|
+
grg list themes # Available themes
|
|
186
|
+
|
|
187
|
+
# AI setup
|
|
188
|
+
grg llm-prompts # Generate AI rules
|
|
259
189
|
```
|
|
260
190
|
|
|
261
191
|
## License
|
package/bin/grg.js
CHANGED
|
@@ -4,53 +4,46 @@ const { Command } = require('commander');
|
|
|
4
4
|
const { add } = require('../commands/add');
|
|
5
5
|
const { list } = require('../commands/list');
|
|
6
6
|
const { init } = require('../commands/init');
|
|
7
|
-
const {
|
|
8
|
-
const { interactive } = require('../commands/interactive');
|
|
7
|
+
const { llmPrompts } = require('../commands/llm-prompts');
|
|
9
8
|
|
|
10
9
|
const program = new Command();
|
|
11
10
|
|
|
12
11
|
program
|
|
13
12
|
.name('grg')
|
|
14
|
-
.description('GRG Kit CLI -
|
|
15
|
-
.version('0.
|
|
13
|
+
.description('GRG Kit CLI - Initialize your Angular project with GRG Kit components and add blocks')
|
|
14
|
+
.version('0.3.0');
|
|
16
15
|
|
|
17
|
-
//
|
|
16
|
+
// Init command - sets up everything in one shot
|
|
18
17
|
program
|
|
19
|
-
.command('
|
|
20
|
-
.
|
|
21
|
-
.description('Interactive mode - browse and add resources with a guided interface')
|
|
22
|
-
.action(interactive);
|
|
23
|
-
|
|
24
|
-
// Init command
|
|
25
|
-
program
|
|
26
|
-
.command('init')
|
|
27
|
-
.description('Initialize GRG Kit in your Angular project with themes directory and configuration')
|
|
18
|
+
.command('init <project-name>')
|
|
19
|
+
.description('Initialize GRG Kit: creates Angular project with zoneless, sets up styles.css with theme, adds all components')
|
|
28
20
|
.option('-t, --theme <name>', 'Theme to install (grg-theme, claude, clean-slate, modern-minimal, amber-minimal, mocks)', 'grg-theme')
|
|
29
21
|
.action(init);
|
|
30
22
|
|
|
31
|
-
// Add command
|
|
32
|
-
program
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.
|
|
23
|
+
// Add command with block subcommand
|
|
24
|
+
const addCommand = program.command('add').description('Add resources to your project');
|
|
25
|
+
|
|
26
|
+
addCommand
|
|
27
|
+
.command('block')
|
|
28
|
+
.description('Add blocks to your project')
|
|
29
|
+
.option('--all', 'Add all blocks')
|
|
30
|
+
.option('--auth', 'Add authentication block (login, signup, forgot password)')
|
|
31
|
+
.option('--shell', 'Add app shell block (sidebar, header, content area)')
|
|
32
|
+
.option('--settings', 'Add settings block (settings page with sidebar navigation)')
|
|
33
|
+
.option('-o, --output <path>', 'Custom output directory')
|
|
36
34
|
.action(add);
|
|
37
35
|
|
|
38
36
|
// List command
|
|
39
37
|
program
|
|
40
38
|
.command('list [category]')
|
|
41
|
-
.description('List available
|
|
39
|
+
.description('List available blocks and components')
|
|
42
40
|
.action(list);
|
|
43
41
|
|
|
44
|
-
//
|
|
42
|
+
// LLM Prompts command
|
|
45
43
|
program
|
|
46
|
-
.command('
|
|
47
|
-
.description('
|
|
48
|
-
.option('-
|
|
49
|
-
.action(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (process.argv.length === 2) {
|
|
53
|
-
interactive();
|
|
54
|
-
} else {
|
|
55
|
-
program.parse();
|
|
56
|
-
}
|
|
44
|
+
.command('llm-prompts')
|
|
45
|
+
.description('Generate LLM-specific prompts and rules for AI assistants (Windsurf, Cursor, etc.)')
|
|
46
|
+
.option('-o, --output <path>', 'Output directory for rules', '.windsurf/rules')
|
|
47
|
+
.action(llmPrompts);
|
|
48
|
+
|
|
49
|
+
program.parse();
|
package/commands/add.js
CHANGED
|
@@ -4,122 +4,80 @@ const ora = require('ora');
|
|
|
4
4
|
const { RESOURCES, REPO } = require('../config/resources');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Add command - downloads
|
|
8
|
-
* Format: grg add
|
|
7
|
+
* Add command - downloads blocks
|
|
8
|
+
* Format: grg add block [options]
|
|
9
9
|
* Examples:
|
|
10
|
-
* grg add
|
|
11
|
-
* grg add
|
|
12
|
-
* grg add
|
|
13
|
-
* grg add examples:all
|
|
10
|
+
* grg add block --auth
|
|
11
|
+
* grg add block --shell --settings
|
|
12
|
+
* grg add block --all
|
|
14
13
|
*/
|
|
15
|
-
async function add(
|
|
16
|
-
|
|
14
|
+
async function add(options) {
|
|
15
|
+
// Determine which blocks to add
|
|
16
|
+
const blocksToAdd = [];
|
|
17
|
+
|
|
18
|
+
if (options.all) {
|
|
19
|
+
blocksToAdd.push(...RESOURCES.blocks);
|
|
20
|
+
} else {
|
|
21
|
+
if (options.auth) {
|
|
22
|
+
const block = RESOURCES.blocks.find(b => b.name === 'auth');
|
|
23
|
+
if (block) blocksToAdd.push(block);
|
|
24
|
+
}
|
|
25
|
+
if (options.shell) {
|
|
26
|
+
const block = RESOURCES.blocks.find(b => b.name === 'shell');
|
|
27
|
+
if (block) blocksToAdd.push(block);
|
|
28
|
+
}
|
|
29
|
+
if (options.settings) {
|
|
30
|
+
const block = RESOURCES.blocks.find(b => b.name === 'settings');
|
|
31
|
+
if (block) blocksToAdd.push(block);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
17
34
|
|
|
18
|
-
if (
|
|
19
|
-
console.
|
|
20
|
-
console.log(chalk.
|
|
21
|
-
console.log(' grg add
|
|
22
|
-
console.log(' grg add
|
|
23
|
-
console.log(' grg add
|
|
24
|
-
console.log('
|
|
35
|
+
if (blocksToAdd.length === 0) {
|
|
36
|
+
console.log(chalk.yellow('\nNo blocks specified. Use one of the following options:\n'));
|
|
37
|
+
console.log(chalk.cyan(' grg add block --all'), chalk.gray(' Add all blocks'));
|
|
38
|
+
console.log(chalk.cyan(' grg add block --auth'), chalk.gray(' Add authentication block'));
|
|
39
|
+
console.log(chalk.cyan(' grg add block --shell'), chalk.gray(' Add app shell block'));
|
|
40
|
+
console.log(chalk.cyan(' grg add block --settings'), chalk.gray(' Add settings block'));
|
|
41
|
+
console.log(chalk.gray('\nRun'), chalk.cyan('grg list blocks'), chalk.gray('for more details'));
|
|
25
42
|
process.exit(1);
|
|
26
43
|
}
|
|
27
44
|
|
|
28
|
-
|
|
29
|
-
let sourcePath;
|
|
30
|
-
let outputPath;
|
|
31
|
-
|
|
32
|
-
// Find the resource
|
|
33
|
-
switch (category) {
|
|
34
|
-
case 'theme':
|
|
35
|
-
resourceData = RESOURCES.themes.find(t => t.name === name);
|
|
36
|
-
if (resourceData) {
|
|
37
|
-
sourcePath = resourceData.path;
|
|
38
|
-
outputPath = options.output || resourceData.defaultOutput;
|
|
39
|
-
}
|
|
40
|
-
break;
|
|
41
|
-
|
|
42
|
-
case 'component':
|
|
43
|
-
resourceData = RESOURCES.components.find(c => c.name === name);
|
|
44
|
-
if (resourceData) {
|
|
45
|
-
sourcePath = resourceData.path;
|
|
46
|
-
outputPath = options.output || resourceData.defaultOutput;
|
|
47
|
-
}
|
|
48
|
-
break;
|
|
49
|
-
|
|
50
|
-
case 'layout':
|
|
51
|
-
resourceData = RESOURCES.layouts.find(l => l.name === name);
|
|
52
|
-
if (resourceData) {
|
|
53
|
-
sourcePath = resourceData.path;
|
|
54
|
-
outputPath = options.output || resourceData.defaultOutput;
|
|
55
|
-
}
|
|
56
|
-
break;
|
|
57
|
-
|
|
58
|
-
case 'examples':
|
|
59
|
-
if (name === 'all') {
|
|
60
|
-
resourceData = RESOURCES.examples.all;
|
|
61
|
-
sourcePath = resourceData.path;
|
|
62
|
-
outputPath = options.output || resourceData.defaultOutput;
|
|
63
|
-
} else {
|
|
64
|
-
resourceData = RESOURCES.examples.components.find(e => e.name === name);
|
|
65
|
-
if (resourceData) {
|
|
66
|
-
sourcePath = resourceData.path;
|
|
67
|
-
outputPath = options.output || resourceData.defaultOutput;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
break;
|
|
71
|
-
|
|
72
|
-
default:
|
|
73
|
-
console.error(chalk.red(`Error: Unknown category "${category}"`));
|
|
74
|
-
console.log(chalk.yellow('Valid categories: theme, component, layout, examples'));
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
45
|
+
console.log(chalk.bold.cyan(`\nš¦ Adding ${blocksToAdd.length} block(s)\n`));
|
|
77
46
|
|
|
78
|
-
|
|
79
|
-
console.error(chalk.red(`Error: Resource "${name}" not found in category "${category}"`));
|
|
80
|
-
console.log(chalk.yellow(`\nRun ${chalk.cyan('grg list ' + category + 's')} to see available resources`));
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
47
|
+
const spinner = ora();
|
|
83
48
|
|
|
84
|
-
|
|
85
|
-
|
|
49
|
+
for (const block of blocksToAdd) {
|
|
50
|
+
const outputPath = options.output
|
|
51
|
+
? `${options.output}/${block.name}`
|
|
52
|
+
: block.defaultOutput;
|
|
86
53
|
|
|
87
|
-
|
|
88
|
-
const emitter = degit(`${REPO}/${sourcePath}`, {
|
|
89
|
-
cache: false,
|
|
90
|
-
force: true,
|
|
91
|
-
verbose: false,
|
|
92
|
-
});
|
|
54
|
+
spinner.start(`Downloading ${block.title}...`);
|
|
93
55
|
|
|
94
|
-
|
|
56
|
+
try {
|
|
57
|
+
const emitter = degit(`${REPO}/${block.path}`, {
|
|
58
|
+
cache: false,
|
|
59
|
+
force: true,
|
|
60
|
+
verbose: false,
|
|
61
|
+
});
|
|
95
62
|
|
|
96
|
-
|
|
97
|
-
console.log(chalk.gray(` Location: ${outputPath}`));
|
|
98
|
-
|
|
99
|
-
if (resourceData.description) {
|
|
100
|
-
console.log(chalk.gray(` ${resourceData.description}`));
|
|
101
|
-
}
|
|
63
|
+
await emitter.clone(outputPath);
|
|
102
64
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
65
|
+
spinner.succeed(chalk.green(`ā ${block.title} added`));
|
|
66
|
+
console.log(chalk.gray(` Location: ${outputPath}`));
|
|
67
|
+
|
|
68
|
+
// Show dependencies if any
|
|
69
|
+
if (block.dependencies && block.dependencies.length > 0) {
|
|
70
|
+
console.log(chalk.gray(` Dependencies: ${block.dependencies.join(', ')}`));
|
|
71
|
+
}
|
|
72
|
+
console.log();
|
|
109
73
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
console.
|
|
113
|
-
resourceData.dependencies.forEach(dep => {
|
|
114
|
-
console.log(chalk.gray(` - ${dep}`));
|
|
115
|
-
});
|
|
74
|
+
} catch (error) {
|
|
75
|
+
spinner.fail(chalk.red(`Failed to download ${block.title}`));
|
|
76
|
+
console.error(chalk.red(error.message));
|
|
116
77
|
}
|
|
117
|
-
|
|
118
|
-
} catch (error) {
|
|
119
|
-
spinner.fail(chalk.red('Failed to download resource'));
|
|
120
|
-
console.error(chalk.red(error.message));
|
|
121
|
-
process.exit(1);
|
|
122
78
|
}
|
|
79
|
+
|
|
80
|
+
console.log(chalk.bold.green('⨠Done!'));
|
|
123
81
|
}
|
|
124
82
|
|
|
125
83
|
module.exports = { add };
|