Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] byul 개선 사항 ( byul 커밋 로그 개선, puncycode 모듈 종속성, byul 삭제 편의성) #74

Closed
4 tasks done
nakyeonko3 opened this issue Sep 27, 2024 · 5 comments
Assignees
Labels
fix 버그 (버그 수정)

Comments

@nakyeonko3
Copy link
Collaborator

nakyeonko3 commented Sep 27, 2024

📄 Description

byul 커밋 로그 개선

  • 한 번 커밋 할 때마다 로그가 너무 길게 나옴

punycode 모듈 관련 종속성 문제 해결

(node:106976) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created)

byul 삭제가 어려움

  • byul을 종속성에서 제거해도 훅 스크립트가 남아 있어서 불편함.

byul 삭제 관련 해결방안

  • index.ts를 실행시키는 명령어를 prepare-commit-msg에서 실행시키지 않고, 외부에서 실행하도록하기
  • byul.config.json이 삭제되면 해당 스크립트도 실행되지 않게 하기
❯ git commit -m "test"
node:internal/modules/cjs/loader:1222
  throw err;
  ^

Error: Cannot find module '/home/badac/works/test_magit/node_modules/byul/dist/index.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1219:15)
    at Module._load (node:internal/modules/cjs/loader:1045:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5)
    at node:internal/main/run_main_module:30:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
Node.js v22.5.1

✅ Tasks

  • byul 커밋 로그 개선
  • puncycode 모듈 종속성 문제 해결
  • byul 종속성 제거 이후에는 byul이 아예 실행되지 않게 하기
  • husky에서 테스트

📝 Notes

No response

@nakyeonko3 nakyeonko3 added the fix 버그 (버그 수정) label Sep 27, 2024
@love1ace
Copy link
Contributor

prepare-commit-msg 훅에서 실행이 되는게 아니면 어떤식으로 할 생각이신가요?

@love1ace
Copy link
Contributor

로그는 어떻게 개선하실 생각이신가요?

nakyeonko3 added a commit that referenced this issue Sep 27, 2024
- openai/openai-node#527
- [email protected]으로 override 이후 puncycode 경고가 없어짐
- 현재 사용하지 않는 ts-node 종속성 제거
@nakyeonko3
Copy link
Collaborator Author

prepare-commit-msg 훅에서 실행이 되는게 아니면 어떤식으로 할 생각이신가요?

prepare-commit-msg 훅에 들어갈 스크립트를 수정

  • prepare-commit-msg에서 실행을 시키는 것은 동일합니다.
  • byul 종속성이 node_modules에서 제거된 경우 byul이 아예 작동이 되지 않게 할 수 있습니다.
  • 아래의 코드에서 find_module() 함수는 node_modules, package.json에서 byul이 제거되었는지를 확인하고 만약에 제거되었다면 아무것도 실행을 하지 않습니다.
  • 사용자가 기존에 prepare-commit-msg 훅을 사용중이였다면 상단에 스크립트를 명시하게 해서 byul 스크립트의 실행과 상관없이 실행되게 할 수 있습니다
#!/usr/bin/env bash

# -----다른 훅 스크립트------
echo "running other prepare-commit-msg hooks!"
echo "다른 스크립트들은 여기서 실행 가능"
# --------------------------

MODULE_NAME="lefthook"

PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo ".")

find_module() {
    if [ -d "$PROJECT_ROOT/node_modules/$MODULE_NAME" ]; then
        return 0
    fi

    if grep -q "\"$MODULE_NAME\"" "$PROJECT_ROOT/package.json" 2>/dev/null; then
        return 0
    fi

    if command -v $MODULE_NAME >/dev/null 2>&1; then
        return 0
    fi

    return 1
}

if find_module; then
# ----------- byul 스크립트 실행 ------------------
    node dist/index.js "$1" "$2" "$3" 
# -----------------------------
else
    :
fi

exit 0

@nakyeonko3
Copy link
Collaborator Author

nakyeonko3 commented Sep 27, 2024

로그는 어떻게 개선하실 생각이신가요?

AI:false인 경우에만 수정할 것입니다. AI 커밋 모드가 아닐 때는 이렇게 긴 로그가 출력 될 필요가 없으니 저 빨간색 사각형 부분들을 1,2줄로 로그로 줄일 예정임.
image

@love1ace
Copy link
Contributor

오 좋네요

nakyeonko3 added a commit that referenced this issue Sep 27, 2024
- setup.mjs 수정, 기존과 다르게 byul_script 파일을 읽고 파일 내용을
  prepare-commit-msg에 옮김
- prepare-commit-msg 내용 수정. package.json에 byul이 없을 경우 byul이
  실행이 되지 않게 막음
nakyeonko3 added a commit that referenced this issue Sep 27, 2024
- ai 커밋 모드가 false일 때 로그를 수정
- 2줄로 수정함
nakyeonko3 added a commit that referenced this issue Sep 27, 2024
- husky 종속성이 설치 되어 있을 때 byul 스크립트가 중복해서
  prepare-commit-msg에 생성되는 것을 막음.
nakyeonko3 added a commit that referenced this issue Sep 27, 2024
- dist/setup.mjs 안에서 실행 될 때 잘못된 경로를 읽는 문제를 해결함
- readByulHookFile 함수는 byul_script 파일을 찾아서 읽고, 읽은 값을
  string으로 바꿔서 리턴하는 함수임.
- readByulHookFile 함수가 읽는 파일경로는 다음과 같음
1. rootDir/node_modules/byul/dist/byul_script
2. rootDir/../../node_modules/byul/dist/byul_script
3. rootDir/dist/setup.mjs
love1ace added a commit that referenced this issue Sep 27, 2024
nakyeonko3 added a commit that referenced this issue Sep 27, 2024
-  readByulHookFile 함수가  '/home/badac/works/byul/node_modules/byul/dist/byul_script',
  '/home/badac/works/byul/dist/byul_script' 경로를 읽도록 수정함.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix 버그 (버그 수정)
Projects
None yet
Development

No branches or pull requests

2 participants