File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
packages/cli/src/commands Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @graphprotocol/graph-cli ' : minor
3
+ ---
4
+
5
+ add ` graph clean ` command to delete generated artifacts
Original file line number Diff line number Diff line change
1
+ import { Command , Flags } from '@oclif/core' ;
2
+ import { print , filesystem } from 'gluegun' ;
3
+
4
+ export default class CleanCommand extends Command {
5
+ static description = 'Clean the cache and generated files.' ;
6
+
7
+ static flags = {
8
+ help : Flags . help ( {
9
+ char : 'h' ,
10
+ } ) ,
11
+ 'codegen-dir' : Flags . directory ( {
12
+ summary : 'Directory where the "graph codegen" code is stored.' ,
13
+ default : 'generated/' ,
14
+ } ) ,
15
+ 'build-dir' : Flags . directory ( {
16
+ summary : 'Directory where the "graph build" code is stored.' ,
17
+ default : 'build/' ,
18
+ } ) ,
19
+ } ;
20
+
21
+ async run ( ) {
22
+ const {
23
+ flags : { 'codegen-dir' : codegenDir , 'build-dir' : buildDir } ,
24
+ } = await this . parse ( CleanCommand ) ;
25
+ const spinner = print . spin ( `Cleaning cache and generated files` ) ;
26
+
27
+ spinner . start ( ) ;
28
+ try {
29
+ await filesystem . removeAsync ( codegenDir ) ;
30
+ await filesystem . removeAsync ( buildDir ) ;
31
+ spinner . succeed ( ) ;
32
+ print . success ( 'Cache and generated files cleaned' ) ;
33
+ } catch ( e ) {
34
+ spinner . fail ( 'Failed to clean cache and generated files' ) ;
35
+ } finally {
36
+ spinner . stop ( ) ;
37
+ }
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments