-
Notifications
You must be signed in to change notification settings - Fork 30
/
init.ts
33 lines (26 loc) · 1.31 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
import path from "node:path";
import { SwankyCommand } from "../../../lib/swankyCommand.js";
import { copyChopsticksTemplateFile, getSwankyConfig, getTemplates } from "../../../lib/index.js";
import { ConfigBuilder } from "../../../lib/config-builder.js";
import { SwankyConfig } from "../../../types/index.js";
export const chopsticksConfig = "dev.yml";
export class InitChopsticks extends SwankyCommand<typeof InitChopsticks> {
static description = "Initialize chopsticks config";
async run(): Promise<void> {
const localConfig = getSwankyConfig("local") as SwankyConfig;
const projectPath = path.resolve();
const chopsticksTemplatePath = getTemplates().chopsticksTemplatesPath;
const configPath = path.resolve(projectPath, "node", "config");
await this.spinner.runCommand(
() => copyChopsticksTemplateFile(chopsticksTemplatePath, configPath),
"Copying Chopsticks template files..."
);
await this.spinner.runCommand(async () => {
const newLocalConfig = new ConfigBuilder(localConfig)
.addChopsticks(path.resolve(projectPath, "node", "config", chopsticksConfig))
.build();
await this.storeConfig(newLocalConfig, "local");
}, "Updating Swanky configuration with Chopsticks settings...");
this.log("Chopsticks config initialized successfully");
}
}