@springmicro/cli 0.1.4 → 0.1.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @springmicro/cli
2
2
 
3
- A new CLI generated with oclif.
3
+ Command line utilities for SpringMicroHost.
4
4
 
5
5
  [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
6
6
  [![Version](https://img.shields.io/npm/v/@springmicro/cli.svg)](https://npmjs.org/package/@springmicro/cli)
@@ -10,11 +10,10 @@ A new CLI generated with oclif.
10
10
  * [@springmicro/cli](#springmicrocli)
11
11
  * [Usage](#usage)
12
12
  * [Commands](#commands)
13
+ * [Development](#development)
13
14
  <!-- tocstop -->
14
15
 
15
- - [Usage](#usage)
16
- - [Commands](#commands)
17
- <!-- tocstop -->
16
+ - [@springmicro/cli](#springmicrocli)
18
17
  - [Usage](#usage)
19
18
  - [Commands](#commands)
20
19
  <!-- tocstop -->
@@ -27,7 +26,7 @@ $ npm install -g @springmicro/cli
27
26
  $ springmicro COMMAND
28
27
  running command...
29
28
  $ springmicro (--version)
30
- @springmicro/cli/0.1.4 win32-x64 node-v18.17.1
29
+ @springmicro/cli/0.1.6 win32-x64 node-v18.17.1
31
30
  $ springmicro --help [COMMAND]
32
31
  USAGE
33
32
  $ springmicro COMMAND
@@ -40,21 +39,7 @@ $ npm install -g @springmicro/cli
40
39
  $ springmicro COMMAND
41
40
  running command...
42
41
  $ springmicro (--version)
43
- @springmicro/cli/0.1.0 win32-x64 node-v18.17.1
44
- $ springmicro --help [COMMAND]
45
- USAGE
46
- $ springmicro COMMAND
47
- ...
48
- ```
49
-
50
- <!-- usagestop -->
51
-
52
- ```sh-session
53
- $ npm install -g @springmicro/cli
54
- $ springmicro COMMAND
55
- running command...
56
- $ springmicro (--version)
57
- @springmicro/cli/0.0.0 win32-x64 node-v18.17.1
42
+ @springmicro/cli/0.1.5 win32-x64 node-v18.17.1
58
43
  $ springmicro --help [COMMAND]
59
44
  USAGE
60
45
  $ springmicro COMMAND
@@ -121,7 +106,7 @@ EXAMPLES
121
106
  $ springmicro init astro -n example
122
107
  ```
123
108
 
124
- _See code: [src/commands/init/index.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.4/src/commands/init/index.ts)_
109
+ _See code: [src/commands/init/index.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.6/src/commands/init/index.ts)_
125
110
 
126
111
  ## `springmicro init astro`
127
112
 
@@ -141,7 +126,7 @@ EXAMPLES
141
126
  $ springmicro init astro -n <project-name>
142
127
  ```
143
128
 
144
- _See code: [src/commands/init/astro.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.4/src/commands/init/astro.ts)_
129
+ _See code: [src/commands/init/astro.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.6/src/commands/init/astro.ts)_
145
130
 
146
131
  ## `springmicro plugins`
147
132
 
@@ -488,6 +473,374 @@ EXAMPLES
488
473
  $ springmicro init astro -n example
489
474
  ```
490
475
 
476
+ _See code: [src/commands/init/index.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.5/src/commands/init/index.ts)_
477
+
478
+ ## `springmicro init astro`
479
+
480
+ Initialize a Astro project according to SpringMicroHost's specifications.
481
+
482
+ ```
483
+ USAGE
484
+ $ springmicro init astro -n <value>
485
+
486
+ FLAGS
487
+ -n, --name=<value> (required) Project name
488
+
489
+ DESCRIPTION
490
+ Initialize a Astro project according to SpringMicroHost's specifications.
491
+
492
+ EXAMPLES
493
+ $ springmicro init astro -n <project-name>
494
+ ```
495
+
496
+ _See code: [src/commands/init/astro.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.5/src/commands/init/astro.ts)_
497
+
498
+ ## `springmicro plugins`
499
+
500
+ List installed plugins.
501
+
502
+ ```
503
+ USAGE
504
+ $ springmicro plugins [--json] [--core]
505
+
506
+ FLAGS
507
+ --core Show core plugins.
508
+
509
+ GLOBAL FLAGS
510
+ --json Format output as json.
511
+
512
+ DESCRIPTION
513
+ List installed plugins.
514
+
515
+ EXAMPLES
516
+ $ springmicro plugins
517
+ ```
518
+
519
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.3/src/commands/plugins/index.ts)_
520
+
521
+ ## `springmicro plugins add PLUGIN`
522
+
523
+ Installs a plugin into springmicro.
524
+
525
+ ```
526
+ USAGE
527
+ $ springmicro plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
528
+
529
+ ARGUMENTS
530
+ PLUGIN... Plugin to install.
531
+
532
+ FLAGS
533
+ -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
534
+ -h, --help Show CLI help.
535
+ -s, --silent Silences npm output.
536
+ -v, --verbose Show verbose npm output.
537
+
538
+ GLOBAL FLAGS
539
+ --json Format output as json.
540
+
541
+ DESCRIPTION
542
+ Installs a plugin into springmicro.
543
+
544
+ Uses npm to install plugins.
545
+
546
+ Installation of a user-installed plugin will override a core plugin.
547
+
548
+ Use the SPRINGMICRO_NPM_LOG_LEVEL environment variable to set the npm loglevel.
549
+ Use the SPRINGMICRO_NPM_REGISTRY environment variable to set the npm registry.
550
+
551
+ ALIASES
552
+ $ springmicro plugins add
553
+
554
+ EXAMPLES
555
+ Install a plugin from npm registry.
556
+
557
+ $ springmicro plugins add myplugin
558
+
559
+ Install a plugin from a github url.
560
+
561
+ $ springmicro plugins add https://github.com/someuser/someplugin
562
+
563
+ Install a plugin from a github slug.
564
+
565
+ $ springmicro plugins add someuser/someplugin
566
+ ```
567
+
568
+ ## `springmicro plugins:inspect PLUGIN...`
569
+
570
+ Displays installation properties of a plugin.
571
+
572
+ ```
573
+ USAGE
574
+ $ springmicro plugins inspect PLUGIN...
575
+
576
+ ARGUMENTS
577
+ PLUGIN... [default: .] Plugin to inspect.
578
+
579
+ FLAGS
580
+ -h, --help Show CLI help.
581
+ -v, --verbose
582
+
583
+ GLOBAL FLAGS
584
+ --json Format output as json.
585
+
586
+ DESCRIPTION
587
+ Displays installation properties of a plugin.
588
+
589
+ EXAMPLES
590
+ $ springmicro plugins inspect myplugin
591
+ ```
592
+
593
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.3/src/commands/plugins/inspect.ts)_
594
+
595
+ ## `springmicro plugins install PLUGIN`
596
+
597
+ Installs a plugin into springmicro.
598
+
599
+ ```
600
+ USAGE
601
+ $ springmicro plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
602
+
603
+ ARGUMENTS
604
+ PLUGIN... Plugin to install.
605
+
606
+ FLAGS
607
+ -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
608
+ -h, --help Show CLI help.
609
+ -s, --silent Silences npm output.
610
+ -v, --verbose Show verbose npm output.
611
+
612
+ GLOBAL FLAGS
613
+ --json Format output as json.
614
+
615
+ DESCRIPTION
616
+ Installs a plugin into springmicro.
617
+
618
+ Uses npm to install plugins.
619
+
620
+ Installation of a user-installed plugin will override a core plugin.
621
+
622
+ Use the SPRINGMICRO_NPM_LOG_LEVEL environment variable to set the npm loglevel.
623
+ Use the SPRINGMICRO_NPM_REGISTRY environment variable to set the npm registry.
624
+
625
+ ALIASES
626
+ $ springmicro plugins add
627
+
628
+ EXAMPLES
629
+ Install a plugin from npm registry.
630
+
631
+ $ springmicro plugins install myplugin
632
+
633
+ Install a plugin from a github url.
634
+
635
+ $ springmicro plugins install https://github.com/someuser/someplugin
636
+
637
+ Install a plugin from a github slug.
638
+
639
+ $ springmicro plugins install someuser/someplugin
640
+ ```
641
+
642
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.3/src/commands/plugins/install.ts)_
643
+
644
+ ## `springmicro plugins link PATH`
645
+
646
+ Links a plugin into the CLI for development.
647
+
648
+ ```
649
+ USAGE
650
+ $ springmicro plugins link PATH [-h] [--install] [-v]
651
+
652
+ ARGUMENTS
653
+ PATH [default: .] path to plugin
654
+
655
+ FLAGS
656
+ -h, --help Show CLI help.
657
+ -v, --verbose
658
+ --[no-]install Install dependencies after linking the plugin.
659
+
660
+ DESCRIPTION
661
+ Links a plugin into the CLI for development.
662
+ Installation of a linked plugin will override a user-installed or core plugin.
663
+
664
+ e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
665
+ command will override the user-installed or core plugin implementation. This is useful for development work.
666
+
667
+
668
+ EXAMPLES
669
+ $ springmicro plugins link myplugin
670
+ ```
671
+
672
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.3/src/commands/plugins/link.ts)_
673
+
674
+ ## `springmicro plugins remove [PLUGIN]`
675
+
676
+ Removes a plugin from the CLI.
677
+
678
+ ```
679
+ USAGE
680
+ $ springmicro plugins remove [PLUGIN...] [-h] [-v]
681
+
682
+ ARGUMENTS
683
+ PLUGIN... plugin to uninstall
684
+
685
+ FLAGS
686
+ -h, --help Show CLI help.
687
+ -v, --verbose
688
+
689
+ DESCRIPTION
690
+ Removes a plugin from the CLI.
691
+
692
+ ALIASES
693
+ $ springmicro plugins unlink
694
+ $ springmicro plugins remove
695
+
696
+ EXAMPLES
697
+ $ springmicro plugins remove myplugin
698
+ ```
699
+
700
+ ## `springmicro plugins reset`
701
+
702
+ Remove all user-installed and linked plugins.
703
+
704
+ ```
705
+ USAGE
706
+ $ springmicro plugins reset [--hard] [--reinstall]
707
+
708
+ FLAGS
709
+ --hard Delete node_modules and package manager related files in addition to uninstalling plugins.
710
+ --reinstall Reinstall all plugins after uninstalling.
711
+ ```
712
+
713
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.3/src/commands/plugins/reset.ts)_
714
+
715
+ ## `springmicro plugins uninstall [PLUGIN]`
716
+
717
+ Removes a plugin from the CLI.
718
+
719
+ ```
720
+ USAGE
721
+ $ springmicro plugins uninstall [PLUGIN...] [-h] [-v]
722
+
723
+ ARGUMENTS
724
+ PLUGIN... plugin to uninstall
725
+
726
+ FLAGS
727
+ -h, --help Show CLI help.
728
+ -v, --verbose
729
+
730
+ DESCRIPTION
731
+ Removes a plugin from the CLI.
732
+
733
+ ALIASES
734
+ $ springmicro plugins unlink
735
+ $ springmicro plugins remove
736
+
737
+ EXAMPLES
738
+ $ springmicro plugins uninstall myplugin
739
+ ```
740
+
741
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.3/src/commands/plugins/uninstall.ts)_
742
+
743
+ ## `springmicro plugins unlink [PLUGIN]`
744
+
745
+ Removes a plugin from the CLI.
746
+
747
+ ```
748
+ USAGE
749
+ $ springmicro plugins unlink [PLUGIN...] [-h] [-v]
750
+
751
+ ARGUMENTS
752
+ PLUGIN... plugin to uninstall
753
+
754
+ FLAGS
755
+ -h, --help Show CLI help.
756
+ -v, --verbose
757
+
758
+ DESCRIPTION
759
+ Removes a plugin from the CLI.
760
+
761
+ ALIASES
762
+ $ springmicro plugins unlink
763
+ $ springmicro plugins remove
764
+
765
+ EXAMPLES
766
+ $ springmicro plugins unlink myplugin
767
+ ```
768
+
769
+ ## `springmicro plugins update`
770
+
771
+ Update installed plugins.
772
+
773
+ ```
774
+ USAGE
775
+ $ springmicro plugins update [-h] [-v]
776
+
777
+ FLAGS
778
+ -h, --help Show CLI help.
779
+ -v, --verbose
780
+
781
+ DESCRIPTION
782
+ Update installed plugins.
783
+ ```
784
+
785
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.3/src/commands/plugins/update.ts)_
786
+
787
+ <!-- commandsstop -->
788
+
789
+ - [`springmicro help [COMMAND]`](#springmicro-help-command)
790
+ - [`springmicro init PROJECTTYPE`](#springmicro-init-projecttype)
791
+ - [`springmicro init astro`](#springmicro-init-astro)
792
+ - [`springmicro plugins`](#springmicro-plugins)
793
+ - [`springmicro plugins add PLUGIN`](#springmicro-plugins-add-plugin)
794
+ - [`springmicro plugins:inspect PLUGIN...`](#springmicro-pluginsinspect-plugin)
795
+ - [`springmicro plugins install PLUGIN`](#springmicro-plugins-install-plugin)
796
+ - [`springmicro plugins link PATH`](#springmicro-plugins-link-path)
797
+ - [`springmicro plugins remove [PLUGIN]`](#springmicro-plugins-remove-plugin)
798
+ - [`springmicro plugins reset`](#springmicro-plugins-reset)
799
+ - [`springmicro plugins uninstall [PLUGIN]`](#springmicro-plugins-uninstall-plugin)
800
+ - [`springmicro plugins unlink [PLUGIN]`](#springmicro-plugins-unlink-plugin)
801
+ - [`springmicro plugins update`](#springmicro-plugins-update)
802
+
803
+ ## `springmicro help [COMMAND]`
804
+
805
+ Display help for springmicro.
806
+
807
+ ```
808
+ USAGE
809
+ $ springmicro help [COMMAND...] [-n]
810
+
811
+ ARGUMENTS
812
+ COMMAND... Command to show help for.
813
+
814
+ FLAGS
815
+ -n, --nested-commands Include all nested commands in the output.
816
+
817
+ DESCRIPTION
818
+ Display help for springmicro.
819
+ ```
820
+
821
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.0/src/commands/help.ts)_
822
+
823
+ ## `springmicro init PROJECTTYPE`
824
+
825
+ Initialize a JavaScript framework project according to SpringMicroHost's specifications.
826
+
827
+ ```
828
+ USAGE
829
+ $ springmicro init PROJECTTYPE -n <value>
830
+
831
+ ARGUMENTS
832
+ PROJECTTYPE Project type (astro)
833
+
834
+ FLAGS
835
+ -n, --name=<value> (required) Project name
836
+
837
+ DESCRIPTION
838
+ Initialize a JavaScript framework project according to SpringMicroHost's specifications.
839
+
840
+ EXAMPLES
841
+ $ springmicro init astro -n example
842
+ ```
843
+
491
844
  _See code: [src/commands/init/index.ts](https://github.com/SpringMicro1/springmicrohost-js/blob/v0.1.0/src/commands/init/index.ts)_
492
845
 
493
846
  ## `springmicro init astro`
@@ -1166,4 +1519,15 @@ DESCRIPTION
1166
1519
 
1167
1520
  _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.3/src/commands/plugins/update.ts)_
1168
1521
 
1169
- <!-- commandsstop -->
1522
+ <!-- commandsstop -->
1523
+
1524
+ # Development
1525
+
1526
+ See [https://oclif.io/docs/templates](https://oclif.io/docs/templates) for details about running the CLI in development.
1527
+
1528
+ The generated CLI project contains 4 bin scripts that you can use for either production or development.
1529
+
1530
+ - `bin/run.js` - Run the CLI in production (macOS and Linux)
1531
+ - `bin/dev.js` - Run the CLI in development (macOS and Linux)
1532
+ - `bin/run.cmd` - Run the CLI in production (Windows)
1533
+ - `bin/dev.cmd` - Run the CLI in development (Windows)
@@ -12,5 +12,6 @@ export default class Astro extends Command {
12
12
  */
13
13
  astroCreate(args: Record<string, string>, flags: Record<string, string>): Promise<void>;
14
14
  astroFileManip(args: Record<string, string>, flags: Record<string, string>): void;
15
+ finished(args: Record<string, string>, flags: Record<string, string>): void;
15
16
  run(): Promise<void>;
16
17
  }
@@ -1,11 +1,10 @@
1
1
  import { Command, Flags } from '@oclif/core';
2
- import { spawn } from 'node:child_process';
3
2
  import fs from 'node:fs';
4
3
  import path from 'node:path';
5
4
  import { tailwindConfigMjs, globalsCSS, libUtils, componentsJSON } from '../../data/astro/index.js';
6
5
  import chalk from 'chalk';
7
6
  import { logStep } from '../../log/index.js';
8
- import os from 'os';
7
+ import { checkUnixShellAndSpawn } from '../../utils/shell.js';
9
8
  export default class Astro extends Command {
10
9
  static step = 1;
11
10
  static totalSteps = 2;
@@ -26,25 +25,12 @@ export default class Astro extends Command {
26
25
  this.log(chalk.red('Filesystem already exists at ' + chalk.bold(name) + ', exiting...'));
27
26
  this.exit(1);
28
27
  }
29
- logStep('Initializing Astro project...', Astro.step, Astro.totalSteps);
30
- const isWindows = os.platform() === 'win32';
31
- const astroCmd = isWindows
32
- ? `./${path.join('scripts', 'astro.bat')} ${name}`
33
- : `sh ${path.join('scripts', 'astro.sh')} ${name}`;
34
- const astroPS = spawn(astroCmd, {
35
- stdio: 'inherit', // This ensures the child process's stdio is piped directly to the parent process's stdio
36
- });
37
- astroPS.on('close', (code) => {
38
- console.log(`child process close all stdio with code ${code}`);
39
- this.astroFileManip(args, flags);
40
- });
41
- astroPS.on('exit', (code) => {
42
- console.log(`child process exited with code ${code}`);
43
- });
28
+ Astro.step = logStep('Initializing Astro project...', Astro.step, Astro.totalSteps);
29
+ await checkUnixShellAndSpawn('sh', [path.posix.join('dist', 'scripts', 'astro.sh'), name], path.join('dist', 'scripts', 'astro.bat'), [name], () => this.astroFileManip(args, flags));
44
30
  }
45
31
  astroFileManip(args, flags) {
46
32
  const { name } = flags;
47
- logStep('Manipulating project files.', Astro.step, Astro.totalSteps);
33
+ Astro.step = logStep('Manipulating project files.', Astro.step, Astro.totalSteps);
48
34
  const componentsJSONFilePath = path.join(name, 'components.json');
49
35
  const tsConfigFilePath = path.join(name, 'tsconfig.json');
50
36
  const tailwindConfigFilePath = path.join(name, 'tailwind.config.mjs');
@@ -82,9 +68,18 @@ export default class Astro extends Command {
82
68
  recursive: true,
83
69
  });
84
70
  }
71
+ finished(args, flags) {
72
+ const { name } = flags;
73
+ this.log('');
74
+ this.log(chalk.bgCyan.black('FINISHED!'));
75
+ this.log('');
76
+ this.log(`cd ${name}`);
77
+ this.log(`pnpm run dev`);
78
+ }
85
79
  async run() {
86
80
  const { args, flags } = await this.parse(Astro);
87
81
  // const {name} = flags;
88
82
  await this.astroCreate(args, flags);
83
+ this.finished(args, flags);
89
84
  }
90
85
  }
@@ -1 +1 @@
1
- export declare function logStep(msg: string, step: number, totalSteps?: number): void;
1
+ export declare function logStep(msg: string, step: number, totalSteps?: number): number;
package/dist/log/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import chalk from 'chalk';
2
2
  export function logStep(msg, step, totalSteps = 0) {
3
3
  const stepDisplay = totalSteps > 0 ? `(${step}/${totalSteps})` : `(${step})`;
4
- console.log(chalk.bgCyan.black.bold(stepDisplay) + ' ' + chalk.cyan.bold(msg));
4
+ console.log('\n' + chalk.bgCyan.black.bold(stepDisplay) + ' ' + chalk.cyan.bold(msg));
5
5
  step += 1;
6
+ return step;
6
7
  }
@@ -0,0 +1 @@
1
+ export declare function checkUnixShellAndSpawn(unixCmd: string, unixArgs: string[], windowsCmd: string, windowsArgs: string[], callback?: Function | null): Promise<void>;
@@ -0,0 +1,20 @@
1
+ import { exec, spawn } from 'node:child_process';
2
+ export async function checkUnixShellAndSpawn(unixCmd, unixArgs, windowsCmd, windowsArgs, callback = null) {
3
+ exec('sh -c "echo $SHELL"', (error, stdout, stderr) => {
4
+ const isWindows = !!error;
5
+ const cmd = isWindows ? windowsCmd : unixCmd;
6
+ const args = isWindows ? windowsArgs : unixArgs;
7
+ const ps = spawn(cmd, args, {
8
+ stdio: 'inherit', // This ensures the child process's stdio is piped directly to the parent process's stdio
9
+ });
10
+ ps.on('close', (code) => {
11
+ console.log(`child process close all stdio with code ${code}`);
12
+ if (callback) {
13
+ callback();
14
+ }
15
+ });
16
+ ps.on('exit', (code) => {
17
+ console.log(`child process exited with code ${code}`);
18
+ });
19
+ });
20
+ }
@@ -77,5 +77,5 @@
77
77
  ]
78
78
  }
79
79
  },
80
- "version": "0.1.4"
80
+ "version": "0.1.6"
81
81
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@springmicro/cli",
3
3
  "description": "A new CLI generated with oclif",
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
5
5
  "author": "David Buckley",
6
6
  "private": false,
7
7
  "publishConfig": {
@@ -76,5 +76,5 @@
76
76
  "version": "oclif readme && git add README.md"
77
77
  },
78
78
  "types": "dist/index.d.ts",
79
- "gitHead": "e5d6158a967da3d0df7ed29fc1d06755ffa240b8"
79
+ "gitHead": "5b3b9598d14078814db999b63a68e7cffaecfdf2"
80
80
  }