Compare commits

...

3 Commits
v6.0.1 ... main

Author SHA1 Message Date
5d18e53e30 update 2025-12-14 01:42:14 +00:00
9ad5222b95 update to deno 2025-12-13 13:27:51 +00:00
dba2e2ae68 chore: Remove deprecated Gitea workflows and add new CI/CD configurations 2025-10-28 06:38:02 +00:00
37 changed files with 1108 additions and 10252 deletions

View File

@@ -0,0 +1,31 @@
## SZCI {{VERSION}}
Pre-compiled binaries for multiple platforms.
### Installation
#### Option 1: Via npm (recommended)
```bash
npm install -g @ship.zone/szci
```
#### Option 2: Via installer script
```bash
curl -sSL https://code.foss.global/ship.zone/szci/raw/branch/master/install.sh | sudo bash
```
#### Option 3: Direct binary download
Download the appropriate binary for your platform from the assets below and make it executable.
### Supported Platforms
- Linux x86_64 (x64)
- Linux ARM64 (aarch64)
- macOS x86_64 (Intel)
- macOS ARM64 (Apple Silicon)
- Windows x86_64
### Checksums
SHA256 checksums are provided in `SHA256SUMS.txt` for binary verification.
### npm Package
The npm package includes automatic binary detection and installation for your platform.

122
.gitea/workflows/README.md Normal file
View File

@@ -0,0 +1,122 @@
# SZCI Gitea CI/CD Workflows
This directory contains Gitea Actions workflows for automated CI/CD of the SZCI project.
## Workflows
### 1. CI (`ci.yml`)
**Trigger:** Push to `master` branch or pull requests
**Purpose:** Continuous integration checks on every push
**Jobs:**
- **Type Check & Lint** - Validates TypeScript types and code style
- **Build Test** - Compiles binary for Linux x64 and tests execution
- **Build All Platforms** - Compiles all 5 platform binaries and uploads as artifacts
**Usage:** Automatically runs on every commit to ensure code quality
---
### 2. Release (`release.yml`)
**Trigger:** Push of version tags (e.g., `v5.0.0`)
**Purpose:** Creates GitHub releases with pre-compiled binaries
**Jobs:**
1. Validates deno.json version matches git tag
2. Compiles binaries for all 5 platforms
3. Generates SHA256 checksums
4. Creates Gitea release with binaries as assets
5. Cleans up old releases (keeps last 3)
**Usage:**
```bash
# Update version in deno.json to 6.0.1
# Then create and push tag:
git tag v6.0.1
git push origin v6.0.1
```
**Output:** Release at `https://code.foss.global/ship.zone/szci/releases/tag/v6.0.1`
---
### 3. NPM Publish (`npm-publish.yml`)
**Trigger:** Push of version tags (e.g., `v5.0.0`)
**Purpose:** Publishes package to npm registry
**Jobs:**
1. Validates deno.json version matches git tag
2. Compiles all binaries
3. Syncs package.json version
4. Creates npm package
5. Publishes to npm with access token
6. Verifies publication
**Prerequisites:**
- `NPM_TOKEN` must be set in Gitea secrets
**Usage:** Same as release workflow (automatically triggered by version tags)
**Output:** Package at `https://www.npmjs.com/package/@ship.zone/szci`
---
## Release Process
To create a new release:
1. **Update version in deno.json:**
```json
{
"version": "6.0.1"
}
```
2. **Commit the version change:**
```bash
git add deno.json
git commit -m "6.0.1"
```
3. **Create and push tag:**
```bash
git tag v6.0.1
git push origin master
git push origin v6.0.1
```
4. **Workflows run automatically:**
- `release.yml` creates Gitea release with binaries
- `npm-publish.yml` publishes to npm
5. **Verify:**
- Check https://code.foss.global/ship.zone/szci/releases
- Check https://www.npmjs.com/package/@ship.zone/szci
---
## Secrets Required
Configure these in Gitea repository settings:
- `GITHUB_TOKEN` - Gitea access token (auto-provided)
- `NPM_TOKEN` - npm publish token (must be configured)
---
## Binary Artifacts
Each workflow produces binaries for:
- Linux x86_64
- Linux ARM64
- macOS x86_64
- macOS ARM64
- Windows x86_64
Total size per release: ~4GB (5 binaries × ~800MB each)

82
.gitea/workflows/ci.yml Normal file
View File

@@ -0,0 +1,82 @@
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
check:
name: Type Check & Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Check TypeScript types
run: deno check mod.ts
- name: Lint code
run: deno lint
continue-on-error: true
- name: Format check
run: deno fmt --check
continue-on-error: true
build:
name: Build Test (Current Platform)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Compile for current platform
run: |
echo "Testing compilation for Linux x86_64..."
deno compile --allow-all --no-check \
--output szci-test \
--target x86_64-unknown-linux-gnu mod.ts
- name: Test binary execution
run: |
chmod +x szci-test
./szci-test --version
build-all:
name: Build All Platforms
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Compile all platform binaries
run: bash scripts/compile-all.sh
- name: Upload all binaries as artifact
uses: actions/upload-artifact@v3
with:
name: szci-binaries.zip
path: dist/binaries/*
retention-days: 30

View File

@@ -1,66 +0,0 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@@ -1,108 +0,0 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_LOGIN_DOCKER_GITEA: ${{secrets.NPMCI_DOCKER_REGISTRYURL_DEFAULT}}|${{ gitea.repository_owner }}|${{ secrets.GITEA_TOKEN }}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm prepare
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

View File

@@ -0,0 +1,129 @@
name: Publish to npm
on:
push:
tags:
- 'v*'
jobs:
npm-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Setup Node.js for npm publishing
uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org/'
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Verify deno.json version matches tag
run: |
DENO_VERSION=$(grep -o '"version": "[^"]*"' deno.json | cut -d'"' -f4)
TAG_VERSION="${{ steps.version.outputs.version_number }}"
echo "deno.json version: $DENO_VERSION"
echo "Tag version: $TAG_VERSION"
if [ "$DENO_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: Version mismatch!"
echo "deno.json has version $DENO_VERSION but tag is $TAG_VERSION"
exit 1
fi
- name: Compile binaries for npm package
run: |
echo "Compiling binaries for npm package..."
deno task compile
echo ""
echo "Binary sizes:"
ls -lh dist/binaries/
- name: Generate SHA256 checksums
run: |
cd dist/binaries
sha256sum * > SHA256SUMS
cat SHA256SUMS
cd ../..
- name: Sync package.json version
run: |
VERSION="${{ steps.version.outputs.version_number }}"
echo "Syncing package.json to version ${VERSION}..."
npm version ${VERSION} --no-git-tag-version --allow-same-version
echo "package.json version: $(grep '"version"' package.json | head -1)"
- name: Create npm package
run: |
echo "Creating npm package..."
npm pack
echo ""
echo "Package created:"
ls -lh *.tgz
- name: Test local installation
run: |
echo "Testing local package installation..."
PACKAGE_FILE=$(ls *.tgz)
npm install -g ${PACKAGE_FILE}
echo ""
echo "Testing szci command:"
szci --version || echo "Note: Binary execution may fail in CI environment"
echo ""
echo "Checking installed files:"
npm ls -g @ship.zone/szci || true
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "Publishing to npm registry..."
npm publish --access public
echo ""
echo "✅ Successfully published @ship.zone/szci to npm!"
echo ""
echo "Package info:"
npm view @ship.zone/szci
- name: Verify npm package
run: |
echo "Waiting for npm propagation..."
sleep 30
echo ""
echo "Verifying published package..."
npm view @ship.zone/szci
echo ""
echo "Testing installation from npm:"
npm install -g @ship.zone/szci
echo ""
echo "Package installed successfully!"
which szci || echo "Binary location check skipped"
- name: Publish Summary
run: |
echo "================================================"
echo " npm Publish Complete!"
echo "================================================"
echo ""
echo "✅ Package: @ship.zone/szci"
echo "✅ Version: ${{ steps.version.outputs.version }}"
echo ""
echo "Installation:"
echo " npm install -g @ship.zone/szci"
echo ""
echo "Registry:"
echo " https://www.npmjs.com/package/@ship.zone/szci"
echo ""

View File

@@ -0,0 +1,248 @@
name: Release
on:
push:
tags:
- 'v*'
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Verify deno.json version matches tag
run: |
DENO_VERSION=$(grep -o '"version": "[^"]*"' deno.json | cut -d'"' -f4)
TAG_VERSION="${{ steps.version.outputs.version_number }}"
echo "deno.json version: $DENO_VERSION"
echo "Tag version: $TAG_VERSION"
if [ "$DENO_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: Version mismatch!"
echo "deno.json has version $DENO_VERSION but tag is $TAG_VERSION"
exit 1
fi
- name: Compile binaries for all platforms
run: |
echo "================================================"
echo " SZCI Release Compilation"
echo " Version: ${{ steps.version.outputs.version }}"
echo "================================================"
echo ""
# Clean up old binaries and create fresh directory
rm -rf dist/binaries
mkdir -p dist/binaries
echo "→ Cleaned old binaries from dist/binaries"
echo ""
# Linux x86_64
echo "→ Compiling for Linux x86_64..."
deno compile --allow-all --no-check \
--output dist/binaries/szci-linux-x64 \
--target x86_64-unknown-linux-gnu mod.ts
echo " ✓ Linux x86_64 complete"
# Linux ARM64
echo "→ Compiling for Linux ARM64..."
deno compile --allow-all --no-check \
--output dist/binaries/szci-linux-arm64 \
--target aarch64-unknown-linux-gnu mod.ts
echo " ✓ Linux ARM64 complete"
# macOS x86_64
echo "→ Compiling for macOS x86_64..."
deno compile --allow-all --no-check \
--output dist/binaries/szci-macos-x64 \
--target x86_64-apple-darwin mod.ts
echo " ✓ macOS x86_64 complete"
# macOS ARM64
echo "→ Compiling for macOS ARM64..."
deno compile --allow-all --no-check \
--output dist/binaries/szci-macos-arm64 \
--target aarch64-apple-darwin mod.ts
echo " ✓ macOS ARM64 complete"
# Windows x86_64
echo "→ Compiling for Windows x86_64..."
deno compile --allow-all --no-check \
--output dist/binaries/szci-windows-x64.exe \
--target x86_64-pc-windows-msvc mod.ts
echo " ✓ Windows x86_64 complete"
echo ""
echo "All binaries compiled successfully!"
ls -lh dist/binaries/
- name: Generate SHA256 checksums
run: |
cd dist/binaries
sha256sum * > SHA256SUMS.txt
cat SHA256SUMS.txt
cd ../..
- name: Extract changelog for this version
id: changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
# Check if changelog.md exists
if [ ! -f changelog.md ]; then
echo "No changelog.md found, using default release notes"
cat > /tmp/release_notes.md << EOF
## SZCI $VERSION
Pre-compiled binaries for multiple platforms.
### Installation
Use the installation script:
\`\`\`bash
curl -sSL https://code.foss.global/ship.zone/szci/raw/branch/master/install.sh | sudo bash
\`\`\`
Or download the binary for your platform and make it executable.
### Supported Platforms
- Linux x86_64 (x64)
- Linux ARM64 (aarch64)
- macOS x86_64 (Intel)
- macOS ARM64 (Apple Silicon)
- Windows x86_64
### Checksums
SHA256 checksums are provided in SHA256SUMS.txt
EOF
else
# Try to extract section for this version from changelog.md
awk "/## \[$VERSION\]/,/## \[/" changelog.md | sed '$d' > /tmp/release_notes.md || cat > /tmp/release_notes.md << EOF
## SZCI $VERSION
See changelog.md for full details.
### Installation
Use the installation script:
\`\`\`bash
curl -sSL https://code.foss.global/ship.zone/szci/raw/branch/master/install.sh | sudo bash
\`\`\`
EOF
fi
echo "Release notes:"
cat /tmp/release_notes.md
- name: Delete existing release if it exists
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "Checking for existing release $VERSION..."
# Try to get existing release by tag
EXISTING_RELEASE_ID=$(curl -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://code.foss.global/api/v1/repos/ship.zone/szci/releases/tags/$VERSION" \
| jq -r '.id // empty')
if [ -n "$EXISTING_RELEASE_ID" ]; then
echo "Found existing release (ID: $EXISTING_RELEASE_ID), deleting..."
curl -X DELETE -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://code.foss.global/api/v1/repos/ship.zone/szci/releases/$EXISTING_RELEASE_ID"
echo "Existing release deleted"
sleep 2
else
echo "No existing release found, proceeding with creation"
fi
- name: Create Gitea Release
run: |
VERSION="${{ steps.version.outputs.version }}"
RELEASE_NOTES=$(cat /tmp/release_notes.md)
# Create the release
echo "Creating release for $VERSION..."
RELEASE_ID=$(curl -X POST -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
"https://code.foss.global/api/v1/repos/ship.zone/szci/releases" \
-d "{
\"tag_name\": \"$VERSION\",
\"name\": \"SZCI $VERSION\",
\"body\": $(jq -Rs . /tmp/release_notes.md),
\"draft\": false,
\"prerelease\": false
}" | jq -r '.id')
echo "Release created with ID: $RELEASE_ID"
# Upload binaries as release assets
for binary in dist/binaries/*; do
filename=$(basename "$binary")
echo "Uploading $filename..."
curl -X POST -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$binary" \
"https://code.foss.global/api/v1/repos/ship.zone/szci/releases/$RELEASE_ID/assets?name=$filename"
done
echo "All assets uploaded successfully"
- name: Clean up old releases
run: |
echo "Cleaning up old releases (keeping only last 3)..."
# Fetch all releases sorted by creation date
RELEASES=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://code.foss.global/api/v1/repos/ship.zone/szci/releases" | \
jq -r 'sort_by(.created_at) | reverse | .[3:] | .[].id')
# Delete old releases
if [ -n "$RELEASES" ]; then
echo "Found releases to delete:"
for release_id in $RELEASES; do
echo " Deleting release ID: $release_id"
curl -X DELETE -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://code.foss.global/api/v1/repos/ship.zone/szci/releases/$release_id"
done
echo "Old releases deleted successfully"
else
echo "No old releases to delete (less than 4 releases total)"
fi
echo ""
- name: Release Summary
run: |
echo "================================================"
echo " Release ${{ steps.version.outputs.version }} Complete!"
echo "================================================"
echo ""
echo "Binaries published:"
ls -lh dist/binaries/
echo ""
echo "Release URL:"
echo "https://code.foss.global/ship.zone/szci/releases/tag/${{ steps.version.outputs.version }}"
echo ""
echo "Installation command:"
echo "curl -sSL https://code.foss.global/ship.zone/szci/raw/branch/master/install.sh | sudo bash"
echo ""

1
.serena/.gitignore vendored
View File

@@ -1 +0,0 @@
/cache

View File

@@ -1,71 +0,0 @@
# language of the project (csharp, python, rust, java, typescript, go, cpp, or ruby)
# * For C, use cpp
# * For JavaScript, use typescript
# Special requirements:
# * csharp: Requires the presence of a .sln file in the project folder.
language: typescript
# the encoding used by text files in the project
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
encoding: "utf-8"
# whether to use the project's gitignore file to ignore files
# Added on 2025-04-07
ignore_all_files_in_gitignore: true
# list of additional paths to ignore
# same syntax as gitignore, so you can use * and **
# Was previously called `ignored_dirs`, please update your config if you are using that.
# Added (renamed) on 2025-04-07
ignored_paths: []
# whether the project is in read-only mode
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
# Added on 2025-04-18
read_only: false
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
# Below is the complete list of tools for convenience.
# To make sure you have the latest list of tools, and to view their descriptions,
# execute `uv run scripts/print_tool_overview.py`.
#
# * `activate_project`: Activates a project by name.
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
# * `create_text_file`: Creates/overwrites a file in the project directory.
# * `delete_lines`: Deletes a range of lines within a file.
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
# * `execute_shell_command`: Executes a shell command.
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
# * `initial_instructions`: Gets the initial instructions for the current project.
# Should only be used in settings where the system prompt cannot be set,
# e.g. in clients you have no control over, like Claude Desktop.
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
# * `insert_at_line`: Inserts content at a given line in a file.
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
# * `list_memories`: Lists memories in Serena's project-specific memory store.
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
# * `read_file`: Reads a file within the project directory.
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
# * `remove_project`: Removes a project from the Serena configuration.
# * `replace_lines`: Replaces a range of lines within a file with new content.
# * `replace_symbol_body`: Replaces the full definition of a symbol.
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
# * `search_for_pattern`: Performs a search for a pattern in the project.
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
# * `switch_modes`: Activates modes by providing a list of their names
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
excluded_tools: []
# initial prompt for the project. It will always be given to the LLM upon activating the project
# (contrary to the memories, which are loaded on demand).
initial_prompt: ""
project_name: "npmci"

View File

@@ -5,9 +5,9 @@
"schema": {
"type": "object",
"properties": {
"npmci": {
"szci": {
"type": "object",
"description": "settings for npmci"
"description": "settings for szci"
},
"gitzone": {
"type": "object",

View File

@@ -1,21 +1,21 @@
{
"npmci": {
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmAccessLevel": "public",
"npmRegistryUrl": "registry.npmjs.org"
},
"npmdocker": {
"@git.zone/tsdocker": {
"baseImage": "hosttoday/ht-docker-node:npmci",
"command": "npmci test stable"
"command": "szci test stable"
},
"gitzone": {
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "ship.zone",
"gitrepo": "npmci",
"gitrepo": "szci",
"description": "A tool to streamline Node.js and Docker workflows within CI environments, particularly GitLab CI, providing various CI/CD utilities.",
"npmPackagename": "@ship.zone/npmci",
"npmPackagename": "@ship.zone/szci",
"license": "MIT",
"keywords": [
"Node.js",

9733
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +0,0 @@
onlyBuiltDependencies:
- esbuild
- mongodb-memory-server
- puppeteer

View File

@@ -1,2 +1,31 @@
- focus on cli usage in CI environments.
- show Gitlab CI, GitHub CI and Gitea CI examples.
## Deno Migration Status
The project has been fully migrated from Node.js to Deno runtime.
### Environment Variables
All environment variables have been rebranded from NPMCI_* to SZCI_*:
| Old Name | New Name |
|----------|----------|
| `NPMCI_COMPUTED_REPOURL` | `SZCI_COMPUTED_REPOURL` |
| `NPMCI_URL_CLOUDLY` | `SZCI_URL_CLOUDLY` |
| `NPMCI_GIT_GITHUBTOKEN` | `SZCI_GIT_GITHUBTOKEN` |
| `NPMCI_GIT_GITHUBGROUP` | `SZCI_GIT_GITHUBGROUP` |
| `NPMCI_GIT_GITHUB` | `SZCI_GIT_GITHUB` |
| `NPMCI_TRIGGER_*` | `SZCI_TRIGGER_*` |
| `NPMCI_LOGIN_CLOUDRON` | `SZCI_LOGIN_CLOUDRON` |
| `NPMCI_SSHKEY_*` | `SZCI_SSHKEY_*` |
| `NPMCI_LOGIN_DOCKER*` | `SZCI_LOGIN_DOCKER*` |
| `NPMCI_TOKEN_NPM*` | `SZCI_TOKEN_NPM*` |
| `NPMTS_TEST` | `SZCI_TEST` |
| `DEBUG_NPMCI` | `DEBUG_SZCI` |
### Runtime
- Uses Deno APIs (`Deno.env`, `Deno.cwd`, `Deno.exit`)
- Logger runtime set to 'deno'
- Dynamic imports use `.ts` extensions

View File

@@ -1,17 +1,29 @@
// Disable TLS certificate validation for testing
Deno.env.set('NODE_TLS_REJECT_UNAUTHORIZED', '0');
Deno.env.set('SZCI_TEST', 'true');
Deno.env.set('CI_REPOSITORY_URL', 'https://yyyyyy:xxxxxxxx@gitlab.com/mygroup/myrepo.git');
import { CloudlyConnector } from '../ts/connector.cloudly/cloudlyconnector.ts';
import { Szci } from '../ts/szci.classes.szci.ts';
Deno.test('should be able to announce a container to cloudly', async () => {
const cloudlyConnector = new CloudlyConnector(null);
await cloudlyConnector.announceDockerContainer(
{
registryUrl: 'registry.losssless.com',
tag: 'testcontainer',
version: 'x.x.x',
labels: [],
},
'cloudly.lossless.one'
);
Deno.test({
name: 'should be able to announce a container to cloudly',
sanitizeResources: false,
sanitizeOps: false,
fn: async () => {
// Create a proper Szci instance for the connector
const szciInstance = new Szci();
await szciInstance.start();
const cloudlyConnector = new CloudlyConnector(szciInstance);
await cloudlyConnector.announceDockerContainer(
{
registryUrl: 'registry.losssless.com',
tag: 'testcontainer',
version: 'x.x.x',
labels: [],
},
'cloudly.lossless.one'
);
},
});

View File

@@ -1,14 +1,14 @@
import { assertEquals } from '@std/assert';
import { assertEquals, assertExists } from '@std/assert';
import * as path from '@std/path';
import * as smartpath from '@push.rocks/smartpath';
// Set up test environment
Deno.env.set('NPMTS_TEST', 'true');
Deno.env.set('NPMCI_URL_CLOUDLY', 'localhost');
// Set up test environment with the NEW SZCI environment variables
Deno.env.set('SZCI_TEST', 'true');
Deno.env.set('SZCI_URL_CLOUDLY', 'localhost');
Deno.env.set('CI_REPOSITORY_URL', 'https://yyyyyy:xxxxxxxx@gitlab.com/mygroup/myrepo.git');
Deno.env.set('CI_BUILD_TOKEN', 'kjlkjfiudofiufs');
Deno.env.set('NPMCI_LOGIN_DOCKER', 'docker.io|someuser|somepass');
Deno.env.set('NPMCI_SSHKEY_1', 'hostString|somePrivKey|##');
Deno.env.set('SZCI_LOGIN_DOCKER', 'docker.io|someuser|somepass');
Deno.env.set('SZCI_SSHKEY_1', 'hostString|somePrivKey|##');
// Get the test assets directory
const testAssetsDir = path.join(smartpath.get.dirnameFromImportMetaUrl(import.meta.url), 'assets/');
@@ -51,44 +51,81 @@ Deno.test('should read a directory of Dockerfiles', async () => {
szciInstance.dockerManager
);
sortableArray = readDockerfilesArray;
assertEquals(readDockerfilesArray[1].version, 'sometag1');
// The test assets directory should have multiple Dockerfiles
assertExists(readDockerfilesArray, 'readDockerfilesArray should exist');
assertEquals(readDockerfilesArray.length > 0, true, 'Should find at least one Dockerfile');
// Find the sometag1 dockerfile
const sometag1Dockerfile = readDockerfilesArray.find(df => df.version === 'sometag1');
assertExists(sometag1Dockerfile, 'Should find Dockerfile_sometag1');
assertEquals(sometag1Dockerfile?.version, 'sometag1');
});
Deno.test('should sort an array of Dockerfiles', async () => {
// Use the sortableArray from previous test, or create a new one if empty
if (!sortableArray || sortableArray.length === 0) {
const szciInstance = new Szci();
await szciInstance.start();
sortableArray = await DockerfileModule.Dockerfile.readDockerfiles(szciInstance.dockerManager);
}
const sortedArray = await DockerfileModule.Dockerfile.sortDockerfiles(sortableArray);
console.log(sortedArray);
assertExists(sortedArray, 'sortedArray should exist');
console.log('Sorted dockerfiles:', sortedArray.map(df => df.cleanTag));
});
Deno.test('should build all Dockerfiles', async () => {
const szciInstance = new Szci();
await szciInstance.start();
await szciInstance.dockerManager.handleCli({
_: ['docker', 'build'],
});
Deno.test({
name: 'should build all Dockerfiles',
// Allow resource leaks since smartshell creates background processes
sanitizeResources: false,
sanitizeOps: false,
fn: async () => {
const szciInstance = new Szci();
await szciInstance.start();
await szciInstance.dockerManager.handleCli({
_: ['docker', 'build'],
});
},
});
Deno.test('should test all Dockerfiles', async () => {
const szciInstance = new Szci();
await szciInstance.start();
await szciInstance.dockerManager.handleCli({
_: ['docker', 'test'],
});
Deno.test({
name: 'should test all Dockerfiles',
// Allow resource leaks since smartshell creates background processes
sanitizeResources: false,
sanitizeOps: false,
fn: async () => {
const szciInstance = new Szci();
await szciInstance.start();
await szciInstance.dockerManager.handleCli({
_: ['docker', 'test'],
});
},
});
Deno.test('should login docker daemon', async () => {
const szciInstance = new Szci();
await szciInstance.start();
await szciInstance.dockerManager.handleCli({
_: ['docker', 'login'],
});
Deno.test({
name: 'should login docker daemon',
// Allow resource leaks since smartshell creates background processes
sanitizeResources: false,
sanitizeOps: false,
fn: async () => {
const szciInstance = new Szci();
await szciInstance.start();
await szciInstance.dockerManager.handleCli({
_: ['docker', 'login'],
});
},
});
// ===
// SSH
// ===
Deno.test('should prepare SSH keys', async () => {
const npmciModSsh = await import('../ts/mod_ssh/index.ts');
await npmciModSsh.handleCli({
// Ensure test mode is set so we don't actually write to disk
Deno.env.set('SZCI_TEST', 'true');
const szciModSsh = await import('../ts/mod_ssh/index.ts');
await szciModSsh.handleCli({
_: ['ssh', 'prepare'],
});
});
@@ -96,18 +133,24 @@ Deno.test('should prepare SSH keys', async () => {
// ====
// node
// ====
Deno.test('should install a certain version of node', async () => {
const szciInstance = new Szci();
await szciInstance.start();
await szciInstance.nodejsManager.handleCli({
_: ['node', 'install', 'stable'],
});
await szciInstance.nodejsManager.handleCli({
_: ['node', 'install', 'lts'],
});
await szciInstance.nodejsManager.handleCli({
_: ['node', 'install', 'legacy'],
});
Deno.test({
name: 'should install a certain version of node',
// Allow resource leaks for this test since nvm creates background processes
sanitizeResources: false,
sanitizeOps: false,
fn: async () => {
const szciInstance = new Szci();
await szciInstance.start();
await szciInstance.nodejsManager.handleCli({
_: ['node', 'install', 'stable'],
});
await szciInstance.nodejsManager.handleCli({
_: ['node', 'install', 'lts'],
});
await szciInstance.nodejsManager.handleCli({
_: ['node', 'install', 'legacy'],
});
},
});
// Restore original working directory after all tests

View File

@@ -17,7 +17,7 @@ export class CloudlyConnector {
optionsArg: plugins.tsclass.container.IContainer,
testCloudlyUrlArg?: string
) {
const cloudlyUrl = testCloudlyUrlArg || this.szciRef.npmciConfig.getConfig().urlCloudly;
const cloudlyUrl = testCloudlyUrlArg || this.szciRef.szciConfig.getConfig().urlCloudly;
if (!cloudlyUrl) {
logger.log(
'warn',

View File

@@ -1,9 +1,9 @@
import { Szci } from './szci.classes.szci.ts';
import { Dockerfile } from './manager.docker/mod.classes.dockerfile.ts';
export const szciInstance = new Npmci();
export const szciInstance = new Szci();
export { Dockerfile, Npmci };
export { Dockerfile, Szci };
export const runCli = async () => {
await szciInstance.start();

View File

@@ -23,12 +23,12 @@ export class SzciCloudronManager {
await this.deploy();
break;
default:
logger.log('error', `>>npmci cloudron ...<< action >>${action}<< not supported`);
logger.log('error', `>>szci cloudron ...<< action >>${action}<< not supported`);
}
} else {
logger.log(
'info',
`>>npmci cloudron ...<< cli arguments invalid... Please read the documentation.`
`>>szci cloudron ...<< cli arguments invalid... Please read the documentation.`
);
}
};
@@ -44,14 +44,18 @@ export class SzciCloudronManager {
logger.log('ok', 'cloudron cli installed');
// lets set the version in the CloudronManifest file
await this.prepareCloudronManifest(this.szciRef.npmciConfig.getConfig().projectInfo.npm.version);
await this.prepareCloudronManifest(this.szciRef.szciConfig.getConfig().projectInfo.npm.version);
logger.log('ok', 'CloudronManifest prepared');
// lets figure out the docker image tag
const dockerImageTag = await this.szciRef.npmciConfig.kvStorage.readKey('latestPushedDockerTag');
const appName = this.szciRef.npmciConfig.getConfig().cloudronAppName;
const dockerImageTag = await this.szciRef.szciConfig.kvStorage.readKey('latestPushedDockerTag');
const appName = this.szciRef.szciConfig.getConfig().cloudronAppName;
const cloudronEnvVar = Deno.env.get("NPMCI_LOGIN_CLOUDRON");
const cloudronEnvVar = Deno.env.get("SZCI_LOGIN_CLOUDRON");
if (!cloudronEnvVar) {
logger.log('error', 'SZCI_LOGIN_CLOUDRON environment variable is not set');
Deno.exit(1);
}
const cloudronServer = cloudronEnvVar.split('|')[0];
const cloudronToken = cloudronEnvVar.split('|')[1];
await bash(`cloudron update --server ${cloudronServer} --token ${cloudronToken} --image ${dockerImageTag} --app ${appName}`);

View File

@@ -11,7 +11,7 @@ import { RegistryStorage } from './mod.classes.registrystorage.ts';
export class SzciDockerManager {
public szciRef: Szci;
public npmciRegistryStorage = new RegistryStorage();
public szciRegistryStorage = new RegistryStorage();
constructor(szciArg: Szci) {
this.szciRef = szciArg;
@@ -42,12 +42,12 @@ export class SzciDockerManager {
await this.pull(argvArg);
break;
default:
logger.log('error', `>>npmci docker ...<< action >>${action}<< not supported`);
logger.log('error', `>>szci docker ...<< action >>${action}<< not supported`);
}
} else {
logger.log(
'info',
`>>npmci docker ...<< cli arguments invalid... Please read the documentation.`
`>>szci docker ...<< cli arguments invalid... Please read the documentation.`
);
}
};
@@ -69,7 +69,7 @@ export class SzciDockerManager {
*/
public login = async () => {
await this.prepare();
await this.npmciRegistryStorage.loginAll();
await this.szciRegistryStorage.loginAll();
};
/**
@@ -83,11 +83,11 @@ export class SzciDockerManager {
logger.log('error', 'Running in Gitlab CI, but no registry token specified by gitlab!');
Deno.exit(1);
}
this.npmciRegistryStorage.addRegistry(
this.szciRegistryStorage.addRegistry(
new DockerRegistry({
registryUrl: 'registry.gitlab.com',
username: 'gitlab-ci-token',
password: Deno.env.get("CI_JOB_TOKEN"),
password: Deno.env.get("CI_JOB_TOKEN")!,
})
);
}
@@ -95,9 +95,9 @@ export class SzciDockerManager {
// handle registries
await plugins.smartobject.forEachMinimatch(
Deno.env.toObject(),
'NPMCI_LOGIN_DOCKER*',
'SZCI_LOGIN_DOCKER*',
async (envString: string) => {
this.npmciRegistryStorage.addRegistry(DockerRegistry.fromEnvString(envString));
this.szciRegistryStorage.addRegistry(DockerRegistry.fromEnvString(envString));
}
);
return;
@@ -115,14 +115,14 @@ export class SzciDockerManager {
if (argvArg._.length >= 3 && argvArg._[2] !== 'npmextra') {
dockerRegistryUrls.push(argvArg._[2]);
} else {
if (this.szciRef.npmciConfig.getConfig().dockerRegistries.length === 0) {
if (this.szciRef.szciConfig.getConfig().dockerRegistries.length === 0) {
logger.log(
'warn',
`There are no docker registries listed in npmextra.json! This is strange!`
);
}
dockerRegistryUrls = dockerRegistryUrls.concat(
this.szciRef.npmciConfig.getConfig().dockerRegistries
this.szciRef.szciConfig.getConfig().dockerRegistries
);
}
@@ -137,7 +137,7 @@ export class SzciDockerManager {
const dockerfileArray = await Dockerfile.readDockerfiles(this)
.then(Dockerfile.sortDockerfiles)
.then(Dockerfile.mapDockerfiles);
const dockerRegistryToPushTo = await this.npmciRegistryStorage.getRegistryByUrl(
const dockerRegistryToPushTo = await this.szciRegistryStorage.getRegistryByUrl(
dockerRegistryUrl
);
if (!dockerRegistryToPushTo) {
@@ -163,7 +163,7 @@ export class SzciDockerManager {
if (argvArg._.length >= 4) {
suffix = argvArg._[3];
}
const localDockerRegistry = await this.npmciRegistryStorage.getRegistryByUrl(registryUrlArg);
const localDockerRegistry = await this.szciRegistryStorage.getRegistryByUrl(registryUrlArg);
const dockerfileArray = await Dockerfile.readDockerfiles(this)
.then(Dockerfile.sortDockerfiles)
.then(Dockerfile.mapDockerfiles);

View File

@@ -10,7 +10,7 @@ import { SzciDockerManager } from './index.ts';
import { Szci } from '../szci.classes.szci.ts';
/**
* class Dockerfile represents a Dockerfile on disk in npmci
* class Dockerfile represents a Dockerfile on disk in szci
*/
export class Dockerfile {
// STATIC
@@ -20,16 +20,16 @@ export class Dockerfile {
* @returns Promise<Dockerfile[]>
*/
public static async readDockerfiles(
npmciDockerManagerRefArg: SzciDockerManager
szciDockerManagerRefArg: SzciDockerManager
): Promise<Dockerfile[]> {
const fileTree = await plugins.smartfile.fs.listFileTree(paths.cwd, 'Dockerfile*');
const fileTree = await plugins.smartfile.fs.listFileTree(paths.getCwd(), 'Dockerfile*');
// create the Dockerfile array
const readDockerfilesArray: Dockerfile[] = [];
logger.log('info', `found ${fileTree.length} Dockerfiles:`);
console.log(fileTree);
for (const dockerfilePath of fileTree) {
const myDockerfile = new Dockerfile(npmciDockerManagerRefArg, {
const myDockerfile = new Dockerfile(szciDockerManagerRefArg, {
filePath: dockerfilePath,
read: true,
});
@@ -61,7 +61,7 @@ export class Dockerfile {
// Check if the baseImage is among the local Dockerfiles
if (tagToDockerfile.has(baseImage)) {
const baseDockerfile = tagToDockerfile.get(baseImage);
const baseDockerfile = tagToDockerfile.get(baseImage)!;
dependencies.push(baseDockerfile);
dockerfile.localBaseImageDependent = true;
dockerfile.localBaseDockerfile = baseDockerfile;
@@ -96,7 +96,7 @@ export class Dockerfile {
}
});
} catch (error) {
logger.log('error', error.message);
logger.log('error', (error as Error).message);
throw error;
}
@@ -167,7 +167,7 @@ export class Dockerfile {
}
versionString = versionString.replace(
'##version##',
dockerfileInstanceArg.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm
dockerfileInstanceArg.szciDockerManagerRef.szciRef.szciConfig.getConfig().projectInfo.npm
.version
);
return versionString;
@@ -236,7 +236,7 @@ export class Dockerfile {
* returns the docker tag
*/
public static getDockerTagString(
npmciDockerManagerRef: SzciDockerManager,
szciDockerManagerRef: SzciDockerManager,
registryArg: string,
repoArg: string,
versionArg: string,
@@ -244,7 +244,7 @@ export class Dockerfile {
): string {
// determine wether the repo should be mapped accordingly to the registry
const mappedRepo =
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerRegistryRepoMap[registryArg];
szciDockerManagerRef.szciRef.szciConfig.getConfig().dockerRegistryRepoMap[registryArg];
const repo = (() => {
if (mappedRepo) {
return mappedRepo;
@@ -264,15 +264,15 @@ export class Dockerfile {
}
public static async getDockerBuildArgs(
npmciDockerManagerRef: SzciDockerManager
szciDockerManagerRef: SzciDockerManager
): Promise<string> {
logger.log('info', 'checking for env vars to be supplied to the docker build');
let buildArgsString: string = '';
for (const dockerArgKey of Object.keys(
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerBuildargEnvMap
szciDockerManagerRef.szciRef.szciConfig.getConfig().dockerBuildargEnvMap
)) {
const dockerArgOuterEnvVar =
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerBuildargEnvMap[dockerArgKey];
szciDockerManagerRef.szciRef.szciConfig.getConfig().dockerBuildargEnvMap[dockerArgKey];
logger.log(
'note',
`docker ARG "${dockerArgKey}" maps to outer env var "${dockerArgOuterEnvVar}"`
@@ -284,31 +284,31 @@ export class Dockerfile {
}
// INSTANCE
public npmciDockerManagerRef: SzciDockerManager;
public szciDockerManagerRef: SzciDockerManager;
public filePath: string;
public filePath!: string;
public repo: string;
public version: string;
public cleanTag: string;
public buildTag: string;
public pushTag: string;
public pushTag!: string;
public containerName: string;
public content: string;
public content!: string;
public baseImage: string;
public localBaseImageDependent: boolean;
public localBaseDockerfile: Dockerfile;
public localBaseDockerfile!: Dockerfile;
constructor(
dockerManagerRefArg: SzciDockerManager,
options: { filePath?: string; fileContents?: string | Buffer; read?: boolean }
options: { filePath?: string; fileContents?: string | Uint8Array; read?: boolean }
) {
this.npmciDockerManagerRef = dockerManagerRefArg;
this.filePath = options.filePath;
this.szciDockerManagerRef = dockerManagerRefArg;
this.filePath = options.filePath!;
this.repo =
this.npmciDockerManagerRef.szciRef.npmciEnv.repo.user +
this.szciDockerManagerRef.szciRef.szciEnv.repo.user +
'/' +
this.npmciDockerManagerRef.szciRef.npmciEnv.repo.repo;
this.version = Dockerfile.dockerFileVersion(this, plugins.path.parse(options.filePath).base);
this.szciDockerManagerRef.szciRef.szciEnv.repo.repo;
this.version = Dockerfile.dockerFileVersion(this, plugins.path.parse(this.filePath).base);
this.cleanTag = this.repo + ':' + this.version;
this.buildTag = this.cleanTag;
@@ -325,9 +325,9 @@ export class Dockerfile {
*/
public async build() {
logger.log('info', 'now building Dockerfile for ' + this.cleanTag);
const buildArgsString = await Dockerfile.getDockerBuildArgs(this.npmciDockerManagerRef);
const buildArgsString = await Dockerfile.getDockerBuildArgs(this.szciDockerManagerRef);
const buildCommand = `docker build --label="version=${
this.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm.version
this.szciDockerManagerRef.szciRef.szciConfig.getConfig().projectInfo.npm.version
}" -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
await bash(buildCommand);
return;
@@ -336,9 +336,9 @@ export class Dockerfile {
/**
* pushes the Dockerfile to a registry
*/
public async push(dockerRegistryArg: DockerRegistry, versionSuffix: string = null) {
public async push(dockerRegistryArg: DockerRegistry, versionSuffix?: string) {
this.pushTag = Dockerfile.getDockerTagString(
this.npmciDockerManagerRef,
this.szciDockerManagerRef,
dockerRegistryArg.registryUrl,
this.repo,
this.version,
@@ -350,13 +350,13 @@ export class Dockerfile {
await bash(`docker inspect --format="{{index .RepoDigests 0}}" ${this.pushTag}`)
).split('@')[1];
console.log(`The image ${this.pushTag} has digest ${imageDigest}`);
await this.npmciDockerManagerRef.szciRef.cloudlyConnector.announceDockerContainer({
await this.szciDockerManagerRef.szciRef.cloudlyConnector.announceDockerContainer({
registryUrl: this.pushTag,
tag: this.buildTag,
labels: [],
version: this.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm.version,
version: this.szciDockerManagerRef.szciRef.szciConfig.getConfig().projectInfo.npm.version,
});
await this.npmciDockerManagerRef.szciRef.npmciConfig.kvStorage.writeKey(
await this.szciDockerManagerRef.szciRef.szciConfig.kvStorage.writeKey(
'latestPushedDockerTag',
this.pushTag
);
@@ -365,9 +365,9 @@ export class Dockerfile {
/**
* pulls the Dockerfile from a registry
*/
public async pull(registryArg: DockerRegistry, versionSuffixArg: string = null) {
public async pull(registryArg: DockerRegistry, versionSuffixArg?: string) {
const pullTag = Dockerfile.getDockerTagString(
this.npmciDockerManagerRef,
this.szciDockerManagerRef,
registryArg.registryUrl,
this.repo,
this.version,
@@ -386,13 +386,13 @@ export class Dockerfile {
if (testFileExists) {
// run tests
await bash(
`docker run --name npmci_test_container --entrypoint="bash" ${this.buildTag} -c "mkdir /npmci_test"`
`docker run --name szci_test_container --entrypoint="bash" ${this.buildTag} -c "mkdir /szci_test"`
);
await bash(`docker cp ${testFile} npmci_test_container:/npmci_test/test.sh`);
await bash(`docker commit npmci_test_container npmci_test_image`);
await bash(`docker run --entrypoint="bash" npmci_test_image -x /npmci_test/test.sh`);
await bash(`docker rm npmci_test_container`);
await bash(`docker rmi --force npmci_test_image`);
await bash(`docker cp ${testFile} szci_test_container:/szci_test/test.sh`);
await bash(`docker commit szci_test_container szci_test_image`);
await bash(`docker run --entrypoint="bash" szci_test_image -x /szci_test/test.sh`);
await bash(`docker rm szci_test_container`);
await bash(`docker rmi --force szci_test_image`);
} else {
logger.log('warn', 'skipping tests for ' + this.cleanTag + ' because no testfile was found!');
}

View File

@@ -24,7 +24,6 @@ export class DockerRegistry {
if (dockerRegexResultArray.length !== 3) {
logger.log('error', 'malformed docker env var...');
Deno.exit(1);
return;
}
const registryUrl = dockerRegexResultArray[0].replace('https://', '').replace('http://', '');
const username = dockerRegexResultArray[1];

View File

@@ -22,20 +22,20 @@ export class SzciGitManager {
await this.mirror();
break;
default:
logger.log('error', `npmci git -> action >>${action}<< not supported!`);
logger.log('error', `szci git -> action >>${action}<< not supported!`);
}
} else {
logger.log('info', `npmci git -> cli arguments invalid! Please read the documentation.`);
logger.log('info', `szci git -> cli arguments invalid! Please read the documentation.`);
}
};
public mirror = async () => {
const githubToken = Deno.env.get("NPMCI_GIT_GITHUBTOKEN");
const githubUser = Deno.env.get("NPMCI_GIT_GITHUBGROUP") || this.szciRef.npmciEnv.repo.user;
const githubRepo = Deno.env.get("NPMCI_GIT_GITHUB") || this.szciRef.npmciEnv.repo.repo;
const githubToken = Deno.env.get("SZCI_GIT_GITHUBTOKEN");
const githubUser = Deno.env.get("SZCI_GIT_GITHUBGROUP") || this.szciRef.szciEnv.repo.user;
const githubRepo = Deno.env.get("SZCI_GIT_GITHUB") || this.szciRef.szciEnv.repo.repo;
if (
this.szciRef.npmciConfig.getConfig().projectInfo.npm.packageJson.private === true ||
this.szciRef.npmciConfig.getConfig().npmAccessLevel === 'private'
this.szciRef.szciConfig.getConfig().projectInfo.npm.packageJson.private === true ||
this.szciRef.szciConfig.getConfig().npmAccessLevel === 'private'
) {
logger.log(
'warn',
@@ -64,7 +64,7 @@ export class SzciGitManager {
// remove old mirrors
await bashNoError('git remote rm mirror');
} else {
logger.log('error', `cannot find NPMCI_GIT_GITHUBTOKEN env var!`);
logger.log('error', `cannot find SZCI_GIT_GITHUBTOKEN env var!`);
Deno.exit(1);
}
};

View File

@@ -24,13 +24,13 @@ export class SzciNodeJsManager {
await this.install(argvArg._[2]);
break;
default:
logger.log('error', `>>npmci node ...<< action >>${action}<< not supported`);
logger.log('error', `>>szci node ...<< action >>${action}<< not supported`);
Deno.exit(1);
}
} else {
logger.log(
'error',
`>>npmci node ...<< cli arguments invalid... Please read the documentation.`
`>>szci node ...<< cli arguments invalid... Please read the documentation.`
);
Deno.exit(1);
}
@@ -64,7 +64,7 @@ export class SzciNodeJsManager {
await bash('npm -v');
// lets look for further config
const config = await this.szciRef.npmciConfig.getConfig();
const config = await this.szciRef.szciConfig.getConfig();
logger.log('info', 'Now checking for needed global npm tools...');
for (const npmTool of config.npmGlobalTools) {
logger.log('info', `Checking for global "${npmTool}"`);

View File

@@ -36,13 +36,13 @@ export class SzciNpmManager {
await this.publish();
break;
default:
logger.log('error', `>>npmci npm ...<< action >>${action}<< not supported`);
logger.log('error', `>>szci npm ...<< action >>${action}<< not supported`);
Deno.exit(1);
}
} else {
logger.log(
'info',
`>>npmci npm ...<< cli arguments invalid... Please read the documentation.`
`>>szci npm ...<< cli arguments invalid... Please read the documentation.`
);
Deno.exit(1);
}
@@ -53,11 +53,11 @@ export class SzciNpmManager {
*/
public async prepare() {
logger.log('info', 'running >>npm prepare<<');
const config = this.szciRef.npmciConfig.getConfig();
const config = this.szciRef.szciConfig.getConfig();
let npmrcFileString: string = '';
await plugins.smartobject.forEachMinimatch(
Deno.env.toObject(),
'NPMCI_TOKEN_NPM*',
'SZCI_TOKEN_NPM*',
(npmEnvArg: string) => {
if (!npmEnvArg) {
logger.log('note','found empty token...');
@@ -103,11 +103,11 @@ export class SzciNpmManager {
let npmAccessCliString = ``;
let npmRegistryCliString = ``;
let publishVerdaccioAsWell = false;
const config = this.szciRef.npmciConfig.getConfig();
const config = this.szciRef.szciConfig.getConfig();
const availableRegistries: string[] = [];
await plugins.smartobject.forEachMinimatch(
Deno.env.toObject(),
'NPMCI_TOKEN_NPM*',
'SZCI_TOKEN_NPM*',
(npmEnvArg: string) => {
availableRegistries.push(npmEnvArg.split('|')[0]);
}
@@ -166,7 +166,7 @@ export class SzciNpmManager {
logger.log('success', `Nice!!! The build for the publication was successfull!`);
logger.log('info', `Lets clean up so we don't publish any packages that don't belong to us:`);
// -> clean up before we publish stuff
await bashNoError(`rm -r ./.npmci_cache`);
await bashNoError(`rm -r ./.szci_cache`);
await bash(`rm -r ./node_modules`);
logger.log('success', `Cleaned up!:`);

View File

@@ -1,10 +1,20 @@
import * as plugins from './mod.plugins.ts';
import * as paths from '../szci.paths.ts';
import { logger } from '../szci.logging.ts';
/**
* cleans npmci config files
* Cleans szci config files from the project directory
*/
export let clean = async (): Promise<void> => {
plugins.smartfile.fs.removeSync(paths.SzciPackageConfig);
return;
export const clean = async (): Promise<void> => {
try {
if (plugins.smartfile.fs.fileExistsSync(paths.SzciPackageConfig)) {
plugins.smartfile.fs.removeSync(paths.SzciPackageConfig);
logger.log('ok', 'Cleaned szci config files');
} else {
logger.log('info', 'No szci config files to clean');
}
} catch (error) {
logger.log('error', `Failed to clean config files: ${(error as Error).message}`);
throw error;
}
};

View File

@@ -1,15 +1,30 @@
import * as plugins from './mod.plugins.ts';
import { bash } from '../szci.bash.ts';
import { logger } from '../szci.logging.ts';
export let command = async () => {
let wrappedCommand: string = '';
let argvArray = ['deno', 'mod.ts', ...Deno.args];
for (let i = 3; i < argvArray.length; i++) {
wrappedCommand = wrappedCommand + argvArray[i];
if (i + 1 !== argvArray.length) {
wrappedCommand = wrappedCommand + ' ';
}
/**
* Executes a wrapped command passed via CLI arguments.
* Usage: szci command <your-command-here>
*
* This allows running arbitrary commands through szci's bash wrapper
* which handles nvm and other environment setup.
*/
export const command = async (): Promise<void> => {
// Skip 'deno', 'mod.ts', 'command' and get the rest
const commandArgs = Deno.args.slice(1); // Skip 'command'
if (commandArgs.length === 0) {
logger.log('error', 'No command specified. Usage: szci command <your-command>');
Deno.exit(1);
}
const wrappedCommand = commandArgs.join(' ');
logger.log('info', `Executing command: ${wrappedCommand}`);
try {
await bash(wrappedCommand);
logger.log('ok', 'Command executed successfully');
} catch (error) {
logger.log('error', `Command failed: ${(error as Error).message}`);
throw error;
}
await bash(wrappedCommand);
return;
};

View File

@@ -5,11 +5,16 @@ import { Szci } from '../szci.classes.szci.ts';
export const handleCli = async (szciRefArg: Szci, argvArg: any) => {
logger.log('info', 'checking execution context');
const presentRunnerTags = Deno.env.get("CI_RUNNER_TAGS").split(',').map((stringArg) =>
const ciRunnerTags = Deno.env.get("CI_RUNNER_TAGS");
if (!ciRunnerTags) {
logger.log('error', 'CI_RUNNER_TAGS environment variable is not set');
Deno.exit(1);
}
const presentRunnerTags = ciRunnerTags.split(',').map((stringArg) =>
stringArg.trim()
);
let allDesiredGitlabRunnerTagsPresent = true;
for (const desiredRunnerTag of szciRefArg.npmciConfig.getConfig().gitlabRunnerTags) {
for (const desiredRunnerTag of szciRefArg.szciConfig.getConfig().gitlabRunnerTags) {
if (!presentRunnerTags.includes(desiredRunnerTag)) {
allDesiredGitlabRunnerTagsPresent = false;
logger.log(

View File

@@ -1,10 +1,22 @@
import { logger } from '../szci.logging.ts';
import * as plugins from './mod.plugins.ts';
let sshInstance: plugins.smartssh.SshInstance;
export let handleCli = async (argvArg: any) => {
/**
* Interface for CLI arguments
*/
interface ICliArgs {
_: string[];
[key: string]: unknown;
}
/**
* Handle SSH CLI commands
*/
export const handleCli = async (argvArg: ICliArgs): Promise<void> => {
if (argvArg._.length >= 2) {
const action: string = argvArg._[1];
const action = argvArg._[1];
switch (action) {
case 'prepare':
await prepare();
@@ -14,51 +26,72 @@ export let handleCli = async (argvArg: any) => {
Deno.exit(1);
}
} else {
logger.log('error', `>>npmci ssh ...<< please specify an action!`);
logger.log('error', `>>szci ssh ...<< please specify an action!`);
Deno.exit(1);
}
};
/**
* checks if not undefined
* Checks if a string value is defined and not a placeholder
*/
const notUndefined = (stringArg: string) => {
return stringArg && stringArg !== 'undefined' && stringArg !== '##';
const isValidValue = (value: string | undefined): boolean => {
return Boolean(value && value !== 'undefined' && value !== '##');
};
/**
* checks for ENV vars in form of NPMCI_SSHKEY_* and deploys any found ones
* Checks for ENV vars in form of SZCI_SSHKEY_* and deploys any found ones
*/
export let prepare = async () => {
sshInstance = new plugins.smartssh.SshInstance(); // init ssh instance
plugins.smartobject.forEachMinimatch(Deno.env.toObject(), 'NPMCI_SSHKEY_*', evaluateSshEnv);
if (!Deno.env.get("NPMTS_TEST")) {
sshInstance.writeToDisk();
export const prepare = async (): Promise<void> => {
sshInstance = new plugins.smartssh.SshInstance();
// Get all env vars and filter for SSH keys
const envVars = Deno.env.toObject();
const sshKeyEnvVars = Object.entries(envVars).filter(([key]) =>
key.startsWith('SZCI_SSHKEY_')
);
// Process each SSH key env var
for (const [key, value] of sshKeyEnvVars) {
logger.log('info', `Processing SSH key from ${key}`);
addSshKeyFromEnvVar(value);
}
// Only write to disk if not in test mode
if (!Deno.env.get('SZCI_TEST')) {
try {
sshInstance.writeToDisk();
logger.log('ok', 'SSH keys written to disk');
} catch (error) {
logger.log('error', `Failed to write SSH keys: ${(error as Error).message}`);
throw error;
}
} else {
logger.log('info', 'In test mode, so not storing SSH keys to disk!');
}
};
/**
* gets called for each found SSH ENV Var and deploys it
* Parses an SSH key env var and adds it to the SSH instance
* Format: host|privKeyBase64|pubKeyBase64
*/
const evaluateSshEnv = async (sshkeyEnvVarArg: string) => {
const sshEnvArray = sshkeyEnvVarArg.split('|');
const addSshKeyFromEnvVar = (sshkeyEnvVarArg: string): void => {
const [host, privKeyBase64, pubKeyBase64] = sshkeyEnvVarArg.split('|');
const sshKey = new plugins.smartssh.SshKey();
logger.log('info', 'Found SSH identity for ' + sshEnvArray[1]);
if (notUndefined(sshEnvArray[0])) {
logger.log('info', `Found SSH identity for ${host || 'unknown host'}`);
if (isValidValue(host)) {
logger.log('info', '---> host defined!');
sshKey.host = sshEnvArray[0];
sshKey.host = host;
}
if (notUndefined(sshEnvArray[1])) {
if (isValidValue(privKeyBase64)) {
logger.log('info', '---> privKey defined!');
sshKey.privKeyBase64 = sshEnvArray[1];
sshKey.privKeyBase64 = privKeyBase64;
}
if (notUndefined(sshEnvArray[2])) {
if (isValidValue(pubKeyBase64)) {
logger.log('info', '---> pubKey defined!');
sshKey.pubKeyBase64 = sshEnvArray[2];
sshKey.pubKeyBase64 = pubKeyBase64;
}
sshInstance.addKey(sshKey);
return;
};

View File

@@ -1,43 +1,101 @@
import * as plugins from './mod.plugins.ts';
import { bash } from '../szci.bash.ts';
import { logger } from '../szci.logging.ts';
const triggerValueRegex =
/^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|?([a-zA-Z0-9\.\-\/]*)/;
/**
* Interface for parsed trigger configuration
*/
interface ITriggerConfig {
domain: string;
projectId: string;
triggerToken: string;
refName: string;
triggerName: string;
}
export let trigger = async () => {
/**
* Regex to parse trigger env var format:
* domain|projectId|triggerToken|refName|triggerName (optional)
*/
const TRIGGER_VALUE_REGEX =
/^([a-zA-Z0-9.]+)\|([a-zA-Z0-9.]+)\|([a-zA-Z0-9.]+)\|([a-zA-Z0-9.]+)\|?([a-zA-Z0-9.\-/]*)$/;
/**
* Execute all configured triggers from environment variables
*/
export const trigger = async (): Promise<void> => {
logger.log('info', 'now running triggers');
await plugins.smartobject.forEachMinimatch(Deno.env.toObject(), 'NPMCI_TRIGGER_*', evaluateTrigger);
// Get all env vars and filter for triggers
const envVars = Deno.env.toObject();
const triggerEnvVars = Object.entries(envVars).filter(([key]) =>
key.startsWith('SZCI_TRIGGER_')
);
if (triggerEnvVars.length === 0) {
logger.log('info', 'no triggers configured');
return;
}
// Process each trigger
for (const [key, value] of triggerEnvVars) {
logger.log('info', `Processing trigger from ${key}`);
await executeTrigger(value);
}
logger.log('ok', `executed ${triggerEnvVars.length} trigger(s)`);
};
const evaluateTrigger = async (triggerEnvVarArg) => {
const triggerRegexResultArray = triggerValueRegex.exec(triggerEnvVarArg);
const regexDomain = triggerRegexResultArray[1];
const regexProjectId = triggerRegexResultArray[2];
const regexProjectTriggerToken = triggerRegexResultArray[3];
const regexRefName = triggerRegexResultArray[4];
let regexTriggerName;
if (triggerRegexResultArray.length === 6) {
regexTriggerName = triggerRegexResultArray[5];
} else {
regexTriggerName = 'Unnamed Trigger';
/**
* Parse a trigger env var string into a config object
*/
const parseTriggerConfig = (triggerEnvVar: string): ITriggerConfig | null => {
const match = TRIGGER_VALUE_REGEX.exec(triggerEnvVar);
if (!match) {
return null;
}
return {
domain: match[1],
projectId: match[2],
triggerToken: match[3],
refName: match[4],
triggerName: match[5] || 'Unnamed Trigger',
};
};
/**
* Execute a single trigger by calling the GitLab API
*/
const executeTrigger = async (triggerEnvVar: string): Promise<void> => {
const config = parseTriggerConfig(triggerEnvVar);
if (!config) {
logger.log('error', 'malformed trigger env var, expected format: domain|projectId|token|ref|name');
return;
}
logger.log('info', `Found Trigger: ${config.triggerName}`);
logger.log('info', `Triggering build for ref "${config.refName}" of "${config.triggerName}"`);
try {
await plugins.smartrequest.postFormData(
`https://${config.domain}/api/v3/projects/${config.projectId}/trigger/builds`,
{},
[
{
name: 'token',
payload: config.triggerToken,
type: 'string',
},
{
name: 'ref',
payload: config.refName,
type: 'string',
},
]
);
logger.log('ok', `Trigger "${config.triggerName}" executed successfully`);
} catch (error) {
logger.log('error', `Failed to execute trigger: ${(error as Error).message}`);
}
logger.log('info', 'Found Trigger!');
logger.log('info', 'triggering build for ref ' + regexRefName + ' of ' + regexTriggerName);
plugins.smartrequest.postFormData(
'https://gitlab.com/api/v3/projects/' + regexProjectId + '/trigger/builds',
{},
[
{
name: 'token',
payload: regexProjectTriggerToken,
type: 'string',
},
{
name: 'ref',
payload: regexRefName,
type: 'string',
},
]
);
};

View File

@@ -7,9 +7,9 @@ import * as paths from './szci.paths.ts';
*/
export let nvmAvailable = plugins.smartpromise.defer<boolean>();
/**
* the smartshell instance for npmci
* the smartshell instance for szci
*/
const npmciSmartshell = new plugins.smartshell.Smartshell({
const szciSmartshell = new plugins.smartshell.Smartshell({
executor: 'bash',
sourceFilePaths: [],
});
@@ -19,16 +19,16 @@ const npmciSmartshell = new plugins.smartshell.Smartshell({
*/
const checkToolsAvailable = async () => {
// check for nvm
if (!Deno.env.get('NPMTS_TEST')) {
if (!Deno.env.get('SZCI_TEST')) {
if (
(await npmciSmartshell.execSilent(`bash -c "source /usr/local/nvm/nvm.sh"`)).exitCode === 0
(await szciSmartshell.execSilent(`bash -c "source /usr/local/nvm/nvm.sh"`)).exitCode === 0
) {
npmciSmartshell.shellEnv.addSourceFiles([`/usr/local/nvm/nvm.sh`]);
szciSmartshell.shellEnv.addSourceFiles([`/usr/local/nvm/nvm.sh`]);
nvmAvailable.resolve(true);
} else if (
(await npmciSmartshell.execSilent(`bash -c "source ~/.nvm/nvm.sh"`)).exitCode === 0
(await szciSmartshell.execSilent(`bash -c "source ~/.nvm/nvm.sh"`)).exitCode === 0
) {
npmciSmartshell.shellEnv.addSourceFiles([`~/.nvm/nvm.sh`]);
szciSmartshell.shellEnv.addSourceFiles([`~/.nvm/nvm.sh`]);
nvmAvailable.resolve(true);
} else {
nvmAvailable.resolve(false);
@@ -46,7 +46,7 @@ checkToolsAvailable();
*/
export let bash = async (commandArg: string, retryArg: number = 2): Promise<string> => {
await nvmAvailable.promise; // make sure nvm check has run
let execResult: plugins.smartshell.IExecResult;
let execResult!: plugins.smartshell.IExecResult;
// determine if we fail
let failOnError: boolean = true;
@@ -55,13 +55,13 @@ export let bash = async (commandArg: string, retryArg: number = 2): Promise<stri
retryArg = 0;
}
if (!Deno.env.get('NPMTS_TEST')) {
// NPMTS_TEST is used during testing
if (!Deno.env.get('SZCI_TEST')) {
// SZCI_TEST is used during testing
for (let i = 0; i <= retryArg; i++) {
if (Deno.env.get('DEBUG_NPMCI') === 'true') {
if (Deno.env.get('DEBUG_SZCI') === 'true') {
console.log(commandArg);
}
execResult = await npmciSmartshell.exec(commandArg);
execResult = await szciSmartshell.exec(commandArg);
// determine how bash reacts to error and success
if (execResult.exitCode !== 0 && i === retryArg) {

View File

@@ -19,19 +19,19 @@ import { SzciNpmManager } from './manager.npm/index.ts';
export class Szci {
public analytics: plugins.smartanalytics.Analytics;
public cloudlyConnector: CloudlyConnector;
public cloudlyConnector!: CloudlyConnector;
public npmciEnv: SzciEnv;
public npmciInfo: SzciInfo;
public npmciConfig: SzciConfig;
public npmciCli: SzciCli;
public szciEnv!: SzciEnv;
public szciInfo!: SzciInfo;
public szciConfig!: SzciConfig;
public szciCli!: SzciCli;
// managers
public cloudronManager: SzciCloudronManager;
public dockerManager: SzciDockerManager;
public gitManager: SzciGitManager;
public nodejsManager: SzciNodeJsManager;
public npmManager: SzciNpmManager;
public cloudronManager!: SzciCloudronManager;
public dockerManager!: SzciDockerManager;
public gitManager!: SzciGitManager;
public nodejsManager!: SzciNodeJsManager;
public npmManager!: SzciNpmManager;
constructor() {
this.analytics = new plugins.smartanalytics.Analytics({
@@ -43,12 +43,12 @@ export class Szci {
public async start() {
this.cloudlyConnector = new CloudlyConnector(this);
this.npmciEnv = new SzciEnv(this);
this.npmciInfo = new SzciInfo(this);
await this.npmciInfo.printToConsole();
this.npmciCli = new SzciCli(this);
this.npmciConfig = new SzciConfig(this);
await this.npmciConfig.init();
this.szciEnv = new SzciEnv(this);
this.szciInfo = new SzciInfo(this);
await this.szciInfo.printToConsole();
this.szciCli = new SzciCli(this);
this.szciConfig = new SzciConfig(this);
await this.szciConfig.init();
// managers
this.cloudronManager = new SzciCloudronManager(this);
@@ -56,6 +56,6 @@ export class Szci {
this.gitManager = new SzciGitManager(this);
this.nodejsManager = new SzciNodeJsManager(this);
this.npmManager = new SzciNpmManager(this);
this.npmciCli.startParse();
this.szciCli.startParse();
}
}

View File

@@ -10,12 +10,12 @@ export class SzciCli {
constructor(szciArg: Szci) {
this.szciRef = szciArg;
this.smartcli = new plugins.smartcli.Smartcli();
this.smartcli.addVersion(this.szciRef.npmciInfo.version);
this.smartcli.addVersion(this.szciRef.szciInfo.version);
// clean
this.smartcli.addCommand('clean').subscribe(
async (argv) => {
const modClean = await import('./mod_clean/index.js');
const modClean = await import('./mod_clean/index.ts');
await modClean.clean();
},
(err) => {
@@ -38,7 +38,7 @@ export class SzciCli {
// command
this.smartcli.addCommand('command').subscribe(
async (argv) => {
const modCommand = await import('./mod_command/index.js');
const modCommand = await import('./mod_command/index.ts');
await modCommand.command();
},
(err) => {
@@ -91,20 +91,20 @@ export class SzciCli {
);
this.smartcli.addCommand('precheck').subscribe(async (argvArg) => {
const modPrecheck = await import('./mod_precheck/index.js');
const modPrecheck = await import('./mod_precheck/index.ts');
await modPrecheck.handleCli(this.szciRef, argvArg);
});
// trigger
this.smartcli.addCommand('ssh').subscribe(async (argvArg) => {
const modSsh = await import('./mod_ssh/index.js');
const modSsh = await import('./mod_ssh/index.ts');
await modSsh.handleCli(argvArg);
});
// trigger
this.smartcli.addCommand('trigger').subscribe(
async (argv) => {
const modTrigger = await import('./mod_trigger/index.js');
const modTrigger = await import('./mod_trigger/index.ts');
await modTrigger.trigger();
},
(err) => {

View File

@@ -5,7 +5,7 @@ import { logger } from './szci.logging.ts';
import { Szci } from './szci.classes.szci.ts';
/**
* the main config interface for npmci
* the main config interface for szci
*/
export interface ISzciOptions {
projectInfo: plugins.projectinfo.ProjectInfo;
@@ -24,35 +24,35 @@ export interface ISzciOptions {
gitlabRunnerTags: string[];
// urls
urlCloudly: string;
urlCloudly?: string;
// cloudron
cloudronAppName?: string;
}
/**
* a config class for Npmci
* a config class for Szci
*/
export class SzciConfig {
public szciRef: Szci;
public npmciNpmextra: plugins.npmextra.Npmextra;
public kvStorage: plugins.npmextra.KeyValueStore;
public npmciQenv: plugins.qenv.Qenv;
public szciNpmextra!: plugins.npmextra.Npmextra;
public kvStorage!: plugins.npmextra.KeyValueStore;
public szciQenv!: plugins.qenv.Qenv;
private configObject: ISzciOptions;
private configObject!: ISzciOptions;
constructor(szciRefArg: Szci) {
this.szciRef = szciRefArg;
}
public async init() {
this.npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
this.szciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
this.kvStorage = new plugins.npmextra.KeyValueStore({
typeArg: 'userHomeDir',
identityArg: `.npmci_${this.szciRef.npmciEnv.repo.user}_${this.szciRef.npmciEnv.repo.repo}`,
identityArg: `.szci_${this.szciRef.szciEnv.repo.user}_${this.szciRef.szciEnv.repo.repo}`,
});
this.npmciQenv = new plugins.qenv.Qenv(
this.szciQenv = new plugins.qenv.Qenv(
paths.SzciProjectDir,
paths.SzciProjectNogitDir,
false
@@ -67,9 +67,9 @@ export class SzciConfig {
npmRegistryUrl: 'registry.npmjs.org',
gitlabRunnerTags: [],
dockerBuildargEnvMap: {},
urlCloudly: await this.npmciQenv.getEnvVarOnDemand('NPMCI_URL_CLOUDLY'),
urlCloudly: await this.szciQenv.getEnvVarOnDemand('SZCI_URL_CLOUDLY'),
};
this.configObject = this.npmciNpmextra.dataFor<ISzciOptions>('szci', this.configObject);
this.configObject = this.szciNpmextra.dataFor<ISzciOptions>('@ship.zone/szci', this.configObject);
}
public getConfig(): ISzciOptions {

View File

@@ -9,15 +9,17 @@ export class SzciEnv {
constructor(szciRefArg: Szci) {
this.szciRef = szciRefArg;
if (!this.repoString && Deno.env.get("GITLAB_CI")) {
this.repoString = Deno.env.get("CI_REPOSITORY_URL");
// Determine repo string from environment
let repoUrl: string | undefined;
if (Deno.env.get("GITLAB_CI")) {
repoUrl = Deno.env.get("CI_REPOSITORY_URL");
}
if (!this.repoString && Deno.env.get("NPMCI_COMPUTED_REPOURL")) {
this.repoString = Deno.env.get("NPMCI_COMPUTED_REPOURL");
}
if (!this.repoString) {
this.repoString = 'https://undefined:undefined@github.com/undefined/undefined.git';
if (!repoUrl && Deno.env.get("SZCI_COMPUTED_REPOURL")) {
repoUrl = Deno.env.get("SZCI_COMPUTED_REPOURL");
}
this.repoString = repoUrl || 'https://undefined:undefined@github.com/undefined/undefined.git';
this.repo = new plugins.smartstring.GitRepo(this.repoString);
}
}

View File

@@ -6,7 +6,7 @@ export const logger = new plugins.smartlog.Smartlog({
companyunit: 'Some Unit',
containerName: 'Some ContainerName',
environment: 'test',
runtime: 'node',
runtime: 'deno',
zone: 'Some Zone',
},
});

View File

@@ -1,5 +1,14 @@
import * as plugins from './szci.plugins.ts';
/**
* Get current working directory (evaluated at call time, not module load time)
*/
export const getCwd = (): string => Deno.cwd();
/**
* Current working directory - use getCwd() if you need the live value after chdir
* @deprecated Use getCwd() for dynamic cwd resolution
*/
export const cwd = Deno.cwd();
// package paths
@@ -9,8 +18,14 @@ export const SzciPackageRoot = plugins.path.join(
);
export const SzciPackageConfig = plugins.path.join(SzciPackageRoot, './config.json');
// project paths
// project paths - use functions for dynamic resolution
export const getSzciProjectDir = (): string => getCwd();
export const getSzciProjectNogitDir = (): string => plugins.path.join(getCwd(), './.nogit');
export const getSzciTestDir = (): string => plugins.path.join(getCwd(), './test');
export const getSzciCacheDir = (): string => plugins.path.join(getCwd(), './.szci_cache');
// Static paths (for backwards compatibility - captured at module load)
export const SzciProjectDir = cwd;
export const SzciProjectNogitDir = plugins.path.join(SzciProjectDir, './.nogit');
export const SzciTestDir = plugins.path.join(cwd, './test');
export const SzciCacheDir = plugins.path.join(cwd, './.npmci_cache');
export const SzciCacheDir = plugins.path.join(cwd, './.szci_cache');