dwkim 0.0.15 → 0.0.17

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.
@@ -0,0 +1,8 @@
1
+ # Changesets
2
+
3
+ Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4
+ with multi-package repos, or single-package repos to help you version and publish your code. You can
5
+ find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6
+
7
+ We have a quick list of common questions to get you started engaging with this project in
8
+ [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3
+ "changelog": "@changesets/cli/changelog",
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "public",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": []
11
+ }
@@ -0,0 +1,21 @@
1
+ name: CI - lint & build
2
+ on:
3
+ push:
4
+ branches:
5
+ - '**'
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+ - uses: pnpm/action-setup@v2
13
+ with:
14
+ version: 9
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: 20
18
+ cache: 'pnpm'
19
+
20
+ - run: pnpm install --frozen-lockfile
21
+ - run: pnpm run lint && pnpm run build
@@ -0,0 +1,36 @@
1
+ name: Publish
2
+ on:
3
+ workflow_run:
4
+ workflows: [CI - lint & build]
5
+ branches: [main]
6
+ types: [completed]
7
+
8
+ concurrency: ${{ github.workflow }}-${{ github.ref }}
9
+
10
+ permissions:
11
+ contents: write
12
+ pull-requests: write
13
+
14
+ jobs:
15
+ publish:
16
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - uses: pnpm/action-setup@v2
21
+ with:
22
+ version: 9
23
+ - uses: actions/setup-node@v3
24
+ with:
25
+ node-version: 20.x
26
+ cache: 'pnpm'
27
+
28
+ - run: pnpm install --frozen-lockfile
29
+ - name: Create Release Pull Request or Publish
30
+ id: changesets
31
+ uses: changesets/action@v1
32
+ with:
33
+ publish: pnpm publish --no-git-checks
34
+ env:
35
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # dwkim
2
+
3
+ ## 0.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - e433534: docs: README.md 및 .changeset/config.json 업데이트
8
+
9
+ ## 0.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 1cf9909: chore: @changesets/cli 추가
14
+ - 1cf9909: chore: tsx 및 dev 스크립트 추가
package/README.md ADDED
@@ -0,0 +1,257 @@
1
+ # NPM 패키지 배포 가이드
2
+
3
+ 이 문서는 [Blazing Fast Tips: Publishing to NPM](https://youtu.be/eh89VE3Mk5g?si=oXgStRKeVp8GBl7c) 영상의 최신 TypeScript 라이브러리 개발 및 NPM 배포 워크플로우를 실습 중심으로 정리한 것입니다.
4
+
5
+ ## TL;DR
6
+
7
+ 빠른 NPM 패키지 배포를 위한 주요 커맨드 요약:
8
+
9
+ - 프로젝트 초기화:
10
+ `npm init -y`
11
+ - Git 초기화:
12
+ `git init`
13
+ - TypeScript 설정:
14
+ `pnpm add -D typescript`
15
+ `pnpm exec tsc --init`
16
+
17
+ - 빌드 도구(tsup) 설치:
18
+ `pnpm add -D tsup`
19
+ - 빌드:
20
+ `pnpm run build`
21
+ - 타입 검사:
22
+ `pnpm run lint`
23
+ - Changesets 설치/초기화:
24
+ `pnpm add -D @changesets/cli`
25
+ `pnpm exec changeset init`
26
+ - 변경점 기록:
27
+ `pnpm exec changeset`
28
+ - NPM 배포(수동):
29
+ `pnpm publish`
30
+
31
+ ---
32
+
33
+ ## 1. 프로젝트 초기화
34
+
35
+ ```bash
36
+ npm init # 또는 npm init -y (기본값 자동입력)
37
+ ```
38
+
39
+ - `package.json`에서 `"name"`, `"license"` 등 기본 정보 지정
40
+ - 예시
41
+ ```json
42
+ {
43
+ "name": "dwkim",
44
+ "version": "0.0.1",
45
+ "description": "this",
46
+ "license": "MIT",
47
+ "author": "dannyworks102@gmail.com",
48
+ "type": "commonjs",
49
+ "main": "src/index.ts"
50
+ }
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 2. Git 초기화 및 .gitignore 작성
56
+
57
+ ```bash
58
+ git init
59
+ ```
60
+
61
+ - `.gitignore` 파일 생성:
62
+
63
+ ```
64
+ node_modules
65
+ dist
66
+ ```
67
+
68
+ ---
69
+
70
+ ## 3. TypeScript 설치 및 설정
71
+
72
+ ```bash
73
+ pnpm add -D typescript
74
+ pnpm exec tsc --init
75
+ ```
76
+
77
+ - `tsconfig.json`에 아래 옵션 추가/수정:
78
+
79
+ ```json
80
+ {
81
+ "compilerOptions": {
82
+ "noUncheckedIndexedAccess": true,
83
+ "noEmit": true
84
+ }
85
+ }
86
+ ```
87
+
88
+ ---
89
+
90
+ ## 4. 소스 코드 작성
91
+
92
+ 예시: `src/index.ts`
93
+
94
+ ```typescript
95
+ export function add(a: number, b: number): number {
96
+ return a + b;
97
+ }
98
+ ```
99
+
100
+ ---
101
+
102
+ ## 5. 빌드 도구(tsup) 설치 및 빌드 스크립트 추가
103
+
104
+ ```bash
105
+ pnpm add -D tsup
106
+ ```
107
+
108
+ - `package.json`에 빌드 스크립트 추가:
109
+
110
+ ```json
111
+ {
112
+ "scripts": {
113
+ "build": "tsup src/index.ts --format cjs,esm",
114
+ "lint": "tsc"
115
+ }
116
+ }
117
+ ```
118
+
119
+ ```bash
120
+ pnpm run build
121
+ ```
122
+
123
+ - 결과: `dist/index.js`, `dist/index.mjs`, `dist/index.d.ts` 등 생성
124
+
125
+ ---
126
+
127
+ ## 6. package.json 진입점 지정
128
+
129
+ ```json
130
+ {
131
+ "main": "dist/index.js",
132
+ "module": "dist/index.mjs",
133
+ "types": "dist/index.d.ts"
134
+ }
135
+ ```
136
+
137
+ ---
138
+
139
+ ## 7. 타입 검사
140
+
141
+ ```bash
142
+ pnpm run lint
143
+ ```
144
+
145
+ ---
146
+
147
+ ## 8. Changesets로 버전/릴리즈 노트 관리 (실무 워크플로우)
148
+
149
+ ```bash
150
+ pnpm add -D @changesets/cli
151
+ pnpm exec changeset init
152
+ ```
153
+
154
+ - `.changeset/` 폴더는 반드시 **git에 커밋**해야 합니다. (gitignore에 추가하면 안 됨)
155
+ - 변경사항이 있을 때마다 아래 명령어로 변경점(md 파일)을 기록합니다 (e.g. PR 할때마다)
156
+
157
+ ```bash
158
+ pnpm exec changeset # 변경점 기록(md 파일 생성)
159
+ ```
160
+
161
+ - 릴리즈(버전 업데이트) 준비 시 (c.f. main 브랜치에서)
162
+
163
+ ```bash
164
+ pnpm exec changeset version # package.json, CHANGELOG.md 자동 업데이트
165
+ ```
166
+
167
+ - 배포(수동) (c.f. main 브랜치에서)
168
+
169
+ ```bash
170
+ pnpm exec changeset publish
171
+ ```
172
+
173
+ > **실무 워크플로우 요약**
174
+ >
175
+ > - PR마다 `pnpm exec changeset`으로 변경점만 기록
176
+ > - main 브랜치에서 `changeset version` & `changeset publish`를 실행하거나,
177
+ > - GitHub Actions에서 자동화(merge → version/publish)하는 것이 일반적입니다.
178
+
179
+ ---
180
+
181
+ ## 9. GitHub Actions로 CI/CD 자동화
182
+
183
+ ### `.github/workflows/main.yml` (테스트/빌드)
184
+
185
+ ```yaml
186
+ name: CI
187
+ on: [push]
188
+ jobs:
189
+ build:
190
+ runs-on: ubuntu-latest
191
+ steps:
192
+ - uses: actions/checkout@v4
193
+ - uses: pnpm/action-setup@v3
194
+ with:
195
+ version: 8
196
+ - uses: actions/setup-node@v4
197
+ with:
198
+ node-version: 20
199
+ - run: pnpm install --frozen-lockfile
200
+ - run: pnpm run lint
201
+ - run: pnpm run build
202
+ ```
203
+
204
+ ### `.github/workflows/publish.yml` (배포)
205
+
206
+ ```yaml
207
+ name: Release
208
+ on:
209
+ push:
210
+ branches: [main]
211
+ jobs:
212
+ release:
213
+ runs-on: ubuntu-latest
214
+ concurrency: release
215
+ steps:
216
+ - uses: actions/checkout@v4
217
+ - uses: pnpm/action-setup@v3
218
+ with:
219
+ version: 8
220
+ - uses: actions/setup-node@v4
221
+ with:
222
+ node-version: 20
223
+ registry-url: 'https://registry.npmjs.org'
224
+ - run: pnpm install --frozen-lockfile
225
+ - run: pnpm run build
226
+ - uses: changesets/action@v1
227
+ with:
228
+ publish: pnpm publish --no-git-checks
229
+ env:
230
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
231
+ ```
232
+
233
+ - NPM_TOKEN은 GitHub 레포지토리의 Secrets에 등록 필요
234
+
235
+ ---
236
+
237
+ ## 10. NPM 배포 (자동화/수동 워크플로우)
238
+
239
+ - **자동화:**
240
+
241
+ 1. PR마다 `pnpm exec changeset`으로 변경점 기록
242
+ 2. main 브랜치 머지 → GitHub Actions가 자동으로 `changeset version` & `changeset publish` 실행
243
+ 3. NPM에 자동 배포
244
+
245
+ - **수동:**
246
+ 1. 변경점 기록 후,
247
+ 2. `pnpm exec changeset version`
248
+ 3. `pnpm exec changeset publish`
249
+
250
+ ---
251
+
252
+ ## 참고
253
+
254
+ - [예제 저장소 ↗]
255
+ - [Changesets 공식 문서 ↗]
256
+ - [tsup 공식문서 ↗]
257
+ - [pnpm 공식문서 ↗]
package/package.json CHANGED
@@ -1,43 +1,25 @@
1
1
  {
2
2
  "name": "dwkim",
3
- "version": "0.0.15",
4
- "type": "module",
5
- "author": "Dongwook Kim",
6
- "scripts": {
7
- "start": "pnpm run build && node dist/index.js",
8
- "build": "node script/build.js",
9
- "build:watch": "node script/build.js --watch",
10
- "prebuild": "rimraf ./dist",
11
- "publish": "npm publish",
12
- "publish:dev": "dotenv -e .env -- node script/private-registry.js"
13
- },
14
- "exports": {
15
- ".": "./dist/index.js"
16
- },
17
- "files": [
18
- "dist/index.js",
19
- "package.json"
20
- ],
21
- "bin": {
22
- "dwkim": "dist/index.js"
3
+ "version": "0.0.17",
4
+ "description": "this",
5
+ "license": "MIT",
6
+ "author": "dannyworks102@gmail.com",
7
+ "type": "commonjs",
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.mjs",
10
+ "types": "dist/index.d.ts",
11
+ "dependencies": {
12
+ "typescript": "^5.8.3"
23
13
  },
24
14
  "devDependencies": {
25
- "@repo/database": "workspace:*",
26
- "@repo/typescript-config": "workspace:*",
27
- "@types/node": "^20.17.10",
28
- "dotenv-cli": "^8.0.0",
29
- "esbuild": "^0.24.2",
30
- "ts-node": "^10.9.2",
31
- "tsx": "4.19.1",
32
- "typescript": "~5.6.3"
15
+ "@changesets/cli": "^2.29.4",
16
+ "tsup": "^8.5.0",
17
+ "tsx": "^4.20.3"
33
18
  },
34
- "dependencies": {
35
- "@ai-sdk/openai": "^1.1.9",
36
- "ai": "^4.1.34",
37
- "boxen": "^8.0.1",
38
- "chalk": "^5.4.1",
39
- "dotenv": "^16.4.7",
40
- "rimraf": "^5.0.5",
41
- "zod": "^3.24.1"
19
+ "scripts": {
20
+ "build": "tsup src/index.ts --format cjs,esm --dts",
21
+ "release": "pnpm run build && changeset publish",
22
+ "dev": "tsx watch src/index.ts",
23
+ "lint": "tsc"
42
24
  }
43
- }
25
+ }
package/src/index.ts ADDED
@@ -0,0 +1,14 @@
1
+ export function multiply(a: number, b: number): number {
2
+ return a * b;
3
+ }
4
+
5
+ export function identitiy<T>(arg: T): T {
6
+ return arg;
7
+ }
8
+
9
+ function main() {
10
+ console.log('multiply 1 2', multiply(1, 2));
11
+ console.log('identitiy 1', identitiy('1'));
12
+ }
13
+
14
+ main();
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+ /* Language and Environment */
5
+ "target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
6
+ "moduleDetection": "force" /* Control what method is used to detect module-format JS files. */,
7
+ "verbatimModuleSyntax": true,
8
+ "moduleResolution": "Bundler", // gonna use tsup
9
+ "module": "ESNext",
10
+
11
+ "lib": ["es2022", "dom", "dom.iterable"],
12
+
13
+ /* Modules */
14
+ "resolveJsonModule": true /* Enable importing .json files. */,
15
+
16
+ /* JavaScript Support */
17
+ "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
18
+
19
+ /* Emit */
20
+ "noEmit": true /* Disable emitting files from a compilation. */,
21
+
22
+ /* Interop Constraints */
23
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
24
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
25
+
26
+ /* Type Checking */
27
+ "strict": true /* Enable all strict type-checking options. */,
28
+
29
+ /* Completeness */
30
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
31
+ }
32
+ }