@things-factory/integration-git 9.1.18 → 10.0.0-beta.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": "@things-factory/integration-git",
3
- "version": "9.1.18",
3
+ "version": "10.0.0-beta.1",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -27,8 +27,8 @@
27
27
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
28
28
  },
29
29
  "dependencies": {
30
- "@things-factory/integration-base": "^9.1.18",
30
+ "@things-factory/integration-base": "^10.0.0-beta.1",
31
31
  "simple-git": "^3.27.0"
32
32
  },
33
- "gitHead": "b3518bba09ed192cdbf4892cd9e0b388ed56a4c0"
33
+ "gitHead": "90f40bf160fa25edf4560d7893cfd576cf474411"
34
34
  }
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "../../tsconfig-base.json",
3
- "compilerOptions": {
4
- "strict": true,
5
- "declaration": true,
6
- "module": "esnext",
7
- "outDir": "../dist-client",
8
- "baseUrl": "./"
9
- },
10
- "include": ["./**/*"]
11
- }
@@ -1,19 +0,0 @@
1
- import fs from 'fs'
2
- import path from 'path'
3
- import fetch from 'node-fetch'
4
-
5
- const REPO_PATH = path.join(__dirname, '../my-repo')
6
-
7
- // ✅ Git 디렉토리 내 파일 변경 감지
8
- fs.watch(REPO_PATH, { recursive: true }, async (eventType, filename) => {
9
- if (!filename) return
10
-
11
- console.log(`🔄 파일 변경 감지: ${filename}`)
12
-
13
- // ✅ Things-Factory API 호출하여 변경된 파일 처리
14
- await fetch('http://localhost:3000/api/git-process-changes', {
15
- method: 'POST',
16
- headers: { 'Content-Type': 'application/json' },
17
- body: JSON.stringify({ files: [filename] })
18
- })
19
- })
@@ -1,26 +0,0 @@
1
- import simpleGit from 'simple-git'
2
- import path from 'path'
3
- import fetch from 'node-fetch'
4
-
5
- const REPO_PATH = path.join(__dirname, '../my-repo')
6
- const git = simpleGit(REPO_PATH)
7
-
8
- // ✅ 일정 주기로 `git status` 실행하여 변경 사항 감지
9
- async function checkForChanges() {
10
- const status = await git.status()
11
- const changedFiles = [...status.modified, ...status.created]
12
-
13
- if (changedFiles.length > 0) {
14
- console.log('🔄 Git 변경 사항 감지:', changedFiles)
15
-
16
- // ✅ Things-Factory 파이프라인 실행
17
- await fetch('http://localhost:3000/api/git-process-changes', {
18
- method: 'POST',
19
- headers: { 'Content-Type': 'application/json' },
20
- body: JSON.stringify({ files: changedFiles })
21
- })
22
- }
23
- }
24
-
25
- // ✅ 10초마다 변경 사항 확인
26
- setInterval(checkForChanges, 10000)
@@ -1,22 +0,0 @@
1
- import { Context, TaskRegistry } from '@things-factory/integration-base'
2
- import fetch from 'node-fetch'
3
-
4
- async function gitWebhookHandler(step, { data }: Context) {
5
- const { commits } = step.params
6
- if (!commits || commits.length === 0) {
7
- throw new Error('No commits found in Webhook payload')
8
- }
9
-
10
- const modifiedFiles = commits.flatMap(commit => commit.modified)
11
-
12
- // ✅ 변경된 파일 분석 및 Qdrant 업데이트 실행
13
- await fetch('http://localhost:3000/api/git-process-changes', {
14
- method: 'POST',
15
- headers: { 'Content-Type': 'application/json' },
16
- body: JSON.stringify({ files: modifiedFiles })
17
- })
18
-
19
- return { data: true }
20
- }
21
-
22
- TaskRegistry.registerTaskHandler('git-webhook-handler', gitWebhookHandler)
@@ -1,79 +0,0 @@
1
- import { Connection, ConnectionManager, Connector } from '@things-factory/integration-base'
2
- import simpleGit from 'simple-git'
3
-
4
- export class GitConnector implements Connector {
5
- async ready(connectionConfigs) {
6
- await Promise.all(connectionConfigs.map(this.connect.bind(this)))
7
-
8
- ConnectionManager.logger.info('Git connections are ready')
9
- }
10
-
11
- // async checkConnectionInstance(domain, connectionName): Promise<boolean> {
12
- // try {
13
- // const connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)
14
- // return !!connection
15
- // } catch (e) {
16
- // return false
17
- // }
18
- // }
19
-
20
- async connect(connection) {
21
- var {
22
- endpoint, // Git 저장소 URL (ex: https://git.com/user/repo.git, https://gitlab.com/user/repo.git, ssh://git@bitbucket.org/user/repo.git)
23
- params: { branch = 'main', token, sshKeyPath }
24
- } = connection
25
-
26
- try {
27
- // ✅ Git 클라이언트 생성
28
- const client = simpleGit()
29
-
30
- // ✅ Git 인증 처리 (토큰 방식 vs SSH 방식)
31
- let remoteUrl = endpoint
32
- if (token) {
33
- // HTTP 인증 방식 (예: GitHub, GitLab의 PAT)
34
- remoteUrl = endpoint.replace('https://', `https://${token}@`)
35
- } else if (sshKeyPath) {
36
- // SSH 방식 인증 (예: Bitbucket, 사내 Git 서버)
37
- client.env({ GIT_SSH_COMMAND: `ssh -i ${sshKeyPath} -o StrictHostKeyChecking=no` })
38
- }
39
-
40
- // ✅ ConnectionManager에 저장할 때 `remoteUrl` 추가
41
- ConnectionManager.addConnectionInstance(connection, {
42
- client,
43
- branch,
44
- endpoint,
45
- remoteUrl, // ✅ remoteUrl 추가
46
- token,
47
- sshKeyPath
48
- })
49
-
50
- ConnectionManager.logger.info(`Git connection(${connection.name}:${endpoint}) is connected`)
51
- } catch (ex) {
52
- ConnectionManager.logger.error(`Git connection(${connection.name}:${endpoint}) failed to connect`, ex)
53
- throw ex
54
- }
55
- }
56
-
57
- async disconnect(connection: Connection) {
58
- ConnectionManager.removeConnectionInstance(connection)
59
- ConnectionManager.logger.info(`Git connection(${connection.name}) is disconnected`)
60
- }
61
-
62
- get parameterSpec() {
63
- return [
64
- { type: 'string', name: 'branch', label: 'git.branch' },
65
- { type: 'string', name: 'token', label: 'git.token' },
66
- { type: 'string', name: 'sshKeyPath', label: 'git.ssh-key-path' }
67
- ]
68
- }
69
-
70
- get taskPrefixes() {
71
- return ['git']
72
- }
73
-
74
- get help() {
75
- return 'integration/connector/git-connector'
76
- }
77
- }
78
-
79
- ConnectionManager.registerConnector('git-connector', new GitConnector())
@@ -1 +0,0 @@
1
- import './git.js'
@@ -1,2 +0,0 @@
1
- import './connector/index.js'
2
- import './task/index.js'
@@ -1,43 +0,0 @@
1
- import { ConnectionManager, Context, TaskRegistry } from '@things-factory/integration-base'
2
- import path from 'path'
3
- import fs from 'fs-extra'
4
-
5
- const debug = require('debug')('things-factory:git-clone')
6
-
7
- async function gitClone(step, { domain, data }: Context) {
8
- const {
9
- connection,
10
- params: { targetDir }
11
- } = step
12
-
13
- // ✅ Git 연결 정보 가져오기
14
- const gitInstance = await ConnectionManager.getConnectionInstanceByName(domain, connection)
15
- if (!gitInstance) {
16
- debug(`No connection: ${connection}`)
17
- throw new Error(`No connection: ${connection}`)
18
- }
19
-
20
- const { client, branch, remoteUrl } = gitInstance
21
- if (!remoteUrl) {
22
- throw new Error(`Remote URL is required for Git repository: ${connection}`)
23
- }
24
-
25
- const repoName = remoteUrl.split('/').pop().replace('.git', '') + `@${branch}`
26
- const repoPath = path.join(targetDir, repoName)
27
-
28
- // ✅ 리포지토리가 이미 존재하면 Pull, 없으면 Clone 실행
29
- if (fs.existsSync(repoPath)) {
30
- debug(`Repository already exists at ${repoPath}. Pulling latest changes...`)
31
- await client.cwd(repoPath).pull()
32
- } else {
33
- debug(`Cloning repository ${remoteUrl} into ${repoPath}...`)
34
- await client.clone(remoteUrl, repoPath, ['-b', branch])
35
- }
36
-
37
- return { data: repoPath }
38
- }
39
-
40
- gitClone.parameterSpec = [{ type: 'string', name: 'targetDir', label: 'git.target-dir' }]
41
- gitClone.help = 'integration/task/git-clone'
42
-
43
- TaskRegistry.registerTaskHandler('git-clone', gitClone)
@@ -1,36 +0,0 @@
1
- import { Context, TaskRegistry } from '@things-factory/integration-base'
2
- import simpleGit from 'simple-git'
3
- import path from 'path'
4
-
5
- async function gitCommit(step, { domain, data }: Context) {
6
- const { repoPath, filePath, message, push } = step.params
7
-
8
- if (!repoPath || !filePath) {
9
- throw new Error(`repoPath와 filePath는 필수 파라미터입니다.`)
10
- }
11
-
12
- const git = simpleGit(repoPath)
13
-
14
- try {
15
- // ✅ 변경된 파일을 Git 스테이징 영역에 추가
16
- await git.add(filePath)
17
-
18
- // ✅ 커밋 메시지가 없으면 기본 메시지 생성
19
- const commitMessage = message || `AI 리팩토링 적용 - ${new Date().toISOString()}`
20
-
21
- // ✅ Git 커밋 실행
22
- await git.commit(commitMessage)
23
-
24
- // ✅ 필요하면 자동 푸시 수행
25
- if (push) {
26
- await git.push()
27
- }
28
-
29
- return { data: { success: true, commitMessage } }
30
- } catch (error) {
31
- throw new Error(`Git 커밋 오류: ${error.message}`)
32
- }
33
- }
34
-
35
- // ✅ 태스크 등록
36
- TaskRegistry.registerTaskHandler('git-commit', gitCommit)
@@ -1,32 +0,0 @@
1
- import { Context, TaskRegistry } from '@things-factory/integration-base'
2
- import simpleGit from 'simple-git'
3
- import path from 'path'
4
-
5
- async function gitDetectChanges(step, { data }: Context) {
6
- const { repoPath } = step.params
7
-
8
- if (!repoPath) {
9
- throw new Error(`repoPath는 필수 파라미터입니다.`)
10
- }
11
-
12
- const git = simpleGit(path.resolve(repoPath))
13
-
14
- try {
15
- // ✅ Git 상태 확인
16
- const status = await git.status()
17
-
18
- // ✅ 변경된 파일 목록 분류
19
- const changedFiles = {
20
- modified: status.modified || [],
21
- created: status.created || [],
22
- deleted: status.deleted || []
23
- }
24
-
25
- return { data: changedFiles }
26
- } catch (error) {
27
- throw new Error(`Git 변경 감지 오류: ${error.message}`)
28
- }
29
- }
30
-
31
- // ✅ 태스크 등록
32
- TaskRegistry.registerTaskHandler('git-detect-changes', gitDetectChanges)
@@ -1,57 +0,0 @@
1
- import { ConnectionManager, Context, TaskRegistry } from '@things-factory/integration-base'
2
- import simpleGit from 'simple-git'
3
- import path from 'path'
4
- import fs from 'fs-extra'
5
-
6
- const debug = require('debug')('things-factory:git-pull')
7
-
8
- async function gitPull(step, { domain, data }: Context) {
9
- const {
10
- connection,
11
- params: { targetDir }
12
- } = step
13
-
14
- // ✅ Git 연결 정보 가져오기
15
- const gitInstance = await ConnectionManager.getConnectionInstanceByName(domain, connection)
16
- if (!gitInstance) {
17
- debug(`No connection found: ${connection}`)
18
- throw new Error(`No connection: ${connection}`)
19
- }
20
-
21
- const { client = simpleGit(), remoteUrl } = gitInstance
22
- if (!remoteUrl) {
23
- throw new Error(`Remote URL is required for Git repository: ${connection}`)
24
- }
25
-
26
- // ✅ 리포지토리 경로 계산
27
- const repoName = remoteUrl.split('/').pop().replace('.git', '')
28
- const repoPath = path.join(targetDir, repoName)
29
-
30
- if (!fs.existsSync(repoPath)) {
31
- throw new Error(`Repository does not exist at ${repoPath}. Please run "git-clone" first.`)
32
- }
33
-
34
- // ✅ Git 저장소인지 확인
35
- const isRepo = await client.cwd(repoPath).checkIsRepo()
36
- if (!isRepo) {
37
- throw new Error(`Invalid Git repository at ${repoPath}`)
38
- }
39
-
40
- // ✅ 최신 변경사항 가져오기 (fetch + pull)
41
- debug(`Fetching latest changes for ${connection}...`)
42
- await client.cwd(repoPath).fetch()
43
-
44
- debug(`Pulling latest changes for ${connection}...`)
45
- await client.cwd(repoPath).pull()
46
-
47
- return { data: repoPath }
48
- }
49
-
50
- // ✅ 파라미터 정의
51
- gitPull.parameterSpec = [{ type: 'string', name: 'targetDir', label: 'git.target-dir' }]
52
-
53
- // ✅ 도움말 정의
54
- gitPull.help = 'integration/task/git-pull'
55
-
56
- // ✅ 태스크 등록
57
- TaskRegistry.registerTaskHandler('git-pull', gitPull)
@@ -1,2 +0,0 @@
1
- import './git-clone.js'
2
- import './git-pull.js'
package/server/index.ts DELETED
@@ -1 +0,0 @@
1
- import './engine/index.js'
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../../tsconfig-base.json",
3
- "compilerOptions": {
4
- "strict": false,
5
- "module": "commonjs",
6
- "outDir": "../dist-server",
7
- "baseUrl": "./"
8
- },
9
- "include": ["./**/*"]
10
- }