Skip to content

Commit

Permalink
Merge pull request #93 from sellersindustry/49-cli-clean-command
Browse files Browse the repository at this point in the history
Added Clean Command
  • Loading branch information
SellersEvan authored Apr 22, 2024
2 parents 47a363d + fc55c50 commit 51bc5bb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ sherpa [options] [command]

#### Commands:
- `build [options]` Build SherpaJS Server
- `clean [options]` Remove SherpaJS Build Directories
- `help [command]` display help for command


Expand All @@ -104,6 +105,21 @@ sherpa build [options]
- `-h`, `--help` display help for command



<br>


### Clean Command
Remove SherpaJS Build Directories.
```bash
sherpa clean [options]
```

#### Options:
- `-i`, `--input <path>` path to SherpaJS build directories, defaults to current directory
- `-h`, `--help` display help for command


<br>
<br>

Expand Down
8 changes: 8 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ CLI.command("build")
});


CLI.command("clean")
.description("Remove SherpaJS Build Directories")
.option("-i, --input <path>", "path to SherpaJS build directories, defaults to current directory")
.action((options) => {
Compiler.clean(getAbsolutePath(options.input, process.cwd()));
});


CLI.parse();


Expand Down
8 changes: 8 additions & 0 deletions src/compiler/bundler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,13 @@ export function NewBundler(endpoints:EndpointStructure, options:BuildOptions, er
}


export function clean(filepath:string) {
let endpoints = { list: [], tree: {} };
let options = { bundler: BundlerType.local, input: filepath, output: filepath };
new Vercel(endpoints, options).clean();
new Local(endpoints, options).clean();
}


// A cheerful heart is good medicine, but a crushed spirit dries up the bones.
// - Proverbs 17:22
7 changes: 6 additions & 1 deletion src/compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import fs from "fs";
import { green, red } from "colorette";
import { getStructure } from "./structure/index.js";
import { Logger } from "./utilities/logger/index.js";
import { NewBundler } from "./bundler/index.js";
import { NewBundler, clean } from "./bundler/index.js";
import { BuildOptions, BundlerType } from "./models.js";
import { Level, Message } from "./utilities/logger/model.js";
import { Path } from "./utilities/path/index.js";
Expand Down Expand Up @@ -56,6 +56,11 @@ export class Compiler {
}


public static clean(filepath:string) {
clean(filepath);
}


private static validateBuildOptions(options:BuildOptions):Message[] {
let errors:Message[] = [];
errors.push(...this.validateFilepath(options.input, "Input"));
Expand Down

0 comments on commit 51bc5bb

Please sign in to comment.