create-task-ops 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -42,10 +42,26 @@ npx create-task-ops add --docs-only
42
42
  - `create`
43
43
  내부적으로 `full` 템플릿을 사용한다.
44
44
  - `add`
45
- 내부적으로 `api` 템플릿을 사용한다.
45
+ 내부적으로 `api` 수신기 파일만 선택적으로 추가한다.
46
46
  - `add --docs-only`
47
47
  내부적으로 `docs` 템플릿을 사용한다.
48
48
 
49
+ ## add가 넣는 파일
50
+
51
+ `add` 는 기존 리포를 통째로 덮어쓰지 않는다. 기본적으로 아래만 추가한다.
52
+
53
+ - `tasks/example-task.md`
54
+ - `CLAUDE.md`
55
+ - `AGENT.md`
56
+ - `docs/TASK_API_CONTRACT.md`
57
+ - `docs/DASHBOARD_CONNECTION.md`
58
+ - `app/api/health/route.ts`
59
+ - `app/api/tasks/route.ts`
60
+ - `app/api/tasks/[id]/route.ts`
61
+ - `lib/task-api.ts`
62
+
63
+ 즉 기존 `package.json`, `app/page.tsx`, `app/layout.tsx`, `tsconfig.json` 같은 루트 파일은 건드리지 않는다.
64
+
49
65
  ## 로컬 테스트
50
66
 
51
67
  ```bash
@@ -8,6 +8,12 @@ import process from "node:process";
8
8
  const args = process.argv.slice(2);
9
9
  const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
10
10
  const templatesRoot = path.join(packageRoot, "templates");
11
+ const addApiFiles = [
12
+ "app/api/health/route.ts",
13
+ "app/api/tasks/route.ts",
14
+ "app/api/tasks/[id]/route.ts",
15
+ "lib/task-api.ts",
16
+ ];
11
17
 
12
18
  function parseArgs(argv) {
13
19
  const options = {
@@ -101,6 +107,26 @@ function copyTemplateTree(sourceDir, targetDir, projectName, force) {
101
107
  }
102
108
  }
103
109
 
110
+ function copySelectedFiles(sourceDir, targetDir, projectName, force, selectedFiles) {
111
+ mkdirSync(targetDir, { recursive: true });
112
+
113
+ for (const relativeFile of selectedFiles) {
114
+ const sourcePath = path.join(sourceDir, relativeFile);
115
+ const targetPath = path.join(targetDir, relativeFile);
116
+ const targetFolder = path.dirname(targetPath);
117
+ mkdirSync(targetFolder, { recursive: true });
118
+
119
+ if (existsSync(targetPath) && !force) {
120
+ console.error(`Refusing to overwrite existing file: ${targetPath}`);
121
+ console.error("Use --force if you want to replace scaffolded files.");
122
+ process.exit(1);
123
+ }
124
+
125
+ const content = readFileSync(sourcePath, "utf8");
126
+ writeFileSync(targetPath, renderTemplate(content, projectName), "utf8");
127
+ }
128
+ }
129
+
104
130
  function main() {
105
131
  const options = parseArgs(args);
106
132
  if (options.command === "add") {
@@ -131,7 +157,12 @@ function main() {
131
157
  const modeDir = path.join(templatesRoot, options.mode);
132
158
 
133
159
  copyTemplateTree(commonDir, targetDir, projectName, options.force);
134
- copyTemplateTree(modeDir, targetDir, projectName, options.force);
160
+
161
+ if (options.command === "add" && options.mode === "api") {
162
+ copySelectedFiles(modeDir, targetDir, projectName, options.force, addApiFiles);
163
+ } else {
164
+ copyTemplateTree(modeDir, targetDir, projectName, options.force);
165
+ }
135
166
 
136
167
  console.log(`create-task-ops completed`);
137
168
  console.log(`target: ${targetDir}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-task-ops",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Next.js-first task-ops scaffold generator for task docs and task APIs",
5
5
  "license": "MIT",
6
6
  "type": "module",