tylersong 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/plans/-----------8c733d2f.plan.md +158 -0
- package/.editorconfig +15 -0
- package/.eslintrc.json +33 -0
- package/.github/workflows/ci.yml +59 -25
- package/.github/workflows/deploy.yml +7 -13
- package/.github/workflows/publish.yml +30 -297
- package/.prettierrc +13 -0
- package/README.md +133 -45
- package/dist/index.js +61 -23
- package/dist/index.js.map +1 -1
- package/docs/auto-deployment.md +191 -0
- package/docs/deployment.md +82 -0
- package/docs/development.md +394 -0
- package/docs/direct-deployment.md +116 -0
- package/docs/discord-setup.md +158 -0
- package/docs/github-actions-fixes.md +142 -0
- package/docs/improvements.md +287 -0
- package/docs/pipeline.md +228 -0
- package/docs/testing.md +173 -0
- package/docs/usage.md +112 -0
- package/docs/workflows.md +176 -0
- package/package.json +16 -3
- package/src/index.ts +77 -32
- package/test/index.test.ts +167 -0
- package/tsconfig.eslint.json +9 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +22 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { exec } from "child_process";
|
|
3
|
+
|
|
4
|
+
// exec 모킹
|
|
5
|
+
vi.mock("child_process", () => ({
|
|
6
|
+
exec: vi.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
// chalk 모킹
|
|
10
|
+
vi.mock("chalk", () => ({
|
|
11
|
+
default: {
|
|
12
|
+
yellow: vi.fn((str: string) => str),
|
|
13
|
+
cyan: vi.fn((str: string) => str),
|
|
14
|
+
bold: {
|
|
15
|
+
cyan: vi.fn((str: string) => str),
|
|
16
|
+
yellow: vi.fn((str: string) => str),
|
|
17
|
+
},
|
|
18
|
+
green: vi.fn((str: string) => str),
|
|
19
|
+
hex: vi.fn(() => vi.fn((str: string) => str)),
|
|
20
|
+
blue: vi.fn((str: string) => str),
|
|
21
|
+
magenta: vi.fn((str: string) => str),
|
|
22
|
+
red: vi.fn((str: string) => str),
|
|
23
|
+
underline: {
|
|
24
|
+
whiteBright: vi.fn((str: string) => str),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
// inquirer 모킹
|
|
30
|
+
vi.mock("inquirer", () => ({
|
|
31
|
+
default: {
|
|
32
|
+
prompt: vi.fn(),
|
|
33
|
+
},
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
// commander 모킹
|
|
37
|
+
vi.mock("commander", () => ({
|
|
38
|
+
program: {
|
|
39
|
+
version: vi.fn().mockReturnThis(),
|
|
40
|
+
option: vi.fn().mockReturnThis(),
|
|
41
|
+
parse: vi.fn().mockReturnThis(),
|
|
42
|
+
opts: vi.fn().mockReturnValue({}),
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
describe("CLI 도구 테스트", () => {
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
vi.clearAllMocks();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
afterEach(() => {
|
|
52
|
+
vi.restoreAllMocks();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("openUrl 함수", () => {
|
|
56
|
+
it("macOS에서 올바른 명령어를 사용해야 함", () => {
|
|
57
|
+
const mockExec = vi.mocked(exec);
|
|
58
|
+
const platform = process.platform;
|
|
59
|
+
|
|
60
|
+
if (platform === "darwin") {
|
|
61
|
+
// macOS에서는 'open' 명령어를 사용
|
|
62
|
+
expect(mockExec).toBeDefined();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("URL을 여는 명령어가 실행되어야 함", () => {
|
|
67
|
+
const mockExec = vi.mocked(exec);
|
|
68
|
+
expect(mockExec).toBeDefined();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe("CLI 옵션 테스트", () => {
|
|
73
|
+
it("--version 옵션이 정의되어 있어야 함", async () => {
|
|
74
|
+
// commander가 버전을 설정하는지 확인
|
|
75
|
+
const { program } = await import("commander");
|
|
76
|
+
expect(typeof program.version).toBe("function");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("--github 옵션이 정의되어 있어야 함", async () => {
|
|
80
|
+
const { program } = await import("commander");
|
|
81
|
+
expect(typeof program.option).toBe("function");
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe("사용자 인터페이스 테스트", () => {
|
|
86
|
+
it("inquirer prompt가 올바르게 정의되어 있어야 함", async () => {
|
|
87
|
+
const inquirer = (await import("inquirer")).default;
|
|
88
|
+
expect(inquirer.prompt).toBeDefined();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("타입 정의 테스트", () => {
|
|
93
|
+
it("ProgramOptions 인터페이스가 올바른 타입을 가져야 함", () => {
|
|
94
|
+
interface ProgramOptions {
|
|
95
|
+
github?: boolean;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const testOptions: ProgramOptions = {
|
|
99
|
+
github: true,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
expect(testOptions.github).toBe(true);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("UserAnswer 인터페이스가 올바른 타입을 가져야 함", () => {
|
|
106
|
+
interface UserAnswer {
|
|
107
|
+
showInfo: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const testAnswer: UserAnswer = {
|
|
111
|
+
showInfo: true,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
expect(testAnswer.showInfo).toBe(true);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe("플랫폼별 명령어 테스트", () => {
|
|
119
|
+
it("Windows에서는 start 명령어를 사용해야 함", () => {
|
|
120
|
+
const getCommand = (platform: string): string => {
|
|
121
|
+
return platform === "win32"
|
|
122
|
+
? "start"
|
|
123
|
+
: platform === "darwin"
|
|
124
|
+
? "open"
|
|
125
|
+
: "xdg-open";
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
expect(getCommand("win32")).toBe("start");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("macOS에서는 open 명령어를 사용해야 함", () => {
|
|
132
|
+
const getCommand = (platform: string): string => {
|
|
133
|
+
return platform === "win32"
|
|
134
|
+
? "start"
|
|
135
|
+
: platform === "darwin"
|
|
136
|
+
? "open"
|
|
137
|
+
: "xdg-open";
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
expect(getCommand("darwin")).toBe("open");
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("Linux에서는 xdg-open 명령어를 사용해야 함", () => {
|
|
144
|
+
const getCommand = (platform: string): string => {
|
|
145
|
+
return platform === "win32"
|
|
146
|
+
? "start"
|
|
147
|
+
: platform === "darwin"
|
|
148
|
+
? "open"
|
|
149
|
+
: "xdg-open";
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
expect(getCommand("linux")).toBe("xdg-open");
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe("URL 검증 테스트", () => {
|
|
157
|
+
it("GitHub URL이 올바른 형식이어야 함", () => {
|
|
158
|
+
const githubUrl = "https://github.com/alstjd0051";
|
|
159
|
+
expect(githubUrl).toMatch(/^https:\/\/github\.com\/[\w-]+$/);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("이메일 주소가 올바른 형식이어야 함", () => {
|
|
163
|
+
const email = "wsc7202@gmail.com";
|
|
164
|
+
expect(email).toMatch(/^[\w.-]+@[\w.-]+\.\w+$/);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
package/tsconfig.json
CHANGED
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true,
|
|
6
|
+
environment: 'node',
|
|
7
|
+
coverage: {
|
|
8
|
+
provider: 'v8',
|
|
9
|
+
reporter: ['text', 'json', 'html'],
|
|
10
|
+
exclude: [
|
|
11
|
+
'node_modules/**',
|
|
12
|
+
'dist/**',
|
|
13
|
+
'test/**',
|
|
14
|
+
'**/*.config.*',
|
|
15
|
+
'**/*.d.ts',
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
include: ['test/**/*.test.ts'],
|
|
19
|
+
exclude: ['node_modules', 'dist'],
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|