Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ jobs:
- name: Lint Effect-TS (lib)
run: pnpm --filter ./packages/lib lint:effect

e2e-local-package:
name: E2E (Local package CLI)
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- name: Install dependencies
uses: ./.github/actions/setup
- name: Pack and run local package via pnpm
run: bash scripts/e2e/local-package-cli.sh

e2e-opencode:
name: E2E (OpenCode)
runs-on: ubuntu-latest
Expand Down
5 changes: 3 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
"prebuild": "pnpm -C ../lib build",
"build": "pnpm run build:app && pnpm run build:docker-git",
"build:app": "vite build --ssr src/app/main.ts",
"prepack": "pnpm run build:docker-git",
"dev": "vite build --watch --ssr src/app/main.ts",
"prelint": "pnpm -C ../lib build",
"lint": "PATH=../../scripts:$PATH vibecode-linter src/",
"lint:tests": "PATH=../../scripts:$PATH vibecode-linter tests/",
"lint:effect": "PATH=../../scripts:$PATH eslint --config eslint.effect-ts-check.config.mjs .",
"prebuild:docker-git": "pnpm -C ../lib build",
"build:docker-git": "tsc -p tsconfig.build.json",
"build:docker-git": "vite build --config vite.docker-git.config.ts",
"check": "pnpm run typecheck",
"clone": "pnpm -C ../.. run clone",
"docker-git": "node dist/src/docker-git/main.js",
Expand Down Expand Up @@ -53,7 +54,6 @@
"homepage": "https://github.com/ProverCoderAI/docker-git#readme",
"packageManager": "pnpm@10.28.0",
"dependencies": {
"@effect-template/lib": "workspace:*",
"@effect/cli": "^0.73.0",
"@effect/cluster": "^0.56.1",
"@effect/experimental": "^0.58.0",
Expand All @@ -73,6 +73,7 @@
"ts-morph": "^27.0.2"
},
"devDependencies": {
"@effect-template/lib": "workspace:*",
"@biomejs/biome": "^2.3.11",
"@effect/eslint-plugin": "^0.3.2",
"@effect/language-service": "latest",
Expand Down
34 changes: 34 additions & 0 deletions packages/app/vite.docker-git.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import path from "node:path"
import { fileURLToPath } from "node:url"
import { defineConfig } from "vite"
import tsconfigPaths from "vite-tsconfig-paths"

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

export default defineConfig({
plugins: [tsconfigPaths()],
publicDir: false,
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
"@effect-template/lib": path.resolve(__dirname, "../lib/src")
}
},
build: {
target: "node20",
outDir: "dist",
sourcemap: true,
ssr: "src/docker-git/main.ts",
rollupOptions: {
output: {
format: "es",
entryFileNames: "src/docker-git/main.js",
inlineDynamicImports: true
}
}
},
ssr: {
target: "node"
}
})
106 changes: 76 additions & 30 deletions packages/lib/src/core/command-builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,69 @@ const resolvePaths = (
}
})

type CreateBehavior = {
readonly runUp: boolean
readonly openSsh: boolean
readonly force: boolean
readonly forceEnv: boolean
readonly enableMcpPlaywright: boolean
}

const resolveCreateBehavior = (raw: RawOptions): CreateBehavior => ({
runUp: raw.up ?? true,
openSsh: raw.openSsh ?? false,
force: raw.force ?? false,
forceEnv: raw.forceEnv ?? false,
enableMcpPlaywright: raw.enableMcpPlaywright ?? false
})

type BuildTemplateConfigInput = {
readonly repo: RepoBasics
readonly names: NameConfig
readonly paths: PathConfig
readonly dockerNetworkMode: CreateCommand["config"]["dockerNetworkMode"]
readonly dockerSharedNetworkName: string
readonly gitTokenLabel: string | undefined
readonly codexAuthLabel: string | undefined
readonly claudeAuthLabel: string | undefined
readonly enableMcpPlaywright: boolean
}

const buildTemplateConfig = ({
claudeAuthLabel,
codexAuthLabel,
dockerNetworkMode,
dockerSharedNetworkName,
enableMcpPlaywright,
gitTokenLabel,
names,
paths,
repo
}: BuildTemplateConfigInput): CreateCommand["config"] => ({
containerName: names.containerName,
serviceName: names.serviceName,
sshUser: repo.sshUser,
sshPort: repo.sshPort,
repoUrl: repo.repoUrl,
repoRef: repo.repoRef,
gitTokenLabel,
codexAuthLabel,
claudeAuthLabel,
targetDir: repo.targetDir,
volumeName: names.volumeName,
dockerGitPath: paths.dockerGitPath,
authorizedKeysPath: paths.authorizedKeysPath,
envGlobalPath: paths.envGlobalPath,
envProjectPath: paths.envProjectPath,
codexAuthPath: paths.codexAuthPath,
codexSharedAuthPath: paths.codexSharedAuthPath,
codexHome: paths.codexHome,
dockerNetworkMode,
dockerSharedNetworkName,
enableMcpPlaywright,
pnpmVersion: defaultTemplateConfig.pnpmVersion
})

// CHANGE: build a typed create command from raw options (CLI or API)
// WHY: share deterministic command construction across CLI and server
// QUOTE(ТЗ): "В lib ты оставляешь бизнес логику, а все CLI морду хранишь в app"
Expand All @@ -217,11 +280,7 @@ export const buildCreateCommand = (
const repo = yield* _(resolveRepoBasics(raw))
const names = yield* _(resolveNames(raw, repo.projectSlug))
const paths = yield* _(resolvePaths(raw, repo.repoPath))
const runUp = raw.up ?? true
const openSsh = raw.openSsh ?? false
const force = raw.force ?? false
const forceEnv = raw.forceEnv ?? false
const enableMcpPlaywright = raw.enableMcpPlaywright ?? false
const behavior = resolveCreateBehavior(raw)
const gitTokenLabel = normalizeGitTokenLabel(raw.gitTokenLabel)
const codexAuthLabel = normalizeAuthLabel(raw.codexTokenLabel)
const claudeAuthLabel = normalizeAuthLabel(raw.claudeTokenLabel)
Expand All @@ -233,34 +292,21 @@ export const buildCreateCommand = (
return {
_tag: "Create",
outDir: paths.outDir,
runUp,
openSsh,
force,
forceEnv,
runUp: behavior.runUp,
openSsh: behavior.openSsh,
force: behavior.force,
forceEnv: behavior.forceEnv,
waitForClone: false,
config: {
containerName: names.containerName,
serviceName: names.serviceName,
sshUser: repo.sshUser,
sshPort: repo.sshPort,
repoUrl: repo.repoUrl,
repoRef: repo.repoRef,
config: buildTemplateConfig({
repo,
names,
paths,
dockerNetworkMode,
dockerSharedNetworkName,
gitTokenLabel,
codexAuthLabel,
claudeAuthLabel,
targetDir: repo.targetDir,
volumeName: names.volumeName,
dockerGitPath: paths.dockerGitPath,
authorizedKeysPath: paths.authorizedKeysPath,
envGlobalPath: paths.envGlobalPath,
envProjectPath: paths.envProjectPath,
codexAuthPath: paths.codexAuthPath,
codexSharedAuthPath: paths.codexSharedAuthPath,
codexHome: paths.codexHome,
dockerNetworkMode,
dockerSharedNetworkName,
enableMcpPlaywright,
pnpmVersion: defaultTemplateConfig.pnpmVersion
}
enableMcpPlaywright: behavior.enableMcpPlaywright
})
}
})
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions scripts/e2e/local-package-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
set -euo pipefail

RUN_ID="$(date +%s)-$RANDOM"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
ROOT_BASE="${DOCKER_GIT_E2E_ROOT_BASE:-/tmp/docker-git-e2e-root}"
mkdir -p "$ROOT_BASE"
ROOT="$(mktemp -d "$ROOT_BASE/local-package-cli.XXXXXX")"
KEEP="${KEEP:-0}"

PACK_LOG="$ROOT/npm-pack.log"
HELP_LOG="$ROOT/docker-git-help.log"
PACKED_TARBALL=""

fail() {
echo "e2e/local-package-cli: $*" >&2
exit 1
}

on_error() {
local line="$1"
echo "e2e/local-package-cli: failed at line $line" >&2
if [[ -f "$PACK_LOG" ]]; then
echo "--- npm pack log ---" >&2
cat "$PACK_LOG" >&2 || true
fi
if [[ -f "$HELP_LOG" ]]; then
echo "--- docker-git --help log ---" >&2
cat "$HELP_LOG" >&2 || true
fi
}

cleanup() {
if [[ "$KEEP" == "1" ]]; then
echo "e2e/local-package-cli: KEEP=1 set; preserving temp dir: $ROOT" >&2
return
fi
if [[ -n "$PACKED_TARBALL" ]] && [[ -f "$PACKED_TARBALL" ]]; then
rm -f "$PACKED_TARBALL" >/dev/null 2>&1 || true
fi
rm -rf "$ROOT" >/dev/null 2>&1 || true
}

trap 'on_error $LINENO' ERR
trap cleanup EXIT

cd "$REPO_ROOT/packages/app"
npm pack --silent >"$PACK_LOG"
tarball_name="$(tail -n 1 "$PACK_LOG" | tr -d '\r')"
[[ -n "$tarball_name" ]] || fail "npm pack did not return tarball name"

PACKED_TARBALL="$REPO_ROOT/packages/app/$tarball_name"
[[ -f "$PACKED_TARBALL" ]] || fail "packed tarball not found: $PACKED_TARBALL"

dep_keys="$(tar -xOf "$PACKED_TARBALL" package/package.json | node -e 'let s="";process.stdin.on("data",(c)=>{s+=c});process.stdin.on("end",()=>{const pkg=JSON.parse(s);const deps=Object.keys(pkg.dependencies ?? {});if (deps.includes("@effect-template/lib")) {console.error("@effect-template/lib must not be a runtime dependency in packed package");process.exit(1)}process.stdout.write(deps.join(","));});')"
[[ "$dep_keys" == *"effect"* ]] || fail "packed dependency set looks invalid: $dep_keys"

mkdir -p "$ROOT/project"
cd "$ROOT/project"
npm init -y >/dev/null
pnpm add "$PACKED_TARBALL" --silent --lockfile=false
pnpm docker-git --help >"$HELP_LOG" 2>&1

grep -Fq -- "docker-git clone <url> [options]" "$HELP_LOG" \
|| fail "expected docker-git help output from local packed package"

echo "e2e/local-package-cli: local tarball install + pnpm docker-git --help OK" >&2
3 changes: 1 addition & 2 deletions scripts/e2e/run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

cases=("$@")
if [[ "${#cases[@]}" -eq 0 ]]; then
cases=("clone-cache" "login-context" "opencode-autoconnect")
cases=("local-package-cli" "clone-cache" "login-context" "opencode-autoconnect")
fi

for case_name in "${cases[@]}"; do
Expand All @@ -20,4 +20,3 @@ for case_name in "${cases[@]}"; do
done

echo "e2e/run-all: all cases OK" >&2