[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,93 +2,203 @@
|
||||
id: wiki-2026-0508-scripts
|
||||
title: Scripts
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-SCRI-001]
|
||||
aliases: [npm scripts, package.json scripts, Build Scripts]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [auto-reinforced, scripts, automation, Efficiency, programming, productivity-tools]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [npm, build, automation, package-json]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: TypeScript
|
||||
framework: Node.js + npm
|
||||
---
|
||||
|
||||
# [[Scripts|Scripts]]
|
||||
# Scripts
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "단순 반복의 해방군: 인간이 수동으로 수백 번 해야 할 일들을 단 한 줄의 명령어로 자동 실행하게 만드는 지능형 명령어 세트이자, 실무자의 귀중한 시간을 '고차원 사고'에만 쓸 수 있게 환경을 정비하는 조용하지만 강력한 도구."
|
||||
## 매 한 줄
|
||||
> **"매 scripts는 package.json 의 entry point 인 명령어 alias"**. `npm run <name>` 으로 실행되며, dev/build/test/lint/deploy 등의 lifecycle automation 을 정의. 2026 기준 npm/pnpm/bun/yarn 호환, 매 monorepo 에서는 turbo/nx 가 orchestration.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
스크립트(Scripts)는 특정한 작업을 자동화하기 위해 작성된 짧은 프로그램이나 명령어의 나열입니다.
|
||||
## 매 핵심
|
||||
|
||||
1. **가치**:
|
||||
* **Automation**: 파일 정리, 데이터 수집, 배포 등 반복 작업 대체. (Efficiency와 연결)
|
||||
* **Reproducibility**: 누가 실행해도 동일한 절차로 작업 수행. (Standard-Operating-Procedure와 연결)
|
||||
* **Customization**: 기성 툴이 해결하지 못하는 아주 세세한 요구 정밀 해결.
|
||||
2. **언어 사례**:
|
||||
* Python (데이터 처리), Bash (시스템 제어), [[JavaScript|JavaScript]] (웹 자동화).
|
||||
3. **왜 중요한가?**:
|
||||
* 스크립팅 능력은 지능 시스템의 '손과 발'이 되어, 머릿속 상상을 현실의 결과물로 빠르게 전이시키기 때문임 (Rapid [[Prototyping|Prototyping]]의 핵심).
|
||||
### 매 lifecycle
|
||||
- **pre/post**: `prebuild` → `build` → `postbuild` 자동 실행
|
||||
- **special names**: `start`, `test`, `install`, `prepare`
|
||||
- **arbitrary**: 매 다른 이름 은 `npm run <name>`
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거에는 개발자의 전유물 정책이었으나, 현대 정책은 AI에게 자연어로 시키면 즉석에서 스크립트 정책을 짜주는 'AI 생성 스크립트 정책' 시대로 진화함(RL Update).
|
||||
- **정책 변화(RL Update)**: 본 시스템인 Antigravity 또한 보이지 않는 곳에서 수많은 `write_to_file`과 `run_command` 스크립트 정책을 동적으로 생성하여 600개 지식 주입 배치 정책을 완수 중임.
|
||||
### 매 cross-platform
|
||||
- `cross-env`, `rimraf`, `mkdirp` 등으로 OS 차이 흡수
|
||||
- 매 modern 대안: zx, execa, tsx-based scripts
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Efficiency|Efficiency]], [[Standard-Operating-Procedure|Standard-Operating-Procedure]], [[Prototyping|Prototyping]], Engineering, [[Technical-Architecture|Technical-Architecture]]
|
||||
- **Modern Tech/Tools**: Python, Bash, Node.js, PowerShell, AutoHotkey.
|
||||
---
|
||||
### 매 응용
|
||||
1. Local dev: `dev`, `build`, `test`, `lint`.
|
||||
2. CI: `ci:test`, `ci:build`, `ci:deploy`.
|
||||
3. Tooling: `typecheck`, `format`, `analyze`.
|
||||
4. Release: `release`, `publish:dry`.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
## 💻 패턴
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
### Modern package.json scripts
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "next dev --turbo",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "biome check .",
|
||||
"lint:fix": "biome check --write .",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest",
|
||||
"test:e2e": "playwright test",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"format": "biome format --write .",
|
||||
"clean": "rimraf .next dist coverage",
|
||||
"prepare": "husky",
|
||||
"release": "changeset publish"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Pre/post hooks
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"prebuild": "npm run typecheck && npm run lint",
|
||||
"build": "tsc -p tsconfig.build.json",
|
||||
"postbuild": "node scripts/copy-assets.mjs"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Composing with `npm-run-all` or `concurrently`
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "concurrently -n web,api -c blue,green \"npm:dev:web\" \"npm:dev:api\"",
|
||||
"dev:web": "next dev",
|
||||
"dev:api": "tsx watch server/index.ts",
|
||||
"verify": "run-p typecheck lint test"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### TypeScript script with tsx
|
||||
```typescript
|
||||
// scripts/seed.ts
|
||||
import { db } from "../src/lib/db";
|
||||
import { users } from "../src/lib/db/schema";
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
await db.insert(users).values([
|
||||
{ email: "alice@example.com" },
|
||||
{ email: "bob@example.com" },
|
||||
]);
|
||||
console.log("매 seed complete");
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
```json
|
||||
{ "scripts": { "db:seed": "tsx scripts/seed.ts" } }
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### zx automation
|
||||
```javascript
|
||||
#!/usr/bin/env zx
|
||||
import "zx/globals";
|
||||
|
||||
const branches = (await $`git branch --merged main`).stdout
|
||||
.split("\n")
|
||||
.map((b) => b.trim())
|
||||
.filter((b) => b && !b.startsWith("*") && b !== "main");
|
||||
|
||||
for (const b of branches) {
|
||||
await $`git branch -d ${b}`;
|
||||
}
|
||||
echo`매 deleted ${branches.length} merged branches`;
|
||||
```
|
||||
|
||||
### Cross-platform env
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"build:prod": "cross-env NODE_ENV=production webpack",
|
||||
"test:debug": "cross-env DEBUG=app:* vitest"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Monorepo with pnpm + turbo
|
||||
```json
|
||||
// root package.json
|
||||
{
|
||||
"scripts": {
|
||||
"build": "turbo run build",
|
||||
"dev": "turbo run dev --parallel",
|
||||
"test": "turbo run test --filter=...[origin/main]"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Bun-native scripts (faster startup)
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "bun --hot src/index.ts",
|
||||
"test": "bun test",
|
||||
"build": "bun build src/index.ts --outdir dist --target node"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### CI matrix script
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"ci:lint": "biome ci .",
|
||||
"ci:typecheck": "tsc --noEmit",
|
||||
"ci:test": "vitest run --coverage --reporter=verbose",
|
||||
"ci:build": "next build",
|
||||
"ci": "run-s ci:lint ci:typecheck ci:test ci:build"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| 매 simple alias | npm script directly |
|
||||
| 매 multi-step orchestration | npm-run-all / concurrently |
|
||||
| Complex shell scripting | zx / bash file |
|
||||
| TS logic | tsx / bun + TS file |
|
||||
| Monorepo | turbo / nx |
|
||||
|
||||
**기본값**: npm scripts + tsx for TS + concurrently for parallel. 매 monorepo 면 turbo.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Node.js]] · [[npm]] · [[Build Tools]]
|
||||
- 변형: [[Make]] · [[Just]] · [[Task]] · [[Turbo]] · [[Nx]]
|
||||
- 응용: [[CI/CD Pipelines]] · [[Husky Git Hooks]]
|
||||
- Adjacent: [[zx]] · [[tsx]] · [[bun]] · [[concurrently]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: package.json 의 standard automation, dev/build/test/lint pipeline.
|
||||
**언제 X**: 매 100+ lines of bash logic — 매 standalone script file 로 추출.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Inline complex shell**: `&& if [[ ... ]]; then ... fi` in JSON → 매 unreadable. zx / bash file.
|
||||
- **No clean script**: 매 stale build artifact debug 어려움. `clean` 필수.
|
||||
- **OS-specific commands**: `rm -rf` Windows 실패 → cross-platform 도구.
|
||||
- **Hidden side effects in postinstall**: 매 supply-chain risk. 신중.
|
||||
- **Duplicate scripts across packages**: 매 monorepo 면 turbo / shared config.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (npm docs, package.json spec).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — npm scripts full content |
|
||||
|
||||
Reference in New Issue
Block a user