Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Refactoring serve directory #6

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { serveCommands } from "./index.js";
import { installServeCommands } from "./index.js";
import { LocalProxy } from "../proxy/local-proxy.js";
import path from "path";
import { Command } from "commander";
import { serveAction } from "./serveAction.js";
import { serveAction } from "../serveAction.js";

vi.mock("./serveAction");
vi.mock("../serveAction.js");

describe("serveCommand", () => {
afterEach(() => {
Expand All @@ -30,7 +30,7 @@ describe("serveCommand", () => {
port: "9001",
});

const command = serveCommands(program);
const command = installServeCommands(program);
await command.parseAsync([
"_",
"serve",
Expand Down
4 changes: 2 additions & 2 deletions src/serve/index.ts → src/serve/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Command } from "commander";
import { LocalProxy } from "../proxy/local-proxy.js";
import path from "path";
import { serveAction } from "./serveAction.js";
import { serveAction } from "../serveAction.js";

export const serveCommands = (program: Command) => {
export const installServeCommands = (program: Command) => {
const serve = program.command("serve");
serve
.description("Manage HTTPS dev server")
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/serve/serveAction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { LiffApiClient } from "../api/liff.js";
import { resolveChannel } from "../channel/resolveChannel.js";
import { spawn } from "node:child_process";
import { LocalProxy } from "../proxy/local-proxy.js";
import { LocalProxy } from "./proxy/local-proxy.js";
import path from "path";
import { serveAction } from "./serveAction.js";

Expand Down
4 changes: 2 additions & 2 deletions src/serve/serveAction.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { spawn } from "child_process";
import { spawn } from "node:child_process";
import { LiffApiClient } from "../api/liff.js";
import { resolveChannel } from "../channel/resolveChannel.js";
import { getCurrentChannelId } from "../channel/stores/channels.js";
import { LocalProxy } from "../proxy/local-proxy.js";
import { LocalProxy } from "./proxy/local-proxy.js";
import resolveEndpointUrl from "./resolveEndpointUrl.js";
import pc from "picocolors";

Expand Down
4 changes: 2 additions & 2 deletions src/setup.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Command } from "commander";
import { installChannelCommands } from "./channel/commands/index.js";
import { installAppCommands } from "./app/commands/index.js";
import { serveCommands } from "./serve/index.js";
import { installServeCommands } from "./serve/commands/index.js";

export const setupCLI = (program: Command) => {
installChannelCommands(program);
installAppCommands(program);
serveCommands(program);
installServeCommands(program);
// TODO .version?
return {
run: (argv = process.argv) => {
Expand Down