@dyyz1993/create-agent 2.1.0 → 2.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyyz1993/create-agent",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Create Agent project scaffolding CLI",
5
5
  "repository": {
6
6
  "type": "git",
package/src/lib/copy.ts CHANGED
@@ -1,4 +1,12 @@
1
- import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync, unlinkSync } from "fs";
1
+ import {
2
+ readFileSync,
3
+ writeFileSync,
4
+ mkdirSync,
5
+ existsSync,
6
+ readdirSync,
7
+ unlinkSync,
8
+ chmodSync,
9
+ } from "fs";
2
10
  import { join, resolve } from "path";
3
11
  import { execSync } from "child_process";
4
12
 
@@ -266,19 +274,115 @@ export async function copyTemplate(options: CopyOptions): Promise<void> {
266
274
 
267
275
  const huskyDir = join(targetDir, ".husky");
268
276
  mkdirSync(huskyDir, { recursive: true });
269
- writeFileSync(
270
- join(huskyDir, "pre-commit"),
271
- [
272
- "#!/bin/sh",
273
- "bun run lint",
274
- 'ERRORS=$(bunx tsc --noEmit 2>&1 | grep "error TS" | grep -v "node_modules" || true)',
275
- 'if [ -n "$ERRORS" ]; then',
276
- ' echo "$ERRORS"',
277
- " exit 1",
278
- "fi",
279
- ].join("\n") + "\n"
277
+
278
+ const hook = (name: string, content: string) => {
279
+ const p = join(huskyDir, name);
280
+ writeFileSync(p, content);
281
+ chmodSync(p, 0o755);
282
+ };
283
+
284
+ hook(
285
+ "pre-commit",
286
+ `#!/bin/sh
287
+ npx lint-staged
288
+
289
+ STAGED_TS=$(git diff --cached --name-only --diff-filter=ACMR | grep -c '\\.tsx\\?$' || true)
290
+
291
+ if [ "$STAGED_TS" -gt 0 ]; then
292
+ echo "⏳ Type checking..."
293
+ bunx tsc --noEmit 2>&1 | grep "error TS" | grep -v "node_modules" && exit 1 || true
294
+ fi
295
+
296
+ echo "✅ Pre-commit checks passed"
297
+ `
298
+ );
299
+
300
+ hook(
301
+ "commit-msg",
302
+ `#!/bin/sh
303
+ npx --no -- commitlint --edit "$1"
304
+ `
305
+ );
306
+
307
+ hook(
308
+ "pre-push",
309
+ `#!/bin/sh
310
+ echo "⏳ Linting..."
311
+ bun run lint || { echo "❌ Lint failed."; exit 1; }
312
+
313
+ echo "⏳ Checking lockfile sync..."
314
+ git diff --name-only HEAD -- pnpm-lock.yaml | grep -q . && { echo "⚠️ pnpm-lock.yaml has uncommitted changes."; exit 1; }
315
+
316
+ echo "✅ Pre-push checks passed (full tests run in CI). Pushing..."
317
+ `
280
318
  );
281
319
 
320
+ hook(
321
+ "prepare-commit-msg",
322
+ `#!/bin/sh
323
+ COMMIT_MSG_FILE="$1"
324
+ COMMIT_SOURCE="$2"
325
+
326
+ if [ "$COMMIT_SOURCE" = "merge" ] || [ "$COMMIT_SOURCE" = "squash" ] || [ "$COMMIT_SOURCE" = "commit" ]; then
327
+ exit 0
328
+ fi
329
+
330
+ FIRST_LINE=$(head -n1 "$COMMIT_MSG_FILE")
331
+
332
+ if echo "$FIRST_LINE" | grep -qE '^[a-z]+(\\([^)]+\\))?:'; then
333
+ exit 0
334
+ fi
335
+
336
+ STAGED=$(git diff --cached --name-only)
337
+
338
+ if echo "$STAGED" | grep -q "^src/"; then
339
+ SCOPE="app"
340
+ elif echo "$STAGED" | grep -q "^components/"; then
341
+ SCOPE="ui"
342
+ elif echo "$STAGED" | grep -q "^server/"; then
343
+ SCOPE="server"
344
+ fi
345
+
346
+ if [ -n "$SCOPE" ]; then
347
+ sed -i.bak -E "s/^([a-z]+)(\\([^)]+\\))?:/\\1($SCOPE):/" "$COMMIT_MSG_FILE"
348
+ rm -f "\${COMMIT_MSG_FILE}.bak"
349
+ fi
350
+ `
351
+ );
352
+
353
+ hook(
354
+ "post-merge",
355
+ `#!/bin/sh
356
+ echo "⏳ Checking for dependency changes..."
357
+ CHANGED=$(git diff HEAD@{1} --name-only HEAD)
358
+
359
+ if echo "$CHANGED" | grep -q "pnpm-lock.yaml\\|package.json"; then
360
+ echo "📦 Dependencies changed, running pnpm install..."
361
+ pnpm install
362
+ fi
363
+ `
364
+ );
365
+
366
+ hook(
367
+ "post-checkout",
368
+ `#!/bin/sh
369
+ PREV_HEAD="$1"
370
+ NEW_HEAD="$2"
371
+ IS_BRANCH="$3"
372
+
373
+ if [ "$IS_BRANCH" = "1" ]; then
374
+ CHANGED=$(git diff --name-only "$PREV_HEAD" "$NEW_HEAD" 2>/dev/null)
375
+ if echo "$CHANGED" | grep -q "pnpm-lock.yaml\\|package.json"; then
376
+ echo "📦 Dependencies changed between branches, running pnpm install..."
377
+ pnpm install
378
+ fi
379
+ fi
380
+ `
381
+ );
382
+
383
+ console.log("Initializing husky...");
384
+ execSync("pnpm run prepare", { cwd: targetDir, stdio: "pipe" });
385
+
282
386
  execSync("git add -A", { cwd: targetDir, stdio: "pipe" });
283
387
 
284
388
  try {
@@ -0,0 +1,6 @@
1
+ node_modules
2
+ build
3
+ dist
4
+ dist-electron
5
+ pnpm-lock.yaml
6
+ *.min.js
@@ -0,0 +1,9 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": true,
4
+ "trailingComma": "all",
5
+ "printWidth": 100,
6
+ "tabWidth": 2,
7
+ "arrowParens": "always",
8
+ "endOfLine": "lf"
9
+ }
@@ -0,0 +1,8 @@
1
+ export default {
2
+ extends: ['@commitlint/config-conventional'],
3
+ rules: {
4
+ 'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore', 'revert', 'perf']],
5
+ 'subject-max-length': [2, 'always', 80],
6
+ 'subject-case': [0],
7
+ },
8
+ };
@@ -67,6 +67,8 @@
67
67
  "electron:build:linux": "vite build && electron-builder --linux",
68
68
  "lint": "eslint .",
69
69
  "lint:fix": "eslint . --fix",
70
+ "format": "prettier --write .",
71
+ "format:check": "prettier --check .",
70
72
  "test": "vitest run",
71
73
  "test:watch": "vitest",
72
74
  "test:coverage": "vitest run --coverage",
@@ -116,7 +118,20 @@
116
118
  "typescript-eslint": "^8.0.0",
117
119
  "vite": "^6.0.3",
118
120
  "vitest": "^4.1.5",
119
- "ws": "^8.18.0"
121
+ "ws": "^8.18.0",
122
+ "@commitlint/cli": "^19.8.1",
123
+ "@commitlint/config-conventional": "^19.8.1",
124
+ "prettier": "^3.5.3",
125
+ "lint-staged": "^15.5.2"
126
+ },
127
+ "lint-staged": {
128
+ "*.{ts,tsx}": [
129
+ "eslint --fix",
130
+ "prettier --write"
131
+ ],
132
+ "*.{json,md,css,html}": [
133
+ "prettier --write"
134
+ ]
120
135
  },
121
136
  "overrides": {
122
137
  "minimatch": "^10.0.1"