This repository has been archived by the owner on Mar 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.ts
59 lines (50 loc) · 1.44 KB
/
init.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import BaseCommand from "../base-command";
import { createEnv } from "yeoman-environment";
import { flags } from "@oclif/command";
import cliBanner from '../core/utils/cli-banner';
export default class New extends BaseCommand {
static description =
"Create a new package to develop a custom ShipEngine app";
static aliases = ["new"];
static flags = {
force: flags.boolean({
description: "Overwrite existing files",
char: "f",
}),
yes: flags.boolean({
description:
"Skips the questions and uses the defaults (carrier|Javascript|yaml)",
char: "y",
}),
help: flags.help({
char: "h",
description: "Show help for the new command",
}),
};
static args = [
{
name: "path",
required: false,
description: "Path to new package (defaults to current directory)",
},
];
static examples = ["$ connect init"];
async run(): Promise<void> {
const { flags, args } = this.parse(New);
const env = createEnv();
env.register(require.resolve("../core/generators/apps-new"), "new");
const generatorOptions = {
path: args.path,
skipQuestions: flags.yes,
force: flags.force,
};
this.log(cliBanner());
this.log("Time to build a Connect app!");
await new Promise((resolve, reject) => {
env.run("new", generatorOptions, (err: Error | null) => {
if (err) reject(err);
else resolve("done");
});
});
}
}