@foundation0/git 1.0.0 → 1.2.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/{packages/git/README.md → README.md} +14 -5
- package/{packages/git/mcp → mcp}/README.md +3 -1
- package/{packages/git/mcp → mcp}/cli.mjs +0 -0
- package/package.json +43 -13
- package/{packages/git/src → src}/git-service-api.ts +3 -0
- package/{packages/git/src → src}/index.ts +8 -0
- package/src/label-management.ts +587 -0
- package/src/platform/config.ts +60 -0
- package/.codex.example/config.toml +0 -10
- package/.env.example +0 -10
- package/packages/fs/README.md +0 -47
- package/packages/fs/node_modules/.bin/f0-git-mcp +0 -21
- package/packages/fs/node_modules/.bin/f0-git-mcp-server +0 -21
- package/packages/fs/node_modules/.bin/f0-git-mcp-server.CMD +0 -12
- package/packages/fs/node_modules/.bin/f0-git-mcp-server.ps1 +0 -41
- package/packages/fs/node_modules/.bin/f0-git-mcp.CMD +0 -12
- package/packages/fs/node_modules/.bin/f0-git-mcp.ps1 +0 -41
- package/packages/fs/node_modules/.bin/tsc +0 -21
- package/packages/fs/node_modules/.bin/tsc.CMD +0 -12
- package/packages/fs/node_modules/.bin/tsc.ps1 +0 -41
- package/packages/fs/node_modules/.bin/tsserver +0 -21
- package/packages/fs/node_modules/.bin/tsserver.CMD +0 -12
- package/packages/fs/node_modules/.bin/tsserver.ps1 +0 -41
- package/packages/fs/node_modules/.bin/vite +0 -21
- package/packages/fs/node_modules/.bin/vite.CMD +0 -12
- package/packages/fs/node_modules/.bin/vite.ps1 +0 -41
- package/packages/fs/node_modules/.bin/vitest +0 -21
- package/packages/fs/node_modules/.bin/vitest.CMD +0 -12
- package/packages/fs/node_modules/.bin/vitest.ps1 +0 -41
- package/packages/fs/package.json +0 -28
- package/packages/fs/src/cli.ts +0 -74
- package/packages/fs/src/git-fs.ts +0 -705
- package/packages/fs/src/index.ts +0 -33
- package/packages/fs/src/mount.ts +0 -297
- package/packages/fs/tsconfig.json +0 -7
- package/packages/git/mcp/tests/e2e/git-mcp-e2e.spec.ts +0 -157
- package/packages/git/mcp/tests/e2e/server.fixture.ts +0 -109
- package/packages/git/node_modules/.bin/tsc +0 -21
- package/packages/git/node_modules/.bin/tsc.CMD +0 -12
- package/packages/git/node_modules/.bin/tsc.ps1 +0 -41
- package/packages/git/node_modules/.bin/tsserver +0 -21
- package/packages/git/node_modules/.bin/tsserver.CMD +0 -12
- package/packages/git/node_modules/.bin/tsserver.ps1 +0 -41
- package/packages/git/node_modules/.bin/vite +0 -21
- package/packages/git/node_modules/.bin/vite.CMD +0 -12
- package/packages/git/node_modules/.bin/vite.ps1 +0 -41
- package/packages/git/node_modules/.bin/vitest +0 -21
- package/packages/git/node_modules/.bin/vitest.CMD +0 -12
- package/packages/git/node_modules/.bin/vitest.ps1 +0 -41
- package/packages/git/node_modules/.vite/vitest/results.json +0 -1
- package/packages/git/package.json +0 -60
- package/packages/git/scripts/create-issue.mjs +0 -93
- package/packages/git/scripts/extract-git-spec.mjs +0 -234
- package/packages/git/scripts/fetch-gitea-swagger.mjs +0 -22
- package/packages/git/src/platform/config.ts +0 -140
- package/packages/git/tests/api.spec.ts +0 -55
- package/packages/git/tests/e2e/git-service-feature-e2e.spec.ts +0 -232
- package/packages/git/tests/git-service-api-object.spec.ts +0 -97
- package/packages/git/tests/git-service-feature-matrix.spec.ts +0 -182
- package/packages/git/tests/issue-dependencies.spec.ts +0 -81
- package/packages/git/tsconfig.json +0 -7
- package/packages/git/vitest.config.ts +0 -7
- package/packages/utils/package.json +0 -9
- package/packages/utils/src/awk.ts +0 -6
- package/packages/utils/src/cat.ts +0 -6
- package/packages/utils/src/cd.ts +0 -6
- package/packages/utils/src/chgrp.ts +0 -6
- package/packages/utils/src/chmod.ts +0 -6
- package/packages/utils/src/chown.ts +0 -6
- package/packages/utils/src/cp.ts +0 -6
- package/packages/utils/src/curl.ts +0 -6
- package/packages/utils/src/cut.ts +0 -6
- package/packages/utils/src/date.ts +0 -6
- package/packages/utils/src/echo.ts +0 -6
- package/packages/utils/src/find.ts +0 -6
- package/packages/utils/src/grep.ts +0 -6
- package/packages/utils/src/gunzip.ts +0 -6
- package/packages/utils/src/gzip.ts +0 -6
- package/packages/utils/src/head.ts +0 -6
- package/packages/utils/src/hostname.ts +0 -6
- package/packages/utils/src/index.ts +0 -37
- package/packages/utils/src/ls.ts +0 -6
- package/packages/utils/src/mkdir.ts +0 -6
- package/packages/utils/src/mv.ts +0 -6
- package/packages/utils/src/ping.ts +0 -6
- package/packages/utils/src/pwd.ts +0 -6
- package/packages/utils/src/rm.ts +0 -6
- package/packages/utils/src/rmdir.ts +0 -6
- package/packages/utils/src/sed.ts +0 -6
- package/packages/utils/src/sort.ts +0 -6
- package/packages/utils/src/tail.ts +0 -6
- package/packages/utils/src/tar.ts +0 -6
- package/packages/utils/src/touch.ts +0 -6
- package/packages/utils/src/tr.ts +0 -6
- package/packages/utils/src/uname.ts +0 -6
- package/packages/utils/src/uniq.ts +0 -6
- package/packages/utils/src/unzip.ts +0 -6
- package/packages/utils/src/util.ts +0 -4
- package/packages/utils/src/wc.ts +0 -6
- package/packages/utils/src/wget.ts +0 -6
- package/packages/utils/src/whoami.ts +0 -6
- package/packages/utils/src/zip.ts +0 -6
- package/pnpm-workspace.yaml +0 -2
- package/tsconfig.base.json +0 -12
- /package/{packages/git/gitea-swagger.json → gitea-swagger.json} +0 -0
- /package/{packages/git/mcp → mcp}/src/cli.ts +0 -0
- /package/{packages/git/mcp → mcp}/src/client.ts +0 -0
- /package/{packages/git/mcp → mcp}/src/index.ts +0 -0
- /package/{packages/git/mcp → mcp}/src/server.ts +0 -0
- /package/{packages/git/src → src}/api.ts +0 -0
- /package/{packages/git/src → src}/git-service-feature-spec.generated.ts +0 -0
- /package/{packages/git/src → src}/issue-dependencies.ts +0 -0
- /package/{packages/git/src → src}/platform/gitea-adapter.ts +0 -0
- /package/{packages/git/src → src}/platform/gitea-rules.ts +0 -0
- /package/{packages/git/src → src}/platform/index.ts +0 -0
- /package/{packages/git/src → src}/repository.ts +0 -0
- /package/{packages/git/src → src}/spec-mock.ts +0 -0
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
-
basedir=`cygpath -w "$basedir"`
|
|
8
|
-
fi
|
|
9
|
-
;;
|
|
10
|
-
esac
|
|
11
|
-
|
|
12
|
-
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/typescript@5.9.3/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/node_modules"
|
|
14
|
-
else
|
|
15
|
-
export NODE_PATH="/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/typescript@5.9.3/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
-
fi
|
|
17
|
-
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
|
|
19
|
-
else
|
|
20
|
-
exec node "$basedir/../typescript/bin/tsserver" "$@"
|
|
21
|
-
fi
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
@SETLOCAL
|
|
2
|
-
@IF NOT DEFINED NODE_PATH (
|
|
3
|
-
@SET "NODE_PATH=C:\Users\marko\Dev\F0\git\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\bin\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\typescript@5.9.3\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\node_modules"
|
|
4
|
-
) ELSE (
|
|
5
|
-
@SET "NODE_PATH=C:\Users\marko\Dev\F0\git\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\bin\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\typescript@5.9.3\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\node_modules;%NODE_PATH%"
|
|
6
|
-
)
|
|
7
|
-
@IF EXIST "%~dp0\node.exe" (
|
|
8
|
-
"%~dp0\node.exe" "%~dp0\..\typescript\bin\tsserver" %*
|
|
9
|
-
) ELSE (
|
|
10
|
-
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
11
|
-
node "%~dp0\..\typescript\bin\tsserver" %*
|
|
12
|
-
)
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env pwsh
|
|
2
|
-
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
3
|
-
|
|
4
|
-
$exe=""
|
|
5
|
-
$pathsep=":"
|
|
6
|
-
$env_node_path=$env:NODE_PATH
|
|
7
|
-
$new_node_path="C:\Users\marko\Dev\F0\git\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\bin\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\typescript@5.9.3\node_modules\typescript\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\typescript@5.9.3\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\node_modules"
|
|
8
|
-
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
9
|
-
# Fix case when both the Windows and Linux builds of Node
|
|
10
|
-
# are installed in the same directory
|
|
11
|
-
$exe=".exe"
|
|
12
|
-
$pathsep=";"
|
|
13
|
-
} else {
|
|
14
|
-
$new_node_path="/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/typescript@5.9.3/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/node_modules"
|
|
15
|
-
}
|
|
16
|
-
if ([string]::IsNullOrEmpty($env_node_path)) {
|
|
17
|
-
$env:NODE_PATH=$new_node_path
|
|
18
|
-
} else {
|
|
19
|
-
$env:NODE_PATH="$new_node_path$pathsep$env_node_path"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
$ret=0
|
|
23
|
-
if (Test-Path "$basedir/node$exe") {
|
|
24
|
-
# Support pipeline input
|
|
25
|
-
if ($MyInvocation.ExpectingInput) {
|
|
26
|
-
$input | & "$basedir/node$exe" "$basedir/../typescript/bin/tsserver" $args
|
|
27
|
-
} else {
|
|
28
|
-
& "$basedir/node$exe" "$basedir/../typescript/bin/tsserver" $args
|
|
29
|
-
}
|
|
30
|
-
$ret=$LASTEXITCODE
|
|
31
|
-
} else {
|
|
32
|
-
# Support pipeline input
|
|
33
|
-
if ($MyInvocation.ExpectingInput) {
|
|
34
|
-
$input | & "node$exe" "$basedir/../typescript/bin/tsserver" $args
|
|
35
|
-
} else {
|
|
36
|
-
& "node$exe" "$basedir/../typescript/bin/tsserver" $args
|
|
37
|
-
}
|
|
38
|
-
$ret=$LASTEXITCODE
|
|
39
|
-
}
|
|
40
|
-
$env:NODE_PATH=$env_node_path
|
|
41
|
-
exit $ret
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
-
basedir=`cygpath -w "$basedir"`
|
|
8
|
-
fi
|
|
9
|
-
;;
|
|
10
|
-
esac
|
|
11
|
-
|
|
12
|
-
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/bin/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/node_modules"
|
|
14
|
-
else
|
|
15
|
-
export NODE_PATH="/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/bin/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
-
fi
|
|
17
|
-
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/bin/vite.js" "$@"
|
|
19
|
-
else
|
|
20
|
-
exec node "$basedir/../../../../node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/bin/vite.js" "$@"
|
|
21
|
-
fi
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
@SETLOCAL
|
|
2
|
-
@IF NOT DEFINED NODE_PATH (
|
|
3
|
-
@SET "NODE_PATH=C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules\vite\bin\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules\vite\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\node_modules"
|
|
4
|
-
) ELSE (
|
|
5
|
-
@SET "NODE_PATH=C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules\vite\bin\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules\vite\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\node_modules;%NODE_PATH%"
|
|
6
|
-
)
|
|
7
|
-
@IF EXIST "%~dp0\node.exe" (
|
|
8
|
-
"%~dp0\node.exe" "%~dp0\..\..\..\..\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules\vite\bin\vite.js" %*
|
|
9
|
-
) ELSE (
|
|
10
|
-
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
11
|
-
node "%~dp0\..\..\..\..\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules\vite\bin\vite.js" %*
|
|
12
|
-
)
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env pwsh
|
|
2
|
-
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
3
|
-
|
|
4
|
-
$exe=""
|
|
5
|
-
$pathsep=":"
|
|
6
|
-
$env_node_path=$env:NODE_PATH
|
|
7
|
-
$new_node_path="C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules\vite\bin\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules\vite\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vite@5.4.21_@types+node@22.19.11\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\node_modules"
|
|
8
|
-
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
9
|
-
# Fix case when both the Windows and Linux builds of Node
|
|
10
|
-
# are installed in the same directory
|
|
11
|
-
$exe=".exe"
|
|
12
|
-
$pathsep=";"
|
|
13
|
-
} else {
|
|
14
|
-
$new_node_path="/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/bin/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/node_modules"
|
|
15
|
-
}
|
|
16
|
-
if ([string]::IsNullOrEmpty($env_node_path)) {
|
|
17
|
-
$env:NODE_PATH=$new_node_path
|
|
18
|
-
} else {
|
|
19
|
-
$env:NODE_PATH="$new_node_path$pathsep$env_node_path"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
$ret=0
|
|
23
|
-
if (Test-Path "$basedir/node$exe") {
|
|
24
|
-
# Support pipeline input
|
|
25
|
-
if ($MyInvocation.ExpectingInput) {
|
|
26
|
-
$input | & "$basedir/node$exe" "$basedir/../../../../node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/bin/vite.js" $args
|
|
27
|
-
} else {
|
|
28
|
-
& "$basedir/node$exe" "$basedir/../../../../node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/bin/vite.js" $args
|
|
29
|
-
}
|
|
30
|
-
$ret=$LASTEXITCODE
|
|
31
|
-
} else {
|
|
32
|
-
# Support pipeline input
|
|
33
|
-
if ($MyInvocation.ExpectingInput) {
|
|
34
|
-
$input | & "node$exe" "$basedir/../../../../node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/bin/vite.js" $args
|
|
35
|
-
} else {
|
|
36
|
-
& "node$exe" "$basedir/../../../../node_modules/.pnpm/vite@5.4.21_@types+node@22.19.11/node_modules/vite/bin/vite.js" $args
|
|
37
|
-
}
|
|
38
|
-
$ret=$LASTEXITCODE
|
|
39
|
-
}
|
|
40
|
-
$env:NODE_PATH=$env_node_path
|
|
41
|
-
exit $ret
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
-
basedir=`cygpath -w "$basedir"`
|
|
8
|
-
fi
|
|
9
|
-
;;
|
|
10
|
-
esac
|
|
11
|
-
|
|
12
|
-
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vitest@2.1.9_@types+node@22.19.11/node_modules/vitest/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vitest@2.1.9_@types+node@22.19.11/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/node_modules"
|
|
14
|
-
else
|
|
15
|
-
export NODE_PATH="/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vitest@2.1.9_@types+node@22.19.11/node_modules/vitest/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vitest@2.1.9_@types+node@22.19.11/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
-
fi
|
|
17
|
-
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../vitest/vitest.mjs" "$@"
|
|
19
|
-
else
|
|
20
|
-
exec node "$basedir/../vitest/vitest.mjs" "$@"
|
|
21
|
-
fi
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
@SETLOCAL
|
|
2
|
-
@IF NOT DEFINED NODE_PATH (
|
|
3
|
-
@SET "NODE_PATH=C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vitest@2.1.9_@types+node@22.19.11\node_modules\vitest\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vitest@2.1.9_@types+node@22.19.11\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\node_modules"
|
|
4
|
-
) ELSE (
|
|
5
|
-
@SET "NODE_PATH=C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vitest@2.1.9_@types+node@22.19.11\node_modules\vitest\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vitest@2.1.9_@types+node@22.19.11\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\node_modules;%NODE_PATH%"
|
|
6
|
-
)
|
|
7
|
-
@IF EXIST "%~dp0\node.exe" (
|
|
8
|
-
"%~dp0\node.exe" "%~dp0\..\vitest\vitest.mjs" %*
|
|
9
|
-
) ELSE (
|
|
10
|
-
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
11
|
-
node "%~dp0\..\vitest\vitest.mjs" %*
|
|
12
|
-
)
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env pwsh
|
|
2
|
-
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
3
|
-
|
|
4
|
-
$exe=""
|
|
5
|
-
$pathsep=":"
|
|
6
|
-
$env_node_path=$env:NODE_PATH
|
|
7
|
-
$new_node_path="C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vitest@2.1.9_@types+node@22.19.11\node_modules\vitest\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\vitest@2.1.9_@types+node@22.19.11\node_modules;C:\Users\marko\Dev\F0\git\node_modules\.pnpm\node_modules"
|
|
8
|
-
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
9
|
-
# Fix case when both the Windows and Linux builds of Node
|
|
10
|
-
# are installed in the same directory
|
|
11
|
-
$exe=".exe"
|
|
12
|
-
$pathsep=";"
|
|
13
|
-
} else {
|
|
14
|
-
$new_node_path="/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vitest@2.1.9_@types+node@22.19.11/node_modules/vitest/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/vitest@2.1.9_@types+node@22.19.11/node_modules:/mnt/c/Users/marko/Dev/F0/git/node_modules/.pnpm/node_modules"
|
|
15
|
-
}
|
|
16
|
-
if ([string]::IsNullOrEmpty($env_node_path)) {
|
|
17
|
-
$env:NODE_PATH=$new_node_path
|
|
18
|
-
} else {
|
|
19
|
-
$env:NODE_PATH="$new_node_path$pathsep$env_node_path"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
$ret=0
|
|
23
|
-
if (Test-Path "$basedir/node$exe") {
|
|
24
|
-
# Support pipeline input
|
|
25
|
-
if ($MyInvocation.ExpectingInput) {
|
|
26
|
-
$input | & "$basedir/node$exe" "$basedir/../vitest/vitest.mjs" $args
|
|
27
|
-
} else {
|
|
28
|
-
& "$basedir/node$exe" "$basedir/../vitest/vitest.mjs" $args
|
|
29
|
-
}
|
|
30
|
-
$ret=$LASTEXITCODE
|
|
31
|
-
} else {
|
|
32
|
-
# Support pipeline input
|
|
33
|
-
if ($MyInvocation.ExpectingInput) {
|
|
34
|
-
$input | & "node$exe" "$basedir/../vitest/vitest.mjs" $args
|
|
35
|
-
} else {
|
|
36
|
-
& "node$exe" "$basedir/../vitest/vitest.mjs" $args
|
|
37
|
-
}
|
|
38
|
-
$ret=$LASTEXITCODE
|
|
39
|
-
}
|
|
40
|
-
$env:NODE_PATH=$env_node_path
|
|
41
|
-
exit $ret
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"2.1.9","results":[[":tests/git-service-api-object.spec.ts",{"duration":35.76499999999987,"failed":false}],[":tests/issue-dependencies.spec.ts",{"duration":20.160900000000083,"failed":false}]]}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@foundation0/git",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Foundation 0 Git API and MCP server",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"f0-git-mcp": "./mcp/cli.mjs",
|
|
8
|
-
"f0-git-mcp-server": "./mcp/cli.mjs"
|
|
9
|
-
},
|
|
10
|
-
"private": false,
|
|
11
|
-
"main": "./src/index.ts",
|
|
12
|
-
"scripts": {
|
|
13
|
-
"fetch:gitea-swagger": "bun run ./scripts/fetch-gitea-swagger.mjs",
|
|
14
|
-
"generate:git-spec": "bun run ./scripts/extract-git-spec.mjs",
|
|
15
|
-
"mcp": "bun run ./mcp/src/cli.ts",
|
|
16
|
-
"test": "bunx vitest run",
|
|
17
|
-
"prepublishOnly": "node ./mcp/cli.mjs --help",
|
|
18
|
-
"deploy": "pnpm prepublishOnly && pnpm publish --access public",
|
|
19
|
-
"version:patch": "pnpm version patch",
|
|
20
|
-
"version:minor": "pnpm version minor",
|
|
21
|
-
"version:major": "pnpm version major"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"foundation0",
|
|
25
|
-
"example",
|
|
26
|
-
"git",
|
|
27
|
-
"mcp"
|
|
28
|
-
],
|
|
29
|
-
"author": "",
|
|
30
|
-
"license": "ISC",
|
|
31
|
-
"files": [
|
|
32
|
-
"src",
|
|
33
|
-
"mcp/src",
|
|
34
|
-
"mcp/cli.mjs",
|
|
35
|
-
"mcp/README.md",
|
|
36
|
-
"README.md",
|
|
37
|
-
"gitea-swagger.json"
|
|
38
|
-
],
|
|
39
|
-
"publishConfig": {
|
|
40
|
-
"access": "public",
|
|
41
|
-
"registry": "https://registry.npmjs.org/"
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"@modelcontextprotocol/sdk": "^1.13.0",
|
|
45
|
-
"zod": "^3.24.1"
|
|
46
|
-
},
|
|
47
|
-
"exports": {
|
|
48
|
-
".": "./src/index.ts",
|
|
49
|
-
"./mcp": "./mcp/src/index.ts",
|
|
50
|
-
"./mcp/server": "./mcp/src/server.ts",
|
|
51
|
-
"./mcp/client": "./mcp/src/client.ts",
|
|
52
|
-
"./mcp/cli": "./mcp/cli.mjs"
|
|
53
|
-
},
|
|
54
|
-
"devDependencies": {
|
|
55
|
-
"@types/node": "^22.10.2",
|
|
56
|
-
"vitest": "^2.1.8",
|
|
57
|
-
"typescript": "^5.5.4"
|
|
58
|
-
},
|
|
59
|
-
"packageManager": "pnpm@10.15.0"
|
|
60
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { createGitPlatformAdapter, getGitPlatformConfig } from '../src/index'
|
|
2
|
-
|
|
3
|
-
const run = async () => {
|
|
4
|
-
const platformConfig = getGitPlatformConfig({ platform: 'GITEA' })
|
|
5
|
-
const adapter = createGitPlatformAdapter({ config: platformConfig })
|
|
6
|
-
|
|
7
|
-
const feature = { path: ['issue', 'create'], args: [], flags: [] }
|
|
8
|
-
const owner = process.env.GITEA_TEST_OWNER ?? 'example-org'
|
|
9
|
-
const repo = process.env.GITEA_TEST_REPO ?? 'example-repo'
|
|
10
|
-
const title = `Automated issue from library ${new Date().toISOString()}`
|
|
11
|
-
|
|
12
|
-
const mapping = await adapter.mapFeature({
|
|
13
|
-
feature,
|
|
14
|
-
args: [owner, repo],
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
const baseHeaders = Object.fromEntries(
|
|
18
|
-
mapping.headers.map((header) => {
|
|
19
|
-
const separator = header.indexOf(':')
|
|
20
|
-
if (separator < 0) {
|
|
21
|
-
return [header.trim(), '']
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return [header.slice(0, separator).trim(), header.slice(separator + 1).trim()]
|
|
25
|
-
}),
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
const authHeaders = new Set(
|
|
29
|
-
platformConfig.giteaToken
|
|
30
|
-
? [baseHeaders.Authorization, `token ${platformConfig.giteaToken}`, `Bearer ${platformConfig.giteaToken}`]
|
|
31
|
-
: [baseHeaders.Authorization],
|
|
32
|
-
)
|
|
33
|
-
const uniqueAuthHeaders = Array.from(authHeaders).filter((value) => Boolean(value))
|
|
34
|
-
|
|
35
|
-
const requestBody = {
|
|
36
|
-
title,
|
|
37
|
-
body: 'Created by git library script',
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let lastFailure
|
|
41
|
-
for (const authHeader of uniqueAuthHeaders) {
|
|
42
|
-
const headers = {
|
|
43
|
-
...baseHeaders,
|
|
44
|
-
Authorization: authHeader,
|
|
45
|
-
'Content-Type': 'application/json',
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const response = await fetch(`${mapping.apiBase}/${mapping.mappedPath.join('/')}`, {
|
|
49
|
-
method: mapping.method,
|
|
50
|
-
headers,
|
|
51
|
-
body: JSON.stringify(requestBody),
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
const responseText = await response.text()
|
|
55
|
-
let body
|
|
56
|
-
try {
|
|
57
|
-
body = JSON.parse(responseText)
|
|
58
|
-
} catch {
|
|
59
|
-
body = responseText
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (response.ok) {
|
|
63
|
-
console.log(
|
|
64
|
-
JSON.stringify(
|
|
65
|
-
{
|
|
66
|
-
status: response.status,
|
|
67
|
-
endpoint: `${mapping.apiBase}/${mapping.mappedPath.join('/')}`,
|
|
68
|
-
issue: {
|
|
69
|
-
id: body.id,
|
|
70
|
-
number: body.number,
|
|
71
|
-
title: body.title,
|
|
72
|
-
url: body.html_url,
|
|
73
|
-
},
|
|
74
|
-
requestBody,
|
|
75
|
-
},
|
|
76
|
-
null,
|
|
77
|
-
2,
|
|
78
|
-
),
|
|
79
|
-
)
|
|
80
|
-
return
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
lastFailure = { status: response.status, body, authHeader }
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (lastFailure) {
|
|
87
|
-
throw new Error(
|
|
88
|
-
`Create issue failed for all auth variants. Last status ${lastFailure.status}: ${JSON.stringify(lastFailure.body)}`,
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
await run()
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process'
|
|
2
|
-
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
3
|
-
import { dirname, join } from 'node:path'
|
|
4
|
-
|
|
5
|
-
/** @typedef {{ name: string; takesValue: boolean }} GitServiceFlag */
|
|
6
|
-
/** @typedef {{ path: string[]; args: string[]; flags: GitServiceFlag[] }} GitServiceFeature */
|
|
7
|
-
/** @typedef {{ features: GitServiceFeature[] }} GitServiceFeatureSpec */
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Extract tokens after the command path from a command signature.
|
|
11
|
-
*
|
|
12
|
-
* @param {string} signature
|
|
13
|
-
* @param {string[]} pathParts
|
|
14
|
-
* @returns {string[]}
|
|
15
|
-
*/
|
|
16
|
-
const collectArgTokens = (signature, pathParts) => {
|
|
17
|
-
const pathPrefix = `${pathParts.join(' ')} `
|
|
18
|
-
const raw = signature.startsWith(pathPrefix) ? signature.slice(pathPrefix.length) : signature
|
|
19
|
-
const tokens = []
|
|
20
|
-
let i = 0
|
|
21
|
-
|
|
22
|
-
while (i < raw.length) {
|
|
23
|
-
while (i < raw.length && /\s/.test(raw[i])) i += 1
|
|
24
|
-
if (i >= raw.length) break
|
|
25
|
-
|
|
26
|
-
const ch = raw[i]
|
|
27
|
-
const tokenStart = i
|
|
28
|
-
|
|
29
|
-
if (ch === '[' || ch === '{' || ch === '<') {
|
|
30
|
-
const close = ch === '[' ? ']' : ch === '{' ? '}' : '>'
|
|
31
|
-
i += 1
|
|
32
|
-
while (i < raw.length && raw[i] !== close) i += 1
|
|
33
|
-
i += 1
|
|
34
|
-
while (raw.slice(i, i + 3) === '...') i += 3
|
|
35
|
-
tokens.push(raw.slice(tokenStart, i))
|
|
36
|
-
continue
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
while (i < raw.length && !/\s/.test(raw[i])) {
|
|
40
|
-
i += 1
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
tokens.push(raw.slice(tokenStart, i))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return tokens
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Parse header of a command section and returns its method path.
|
|
51
|
-
*
|
|
52
|
-
* @param {string} signature
|
|
53
|
-
* @returns {string[]}
|
|
54
|
-
*/
|
|
55
|
-
const parseMethodPath = (signature) => {
|
|
56
|
-
const tokens = signature.split(/\s+/).filter(Boolean)
|
|
57
|
-
const path = []
|
|
58
|
-
|
|
59
|
-
for (const token of tokens) {
|
|
60
|
-
if (token.startsWith('[') || token.startsWith('{') || token.startsWith('<')) {
|
|
61
|
-
break
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
path.push(token)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return path
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @param {string} signature
|
|
72
|
-
* @param {string[]} path
|
|
73
|
-
* @returns {string[]}
|
|
74
|
-
*/
|
|
75
|
-
const parseArgs = (signature, path) => {
|
|
76
|
-
const args = []
|
|
77
|
-
const pathPrefix = path.join(' ')
|
|
78
|
-
let raw = ''
|
|
79
|
-
|
|
80
|
-
if (signature === pathPrefix) {
|
|
81
|
-
raw = ''
|
|
82
|
-
} else if (signature.startsWith(`${pathPrefix} `)) {
|
|
83
|
-
raw = signature.slice(pathPrefix.length + 1)
|
|
84
|
-
} else {
|
|
85
|
-
raw = signature
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
for (const token of collectArgTokens(raw, path)) {
|
|
89
|
-
const trimmed = token.trim()
|
|
90
|
-
if (!trimmed) continue
|
|
91
|
-
if (trimmed === '[flags]' || trimmed === '--help' || trimmed === '--version') continue
|
|
92
|
-
if (trimmed.startsWith('[') && trimmed.endsWith(']')) {
|
|
93
|
-
const inner = trimmed.slice(1, -1).trim()
|
|
94
|
-
if (!inner || inner === 'flags' || inner.startsWith('--')) {
|
|
95
|
-
continue
|
|
96
|
-
}
|
|
97
|
-
args.push(inner)
|
|
98
|
-
continue
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
102
|
-
const inner = trimmed.slice(1, -1).trim()
|
|
103
|
-
if (!inner || inner.includes('--')) {
|
|
104
|
-
continue
|
|
105
|
-
}
|
|
106
|
-
args.push(inner)
|
|
107
|
-
continue
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (!trimmed.startsWith('-')) {
|
|
111
|
-
args.push(trimmed)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return args
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @param {string} line
|
|
120
|
-
* @returns {GitServiceFlag | null}
|
|
121
|
-
*/
|
|
122
|
-
const parseFlagLine = (line) => {
|
|
123
|
-
const trimmed = line.trim()
|
|
124
|
-
if (!trimmed.startsWith('-')) return null
|
|
125
|
-
|
|
126
|
-
const tokens = trimmed.split(/\s+/)
|
|
127
|
-
if (tokens.length === 0) return null
|
|
128
|
-
|
|
129
|
-
let name = null
|
|
130
|
-
let typeToken = null
|
|
131
|
-
|
|
132
|
-
if (tokens[0].startsWith('--')) {
|
|
133
|
-
name = tokens[0]
|
|
134
|
-
typeToken = tokens[1]
|
|
135
|
-
} else if (tokens[1]?.startsWith('--')) {
|
|
136
|
-
name = tokens[1]
|
|
137
|
-
typeToken = tokens[2]
|
|
138
|
-
} else {
|
|
139
|
-
name = tokens[0].replace(/,$/, '')
|
|
140
|
-
typeToken = tokens[1]
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (!name) return null
|
|
144
|
-
|
|
145
|
-
const takesValue = typeToken && (typeToken === '[flags]' || typeToken === '[<flags>]' ? false : /^[a-z][a-z0-9._:=+./-]*$/i.test(typeToken))
|
|
146
|
-
if (/^[A-Z]/.test(typeToken ?? '')) {
|
|
147
|
-
return {
|
|
148
|
-
name,
|
|
149
|
-
takesValue: false,
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return {
|
|
154
|
-
name,
|
|
155
|
-
takesValue,
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* @param {string} text
|
|
161
|
-
* @returns {GitServiceFeatureSpec}
|
|
162
|
-
*/
|
|
163
|
-
const parseReference = (text) => {
|
|
164
|
-
const lines = text.split(/\r?\n/)
|
|
165
|
-
const features = []
|
|
166
|
-
|
|
167
|
-
/** @type {GitServiceFeature | null} */
|
|
168
|
-
let currentFeature = null
|
|
169
|
-
|
|
170
|
-
for (const line of lines) {
|
|
171
|
-
if (line.startsWith('### gh ')) {
|
|
172
|
-
const signature = line.slice(6).trim()
|
|
173
|
-
const path = parseMethodPath(signature)
|
|
174
|
-
if (path.length === 0) {
|
|
175
|
-
currentFeature = null
|
|
176
|
-
continue
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const args = parseArgs(signature, path)
|
|
180
|
-
currentFeature = {
|
|
181
|
-
path,
|
|
182
|
-
args,
|
|
183
|
-
flags: [],
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
features.push(currentFeature)
|
|
187
|
-
continue
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (currentFeature && line.startsWith('###')) {
|
|
191
|
-
currentFeature = null
|
|
192
|
-
continue
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (!currentFeature) {
|
|
196
|
-
continue
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const maybeFlag = parseFlagLine(line)
|
|
200
|
-
if (!maybeFlag) continue
|
|
201
|
-
|
|
202
|
-
if (!currentFeature.flags.some((flag) => flag.name === maybeFlag.name)) {
|
|
203
|
-
currentFeature.flags.push(maybeFlag)
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return { features }
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const raw = execSync('gh help reference', { encoding: 'utf8' })
|
|
211
|
-
const payload = parseReference(raw)
|
|
212
|
-
const outputPath = join(process.cwd(), 'src', 'git-service-feature-spec.generated.ts')
|
|
213
|
-
const outputDir = dirname(outputPath)
|
|
214
|
-
mkdirSync(outputDir, { recursive: true })
|
|
215
|
-
|
|
216
|
-
const ts = [
|
|
217
|
-
'export interface GitServiceFlag {',
|
|
218
|
-
' name: string',
|
|
219
|
-
' takesValue: boolean',
|
|
220
|
-
'}',
|
|
221
|
-
'export interface GitServiceFeature {',
|
|
222
|
-
' path: string[]',
|
|
223
|
-
' args: string[]',
|
|
224
|
-
' flags: GitServiceFlag[]',
|
|
225
|
-
'}',
|
|
226
|
-
'export interface GitServiceFeatureSpec {',
|
|
227
|
-
' features: GitServiceFeature[]',
|
|
228
|
-
'}',
|
|
229
|
-
'',
|
|
230
|
-
`export const gitServiceFeatureSpec: GitServiceFeatureSpec = ${JSON.stringify(payload, null, 2)}`,
|
|
231
|
-
].join('\n')
|
|
232
|
-
|
|
233
|
-
writeFileSync(outputPath, `${ts}\n`)
|
|
234
|
-
console.log(`Wrote ${payload.features.length} features to ${outputPath}`)
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from 'node:fs'
|
|
2
|
-
import { resolve } from 'node:path'
|
|
3
|
-
import { getGitPlatformConfig } from '../src/platform/config'
|
|
4
|
-
|
|
5
|
-
const config = getGitPlatformConfig()
|
|
6
|
-
const swaggerPath = config.giteaSwaggerPath || '/swagger.v1.json'
|
|
7
|
-
const host = config.giteaHost.replace(/\/$/, '')
|
|
8
|
-
const base = host.endsWith('/api/v1') ? host.slice(0, -6) : host
|
|
9
|
-
const swaggerUrl = new URL(swaggerPath, `${base}/`).toString()
|
|
10
|
-
|
|
11
|
-
const headers = config.giteaToken ? { Authorization: `token ${config.giteaToken}` } : undefined
|
|
12
|
-
const response = await fetch(swaggerUrl, { headers })
|
|
13
|
-
|
|
14
|
-
if (!response.ok) {
|
|
15
|
-
throw new Error(`Failed to fetch swagger definition from ${swaggerUrl}: ${response.status}`)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const payload = await response.json()
|
|
19
|
-
const outputPath = resolve(process.cwd(), 'gitea-swagger.json')
|
|
20
|
-
|
|
21
|
-
writeFileSync(outputPath, `${JSON.stringify(payload, null, 2)}\n`)
|
|
22
|
-
console.log(`Wrote Swagger definition to ${outputPath}`)
|