grg-kit-cli 0.2.0 → 0.3.0

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/commands/init.js CHANGED
@@ -7,7 +7,7 @@ const { RESOURCES, REPO } = require('../config/resources');
7
7
 
8
8
  /**
9
9
  * Init command - initializes GRG Kit in the project
10
- * Creates themes directory and downloads a theme
10
+ * Downloads theme, all components, and all spartan-ng examples in one shot
11
11
  */
12
12
  async function init(options) {
13
13
  const themeName = options.theme || 'grg-theme';
@@ -22,36 +22,74 @@ async function init(options) {
22
22
 
23
23
  console.log(chalk.bold.cyan('\nšŸš€ Initializing GRG Kit\n'));
24
24
 
25
- // Step 1: Create themes directory
26
- const spinner = ora('Creating themes directory...').start();
25
+ const spinner = ora();
26
+
27
+ // Step 1: Create directories
28
+ spinner.start('Creating directories...');
27
29
  try {
28
30
  await fs.mkdir('src/themes', { recursive: true });
29
- spinner.succeed(chalk.green('āœ“ Created src/themes directory'));
31
+ await fs.mkdir('src/app/components', { recursive: true });
32
+ await fs.mkdir('src/app/spartan-examples', { recursive: true });
33
+ spinner.succeed(chalk.green('āœ“ Created directories'));
30
34
  } catch (error) {
31
- spinner.fail(chalk.red('Failed to create themes directory'));
35
+ spinner.fail(chalk.red('Failed to create directories'));
32
36
  console.error(chalk.red(error.message));
33
37
  process.exit(1);
34
38
  }
35
39
 
36
40
  // Step 2: Download theme
37
- spinner.start(`Downloading ${theme.title}...`);
41
+ spinner.start(`Downloading ${theme.title} theme...`);
38
42
  try {
39
43
  const emitter = degit(`${REPO}/${theme.path}`, {
40
44
  cache: false,
41
45
  force: true,
42
46
  verbose: false,
43
47
  });
44
-
45
48
  await emitter.clone(theme.defaultOutput);
46
- spinner.succeed(chalk.green(`āœ“ Downloaded ${theme.title}`));
49
+ spinner.succeed(chalk.green(`āœ“ Downloaded ${theme.title} theme`));
47
50
  } catch (error) {
48
51
  spinner.fail(chalk.red('Failed to download theme'));
49
52
  console.error(chalk.red(error.message));
50
53
  process.exit(1);
51
54
  }
52
55
 
53
- // Step 3: Check and update styles.css
54
- spinner.start('Checking src/styles.css...');
56
+ // Step 3: Download all components
57
+ spinner.start(`Downloading ${RESOURCES.components.length} components...`);
58
+ try {
59
+ for (const component of RESOURCES.components) {
60
+ const emitter = degit(`${REPO}/${component.path}`, {
61
+ cache: false,
62
+ force: true,
63
+ verbose: false,
64
+ });
65
+ await emitter.clone(component.defaultOutput);
66
+ }
67
+ spinner.succeed(chalk.green(`āœ“ Downloaded ${RESOURCES.components.length} components`));
68
+ } catch (error) {
69
+ spinner.fail(chalk.red('Failed to download components'));
70
+ console.error(chalk.red(error.message));
71
+ process.exit(1);
72
+ }
73
+
74
+ // Step 4: Download all spartan-ng examples
75
+ const examplesAll = RESOURCES.examples.all;
76
+ spinner.start(`Downloading spartan-ng examples (${examplesAll.count})...`);
77
+ try {
78
+ const emitter = degit(`${REPO}/${examplesAll.path}`, {
79
+ cache: false,
80
+ force: true,
81
+ verbose: false,
82
+ });
83
+ await emitter.clone(examplesAll.defaultOutput);
84
+ spinner.succeed(chalk.green(`āœ“ Downloaded spartan-ng examples (${examplesAll.count})`));
85
+ } catch (error) {
86
+ spinner.fail(chalk.red('Failed to download spartan-ng examples'));
87
+ console.error(chalk.red(error.message));
88
+ process.exit(1);
89
+ }
90
+
91
+ // Step 5: Update styles.css
92
+ spinner.start('Updating src/styles.css...');
55
93
  try {
56
94
  const stylesPath = 'src/styles.css';
57
95
  let stylesContent = '';
@@ -66,7 +104,6 @@ async function init(options) {
66
104
  const themeImport = `@import './themes/${theme.file}';`;
67
105
 
68
106
  if (!stylesContent.includes(themeImport)) {
69
- // Add required imports if not present
70
107
  const requiredImports = [
71
108
  '@import "@angular/cdk/overlay-prebuilt.css";',
72
109
  '@import "tailwindcss";',
@@ -89,13 +126,15 @@ async function init(options) {
89
126
 
90
127
  // Success message
91
128
  console.log(chalk.bold.green('\n✨ GRG Kit initialized successfully!\n'));
92
- console.log(chalk.gray('Theme installed:'), chalk.cyan(theme.title));
93
- console.log(chalk.gray('Description:'), theme.description);
129
+
130
+ console.log(chalk.bold('Installed:'));
131
+ console.log(chalk.gray(' Theme:'), chalk.cyan(theme.title));
132
+ console.log(chalk.gray(' Components:'), chalk.cyan(`${RESOURCES.components.length} components`));
133
+ console.log(chalk.gray(' Examples:'), chalk.cyan(`${examplesAll.count} spartan-ng examples`));
94
134
 
95
135
  console.log(chalk.yellow('\nNext steps:'));
96
- console.log(chalk.gray(' 1. Run'), chalk.cyan('grg list'), chalk.gray('to see available resources'));
97
- console.log(chalk.gray(' 2. Add components with'), chalk.cyan('grg add component:<name>'));
98
- console.log(chalk.gray(' 3. Add examples with'), chalk.cyan('grg add examples:all'));
136
+ console.log(chalk.gray(' 1. Run'), chalk.cyan('grg list'), chalk.gray('to see available blocks'));
137
+ console.log(chalk.gray(' 2. Add blocks with'), chalk.cyan('grg add <block-name>'));
99
138
  console.log();
100
139
  }
101
140
 
package/commands/list.js CHANGED
@@ -2,91 +2,59 @@ const chalk = require('chalk');
2
2
  const { RESOURCES } = require('../config/resources');
3
3
 
4
4
  /**
5
- * List command - displays available resources
5
+ * List command - displays available blocks and themes
6
6
  * Usage: grg list [category]
7
7
  */
8
8
  async function list(category) {
9
9
  if (!category) {
10
- // Show all categories
10
+ // Show overview
11
11
  console.log(chalk.bold.cyan('\nšŸ“¦ GRG Kit Resources\n'));
12
12
 
13
+ console.log(chalk.bold('Blocks') + chalk.gray(` (${RESOURCES.blocks.length} available)`));
14
+ console.log(chalk.gray(' Add with: grg add block --<name>'));
15
+ console.log(chalk.gray(' Run: grg list blocks\n'));
16
+
13
17
  console.log(chalk.bold('Themes') + chalk.gray(` (${RESOURCES.themes.length} available)`));
18
+ console.log(chalk.gray(' Set with: grg init --theme <name>'));
14
19
  console.log(chalk.gray(' Run: grg list themes\n'));
15
20
 
16
- console.log(chalk.bold('Components') + chalk.gray(` (${RESOURCES.components.length} available)`));
17
- console.log(chalk.gray(' Run: grg list components\n'));
18
-
19
- console.log(chalk.bold('Layouts') + chalk.gray(` (${RESOURCES.layouts.length} available)`));
20
- console.log(chalk.gray(' Run: grg list layouts\n'));
21
-
22
- console.log(chalk.bold('Spartan-NG Examples') + chalk.gray(` (${RESOURCES.examples.components.length}+ available)`));
23
- console.log(chalk.gray(' Run: grg list examples\n'));
21
+ console.log(chalk.gray('Components and spartan-ng examples are installed automatically with'), chalk.cyan('grg init'));
22
+ console.log();
24
23
 
25
24
  return;
26
25
  }
27
26
 
28
27
  switch (category) {
28
+ case 'blocks':
29
+ console.log(chalk.bold.cyan('\n🧱 Available Blocks\n'));
30
+ RESOURCES.blocks.forEach(block => {
31
+ console.log(chalk.bold(` ${block.name}`));
32
+ console.log(chalk.gray(` ${block.description}`));
33
+ console.log(chalk.yellow(` grg add block --${block.name}`));
34
+ if (block.tags && block.tags.length > 0) {
35
+ console.log(chalk.gray(` Tags: ${block.tags.join(', ')}`));
36
+ }
37
+ console.log();
38
+ });
39
+ break;
40
+
29
41
  case 'themes':
30
42
  console.log(chalk.bold.cyan('\nšŸŽØ Available Themes\n'));
43
+ console.log(chalk.gray(' Use with: grg init --theme <name>\n'));
31
44
  RESOURCES.themes.forEach(theme => {
32
45
  console.log(chalk.bold(` ${theme.name}`));
33
46
  console.log(chalk.gray(` ${theme.description}`));
34
- console.log(chalk.yellow(` grg add theme:${theme.name}`));
35
- if (theme.tags.length > 0) {
47
+ console.log(chalk.yellow(` grg init --theme ${theme.name}`));
48
+ if (theme.tags && theme.tags.length > 0) {
36
49
  console.log(chalk.gray(` Tags: ${theme.tags.join(', ')}`));
37
50
  }
38
51
  console.log();
39
52
  });
40
53
  break;
41
54
 
42
- case 'components':
43
- console.log(chalk.bold.cyan('\n🧩 Available Components\n'));
44
- RESOURCES.components.forEach(component => {
45
- console.log(chalk.bold(` ${component.name}`));
46
- console.log(chalk.gray(` ${component.description}`));
47
- console.log(chalk.yellow(` grg add component:${component.name}`));
48
- if (component.tags.length > 0) {
49
- console.log(chalk.gray(` Tags: ${component.tags.join(', ')}`));
50
- }
51
- console.log();
52
- });
53
- break;
54
-
55
- case 'layouts':
56
- console.log(chalk.bold.cyan('\nšŸ“ Available Layouts\n'));
57
- RESOURCES.layouts.forEach(layout => {
58
- console.log(chalk.bold(` ${layout.name}`));
59
- console.log(chalk.gray(` ${layout.description}`));
60
- console.log(chalk.yellow(` grg add layout:${layout.name}`));
61
- if (layout.tags.length > 0) {
62
- console.log(chalk.gray(` Tags: ${layout.tags.join(', ')}`));
63
- }
64
- console.log();
65
- });
66
- break;
67
-
68
- case 'examples':
69
- console.log(chalk.bold.cyan('\nšŸ“š Available Spartan-NG Examples\n'));
70
-
71
- // Show "all" option first
72
- console.log(chalk.bold(` all`) + chalk.gray(' (recommended)'));
73
- console.log(chalk.gray(` ${RESOURCES.examples.all.description}`));
74
- console.log(chalk.yellow(` grg add examples:all`));
75
- console.log();
76
-
77
- console.log(chalk.gray(' Or add individual component examples:\n'));
78
-
79
- RESOURCES.examples.components.forEach(example => {
80
- console.log(chalk.bold(` ${example.name}`));
81
- console.log(chalk.gray(` ${example.description}`));
82
- console.log(chalk.yellow(` grg add examples:${example.name}`));
83
- console.log();
84
- });
85
- break;
86
-
87
55
  default:
88
56
  console.error(chalk.red(`Error: Unknown category "${category}"`));
89
- console.log(chalk.yellow('Valid categories: themes, components, layouts, examples'));
57
+ console.log(chalk.yellow('Valid categories: blocks, themes'));
90
58
  process.exit(1);
91
59
  }
92
60
  }