Compare commits

..

10 Commits

Author SHA1 Message Date
David Barroso
438355bff0 asd 2025-09-26 14:52:50 +02:00
David Barroso
62b97838fe sad 2025-09-26 14:50:26 +02:00
David Barroso
d287191f7a asd 2025-09-26 14:16:53 +02:00
David Barroso
b8d2127b06 sad 2025-09-26 14:08:09 +02:00
David Barroso
28cec232c8 asd 2025-09-26 14:06:37 +02:00
David Barroso
fe853da133 asd 2025-09-26 14:04:54 +02:00
David Barroso
c4445135bf asd 2025-09-26 13:50:21 +02:00
David Barroso
db7366dfc7 Merge branch 'main' of github.com:nhost/nhost into storage-releases 2025-09-26 13:49:59 +02:00
David Barroso
31c503e458 asd 2025-09-26 13:46:58 +02:00
David Barroso
187d35412e chore(ci): prepare storage releases 2025-09-26 13:46:48 +02:00
2076 changed files with 685397 additions and 19010 deletions

View File

@@ -1,41 +0,0 @@
---
name: "Validate PR Title"
description: "Validates that PR title follows the required format: TYPE(PKG): SUMMARY"
inputs:
pr_title:
description: "The PR title to validate"
required: true
runs:
using: "composite"
steps:
- name: "Validate PR title format"
shell: bash
run: |
PR_TITLE="${{ inputs.pr_title }}"
echo "Validating PR title: $PR_TITLE"
# Define valid types and packages
VALID_TYPES="feat|fix|chore"
VALID_PKGS="ci|cli|codegen|dashboard|deps|docs|examples|mintlify-openapi|nhost-js|nixops|storage"
# Check if title matches the pattern TYPE(PKG): SUMMARY
if [[ ! "$PR_TITLE" =~ ^(${VALID_TYPES})\((${VALID_PKGS})\):\ .+ ]]; then
echo "❌ PR title does not follow the required format!"
echo ""
echo "Expected format: TYPE(PKG): SUMMARY"
echo ""
echo "Valid TYPEs:"
echo " - feat: mark this pull request as a feature"
echo " - fix: mark this pull request as a bug fix"
echo " - chore: mark this pull request as a maintenance item"
echo ""
echo "Valid PKGs:"
echo " - ci, cli, codegen, dashboard, deps, docs, examples,"
echo " - mintlify-openapi, nhost-js, nixops, storage"
echo ""
echo "Example: feat(cli): add new command for database migrations"
exit 1
fi
echo "✅ PR title is valid!"

View File

@@ -36,7 +36,7 @@ jobs:
cli:
needs: extract-project
if: needs.extract-project.outputs.project == 'cli'
uses: ./.github/workflows/cli_wf_release.yaml
uses: ./.github/workflows/cli_release.yaml
with:
GIT_REF: ${{ github.sha }}
VERSION: ${{ needs.extract-project.outputs.version }}
@@ -51,7 +51,7 @@ jobs:
dashboard:
needs: extract-project
if: needs.extract-project.outputs.project == '@nhost/dashboard'
uses: ./.github/workflows/dashboard_wf_release.yaml
uses: ./.github/workflows/dashboard_release.yaml
with:
GIT_REF: ${{ github.sha }}
VERSION: ${{ needs.extract-project.outputs.version }}
@@ -85,7 +85,7 @@ jobs:
storage:
needs: extract-project
if: needs.extract-project.outputs.project == 'storage'
uses: ./.github/workflows/storage_wf_release.yaml
uses: ./.github/workflows/storage_release.yaml
with:
GIT_REF: ${{ github.sha }}
VERSION: ${{ needs.extract-project.outputs.version }}

View File

@@ -27,10 +27,6 @@ on:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('push-{0}', github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-permissions:
runs-on: ubuntu-latest
@@ -74,7 +70,7 @@ jobs:
NIX_CACHE_PRIV_KEY: ${{ secrets.NIX_CACHE_PRIV_KEY }}
test_cli_build:
uses: ./.github/workflows/cli_wf_test_new_project.yaml
uses: ./.github/workflows/cli_test_new_project.yaml
needs:
- check-permissions
- build_artifacts

View File

@@ -68,7 +68,7 @@ jobs:
ref: ${{ inputs.GIT_REF }}
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v5
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1

View File

@@ -50,7 +50,7 @@ jobs:
comment_on_pr: false
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v5
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1

View File

@@ -25,10 +25,6 @@ on:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('push-{0}', github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-permissions:
runs-on: ubuntu-latest

View File

@@ -32,10 +32,6 @@ on:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('push-{0}', github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-permissions:
runs-on: ubuntu-latest
@@ -63,7 +59,6 @@ jobs:
VERCEL_TEAM_ID: ${{ secrets.DASHBOARD_VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.DASHBOARD_STAGING_VERCEL_PROJECT_ID }}
VERCEL_DEPLOY_TOKEN: ${{ secrets.DASHBOARD_VERCEL_DEPLOY_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
build_artifacts:
@@ -76,7 +71,6 @@ jobs:
GIT_REF: ${{ github.sha }}
VERSION: 0.0.0-dev # we use a fixed version here to avoid unnecessary rebuilds
DOCKER: true
OS_MATRIX: '["blacksmith-2vcpu-ubuntu-2404"]'
secrets:
AWS_ACCOUNT_ID: ${{ secrets.AWS_PRODUCTION_CORE_ACCOUNT_ID }}
NIX_CACHE_PUB_KEY: ${{ secrets.NIX_CACHE_PUB_KEY }}
@@ -99,7 +93,7 @@ jobs:
e2e_staging:
uses: ./.github/workflows/dashboard_wf_e2e_staging.yaml
uses: ./.github/workflows/wf_dashboard_e2e_staging.yaml
needs:
- check-permissions
- deploy-vercel

View File

@@ -46,7 +46,6 @@ jobs:
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_DEPLOY_TOKEN: ${{ secrets.VERCEL_DEPLOY_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
build_artifacts:
@@ -98,7 +97,6 @@ jobs:
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
body: |
This PR bumps the Nhost Dashboard Docker image to version ${{ inputs.VERSION }}.
This PR bumps the Nhost Dashboard Docker image to version ${{ needs.version.outputs.dashboardVersion }}.
branch: bump-dashboard-version
base: main
delete-branch: true

View File

@@ -4,32 +4,6 @@ on:
push:
branches:
- main
paths:
- '.github/workflows/wf_build_artifacts.yaml'
- '.github/workflows/wf_check.yaml'
- '.github/workflows/dashboard_checks.yaml'
# common build
- 'flake.nix'
- 'flake.lock'
- 'nixops/**'
- 'build/**'
# common javascript
- ".npmrc"
- ".prettierignore"
- ".prettierrc.js"
- "audit-ci.jsonc"
- "package.json"
- "pnpm-workspace.yaml"
- "pnpm-lock.yaml"
- "turbo.json"
# dashboard
- "dashboard/**"
# nhost-js
- packages/nhost-js/**
jobs:
deploy-vercel:
@@ -45,5 +19,4 @@ jobs:
VERCEL_TEAM_ID: ${{ secrets.DASHBOARD_VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.DASHBOARD_STAGING_VERCEL_PROJECT_ID }}
VERCEL_DEPLOY_TOKEN: ${{ secrets.DASHBOARD_VERCEL_DEPLOY_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_STAGING }}

View File

@@ -31,10 +31,6 @@ on:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('push-{0}', github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-permissions:
runs-on: ubuntu-latest

View File

@@ -41,10 +41,6 @@ on:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('push-{0}', github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-permissions:
runs-on: ubuntu-latest
@@ -81,7 +77,6 @@ jobs:
GIT_REF: ${{ github.sha }}
VERSION: 0.0.0-dev # we use a fixed version here to avoid unnecessary rebuilds
DOCKER: false
OS_MATRIX: '["blacksmith-2vcpu-ubuntu-2404"]'
secrets:
AWS_ACCOUNT_ID: ${{ secrets.AWS_PRODUCTION_CORE_ACCOUNT_ID }}
NIX_CACHE_PUB_KEY: ${{ secrets.NIX_CACHE_PUB_KEY }}

View File

@@ -41,10 +41,6 @@ on:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('push-{0}', github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-permissions:
runs-on: ubuntu-latest
@@ -81,7 +77,6 @@ jobs:
GIT_REF: ${{ github.sha }}
VERSION: 0.0.0-dev # we use a fixed version here to avoid unnecessary rebuilds
DOCKER: false
OS_MATRIX: '["blacksmith-2vcpu-ubuntu-2404"]'
secrets:
AWS_ACCOUNT_ID: ${{ secrets.AWS_PRODUCTION_CORE_ACCOUNT_ID }}
NIX_CACHE_PUB_KEY: ${{ secrets.NIX_CACHE_PUB_KEY }}

View File

@@ -41,10 +41,6 @@ on:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('push-{0}', github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-permissions:
runs-on: ubuntu-latest
@@ -81,7 +77,6 @@ jobs:
GIT_REF: ${{ github.sha }}
VERSION: 0.0.0-dev # we use a fixed version here to avoid unnecessary rebuilds
DOCKER: false
OS_MATRIX: '["blacksmith-2vcpu-ubuntu-2404"]'
secrets:
AWS_ACCOUNT_ID: ${{ secrets.AWS_PRODUCTION_CORE_ACCOUNT_ID }}
NIX_CACHE_PUB_KEY: ${{ secrets.NIX_CACHE_PUB_KEY }}

View File

@@ -21,6 +21,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
config.model: ${{ vars.GEN_AI_MODEL }}
config.model_turbo: $${{ vars.GEN_AI_MODEL_TURBO }}
config.model: "anthropic/claude-sonnet-4-20250514"
config.model_turbo: "anthropic/claude-sonnet-4-20250514"
ignore.glob: "['pnpm-lock.yaml','**/pnpm-lock.yaml', 'vendor/**','**/client_gen.go','**/models_gen.go','**/generated.go','**/*.gen.go']"

View File

@@ -1,6 +1,8 @@
name: "CodeQL"
on:
push: {}
pull_request: {}
schedule:
- cron: '20 23 * * 3'
@@ -16,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'go' ]
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
@@ -26,7 +28,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -37,7 +39,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@@ -51,4 +53,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v2

View File

@@ -18,12 +18,12 @@ jobs:
uses: actions/checkout@v5
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v5
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_PRODUCTION_CORE_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1
- uses: nixbuild/nix-quick-install-action@v34
- uses: nixbuild/nix-quick-install-action@v26
with:
nix_version: 2.16.2
nix_conf: |
@@ -51,7 +51,7 @@ jobs:
"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update dependencies

View File

@@ -38,10 +38,6 @@ on:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('push-{0}', github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-permissions:
runs-on: ubuntu-latest

View File

@@ -17,10 +17,6 @@ on:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('push-{0}', github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-permissions:
runs-on: ubuntu-latest

View File

@@ -21,15 +21,11 @@ on:
- 'vendor/**'
# storage
- 'services/storage/**'
- 'storage/**'
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('push-{0}', github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-permissions:
runs-on: ubuntu-latest

View File

@@ -17,10 +17,6 @@ on:
DOCKER:
type: boolean
required: true
OS_MATRIX:
type: string
required: false
default: '["blacksmith-4vcpu-ubuntu-2404-arm", "blacksmith-2vcpu-ubuntu-2404"]'
secrets:
AWS_ACCOUNT_ID:
required: true
@@ -41,7 +37,7 @@ jobs:
strategy:
matrix:
os: ${{ fromJSON(inputs.OS_MATRIX) }}
os: [blacksmith-4vcpu-ubuntu-2404-arm, blacksmith-2vcpu-ubuntu-2404]
fail-fast: true
runs-on: ${{ matrix.os }}
@@ -53,14 +49,8 @@ jobs:
with:
ref: ${{ inputs.GIT_REF }}
- name: "Validate PR title"
uses: ./.github/actions/validate-pr-title
with:
pr_title: ${{ github.event.pull_request.title }}
if: ${{ github.event_name == 'pull_request' }}
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v5
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1

View File

@@ -44,19 +44,13 @@ jobs:
with:
ref: ${{ inputs.GIT_REF }}
- name: "Validate PR title"
uses: ./.github/actions/validate-pr-title
with:
pr_title: ${{ github.event.pull_request.title }}
if: ${{ github.event_name == 'pull_request' }}
- name: Collect Workflow Telemetry
uses: catchpoint/workflow-telemetry-action@v2
with:
comment_on_pr: false
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v5
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1

View File

@@ -59,10 +59,6 @@ on:
PLAYWRIGHT_REPORT_ENCRYPTION_KEY:
required: true
concurrency:
group: dashboard-e2e-staging
cancel-in-progress: false
env:
NEXT_PUBLIC_ENV: dev
NEXT_TELEMETRY_DISABLED: 1
@@ -105,7 +101,7 @@ jobs:
comment_on_pr: false
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v5
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1

View File

@@ -27,8 +27,6 @@ on:
required: true
DISCORD_WEBHOOK:
required: false
TURBO_TOKEN:
required: true
outputs:
preview-url:
@@ -54,7 +52,7 @@ jobs:
ref: ${{ inputs.GIT_REF }}
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v5
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1
@@ -71,8 +69,6 @@ jobs:
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: nhost
run: |
TARGET_OPTS="--target=${{ inputs.ENVIRONMENT }}"
echo "Deploying to: ${{ inputs.ENVIRONMENT }}..."

View File

@@ -33,7 +33,7 @@ jobs:
steps:
- name: "Check out repository"
uses: actions/checkout@v5
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

View File

@@ -33,13 +33,13 @@ jobs:
steps:
- name: "Check out repository"
uses: actions/checkout@v5
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v5
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1

View File

@@ -42,7 +42,7 @@ jobs:
uses: actions/checkout@v5
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v5
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1

20
cli/.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,20 @@
## Description
<!--
Use one of the following title prefix to categorize the pull request:
feat: mark this pull request as a feature
fix: mark this pull request as a bug fix
chore: mark this pull request as a maintenance item
To auto merge this pull request when it was approved
by another member of the organization: set the label `auto-merge`
-->
## Problem
A short description of the problem this PR is addressing.
## Solution
A short description of the chosen method to resolve the problem
with an overview of the logic and implementation details when needed.
## Notes
Other notes that you want to share but do not fit into _Problem_ or _Solution_.

36
cli/.github/cert.sh vendored Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
set -euo pipefail
mkdir -p /tmp/letsencrypt
echo "Generating SSL certificate for hostnames: local.nhost.run, local.graphql.nhost.run, local.auth.nhost.run, local.storage.nhost.run, local.functions.nhost.run, local.mail.nhost.run"
docker run --rm \
--name certbot \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN \
-e AWS_REGION \
-v /tmp/letsencrypt:/etc/letsencrypt \
-v /tmp/letsencrypt:/var/lib/letsencrypt \
certbot/dns-route53 certonly --dns-route53 --dns-route53-propagation-seconds 60 \
-d local.auth.nhost.run \
-d local.dashboard.nhost.run \
-d local.db.nhost.run \
-d local.functions.nhost.run \
-d local.graphql.nhost.run \
-d local.hasura.nhost.run \
-d local.mailhog.nhost.run \
-d local.storage.nhost.run \
-d *.auth.local.nhost.run \
-d *.dashboard.local.nhost.run \
-d *.db.local.nhost.run \
-d *.functions.local.nhost.run \
-d *.graphql.local.nhost.run \
-d *.hasura.local.nhost.run \
-d *.mailhog.local.nhost.run \
-d *.storage.local.nhost.run \
-m 'admin@nhost.io' --non-interactive --agree-tos --server https://acme-v02.api.letsencrypt.org/directory
sudo cp /tmp/letsencrypt/live/local.db.nhost.run/fullchain.pem ssl/.ssl/
sudo cp /tmp/letsencrypt/live/local.db.nhost.run/privkey.pem ssl/.ssl/

8
cli/.github/labeler.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
labels:
'feature':
- '^(?i:feat)'
- '^(?i:feature)'
'fix':
- '^(?i:fix)'
'chore':
- '^(?i:chore)'

39
cli/.github/release-drafter.yml vendored Normal file
View File

@@ -0,0 +1,39 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
label: 'feature'
- title: '🐛 Bug Fixes'
label: 'fix'
- title: '🧰 Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
autolabeler:
- label: 'feature'
title:
- '/^feat/i'
- '/^feature/i'
- label: 'fix'
title:
- '/^fix/i'
- label: 'chore'
title:
- '/^chore/i'
prerelease: true
template: |
## Changes
$CHANGES

16
cli/.github/stale.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
# Configuration for probot-stale - https://github.com/probot/stale
daysUntilStale: 180
daysUntilClose: 7
limitPerRun: 30
onlyLabels: []
exemptLabels: []
exemptProjects: false
exemptMilestones: false
exemptAssignees: false
staleLabel: stale
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.

17
cli/.github/workflows/assign_labels.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
# this workflow will run on all pull requests opened but in the context of the base of the pull request.
on:
pull_request_target:
types: [opened]
name: "assign labels"
jobs:
# labeler will label pull requests based on their title.
# the configuration is at .github/labeler.yml.
label_pull_request:
runs-on: ubuntu-latest
steps:
-
name: Label Pull Request
uses: jimschubert/labeler-action@v2
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

View File

@@ -0,0 +1,53 @@
---
name: "build certificate weekly"
on:
schedule:
- cron: '0 0 * * 1'
jobs:
run:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::796351718684:role/github-actions-nhost-cli
aws-region: eu-central-1
- name: fetch let's encrypt cert
id: certs
run: |
.github/cert.sh
echo "CERT_FULL_CHAIN<<EOF" >> $GITHUB_OUTPUT
sudo cat /tmp/letsencrypt/live/local.db.nhost.run/fullchain.pem >> "$GITHUB_OUTPUT"
echo EOF >> $GITHUB_OUTPUT
echo "CERT_PRIV_KEY<<EOF" >> $GITHUB_OUTPUT
sudo cat /tmp/letsencrypt/live/local.db.nhost.run/privkey.pem >> "$GITHUB_OUTPUT"
echo EOF >> $GITHUB_OUTPUT
shell: bash
- uses: hmanzur/actions-set-secret@v2.0.0
with:
name: 'CERT_FULL_CHAIN'
value: "${{ steps.certs.outputs.CERT_FULL_CHAIN }}"
repository: nhost/cli
token: ${{ secrets.GH_PAT }}
- uses: hmanzur/actions-set-secret@v2.0.0
with:
name: 'CERT_PRIV_KEY'
value: "${{ steps.certs.outputs.CERT_PRIV_KEY }}"
repository: nhost/cli
token: ${{ secrets.GH_PAT }}

27
cli/.github/workflows/checks.yaml vendored Normal file
View File

@@ -0,0 +1,27 @@
---
name: "check and build"
on:
pull_request:
push:
branches:
- main
jobs:
tests:
uses: ./.github/workflows/wf_check.yaml
secrets:
NHOST_PAT: ${{ secrets.NHOST_PAT }}
build_artifacts:
strategy:
fail-fast: true
matrix:
GOOS: ["darwin", "linux"]
GOARCH: ["amd64", "arm64"]
uses: ./.github/workflows/wf_build_artifacts.yaml
with:
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
VERSION: ${{ github.sha }}
secrets:
NHOST_PAT: ${{ secrets.NHOST_PAT }}

View File

@@ -0,0 +1,56 @@
name: "CodeQL"
on:
push: {}
pull_request: {}
schedule:
- cron: '20 23 * * 3'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View File

@@ -0,0 +1,27 @@
---
name: "gen: AI review"
on:
pull_request:
types: [opened, reopened, ready_for_review]
issue_comment:
jobs:
pr_agent_job:
if: ${{ github.event.sender.type != 'Bot' }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
issues: write
pull-requests: write
name: Run pr agent on every pull request, respond to user comments
steps:
- name: PR Agent action step
id: pragent
uses: Codium-ai/pr-agent@v0.29
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
config.max_model_tokens: 100000
config.model: "anthropic/claude-sonnet-4-20250514"
config.model_turbo: "anthropic/claude-sonnet-4-20250514"
ignore.glob: "['vendor/**','**/client_gen.go','**/models_gen.go','**/generated.go','**/*.gen.go']"

View File

@@ -0,0 +1,91 @@
---
name: "gen: update depenendencies"
on:
schedule:
- cron: '0 2 1 2,5,8,11 *'
jobs:
run:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure aws
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_PRODUCTION_CORE_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
aws-region: eu-central-1
- uses: nixbuild/nix-quick-install-action@v26
with:
nix_version: 2.16.2
nix_conf: |
experimental-features = nix-command flakes
sandbox = false
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
substituters = https://cache.nixos.org/?priority=40 s3://nhost-nix-cache?region=eu-central-1&priority=50
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ${{ secrets.NIX_CACHE_PUB_KEY }}
- name: Cache nix store
uses: actions/cache@v4
with:
path: /nix
key: nix-update-deps-${{ hashFiles('flakes.nix', 'flake.lock') }}
- name: Update nix flakes
run: nix flake update
- uses: shaunco/ssh-agent@git-repo-mapping
with:
ssh-private-key: |
${{ secrets.NHOST_BE_DEPLOY_SSH_PRIVATE_KEY}}
repo-mappings: |
github.com/nhost/be
- name: Update golang dependencies
run: |
export GOPRIVATE=github.com/nhost/be
nix develop -c bash -c "
go mod tidy
go get -u $(cat go.mod | grep nhost\/be | tr ' ' '@') ./...
go mod tidy
go mod vendor
"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update dependencies
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: automated/update-deps
delete-branch: true
title: '[Scheduled] Update dependencies'
body: |
Dependencies updated
Note - If you see this PR and the checks haven't run, close and reopen the PR. See https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs
labels: |
dependencies
draft: false
- name: "Cache nix store on s3"
run: |
echo ${{ secrets.NIX_CACHE_PRIV_KEY }} > cache-priv-key.pem
nix build .\#devShells.x86_64-linux.default
nix store sign --key-file cache-priv-key.pem --all
nix copy --to s3://nhost-nix-cache\?region=eu-central-1 .\#devShells.x86_64-linux.default
- run: rm cache-priv-key.pem
if: always()

35
cli/.github/workflows/release.yaml vendored Normal file
View File

@@ -0,0 +1,35 @@
---
name: "release"
on:
release:
types: [published]
jobs:
tests:
uses: ./.github/workflows/wf_check.yaml
secrets:
NHOST_PAT: ${{ secrets.NHOST_PAT }}
build_artifacts:
strategy:
matrix:
GOOS: ["darwin", "linux"]
GOARCH: ["amd64", "arm64"]
uses: ./.github/workflows/wf_build_artifacts.yaml
with:
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
VERSION: ${{ github.ref_name }}
secrets:
NHOST_PAT: ${{ secrets.NHOST_PAT }}
publish:
uses: ./.github/workflows/wf_publish.yaml
needs:
- tests
- build_artifacts
with:
VERSION: ${{ github.ref_name }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

View File

@@ -0,0 +1,17 @@
name: "release drafter"
on:
push:
branches:
- main
jobs:
# draft your next release notes as pull requests are merged into "master"
# the configuration is at /.github/release-drafter.yml.
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,89 @@
---
on:
workflow_call:
inputs:
GIT_REF:
type: string
required: false
VERSION:
type: string
required: true
GOOS:
type: string
required: true
GOARCH:
type: string
required: true
secrets:
NHOST_PAT:
required: true
jobs:
artifacts:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: "Check out repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.GIT_REF }}
submodules: true
- uses: cachix/install-nix-action@v27
with:
install_url: "https://releases.nixos.org/nix/nix-2.22.3/install"
install_options: "--no-daemon"
extra_nix_config: |
experimental-features = nix-command flakes
sandbox = false
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
substituters = https://cache.nixos.org/?priority=40
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
- name: Compute common env vars
id: vars
run: |
echo "VERSION=$(make get-version VERSION=${{ inputs.VERSION }})" >> $GITHUB_OUTPUT
- name: "Build artifact"
run: |
make build ARCH=${{ inputs.GOARCH }} OS=${{ inputs.GOOS }}
find -L result -type f -exec cp {} nhost-cli \;
- name: "Push artifact to artifact repository"
uses: actions/upload-artifact@v4
with:
name: cli-${{ steps.vars.outputs.VERSION }}-${{ inputs.GOOS }}-${{ inputs.GOARCH }}
path: nhost-cli
retention-days: 7
- name: "Build docker-image"
run: |
make build-docker-image ARCH=${{ inputs.GOARCH }}
if: ${{ ( inputs.GOOS == 'linux' ) }}
- name: "Create a new project"
run: |
export NHOST_DOMAIN=staging.nhost.run
export NHOST_CONFIGSERVER_IMAGE=nhost/cli:${{ steps.vars.outputs.VERSION }}
mkdir new-project
cd new-project
../nhost-cli login --pat ${{ secrets.NHOST_PAT }}
../nhost-cli init
../nhost-cli up --down-on-error
../nhost-cli down
if: ${{ ( inputs.GOOS == 'linux' && inputs.GOARCH == 'amd64' ) }}
- name: "Push docker-image to artifact repository"
uses: actions/upload-artifact@v4
with:
name: cli-docker-image-${{ steps.vars.outputs.VERSION }}-${{ inputs.GOOS }}-${{ inputs.GOARCH }}
path: result
retention-days: 7
if: ${{ ( inputs.GOOS == 'linux' ) }}

42
cli/.github/workflows/wf_check.yaml vendored Normal file
View File

@@ -0,0 +1,42 @@
---
on:
workflow_call:
inputs:
GIT_REF:
type: string
required: false
secrets:
NHOST_PAT:
required: true
jobs:
tests:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: "Check out repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.GIT_REF }}
submodules: true
- uses: cachix/install-nix-action@v27
with:
install_url: "https://releases.nixos.org/nix/nix-2.22.3/install"
install_options: "--no-daemon"
extra_nix_config: |
experimental-features = nix-command flakes
sandbox = false
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
substituters = https://cache.nixos.org/?priority=40
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
- name: "Run checks"
run: |
export NHOST_PAT=${{ secrets.NHOST_PAT }}
make check

93
cli/.github/workflows/wf_publish.yaml vendored Normal file
View File

@@ -0,0 +1,93 @@
---
on:
workflow_call:
inputs:
VERSION:
type: string
required: true
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
name: release
jobs:
release:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: "Check out repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.GIT_REF }}
submodules: true
- name: Compute common env vars
id: vars
run: |
echo "VERSION=$(make get-version VERSION=${{ inputs.VERSION }})" >> $GITHUB_OUTPUT
- name: "Get artifacts"
uses: actions/download-artifact@v4
with:
path: ~/artifacts
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Upload docker images
shell: bash
run: |
export VERSION=${{ steps.vars.outputs.VERSION }}
export CONTAINER_NAME=nhost/cli
skopeo copy --insecure-policy \
dir:/home/runner/artifacts/cli-docker-image-$VERSION-linux-amd64 \
docker-daemon:$CONTAINER_NAME:$VERSION-amd64
docker push $CONTAINER_NAME:$VERSION-amd64
skopeo copy --insecure-policy \
dir:/home/runner/artifacts/cli-docker-image-$VERSION-linux-arm64 \
docker-daemon:$CONTAINER_NAME:$VERSION-arm64
docker push $CONTAINER_NAME:$VERSION-arm64
docker manifest create \
$CONTAINER_NAME:$VERSION \
--amend $CONTAINER_NAME:$VERSION-amd64 \
--amend $CONTAINER_NAME:$VERSION-arm64
docker manifest push $CONTAINER_NAME:$VERSION
- name: Upload assets
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export VERSION=${{ steps.vars.outputs.VERSION }}
mkdir upload
find ~/artifacts -type f -name "nhost-cli" -exec bash -c 'chmod +x "$0" && mv "$0" "${0//nhost-cli/cli}"' {} \;
tar cvzf upload/cli-$VERSION-darwin-amd64.tar.gz -C ~/artifacts/cli-$VERSION-darwin-amd64 cli
tar cvzf upload/cli-$VERSION-darwin-arm64.tar.gz -C ~/artifacts/cli-$VERSION-darwin-arm64 cli
tar cvzf upload/cli-$VERSION-linux-amd64.tar.gz -C ~/artifacts/cli-$VERSION-linux-amd64 cli
tar cvzf upload/cli-$VERSION-linux-arm64.tar.gz -C ~/artifacts/cli-$VERSION-linux-arm64 cli
cd upload
find . -type f -exec sha256sum {} + > ../checksums.txt
cd ..
cat checksums.txt
gh release upload \
--clobber "${{ github.ref_name }}" \
./upload/* checksums.txt

View File

@@ -1,34 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
## [cli@1.33.0] - 2025-10-02
### 🚀 Features
- *(cli)* Migrate from urfave/v2 to urfave/v3 (#3545)
### 🐛 Bug Fixes
- *(cli)* Disable tls on AUTH_SERVER_URL when auth uses custom port (#3549)
- *(cli)* Fix breaking change in go-getter dependency (#3551)
### ⚙️ Miscellaneous Tasks
- *(cli)* Update certs (#3552)
## [cli@1.32.2] - 2025-10-01
### ⚙️ Miscellaneous Tasks
- *(cli)* Remove hasura- prefix from auth/storage images (#3538)
## [cli@1.32.1] - 2025-09-29
### ⚙️ Miscellaneous Tasks
- *(ci)* Minor improvements to the ci (#3527)
- *(cli)* Update schema (#3529)

View File

@@ -12,9 +12,9 @@ It's recommended to use the Nhost CLI and the [Nhost GitHub Integration](https:/
- [Nhost Dashboard](https://github.com/nhost/nhost/tree/main/dashboard)
- [Postgres Database](https://www.postgresql.org/)
- [GraphQL Engine](https://github.com/hasura/graphql-engine)
- [Auth](https://github.com/nhost/nhost/main/auth)
- [Storage](https://github.com/nhost/nhost/main/storage)
- [Hasura's GraphQL Engine](https://github.com/hasura/graphql-engine)
- [Hasura Auth](https://github.com/nhost/hasura-auth)
- [Hasura Storage](https://github.com/nhost/hasura-storage)
- [Nhost Serverless Functions](https://github.com/nhost/functions)
- [Minio S3](https://github.com/minio/minio)
- [Mailhog](https://github.com/mailhog/MailHog)

View File

@@ -10,7 +10,7 @@ import (
"github.com/nhost/nhost/cli/nhostclient"
"github.com/nhost/nhost/cli/nhostclient/graphql"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func sanitizeName(name string) string {
@@ -55,28 +55,28 @@ func New(
}
}
func FromCLI(cmd *cli.Command) *CliEnv {
func FromCLI(cCtx *cli.Context) *CliEnv {
cwd, err := os.Getwd()
if err != nil {
panic(err)
}
return &CliEnv{
stdout: cmd.Writer,
stderr: cmd.ErrWriter,
stdout: cCtx.App.Writer,
stderr: cCtx.App.ErrWriter,
Path: NewPathStructure(
cwd,
cmd.String(flagRootFolder),
cmd.String(flagDotNhostFolder),
cmd.String(flagNhostFolder),
cCtx.String(flagRootFolder),
cCtx.String(flagDotNhostFolder),
cCtx.String(flagNhostFolder),
),
authURL: cmd.String(flagAuthURL),
graphqlURL: cmd.String(flagGraphqlURL),
branch: cmd.String(flagBranch),
projectName: sanitizeName(cmd.String(flagProjectName)),
authURL: cCtx.String(flagAuthURL),
graphqlURL: cCtx.String(flagGraphqlURL),
branch: cCtx.String(flagBranch),
projectName: sanitizeName(cCtx.String(flagProjectName)),
nhclient: nil,
nhpublicclient: nil,
localSubdomain: cmd.String(flagLocalSubdomain),
localSubdomain: cCtx.String(flagLocalSubdomain),
}
}

View File

@@ -6,7 +6,7 @@ import (
"path/filepath"
"github.com/go-git/go-git/v5"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -53,42 +53,42 @@ func Flags() ([]cli.Flag, error) {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagAuthURL,
Usage: "Nhost auth URL",
Sources: cli.EnvVars("NHOST_CLI_AUTH_URL"),
EnvVars: []string{"NHOST_CLI_AUTH_URL"},
Value: "https://otsispdzcwxyqzbfntmj.auth.eu-central-1.nhost.run/v1",
Hidden: true,
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagGraphqlURL,
Usage: "Nhost GraphQL URL",
Sources: cli.EnvVars("NHOST_CLI_GRAPHQL_URL"),
EnvVars: []string{"NHOST_CLI_GRAPHQL_URL"},
Value: "https://otsispdzcwxyqzbfntmj.graphql.eu-central-1.nhost.run/v1",
Hidden: true,
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagBranch,
Usage: "Git branch name. If not set, it will be detected from the current git repository. This flag is used to dynamically create docker volumes for each branch. If you want to have a static volume name or if you are not using git, set this flag to a static value.", //nolint:lll
Sources: cli.EnvVars("BRANCH"),
EnvVars: []string{"BRANCH"},
Value: branch,
Hidden: false,
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagRootFolder,
Usage: "Root folder of project\n\t",
Sources: cli.EnvVars("NHOST_ROOT_FOLDER"),
EnvVars: []string{"NHOST_ROOT_FOLDER"},
Value: workingDir,
Category: "Project structure",
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagDotNhostFolder,
Usage: "Path to .nhost folder\n\t",
Sources: cli.EnvVars("NHOST_DOT_NHOST_FOLDER"),
EnvVars: []string{"NHOST_DOT_NHOST_FOLDER"},
Value: dotNhostFolder,
Category: "Project structure",
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagNhostFolder,
Usage: "Path to nhost folder\n\t",
Sources: cli.EnvVars("NHOST_NHOST_FOLDER"),
EnvVars: []string{"NHOST_NHOST_FOLDER"},
Value: nhostFolder,
Category: "Project structure",
},
@@ -96,13 +96,13 @@ func Flags() ([]cli.Flag, error) {
Name: flagProjectName,
Usage: "Project name",
Value: filepath.Base(fullWorkingDir),
Sources: cli.EnvVars("NHOST_PROJECT_NAME"),
EnvVars: []string{"NHOST_PROJECT_NAME"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagLocalSubdomain,
Usage: "Local subdomain to reach the development environment",
Value: "local",
Sources: cli.EnvVars("NHOST_LOCAL_SUBDOMAIN"),
EnvVars: []string{"NHOST_LOCAL_SUBDOMAIN"},
},
}, nil
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandApply() *cli.Command {
@@ -22,42 +22,38 @@ func CommandApply() *cli.Command {
Name: flagSubdomain,
Usage: "Subdomain of the Nhost project to apply configuration to. Defaults to linked project",
Required: true,
Sources: cli.EnvVars("NHOST_SUBDOMAIN"),
EnvVars: []string{"NHOST_SUBDOMAIN"},
},
&cli.BoolFlag{ //nolint:exhaustruct
Name: flagYes,
Usage: "Skip confirmation",
Sources: cli.EnvVars("NHOST_YES"),
EnvVars: []string{"NHOST_YES"},
},
},
}
}
func commandApply(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandApply(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain))
proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))
if err != nil {
return cli.Exit(fmt.Sprintf("Failed to get app info: %v", err), 1)
return fmt.Errorf("failed to get app info: %w", err)
}
ce.Infoln("Validating configuration...")
cfg, _, err := ValidateRemote(
ctx,
cCtx.Context,
ce,
proj.GetSubdomain(),
proj.GetID(),
)
if err != nil {
return cli.Exit(err.Error(), 1)
return err
}
if err := Apply(ctx, ce, proj.ID, cfg, cmd.Bool(flagYes)); err != nil {
return cli.Exit(err.Error(), 1)
}
return nil
return Apply(cCtx.Context, ce, proj.ID, cfg, cCtx.Bool(flagYes))
}
func Apply(

View File

@@ -1,6 +1,6 @@
package config
import "github.com/urfave/cli/v3"
import "github.com/urfave/cli/v2"
const flagSubdomain = "subdomain"
@@ -9,7 +9,7 @@ func Command() *cli.Command {
Name: "config",
Aliases: []string{},
Usage: "Perform config operations",
Commands: []*cli.Command{
Subcommands: []*cli.Command{
CommandDefault(),
CommandExample(),
CommandApply(),

View File

@@ -1,7 +1,6 @@
package config
import (
"context"
"fmt"
"os"
@@ -9,7 +8,7 @@ import (
"github.com/nhost/nhost/cli/project"
"github.com/nhost/nhost/cli/project/env"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandDefault() *cli.Command {
@@ -22,8 +21,8 @@ func CommandDefault() *cli.Command {
}
}
func commandDefault(_ context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandDefault(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
if err := os.MkdirAll(ce.Path.NhostFolder(), 0o755); err != nil { //nolint:mnd
return fmt.Errorf("failed to create nhost folder: %w", err)

View File

@@ -13,7 +13,7 @@ import (
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
"github.com/wI2L/jsondiff"
)
@@ -31,13 +31,13 @@ func CommandEdit() *cli.Command {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagSubdomain,
Usage: "If specified, edit this subdomain's overlay, otherwise edit base configuation",
Sources: cli.EnvVars("NHOST_SUBDOMAIN"),
EnvVars: []string{"NHOST_SUBDOMAIN"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagEditor,
Usage: "Editor to use",
Value: "vim",
Sources: cli.EnvVars("EDITOR"),
EnvVars: []string{"EDITOR"},
},
},
}
@@ -139,11 +139,11 @@ func GenerateJSONPatch(origfilepath, newfilepath, dst string) error {
return nil
}
func edit(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func edit(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
if cmd.String(flagSubdomain) == "" {
if err := EditFile(ctx, cmd.String(flagEditor), ce.Path.NhostToml()); err != nil {
if cCtx.String(flagSubdomain) == "" {
if err := EditFile(cCtx.Context, cCtx.String(flagEditor), ce.Path.NhostToml()); err != nil {
return fmt.Errorf("failed to edit config: %w", err)
}
@@ -163,17 +163,17 @@ func edit(ctx context.Context, cmd *cli.Command) error {
tmpfileName := filepath.Join(tmpdir, "nhost.toml")
if err := CopyConfig[model.ConfigConfig](
ce.Path.NhostToml(), tmpfileName, ce.Path.Overlay(cmd.String(flagSubdomain)),
ce.Path.NhostToml(), tmpfileName, ce.Path.Overlay(cCtx.String(flagSubdomain)),
); err != nil {
return fmt.Errorf("failed to copy config: %w", err)
}
if err := EditFile(ctx, cmd.String(flagEditor), tmpfileName); err != nil {
if err := EditFile(cCtx.Context, cCtx.String(flagEditor), tmpfileName); err != nil {
return fmt.Errorf("failed to edit config: %w", err)
}
if err := GenerateJSONPatch(
ce.Path.NhostToml(), tmpfileName, ce.Path.Overlay(cmd.String(flagSubdomain)),
ce.Path.NhostToml(), tmpfileName, ce.Path.Overlay(cCtx.String(flagSubdomain)),
); err != nil {
return fmt.Errorf("failed to generate json patch: %w", err)
}

View File

@@ -1,14 +1,13 @@
package config
import (
"context"
"fmt"
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/be/services/mimir/schema"
"github.com/nhost/nhost/cli/clienv"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandExample() *cli.Command {
@@ -23,8 +22,8 @@ func CommandExample() *cli.Command {
func ptr[T any](v T) *T { return &v }
func commandExample(_ context.Context, cmd *cli.Command) error { //nolint:funlen,maintidx
ce := clienv.FromCLI(cmd)
func commandExample(cCtx *cli.Context) error { //nolint:funlen,maintidx
ce := clienv.FromCLI(cCtx)
//nolint:mnd
cfg := model.ConfigConfig{

View File

@@ -13,7 +13,7 @@ import (
"github.com/nhost/nhost/cli/project/env"
"github.com/nhost/nhost/cli/system"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -36,21 +36,21 @@ func CommandPull() *cli.Command {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagSubdomain,
Usage: "Pull this subdomain's configuration. Defaults to linked project",
Sources: cli.EnvVars("NHOST_SUBDOMAIN"),
EnvVars: []string{"NHOST_SUBDOMAIN"},
},
&cli.BoolFlag{ //nolint:exhaustruct
Name: flagYes,
Usage: "Skip confirmation",
Sources: cli.EnvVars("NHOST_YES"),
EnvVars: []string{"NHOST_YES"},
},
},
}
}
func commandPull(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandPull(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
skipConfirmation := cmd.Bool(flagYes)
skipConfirmation := cCtx.Bool(flagYes)
if !skipConfirmation {
if err := verifyFile(ce, ce.Path.NhostToml()); err != nil {
@@ -66,12 +66,12 @@ func commandPull(ctx context.Context, cmd *cli.Command) error {
}
}
proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain))
proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))
if err != nil {
return fmt.Errorf("failed to get app info: %w", err)
}
_, err = Pull(ctx, ce, proj, writeSecrets)
_, err = Pull(cCtx.Context, ce, proj, writeSecrets)
return err
}

View File

@@ -1,14 +1,13 @@
package config
import (
"context"
"fmt"
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/project/env"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandShow() *cli.Command {
@@ -22,14 +21,14 @@ func CommandShow() *cli.Command {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagSubdomain,
Usage: "Show this subdomain's rendered configuration. Defaults to base configuration",
Sources: cli.EnvVars("NHOST_SUBDOMAIN"),
EnvVars: []string{"NHOST_SUBDOMAIN"},
},
},
}
}
func commandShow(_ context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandShow(c *cli.Context) error {
ce := clienv.FromCLI(c)
var secrets model.Secrets
if err := clienv.UnmarshalFile(ce.Path.Secrets(), &secrets, env.Unmarshal); err != nil {
@@ -39,7 +38,7 @@ func commandShow(_ context.Context, cmd *cli.Command) error {
)
}
cfg, err := Validate(ce, cmd.String(flagSubdomain), secrets)
cfg, err := Validate(ce, c.String(flagSubdomain), secrets)
if err != nil {
return err
}

View File

@@ -13,7 +13,7 @@ import (
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/project/env"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
jsonpatch "gopkg.in/evanphx/json-patch.v5"
)
@@ -27,24 +27,24 @@ func CommandValidate() *cli.Command {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagSubdomain,
Usage: "Validate this subdomain's configuration. Defaults to linked project",
Sources: cli.EnvVars("NHOST_SUBDOMAIN"),
EnvVars: []string{"NHOST_SUBDOMAIN"},
},
},
}
}
func commandValidate(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandValidate(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
subdomain := cmd.String(flagSubdomain)
subdomain := cCtx.String(flagSubdomain)
if subdomain != "" && subdomain != "local" {
proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain))
proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))
if err != nil {
return fmt.Errorf("failed to get app info: %w", err)
}
_, _, err = ValidateRemote(
ctx,
cCtx.Context,
ce,
proj.GetSubdomain(),
proj.GetID(),

View File

@@ -9,7 +9,7 @@ import (
"github.com/google/uuid"
"github.com/nhost/be/services/mimir/graph"
cors "github.com/rs/cors/wrapper/gin"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -48,27 +48,27 @@ func Command() *cli.Command {
Name: enablePlaygroundFlag,
Usage: "enable graphql playground (under /v1)",
Category: "server",
Sources: cli.EnvVars("ENABLE_PLAYGROUND"),
EnvVars: []string{"ENABLE_PLAYGROUND"},
},
&cli.StringFlag{ //nolint: exhaustruct
Name: storageLocalConfigPath,
Usage: "Path to the local mimir config file",
Value: "/tmp/root/nhost/nhost.toml",
Category: "plugins",
Sources: cli.EnvVars("STORAGE_LOCAL_CONFIG_PATH"),
EnvVars: []string{"STORAGE_LOCAL_CONFIG_PATH"},
},
&cli.StringFlag{ //nolint: exhaustruct
Name: storageLocalSecretsPath,
Usage: "Path to the local mimir secrets file",
Value: "/tmp/root/.secrets",
Category: "plugins",
Sources: cli.EnvVars("STORAGE_LOCAL_SECRETS_PATH"),
EnvVars: []string{"STORAGE_LOCAL_SECRETS_PATH"},
},
&cli.StringSliceFlag{ //nolint: exhaustruct
Name: storageLocalRunServicesPath,
Usage: "Path to the local mimir run services files",
Category: "plugins",
Sources: cli.EnvVars("STORAGE_LOCAL_RUN_SERVICES_PATH"),
EnvVars: []string{"STORAGE_LOCAL_RUN_SERVICES_PATH"},
},
},
Action: serve,
@@ -103,14 +103,14 @@ func runServicesFiles(runServices ...string) map[string]string {
return m
}
func serve(_ context.Context, cmd *cli.Command) error {
logger := getLogger(cmd.Bool(debugFlag), cmd.Bool(logFormatJSONFlag))
logger.Info(cmd.Root().Name + " v" + cmd.Root().Version)
logFlags(logger, cmd)
func serve(cCtx *cli.Context) error {
logger := getLogger(cCtx.Bool(debugFlag), cCtx.Bool(logFormatJSONFlag))
logger.Info(cCtx.App.Name + " v" + cCtx.App.Version)
logFlags(logger, cCtx)
configFile := cmd.String(storageLocalConfigPath)
secretsFile := cmd.String(storageLocalSecretsPath)
runServices := runServicesFiles(cmd.StringSlice(storageLocalRunServicesPath)...)
configFile := cCtx.String(storageLocalConfigPath)
secretsFile := cCtx.String(storageLocalSecretsPath)
runServices := runServicesFiles(cCtx.StringSlice(storageLocalRunServicesPath)...)
st := NewLocal(configFile, secretsFile, runServices)
@@ -131,13 +131,13 @@ func serve(_ context.Context, cmd *cli.Command) error {
resolver,
dummyMiddleware,
dummyMiddleware2,
cmd.Bool(enablePlaygroundFlag),
cmd.Root().Version,
cCtx.Bool(enablePlaygroundFlag),
cCtx.App.Version,
[]graphql.FieldMiddleware{},
gin.Recovery(),
cors.Default(),
)
if err := r.Run(cmd.String(bindFlag)); err != nil {
if err := r.Run(cCtx.String(bindFlag)); err != nil {
return fmt.Errorf("failed to run gin: %w", err)
}

View File

@@ -5,7 +5,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func getLogger(debug bool, formatJSON bool) *logrus.Logger {
@@ -29,15 +29,15 @@ func getLogger(debug bool, formatJSON bool) *logrus.Logger {
return logger
}
func logFlags(logger logrus.FieldLogger, cmd *cli.Command) {
func logFlags(logger logrus.FieldLogger, cCtx *cli.Context) {
fields := logrus.Fields{}
for _, flag := range cmd.Root().Flags {
for _, flag := range cCtx.App.Flags {
name := flag.Names()[0]
fields[name] = cmd.Value(name)
fields[name] = cCtx.Generic(name)
}
for _, flag := range cmd.Flags {
for _, flag := range cCtx.Command.Flags {
name := flag.Names()[0]
if strings.Contains(name, "pass") ||
strings.Contains(name, "token") ||
@@ -47,7 +47,7 @@ func logFlags(logger logrus.FieldLogger, cmd *cli.Command) {
continue
}
fields[name] = cmd.Value(name)
fields[name] = cCtx.Generic(name)
}
logger.WithFields(fields).Info("started with settings")

View File

@@ -1,6 +1,6 @@
package deployments
import "github.com/urfave/cli/v3"
import "github.com/urfave/cli/v2"
const flagSubdomain = "subdomain"
@@ -9,7 +9,7 @@ func commonFlags() []cli.Flag {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagSubdomain,
Usage: "Project's subdomain to operate on, defaults to linked project",
Sources: cli.EnvVars("NHOST_SUBDOMAIN"),
EnvVars: []string{"NHOST_SUBDOMAIN"},
},
}
}
@@ -19,7 +19,7 @@ func Command() *cli.Command {
Name: "deployments",
Aliases: []string{},
Usage: "Manage deployments",
Commands: []*cli.Command{
Subcommands: []*cli.Command{
CommandList(),
CommandLogs(),
CommandNew(),

View File

@@ -1,13 +1,12 @@
package deployments
import (
"context"
"fmt"
"time"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/nhostclient/graphql"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandList() *cli.Command {
@@ -78,21 +77,21 @@ func printDeployments(ce *clienv.CliEnv, deployments []*graphql.ListDeployments_
ce.Println("%s", clienv.Table(id, date, duration, status, user, ref, message))
}
func commandList(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandList(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain))
proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))
if err != nil {
return fmt.Errorf("failed to get app info: %w", err)
}
cl, err := ce.GetNhostClient(ctx)
cl, err := ce.GetNhostClient(cCtx.Context)
if err != nil {
return fmt.Errorf("failed to get nhost client: %w", err)
}
deployments, err := cl.ListDeployments(
ctx,
cCtx.Context,
proj.ID,
)
if err != nil {

View File

@@ -8,7 +8,7 @@ import (
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/nhostclient"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -101,28 +101,28 @@ func showLogsFollow(
}
}
func commandLogs(ctx context.Context, cmd *cli.Command) error {
deploymentID := cmd.Args().First()
func commandLogs(cCtx *cli.Context) error {
deploymentID := cCtx.Args().First()
if deploymentID == "" {
return errors.New("deployment_id is required") //nolint:err113
}
ce := clienv.FromCLI(cmd)
ce := clienv.FromCLI(cCtx)
cl, err := ce.GetNhostClient(ctx)
cl, err := ce.GetNhostClient(cCtx.Context)
if err != nil {
return fmt.Errorf("failed to get nhost client: %w", err)
}
if cmd.Bool(flagFollow) {
ctxWithTimeout, cancel := context.WithTimeout(ctx, cmd.Duration(flagTimeout))
if cCtx.Bool(flagFollow) {
ctx, cancel := context.WithTimeout(cCtx.Context, cCtx.Duration(flagTimeout))
defer cancel()
if _, err := showLogsFollow(ctxWithTimeout, ce, cl, deploymentID); err != nil {
if _, err := showLogsFollow(ctx, ce, cl, deploymentID); err != nil {
return err
}
} else {
if err := showLogsSimple(ctx, ce, cl, deploymentID); err != nil {
if err := showLogsSimple(cCtx.Context, ce, cl, deploymentID); err != nil {
return err
}
}

View File

@@ -7,7 +7,7 @@ import (
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/nhostclient/graphql"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -40,7 +40,7 @@ func CommandNew() *cli.Command {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagRef,
Usage: "Git reference",
Sources: cli.EnvVars("GITHUB_SHA"),
EnvVars: []string{"GITHUB_SHA"},
Required: true,
},
&cli.StringFlag{ //nolint:exhaustruct
@@ -51,7 +51,7 @@ func CommandNew() *cli.Command {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagUser,
Usage: "Commit user name",
Sources: cli.EnvVars("GITHUB_ACTOR"),
EnvVars: []string{"GITHUB_ACTOR"},
Required: true,
},
&cli.StringFlag{ //nolint:exhaustruct
@@ -67,28 +67,28 @@ func ptr[i any](v i) *i {
return &v
}
func commandNew(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandNew(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
cl, err := ce.GetNhostClient(ctx)
cl, err := ce.GetNhostClient(cCtx.Context)
if err != nil {
return fmt.Errorf("failed to get nhost client: %w", err)
}
proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain))
proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))
if err != nil {
return fmt.Errorf("failed to get app info: %w", err)
}
resp, err := cl.InsertDeployment(
ctx,
cCtx.Context,
graphql.DeploymentsInsertInput{
App: nil,
AppID: ptr(proj.ID),
CommitMessage: ptr(cmd.String(flagMessage)),
CommitSha: ptr(cmd.String(flagRef)),
CommitUserAvatarURL: ptr(cmd.String(flagUserAvatarURL)),
CommitUserName: ptr(cmd.String(flagUser)),
CommitMessage: ptr(cCtx.String(flagMessage)),
CommitSha: ptr(cCtx.String(flagRef)),
CommitUserAvatarURL: ptr(cCtx.String(flagUserAvatarURL)),
CommitUserName: ptr(cCtx.String(flagUser)),
DeploymentStatus: ptr("SCHEDULED"),
},
)
@@ -98,13 +98,13 @@ func commandNew(ctx context.Context, cmd *cli.Command) error {
ce.Println("Deployment created: %s", resp.InsertDeployment.ID)
if cmd.Bool(flagFollow) {
if cCtx.Bool(flagFollow) {
ce.Println("")
ctxWithTimeout, cancel := context.WithTimeout(ctx, cmd.Duration(flagTimeout))
ctx, cancel := context.WithTimeout(cCtx.Context, cCtx.Duration(flagTimeout))
defer cancel()
status, err := showLogsFollow(ctxWithTimeout, ce, cl, resp.InsertDeployment.ID)
status, err := showLogsFollow(ctx, ce, cl, resp.InsertDeployment.ID)
if err != nil {
return fmt.Errorf("error streaming logs: %w", err)
}

View File

@@ -15,7 +15,7 @@ import (
"github.com/nhost/nhost/cli/cmd/software"
"github.com/nhost/nhost/cli/dockercompose"
"github.com/nhost/nhost/cli/nhostclient/graphql"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -34,19 +34,19 @@ func CommandCloud() *cli.Command {
Name: flagHTTPPort,
Usage: "HTTP port to listen on",
Value: defaultHTTPPort,
Sources: cli.EnvVars("NHOST_HTTP_PORT"),
EnvVars: []string{"NHOST_HTTP_PORT"},
},
&cli.BoolFlag{ //nolint:exhaustruct
Name: flagDisableTLS,
Usage: "Disable TLS",
Value: false,
Sources: cli.EnvVars("NHOST_DISABLE_TLS"),
EnvVars: []string{"NHOST_DISABLE_TLS"},
},
&cli.BoolFlag{ //nolint:exhaustruct
Name: flagApplySeeds,
Usage: "Apply seeds. If the .nhost folder does not exist, seeds will be applied regardless of this flag",
Value: false,
Sources: cli.EnvVars("NHOST_APPLY_SEEDS"),
EnvVars: []string{"NHOST_APPLY_SEEDS"},
},
&cli.UintFlag{ //nolint:exhaustruct
Name: flagsHasuraConsolePort,
@@ -56,42 +56,42 @@ func CommandCloud() *cli.Command {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagDashboardVersion,
Usage: "Dashboard version to use",
Value: "nhost/dashboard:2.38.0",
Sources: cli.EnvVars("NHOST_DASHBOARD_VERSION"),
Value: "nhost/dashboard:2.33.0",
EnvVars: []string{"NHOST_DASHBOARD_VERSION"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagConfigserverImage,
Hidden: true,
Value: "",
Sources: cli.EnvVars("NHOST_CONFIGSERVER_IMAGE"),
EnvVars: []string{"NHOST_CONFIGSERVER_IMAGE"},
},
&cli.BoolFlag{ //nolint:exhaustruct
Name: flagDownOnError,
Usage: "Skip confirmation",
Sources: cli.EnvVars("NHOST_YES"),
EnvVars: []string{"NHOST_YES"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagCACertificates,
Usage: "Mounts and everrides path to CA certificates in the containers",
Sources: cli.EnvVars("NHOST_CA_CERTIFICATES"),
EnvVars: []string{"NHOST_CA_CERTIFICATES"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagSubdomain,
Usage: "Project's subdomain to operate on, defaults to linked project",
Sources: cli.EnvVars("NHOST_SUBDOMAIN"),
EnvVars: []string{"NHOST_SUBDOMAIN"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagPostgresURL,
Usage: "Postgres URL",
Required: true,
Sources: cli.EnvVars("NHOST_POSTGRES_URL"),
EnvVars: []string{"NHOST_POSTGRES_URL"},
},
},
}
}
func commandCloud(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandCloud(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
if !clienv.PathExists(ce.Path.NhostToml()) {
return errors.New( //nolint:err113
@@ -105,38 +105,38 @@ func commandCloud(ctx context.Context, cmd *cli.Command) error {
)
}
proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain))
proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))
if err != nil {
return fmt.Errorf("failed to get app info: %w", err)
}
configserverImage := cmd.String(flagConfigserverImage)
configserverImage := cCtx.String(flagConfigserverImage)
if configserverImage == "" {
configserverImage = "nhost/cli:" + cmd.Root().Version
configserverImage = "nhost/cli:" + cCtx.App.Version
}
applySeeds := cmd.Bool(flagApplySeeds)
applySeeds := cCtx.Bool(flagApplySeeds)
return Cloud(
ctx,
cCtx.Context,
ce,
cmd.Root().Version,
cmd.Uint(flagHTTPPort),
!cmd.Bool(flagDisableTLS),
cCtx.App.Version,
cCtx.Uint(flagHTTPPort),
!cCtx.Bool(flagDisableTLS),
applySeeds,
dockercompose.ExposePorts{
Auth: cmd.Uint(flagAuthPort),
Storage: cmd.Uint(flagStoragePort),
Graphql: cmd.Uint(flagsHasuraPort),
Console: cmd.Uint(flagsHasuraConsolePort),
Functions: cmd.Uint(flagsFunctionsPort),
Auth: cCtx.Uint(flagAuthPort),
Storage: cCtx.Uint(flagStoragePort),
Graphql: cCtx.Uint(flagsHasuraPort),
Console: cCtx.Uint(flagsHasuraConsolePort),
Functions: cCtx.Uint(flagsFunctionsPort),
},
cmd.String(flagDashboardVersion),
cCtx.String(flagDashboardVersion),
configserverImage,
cmd.String(flagCACertificates),
cmd.Bool(flagDownOnError),
cCtx.String(flagCACertificates),
cCtx.Bool(flagDownOnError),
proj,
cmd.String(flagPostgresURL),
cCtx.String(flagPostgresURL),
)
}

View File

@@ -1,11 +1,9 @@
package dev
import (
"context"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/dockercompose"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandCompose() *cli.Command {
@@ -19,9 +17,9 @@ func CommandCompose() *cli.Command {
}
}
func commandCompose(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandCompose(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
dc := dockercompose.New(ce.Path.WorkingDir(), ce.Path.DockerCompose(), ce.ProjectName())
return dc.Wrapper(ctx, cmd.Args().Slice()...) //nolint:wrapcheck
return dc.Wrapper(cCtx.Context, cCtx.Args().Slice()...) //nolint:wrapcheck
}

View File

@@ -1,13 +1,13 @@
package dev
import "github.com/urfave/cli/v3"
import "github.com/urfave/cli/v2"
func Command() *cli.Command {
return &cli.Command{ //nolint:exhaustruct
Name: "dev",
Aliases: []string{},
Usage: "Operate local development environment",
Commands: []*cli.Command{
Subcommands: []*cli.Command{
CommandCompose(),
CommandHasura(),
},

View File

@@ -1,11 +1,9 @@
package dev
import (
"context"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/dockercompose"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -28,12 +26,12 @@ func CommandDown() *cli.Command {
}
}
func commandDown(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandDown(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
dc := dockercompose.New(ce.Path.WorkingDir(), ce.Path.DockerCompose(), ce.ProjectName())
if err := dc.Stop(ctx, cmd.Bool(flagVolumes)); err != nil {
if err := dc.Stop(cCtx.Context, cCtx.Bool(flagVolumes)); err != nil {
ce.Warnln("failed to stop Nhost development environment: %s", err)
}

View File

@@ -1,14 +1,13 @@
package dev
import (
"context"
"fmt"
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/dockercompose"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandHasura() *cli.Command {
@@ -22,8 +21,8 @@ func CommandHasura() *cli.Command {
}
}
func commandHasura(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandHasura(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
cfg := &model.ConfigConfig{} //nolint:exhaustruct
if err := clienv.UnmarshalFile(ce.Path.NhostToml(), cfg, toml.Unmarshal); err != nil {
@@ -33,10 +32,10 @@ func commandHasura(ctx context.Context, cmd *cli.Command) error {
docker := dockercompose.NewDocker()
return docker.HasuraWrapper( //nolint:wrapcheck
ctx,
cCtx.Context,
ce.LocalSubdomain(),
ce.Path.NhostFolder(),
*cfg.Hasura.Version,
cmd.Args().Slice()...,
cCtx.Args().Slice()...,
)
}

View File

@@ -1,11 +1,9 @@
package dev
import (
"context"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/dockercompose"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandLogs() *cli.Command {
@@ -19,12 +17,12 @@ func CommandLogs() *cli.Command {
}
}
func commandLogs(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandLogs(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
dc := dockercompose.New(ce.Path.WorkingDir(), ce.Path.DockerCompose(), ce.ProjectName())
if err := dc.Logs(ctx, cmd.Args().Slice()...); err != nil {
if err := dc.Logs(cCtx.Context, cCtx.Args().Slice()...); err != nil {
ce.Warnln("%s", err)
}

View File

@@ -19,7 +19,7 @@ import (
"github.com/nhost/nhost/cli/cmd/software"
"github.com/nhost/nhost/cli/dockercompose"
"github.com/nhost/nhost/cli/project/env"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func deptr[T any](t *T) T { //nolint:ireturn
@@ -63,25 +63,25 @@ func CommandUp() *cli.Command { //nolint:funlen
Name: flagHTTPPort,
Usage: "HTTP port to listen on",
Value: defaultHTTPPort,
Sources: cli.EnvVars("NHOST_HTTP_PORT"),
EnvVars: []string{"NHOST_HTTP_PORT"},
},
&cli.BoolFlag{ //nolint:exhaustruct
Name: flagDisableTLS,
Usage: "Disable TLS",
Value: false,
Sources: cli.EnvVars("NHOST_DISABLE_TLS"),
EnvVars: []string{"NHOST_DISABLE_TLS"},
},
&cli.UintFlag{ //nolint:exhaustruct
Name: flagPostgresPort,
Usage: "Postgres port to listen on",
Value: defaultPostgresPort,
Sources: cli.EnvVars("NHOST_POSTGRES_PORT"),
EnvVars: []string{"NHOST_POSTGRES_PORT"},
},
&cli.BoolFlag{ //nolint:exhaustruct
Name: flagApplySeeds,
Usage: "Apply seeds. If the .nhost folder does not exist, seeds will be applied regardless of this flag",
Value: false,
Sources: cli.EnvVars("NHOST_APPLY_SEEDS"),
EnvVars: []string{"NHOST_APPLY_SEEDS"},
},
&cli.UintFlag{ //nolint:exhaustruct
Name: flagAuthPort,
@@ -111,39 +111,39 @@ func CommandUp() *cli.Command { //nolint:funlen
&cli.StringFlag{ //nolint:exhaustruct
Name: flagDashboardVersion,
Usage: "Dashboard version to use",
Value: "nhost/dashboard:2.38.0",
Sources: cli.EnvVars("NHOST_DASHBOARD_VERSION"),
Value: "nhost/dashboard:2.33.0",
EnvVars: []string{"NHOST_DASHBOARD_VERSION"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagConfigserverImage,
Hidden: true,
Value: "",
Sources: cli.EnvVars("NHOST_CONFIGSERVER_IMAGE"),
EnvVars: []string{"NHOST_CONFIGSERVER_IMAGE"},
},
&cli.StringSliceFlag{ //nolint:exhaustruct
Name: flagRunService,
Usage: "Run service to add to the development environment. Can be passed multiple times. Comma-separated values are also accepted. Format: /path/to/run-service.toml[:overlay_name]", //nolint:lll
Sources: cli.EnvVars("NHOST_RUN_SERVICE"),
EnvVars: []string{"NHOST_RUN_SERVICE"},
},
&cli.BoolFlag{ //nolint:exhaustruct
Name: flagDownOnError,
Usage: "Skip confirmation",
Sources: cli.EnvVars("NHOST_YES"),
EnvVars: []string{"NHOST_YES"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagCACertificates,
Usage: "Mounts and everrides path to CA certificates in the containers",
Sources: cli.EnvVars("NHOST_CA_CERTIFICATES"),
EnvVars: []string{"NHOST_CA_CERTIFICATES"},
},
},
Commands: []*cli.Command{
Subcommands: []*cli.Command{
CommandCloud(),
},
}
}
func commandUp(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandUp(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
// projname to be root directory
@@ -159,33 +159,33 @@ func commandUp(ctx context.Context, cmd *cli.Command) error {
)
}
configserverImage := cmd.String(flagConfigserverImage)
configserverImage := cCtx.String(flagConfigserverImage)
if configserverImage == "" {
configserverImage = "nhost/cli:" + cmd.Root().Version
configserverImage = "nhost/cli:" + cCtx.App.Version
}
applySeeds := cmd.Bool(flagApplySeeds) || !clienv.PathExists(ce.Path.DotNhostFolder())
applySeeds := cCtx.Bool(flagApplySeeds) || !clienv.PathExists(ce.Path.DotNhostFolder())
return Up(
ctx,
cCtx.Context,
ce,
cmd.Root().Version,
cmd.Uint(flagHTTPPort),
!cmd.Bool(flagDisableTLS),
cmd.Uint(flagPostgresPort),
cCtx.App.Version,
cCtx.Uint(flagHTTPPort),
!cCtx.Bool(flagDisableTLS),
cCtx.Uint(flagPostgresPort),
applySeeds,
dockercompose.ExposePorts{
Auth: cmd.Uint(flagAuthPort),
Storage: cmd.Uint(flagStoragePort),
Graphql: cmd.Uint(flagsHasuraPort),
Console: cmd.Uint(flagsHasuraConsolePort),
Functions: cmd.Uint(flagsFunctionsPort),
Auth: cCtx.Uint(flagAuthPort),
Storage: cCtx.Uint(flagStoragePort),
Graphql: cCtx.Uint(flagsHasuraPort),
Console: cCtx.Uint(flagsHasuraConsolePort),
Functions: cCtx.Uint(flagsFunctionsPort),
},
cmd.String(flagDashboardVersion),
cCtx.String(flagDashboardVersion),
configserverImage,
cmd.String(flagCACertificates),
cmd.StringSlice(flagRunService),
cmd.Bool(flagDownOnError),
cCtx.String(flagCACertificates),
cCtx.StringSlice(flagRunService),
cCtx.Bool(flagDownOnError),
)
}

View File

@@ -8,7 +8,7 @@ import (
"os/exec"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -35,13 +35,13 @@ func CommandConfigure() *cli.Command {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagDockerConfig,
Usage: "Path to docker config file",
Sources: cli.EnvVars("DOCKER_CONFIG"),
EnvVars: []string{"DOCKER_CONFIG"},
Value: home + "/.docker/config.json",
},
&cli.BoolFlag{ //nolint:exhaustruct
Name: flagNoInteractive,
Usage: "Do not prompt for confirmation",
Sources: cli.EnvVars("NO_INTERACTIVE"),
EnvVars: []string{"NO_INTERACTIVE"},
Value: false,
},
},
@@ -140,21 +140,21 @@ func configureDocker(dockerConfig string) error {
return nil
}
func actionConfigure(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func actionConfigure(c *cli.Context) error {
ce := clienv.FromCLI(c)
if err := writeScript(ctx, ce); err != nil {
if err := writeScript(c.Context, ce); err != nil {
return err
}
if cmd.Bool(flagNoInteractive) {
return configureDocker(cmd.String(flagDockerConfig))
if c.Bool(flagNoInteractive) {
return configureDocker(c.String(flagDockerConfig))
}
//nolint:lll
ce.PromptMessage(
"I am about to configure docker to authenticate with Nhost's registry. This will modify your docker config file on %s. Should I continue? [y/N] ",
cmd.String(flagDockerConfig),
c.String(flagDockerConfig),
)
v, err := ce.PromptInput(false)
@@ -163,7 +163,7 @@ func actionConfigure(ctx context.Context, cmd *cli.Command) error {
}
if v == "y" || v == "Y" {
return configureDocker(cmd.String(flagDockerConfig))
return configureDocker(c.String(flagDockerConfig))
}
return nil

View File

@@ -1,13 +1,13 @@
package dockercredentials
import "github.com/urfave/cli/v3"
import "github.com/urfave/cli/v2"
func Command() *cli.Command {
return &cli.Command{ //nolint:exhaustruct
Name: "docker-credentials",
Aliases: []string{},
Usage: "Perform docker-credentials operations",
Commands: []*cli.Command{
Subcommands: []*cli.Command{
CommandGet(),
CommandErase(),
CommandStore(),

View File

@@ -1,9 +1,7 @@
package dockercredentials
import (
"context"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandErase() *cli.Command {
@@ -16,7 +14,7 @@ func CommandErase() *cli.Command {
}
}
func actionErase(_ context.Context, cmd *cli.Command) error {
_, _ = cmd.Root().Writer.Write([]byte("Please, use the nhost CLI to logout\n"))
func actionErase(c *cli.Context) error {
_, _ = c.App.Writer.Write([]byte("Please, use the nhost CLI to logout\n"))
return nil
}

View File

@@ -8,7 +8,7 @@ import (
"os"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -26,14 +26,14 @@ func CommandGet() *cli.Command {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagAuthURL,
Usage: "Nhost auth URL",
Sources: cli.EnvVars("NHOST_CLI_AUTH_URL"),
EnvVars: []string{"NHOST_CLI_AUTH_URL"},
Value: "https://otsispdzcwxyqzbfntmj.auth.eu-central-1.nhost.run/v1",
Hidden: true,
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagGraphqlURL,
Usage: "Nhost GraphQL URL",
Sources: cli.EnvVars("NHOST_CLI_GRAPHQL_URL"),
EnvVars: []string{"NHOST_CLI_GRAPHQL_URL"},
Value: "https://otsispdzcwxyqzbfntmj.graphql.eu-central-1.nhost.run/v1",
Hidden: true,
},
@@ -69,15 +69,15 @@ type response struct {
Secret string `json:"Secret"`
}
func actionGet(ctx context.Context, cmd *cli.Command) error {
scanner := bufio.NewScanner(cmd.Root().Reader)
func actionGet(c *cli.Context) error {
scanner := bufio.NewScanner(c.App.Reader)
var input string
for scanner.Scan() {
input += scanner.Text()
}
token, err := getToken(ctx, cmd.String(flagAuthURL), cmd.String(flagGraphqlURL))
token, err := getToken(c.Context, c.String(flagAuthURL), c.String(flagGraphqlURL))
if err != nil {
return err
}
@@ -91,7 +91,7 @@ func actionGet(ctx context.Context, cmd *cli.Command) error {
return fmt.Errorf("failed to marshal response: %w", err)
}
if _, err = cmd.Root().Writer.Write(b); err != nil {
if _, err = c.App.Writer.Write(b); err != nil {
return fmt.Errorf("failed to write response: %w", err)
}

View File

@@ -1,9 +1,7 @@
package dockercredentials
import (
"context"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandStore() *cli.Command {
@@ -16,7 +14,7 @@ func CommandStore() *cli.Command {
}
}
func actionStore(_ context.Context, cmd *cli.Command) error {
_, _ = cmd.Root().Writer.Write([]byte("Please, use the nhost CLI to login\n"))
func actionStore(c *cli.Context) error {
_, _ = c.App.Writer.Write([]byte("Please, use the nhost CLI to login\n"))
return nil
}

View File

@@ -9,12 +9,12 @@ import (
"os"
"path/filepath"
"github.com/hashicorp/go-getter/v2"
"github.com/hashicorp/go-getter"
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/cmd/config"
"github.com/nhost/nhost/cli/dockercompose"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
"gopkg.in/yaml.v3"
)
@@ -75,14 +75,14 @@ func CommandInit() *cli.Command {
Name: flagRemote,
Usage: "Initialize pulling configuration, migrations and metadata from the linked project",
Value: false,
Sources: cli.EnvVars("NHOST_REMOTE"),
EnvVars: []string{"NHOST_REMOTE"},
},
},
}
}
func commandInit(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandInit(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
if clienv.PathExists(ce.Path.NhostFolder()) {
return errors.New("nhost folder already exists") //nolint:err113
@@ -98,12 +98,12 @@ func commandInit(ctx context.Context, cmd *cli.Command) error {
return fmt.Errorf("failed to initialize configuration: %w", err)
}
if cmd.Bool(flagRemote) {
if err := InitRemote(ctx, ce); err != nil {
if cCtx.Bool(flagRemote) {
if err := InitRemote(cCtx.Context, ce); err != nil {
return fmt.Errorf("failed to initialize remote project: %w", err)
}
} else {
if err := initInit(ctx, ce.Path); err != nil {
if err := initInit(cCtx.Context, ce.Path); err != nil {
return fmt.Errorf("failed to initialize project: %w", err)
}
}
@@ -129,12 +129,17 @@ func initInit(
return err
}
getclient := &getter.Client{} //nolint:exhaustruct
if _, err := getclient.Get(ctx, &getter.Request{ //nolint:exhaustruct
Src: "git::https://github.com/nhost/hasura-auth.git//email-templates",
Dst: "nhost/emails",
DisableSymlinks: true,
}); err != nil {
getclient := &getter.Client{ //nolint:exhaustruct
Ctx: ctx,
Src: "github.com/nhost/hasura-auth/email-templates",
Dst: "nhost/emails",
Mode: getter.ClientModeAny,
Detectors: []getter.Detector{
&getter.GitHubDetector{},
},
}
if err := getclient.Get(); err != nil {
return fmt.Errorf("failed to download email templates: %w", err)
}

View File

@@ -1,12 +1,11 @@
package project
import (
"context"
"fmt"
"os"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandLink() *cli.Command {
@@ -19,14 +18,14 @@ func CommandLink() *cli.Command {
}
}
func commandLink(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandLink(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
if err := os.MkdirAll(ce.Path.DotNhostFolder(), 0o755); err != nil { //nolint:mnd
return fmt.Errorf("failed to create .nhost folder: %w", err)
}
_, err := ce.Link(ctx)
_, err := ce.Link(cCtx.Context)
return err //nolint:wrapcheck
}

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandList() *cli.Command {
@@ -18,9 +18,9 @@ func CommandList() *cli.Command {
}
}
func commandList(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
return List(ctx, ce)
func commandList(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
return List(cCtx.Context, ce)
}
func List(ctx context.Context, ce *clienv.CliEnv) error {

View File

@@ -1,14 +1,13 @@
package run
import (
"context"
"encoding/json"
"fmt"
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/nhostclient/graphql"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandConfigDeploy() *cli.Command {
@@ -24,13 +23,13 @@ func CommandConfigDeploy() *cli.Command {
Usage: "Service configuration file",
Value: "nhost-run-service.toml",
Required: true,
Sources: cli.EnvVars("NHOST_RUN_SERVICE_CONFIG"),
EnvVars: []string{"NHOST_RUN_SERVICE_CONFIG"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagServiceID,
Usage: "Service ID to update. Applies overlay of the same name",
Required: true,
Sources: cli.EnvVars("NHOST_RUN_SERVICE_ID"),
EnvVars: []string{"NHOST_RUN_SERVICE_ID"},
},
},
}
@@ -50,23 +49,23 @@ func transform[T, V any](t *T) (*V, error) {
return &v, nil
}
func commandConfigDeploy(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandConfigDeploy(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
cl, err := ce.GetNhostClient(ctx)
cl, err := ce.GetNhostClient(cCtx.Context)
if err != nil {
return fmt.Errorf("failed to get nhost client: %w", err)
}
secrets, appID, err := getRemoteSecrets(ctx, cl, cmd.String(flagServiceID))
secrets, appID, err := getRemoteSecrets(cCtx.Context, cl, cCtx.String(flagServiceID))
if err != nil {
return err
}
cfg, err := Validate(
ce,
cmd.String(flagConfig),
cmd.String(flagServiceID),
cCtx.String(flagConfig),
cCtx.String(flagServiceID),
secrets,
true,
)
@@ -82,9 +81,9 @@ func commandConfigDeploy(ctx context.Context, cmd *cli.Command) error {
}
if _, err := cl.ReplaceRunServiceConfig(
ctx,
cCtx.Context,
appID,
cmd.String(flagServiceID),
cCtx.String(flagServiceID),
*replaceConfig,
); err != nil {
return fmt.Errorf("failed to replace service config: %w", err)

View File

@@ -1,7 +1,6 @@
package run
import (
"context"
"fmt"
"os"
"path/filepath"
@@ -9,7 +8,7 @@ import (
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/cmd/config"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const flagEditor = "editor"
@@ -26,31 +25,31 @@ func CommandConfigEdit() *cli.Command {
Usage: "Service configuration file",
Value: "nhost-run-service.toml",
Required: true,
Sources: cli.EnvVars("NHOST_RUN_SERVICE_CONFIG"),
EnvVars: []string{"NHOST_RUN_SERVICE_CONFIG"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagEditor,
Usage: "Editor to use",
Value: "vim",
Sources: cli.EnvVars("EDITOR"),
EnvVars: []string{"EDITOR"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagOverlayName,
Usage: "If specified, apply this overlay",
Sources: cli.EnvVars("NHOST_RUN_SERVICE_ID", "NHOST_SERVICE_OVERLAY_NAME"),
EnvVars: []string{"NHOST_RUN_SERVICE_ID", "NHOST_SERVICE_OVERLAY_NAME"},
},
},
Action: commandConfigEdit,
}
}
func commandConfigEdit(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandConfigEdit(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
overlayName := cmd.String(flagOverlayName)
overlayName := cCtx.String(flagOverlayName)
if overlayName == "" {
if err := config.EditFile(
ctx, cmd.String(flagEditor), cmd.String(flagConfig),
cCtx.Context, cCtx.String(flagEditor), cCtx.String(flagConfig),
); err != nil {
return fmt.Errorf("failed to edit config: %w", err)
}
@@ -59,7 +58,7 @@ func commandConfigEdit(ctx context.Context, cmd *cli.Command) error {
}
if err := os.MkdirAll(ce.Path.RunServiceOverlaysFolder(
cmd.String(flagConfig),
cCtx.String(flagConfig),
), 0o755); err != nil { //nolint:mnd
return fmt.Errorf("failed to create json patches directory: %w", err)
}
@@ -73,21 +72,21 @@ func commandConfigEdit(ctx context.Context, cmd *cli.Command) error {
tmpfileName := filepath.Join(tmpdir, "nhost.toml")
if err := config.CopyConfig[model.ConfigRunServiceConfig](
cmd.String(flagConfig),
cCtx.String(flagConfig),
tmpfileName,
ce.Path.RunServiceOverlay(cmd.String(flagConfig), overlayName),
ce.Path.RunServiceOverlay(cCtx.String(flagConfig), overlayName),
); err != nil {
return fmt.Errorf("failed to copy config: %w", err)
}
if err := config.EditFile(ctx, cmd.String(flagEditor), tmpfileName); err != nil {
if err := config.EditFile(cCtx.Context, cCtx.String(flagEditor), tmpfileName); err != nil {
return fmt.Errorf("failed to edit config: %w", err)
}
if err := config.GenerateJSONPatch(
cmd.String(flagConfig),
cCtx.String(flagConfig),
tmpfileName,
ce.Path.RunServiceOverlay(cmd.String(flagConfig), overlayName),
ce.Path.RunServiceOverlay(cCtx.String(flagConfig), overlayName),
); err != nil {
return fmt.Errorf("failed to generate json patch: %w", err)
}

View File

@@ -1,13 +1,12 @@
package run
import (
"context"
"fmt"
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const flagImage = "image"
@@ -23,29 +22,29 @@ func CommandConfigEditImage() *cli.Command {
Aliases: []string{},
Usage: "Service configuration file",
Value: "nhost-run-service.toml",
Sources: cli.EnvVars("NHOST_RUN_SERVICE_CONFIG"),
EnvVars: []string{"NHOST_RUN_SERVICE_CONFIG"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagImage,
Aliases: []string{},
Usage: "Image to use",
Required: true,
Sources: cli.EnvVars("NHOST_RUN_SERVICE_IMAGE"),
EnvVars: []string{"NHOST_RUN_SERVICE_IMAGE"},
},
},
Action: commandConfigEditImage,
}
}
func commandConfigEditImage(_ context.Context, cmd *cli.Command) error {
func commandConfigEditImage(cCtx *cli.Context) error {
var cfg model.ConfigRunServiceConfig
if err := clienv.UnmarshalFile(cmd.String(flagConfig), &cfg, toml.Unmarshal); err != nil {
if err := clienv.UnmarshalFile(cCtx.String(flagConfig), &cfg, toml.Unmarshal); err != nil {
return fmt.Errorf("failed to unmarshal config: %w", err)
}
cfg.Image.Image = cmd.String(flagImage)
cfg.Image.Image = cCtx.String(flagImage)
if err := clienv.MarshalFile(cfg, cmd.String(flagConfig), toml.Marshal); err != nil {
if err := clienv.MarshalFile(cfg, cCtx.String(flagConfig), toml.Marshal); err != nil {
return fmt.Errorf("failed to marshal config: %w", err)
}

View File

@@ -1,14 +1,13 @@
package run
import (
"context"
"fmt"
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/be/services/mimir/schema"
"github.com/nhost/nhost/cli/clienv"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func ptr[T any](v T) *T {
@@ -25,8 +24,8 @@ func CommandConfigExample() *cli.Command {
}
}
func commandConfigExample(_ context.Context, cmd *cli.Command) error { //nolint:funlen
ce := clienv.FromCLI(cmd)
func commandConfigExample(cCtx *cli.Context) error { //nolint:funlen
ce := clienv.FromCLI(cCtx)
//nolint:mnd
cfg := &model.ConfigRunServiceConfig{

View File

@@ -1,14 +1,13 @@
package run
import (
"context"
"encoding/json"
"fmt"
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const flagServiceID = "service-id"
@@ -24,36 +23,36 @@ func CommandConfigPull() *cli.Command {
Aliases: []string{},
Usage: "Service configuration file",
Value: "nhost-run-service.toml",
Sources: cli.EnvVars("NHOST_RUN_SERVICE_CONFIG"),
EnvVars: []string{"NHOST_RUN_SERVICE_CONFIG"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagServiceID,
Usage: "Service ID to update",
Required: true,
Sources: cli.EnvVars("NHOST_RUN_SERVICE_ID"),
EnvVars: []string{"NHOST_RUN_SERVICE_ID"},
},
},
Action: commandConfigPull,
}
}
func commandConfigPull(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandConfigPull(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
cl, err := ce.GetNhostClient(ctx)
cl, err := ce.GetNhostClient(cCtx.Context)
if err != nil {
return fmt.Errorf("failed to get nhost client: %w", err)
}
appID, err := getAppIDFromServiceID(ctx, cl, cmd.String(flagServiceID))
appID, err := getAppIDFromServiceID(cCtx.Context, cl, cCtx.String(flagServiceID))
if err != nil {
return err
}
resp, err := cl.GetRunServiceConfigRawJSON(
ctx,
cCtx.Context,
appID,
cmd.String(flagServiceID),
cCtx.String(flagServiceID),
false,
)
if err != nil {
@@ -65,7 +64,7 @@ func commandConfigPull(ctx context.Context, cmd *cli.Command) error {
return fmt.Errorf("failed to unmarshal config: %w", err)
}
if err := clienv.MarshalFile(v, cmd.String(flagConfig), toml.Marshal); err != nil {
if err := clienv.MarshalFile(v, cCtx.String(flagConfig), toml.Marshal); err != nil {
return fmt.Errorf("failed to save config to file: %w", err)
}

View File

@@ -1,14 +1,13 @@
package run
import (
"context"
"fmt"
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/project/env"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandConfigShow() *cli.Command {
@@ -24,19 +23,19 @@ func CommandConfigShow() *cli.Command {
Aliases: []string{},
Usage: "Service configuration file",
Value: "nhost-run-service.toml",
Sources: cli.EnvVars("NHOST_RUN_SERVICE_CONFIG"),
EnvVars: []string{"NHOST_RUN_SERVICE_CONFIG"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagOverlayName,
Usage: "If specified, apply this overlay",
Sources: cli.EnvVars("NHOST_RUN_SERVICE_ID", "NHOST_SERVICE_OVERLAY_NAME"),
EnvVars: []string{"NHOST_RUN_SERVICE_ID", "NHOST_SERVICE_OVERLAY_NAME"},
},
},
}
}
func commandConfigShow(_ context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandConfigShow(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
var secrets model.Secrets
if err := clienv.UnmarshalFile(ce.Path.Secrets(), &secrets, env.Unmarshal); err != nil {
@@ -48,8 +47,8 @@ func commandConfigShow(_ context.Context, cmd *cli.Command) error {
cfg, err := Validate(
ce,
cmd.String(flagConfig),
cmd.String(flagOverlayName),
cCtx.String(flagConfig),
cCtx.String(flagOverlayName),
secrets,
false,
)

View File

@@ -15,7 +15,7 @@ import (
"github.com/nhost/nhost/cli/nhostclient/graphql"
"github.com/nhost/nhost/cli/project/env"
"github.com/pelletier/go-toml/v2"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -35,17 +35,17 @@ func CommandConfigValidate() *cli.Command {
Aliases: []string{},
Usage: "Service configuration file",
Value: "nhost-run-service.toml",
Sources: cli.EnvVars("NHOST_RUN_SERVICE_CONFIG"),
EnvVars: []string{"NHOST_RUN_SERVICE_CONFIG"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagOverlayName,
Usage: "If specified, apply this overlay",
Sources: cli.EnvVars("NHOST_SERVICE_OVERLAY_NAME"),
EnvVars: []string{"NHOST_SERVICE_OVERLAY_NAME"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagServiceID,
Usage: "If specified, apply this overlay and remote secrets for this service",
Sources: cli.EnvVars("NHOST_RUN_SERVICE_ID"),
EnvVars: []string{"NHOST_RUN_SERVICE_ID"},
},
},
}
@@ -157,35 +157,35 @@ func getRemoteSecrets(
return respToSecrets(secretsResp.GetAppSecrets()), appID, nil
}
func commandConfigValidate(ctx context.Context, cmd *cli.Command) error {
func commandConfigValidate(cCtx *cli.Context) error {
var (
overlayName string
serviceID string
)
switch {
case cmd.String(flagServiceID) != "" && cmd.String(flagOverlayName) != "":
case cCtx.String(flagServiceID) != "" && cCtx.String(flagOverlayName) != "":
return errors.New("cannot specify both service id and overlay name") //nolint:err113
case cmd.String(flagServiceID) != "":
serviceID = cmd.String(flagServiceID)
case cCtx.String(flagServiceID) != "":
serviceID = cCtx.String(flagServiceID)
overlayName = serviceID
case cmd.String(flagOverlayName) != "":
overlayName = cmd.String(flagOverlayName)
case cCtx.String(flagOverlayName) != "":
overlayName = cCtx.String(flagOverlayName)
}
ce := clienv.FromCLI(cmd)
ce := clienv.FromCLI(cCtx)
var secrets model.Secrets
ce.Infoln("Getting secrets...")
if serviceID != "" {
cl, err := ce.GetNhostClient(ctx)
cl, err := ce.GetNhostClient(cCtx.Context)
if err != nil {
return fmt.Errorf("failed to get nhost client: %w", err)
}
secrets, _, err = getRemoteSecrets(ctx, cl, serviceID)
secrets, _, err = getRemoteSecrets(cCtx.Context, cl, serviceID)
if err != nil {
return err
}
@@ -202,7 +202,7 @@ func commandConfigValidate(ctx context.Context, cmd *cli.Command) error {
if _, err := Validate(
ce,
cmd.String(flagConfig),
cCtx.String(flagConfig),
overlayName,
secrets,
false,

View File

@@ -1,14 +1,13 @@
package run
import (
"context"
"fmt"
"regexp"
"github.com/nhost/be/services/mimir/model"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/project/env"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -29,17 +28,17 @@ func CommandEnv() *cli.Command {
Aliases: []string{},
Usage: "Service configuration file",
Value: "nhost-run-service.toml",
Sources: cli.EnvVars("NHOST_RUN_SERVICE_CONFIG"),
EnvVars: []string{"NHOST_RUN_SERVICE_CONFIG"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagOverlayName,
Usage: "If specified, apply this overlay",
Sources: cli.EnvVars("NHOST_RUN_SERVICE_ID", "NHOST_SERVICE_OVERLAY_NAME"),
EnvVars: []string{"NHOST_RUN_SERVICE_ID", "NHOST_SERVICE_OVERLAY_NAME"},
},
&cli.BoolFlag{ //nolint:exhaustruct
Name: flagDevPrependExport,
Usage: "Prepend 'export' to each line",
Sources: cli.EnvVars("NHOST_RuN_SERVICE_ENV_PREPEND_EXPORT"),
EnvVars: []string{"NHOST_RuN_SERVICE_ENV_PREPEND_EXPORT"},
},
},
}
@@ -50,8 +49,8 @@ func escape(s string) string {
return re.ReplaceAllString(s, "\\$0")
}
func commandConfigDev(_ context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandConfigDev(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
var secrets model.Secrets
if err := clienv.UnmarshalFile(ce.Path.Secrets(), &secrets, env.Unmarshal); err != nil {
@@ -63,8 +62,8 @@ func commandConfigDev(_ context.Context, cmd *cli.Command) error {
cfg, err := Validate(
ce,
cmd.String(flagConfig),
cmd.String(flagOverlayName),
cCtx.String(flagConfig),
cCtx.String(flagOverlayName),
secrets,
false,
)
@@ -74,7 +73,7 @@ func commandConfigDev(_ context.Context, cmd *cli.Command) error {
for _, v := range cfg.GetEnvironment() {
value := escape(v.Value)
if cmd.Bool(flagDevPrependExport) {
if cCtx.Bool(flagDevPrependExport) {
ce.Println("export %s=\"%s\"", v.Name, value)
} else {
ce.Println("%s=\"%s\"", v.Name, value)

View File

@@ -1,13 +1,13 @@
package run
import "github.com/urfave/cli/v3"
import "github.com/urfave/cli/v2"
func Command() *cli.Command {
return &cli.Command{ //nolint:exhaustruct
Name: "run",
Aliases: []string{},
Usage: "Perform operations on Nhost Run",
Commands: []*cli.Command{
Subcommands: []*cli.Command{
CommandConfigShow(),
CommandConfigDeploy(),
CommandConfigEdit(),

View File

@@ -1,12 +1,11 @@
package secrets //nolint:dupl
import (
"context"
"errors"
"fmt"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandCreate() *cli.Command {
@@ -20,28 +19,28 @@ func CommandCreate() *cli.Command {
}
}
func commandCreate(ctx context.Context, cmd *cli.Command) error {
if cmd.NArg() != 2 { //nolint:mnd
func commandCreate(cCtx *cli.Context) error {
if cCtx.NArg() != 2 { //nolint:mnd
return errors.New("invalid number of arguments") //nolint:err113
}
ce := clienv.FromCLI(cmd)
ce := clienv.FromCLI(cCtx)
proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain))
proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))
if err != nil {
return fmt.Errorf("failed to get app info: %w", err)
}
cl, err := ce.GetNhostClient(ctx)
cl, err := ce.GetNhostClient(cCtx.Context)
if err != nil {
return fmt.Errorf("failed to get nhost client: %w", err)
}
if _, err := cl.CreateSecret(
ctx,
cCtx.Context,
proj.ID,
cmd.Args().Get(0),
cmd.Args().Get(1),
cCtx.Args().Get(0),
cCtx.Args().Get(1),
); err != nil {
return fmt.Errorf("failed to create secret: %w", err)
}

View File

@@ -1,12 +1,11 @@
package secrets
import (
"context"
"errors"
"fmt"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandDelete() *cli.Command {
@@ -20,27 +19,27 @@ func CommandDelete() *cli.Command {
}
}
func commandDelete(ctx context.Context, cmd *cli.Command) error {
if cmd.NArg() != 1 {
func commandDelete(cCtx *cli.Context) error {
if cCtx.NArg() != 1 {
return errors.New("invalid number of arguments") //nolint:err113
}
ce := clienv.FromCLI(cmd)
ce := clienv.FromCLI(cCtx)
proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain))
proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))
if err != nil {
return fmt.Errorf("failed to get app info: %w", err)
}
cl, err := ce.GetNhostClient(ctx)
cl, err := ce.GetNhostClient(cCtx.Context)
if err != nil {
return fmt.Errorf("failed to get nhost client: %w", err)
}
if _, err := cl.DeleteSecret(
ctx,
cCtx.Context,
proj.ID,
cmd.Args().Get(0),
cCtx.Args().Get(0),
); err != nil {
return fmt.Errorf("failed to delete secret: %w", err)
}

View File

@@ -1,11 +1,10 @@
package secrets
import (
"context"
"fmt"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandList() *cli.Command {
@@ -18,21 +17,21 @@ func CommandList() *cli.Command {
}
}
func commandList(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandList(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain))
proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))
if err != nil {
return fmt.Errorf("failed to get app info: %w", err)
}
cl, err := ce.GetNhostClient(ctx)
cl, err := ce.GetNhostClient(cCtx.Context)
if err != nil {
return fmt.Errorf("failed to get nhost client: %w", err)
}
secrets, err := cl.GetSecrets(
ctx,
cCtx.Context,
proj.ID,
)
if err != nil {

View File

@@ -1,6 +1,6 @@
package secrets
import "github.com/urfave/cli/v3"
import "github.com/urfave/cli/v2"
const flagSubdomain = "subdomain"
@@ -9,7 +9,7 @@ func commonFlags() []cli.Flag {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagSubdomain,
Usage: "Project's subdomain to operate on, defaults to linked project",
Sources: cli.EnvVars("NHOST_SUBDOMAIN"),
EnvVars: []string{"NHOST_SUBDOMAIN"},
},
}
}
@@ -19,7 +19,7 @@ func Command() *cli.Command {
Name: "secrets",
Aliases: []string{},
Usage: "Manage secrets",
Commands: []*cli.Command{
Subcommands: []*cli.Command{
CommandCreate(),
CommandDelete(),
CommandList(),

View File

@@ -1,12 +1,11 @@
package secrets //nolint:dupl
import (
"context"
"errors"
"fmt"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandUpdate() *cli.Command {
@@ -20,28 +19,28 @@ func CommandUpdate() *cli.Command {
}
}
func commandUpdate(ctx context.Context, cmd *cli.Command) error {
if cmd.NArg() != 2 { //nolint:mnd
func commandUpdate(cCtx *cli.Context) error {
if cCtx.NArg() != 2 { //nolint:mnd
return errors.New("invalid number of arguments") //nolint:err113
}
ce := clienv.FromCLI(cmd)
ce := clienv.FromCLI(cCtx)
proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain))
proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain))
if err != nil {
return fmt.Errorf("failed to get app info: %w", err)
}
cl, err := ce.GetNhostClient(ctx)
cl, err := ce.GetNhostClient(cCtx.Context)
if err != nil {
return fmt.Errorf("failed to get nhost client: %w", err)
}
if _, err := cl.UpdateSecret(
ctx,
cCtx.Context,
proj.ID,
cmd.Args().Get(0),
cmd.Args().Get(1),
cCtx.Args().Get(0),
cCtx.Args().Get(1),
); err != nil {
return fmt.Errorf("failed to update secret: %w", err)
}

View File

@@ -1,6 +1,6 @@
package software
import "github.com/urfave/cli/v3"
import "github.com/urfave/cli/v2"
const (
devVersion = "dev"
@@ -11,7 +11,7 @@ func Command() *cli.Command {
Name: "sw",
Aliases: []string{},
Usage: "Perform software management operations",
Commands: []*cli.Command{
Subcommands: []*cli.Command{
CommandUninstall(),
CommandUpgrade(),
CommandVersion(),

View File

@@ -1,12 +1,11 @@
package software
import (
"context"
"fmt"
"os"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -23,29 +22,29 @@ func CommandUninstall() *cli.Command {
&cli.BoolFlag{ //nolint:exhaustruct
Name: forceFlag,
Usage: "Force uninstall without confirmation",
Sources: cli.EnvVars("NHOST_FORCE_UNINSTALL"),
EnvVars: []string{"NHOST_FORCE_UNINSTALL"},
DefaultText: "false",
},
},
}
}
func commandUninstall(_ context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandUninstall(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
path, err := os.Executable()
if err != nil {
return fmt.Errorf("failed to find installed CLI: %w", err)
}
if cmd.Root().Version == devVersion || cmd.Root().Version == "" {
if cCtx.App.Version == devVersion || cCtx.App.Version == "" {
// we fake it in dev mode
path = "/tmp/nhost"
}
ce.Infoln("Found Nhost cli in %s", path)
if !cmd.Bool(forceFlag) {
if !cCtx.Bool(forceFlag) {
ce.PromptMessage("Are you sure you want to uninstall Nhost CLI? [y/N] ")
resp, err := ce.PromptInput(false)

View File

@@ -1,7 +1,6 @@
package software
import (
"context"
"fmt"
"os"
"runtime"
@@ -9,7 +8,7 @@ import (
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/software"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandUpgrade() *cli.Command {
@@ -21,12 +20,12 @@ func CommandUpgrade() *cli.Command {
}
}
func commandUpgrade(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandUpgrade(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
mgr := software.NewManager()
releases, err := mgr.GetReleases(ctx, cmd.Root().Version)
releases, err := mgr.GetReleases(cCtx.Context, cCtx.App.Version)
if err != nil {
return fmt.Errorf("failed to get releases: %w", err)
}
@@ -37,7 +36,7 @@ func commandUpgrade(ctx context.Context, cmd *cli.Command) error {
}
latest := releases[0]
if latest.TagName == cmd.Root().Version {
if latest.TagName == cCtx.App.Version {
ce.Infoln("You have the latest version. Hurray!")
return nil
}
@@ -72,20 +71,20 @@ func commandUpgrade(ctx context.Context, cmd *cli.Command) error {
defer os.Remove(tmpFile.Name())
defer tmpFile.Close()
if err := mgr.DownloadAsset(ctx, url, tmpFile); err != nil {
if err := mgr.DownloadAsset(cCtx.Context, url, tmpFile); err != nil {
return fmt.Errorf("failed to download asset: %w", err)
}
return install(cmd, ce, tmpFile.Name())
return install(cCtx, ce, tmpFile.Name())
}
func install(cmd *cli.Command, ce *clienv.CliEnv, tmpFile string) error {
func install(cCtx *cli.Context, ce *clienv.CliEnv, tmpFile string) error {
curBin, err := os.Executable()
if err != nil {
return fmt.Errorf("failed to find installed CLI: %w", err)
}
if cmd.Root().Version == devVersion || cmd.Root().Version == "" {
if cCtx.App.Version == devVersion || cCtx.App.Version == "" {
// we are in dev mode, we fake curBin for testing
curBin = "/tmp/nhost"
}

View File

@@ -12,7 +12,7 @@ import (
"github.com/nhost/nhost/cli/nhostclient/graphql"
"github.com/nhost/nhost/cli/project/env"
"github.com/nhost/nhost/cli/software"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
func CommandVersion() *cli.Command {
@@ -111,11 +111,11 @@ func CheckVersions(
checkServiceVersion(
ce, graphql.SoftwareTypeEnumAuth, *cfg.GetAuth().GetVersion(), swv,
"https://github.com/nhost/nhost/releases",
"https://github.com/nhost/hasura-auth/releases",
)
checkServiceVersion(
ce, graphql.SoftwareTypeEnumStorage, *cfg.GetStorage().GetVersion(), swv,
"https://github.com/nhost/nhost/releases",
"https://github.com/nhost/hasura-storage/releases",
)
checkServiceVersion(
ce, graphql.SoftwareTypeEnumPostgreSQL, *cfg.GetPostgres().GetVersion(), swv,
@@ -132,8 +132,8 @@ func CheckVersions(
return checkCLIVersion(ctx, ce, appVersion)
}
func commandVersion(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandVersion(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
var (
cfg *model.ConfigConfig
@@ -157,5 +157,5 @@ func commandVersion(ctx context.Context, cmd *cli.Command) error {
ce.Warnln("🟡 No Nhost project found")
}
return CheckVersions(ctx, ce, cfg, cmd.Root().Version)
return CheckVersions(cCtx.Context, ce, cfg, cCtx.App.Version)
}

View File

@@ -1,10 +1,8 @@
package user
import (
"context"
"github.com/nhost/nhost/cli/clienv"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
const (
@@ -23,26 +21,26 @@ func CommandLogin() *cli.Command {
&cli.StringFlag{ //nolint:exhaustruct
Name: flagPAT,
Usage: "Use this Personal Access Token instead of generating a new one with your email/password",
Sources: cli.EnvVars("NHOST_PAT"),
EnvVars: []string{"NHOST_PAT"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagEmail,
Usage: "Email address",
Sources: cli.EnvVars("NHOST_EMAIL"),
EnvVars: []string{"NHOST_EMAIL"},
},
&cli.StringFlag{ //nolint:exhaustruct
Name: flagPassword,
Usage: "Password",
Sources: cli.EnvVars("NHOST_PASSWORD"),
EnvVars: []string{"NHOST_PASSWORD"},
},
},
}
}
func commandLogin(ctx context.Context, cmd *cli.Command) error {
ce := clienv.FromCLI(cmd)
func commandLogin(cCtx *cli.Context) error {
ce := clienv.FromCLI(cCtx)
_, err := ce.Login(
ctx, cmd.String(flagPAT), cmd.String(flagEmail), cmd.String(flagPassword),
cCtx.Context, cCtx.String(flagPAT), cCtx.String(flagEmail), cCtx.String(flagPassword),
)
return err //nolint:wrapcheck

View File

@@ -41,7 +41,7 @@ func auth( //nolint:funlen
envars, err := appconfig.HasuraAuthEnv(
cfg,
"http://graphql:8080/v1/graphql",
URL(subdomain, "auth", httpPort, useTLS && exposePort == 0)+"/v1",
URL(subdomain, "auth", httpPort, useTLS)+"/v1",
"postgres://nhost_hasura@postgres:5432/local",
"postgres://nhost_auth_admin@postgres:5432/local",
&model.ConfigSmtp{
@@ -67,7 +67,7 @@ func auth( //nolint:funlen
}
svc := &Service{
Image: "nhost/auth:" + *cfg.Auth.Version,
Image: "nhost/hasura-auth:" + *cfg.Auth.Version,
DependsOn: map[string]DependsOn{
"graphql": {
Condition: "service_healthy",

View File

@@ -10,7 +10,7 @@ import (
func expectedAuth() *Service {
//nolint:lll
return &Service{
Image: "nhost/auth:0.31.0",
Image: "nhost/hasura-auth:0.31.0",
Command: nil,
DependsOn: map[string]DependsOn{
"graphql": {Condition: "service_healthy"},
@@ -132,7 +132,7 @@ func expectedAuth() *Service {
"AUTH_RATE_LIMIT_SMS_INTERVAL": "5m",
"AUTH_REFRESH_TOKEN_EXPIRES_IN": "99",
"AUTH_REQUIRE_ELEVATED_CLAIM": "required",
"AUTH_SERVER_URL": "https://dev.auth.local.nhost.run:1336/v1",
"AUTH_SERVER_URL": "http://dev.auth.local.nhost.run:1336/v1",
"AUTH_SMS_PASSWORDLESS_ENABLED": "true",
"AUTH_SMS_PROVIDER": "twilio",
"AUTH_SMS_TWILIO_ACCOUNT_SID": "smsAccountSid",
@@ -186,7 +186,7 @@ func expectedAuth() *Service {
"traefik.http.routers.auth.entrypoints": "web",
"traefik.http.routers.auth.rule": "(HostRegexp(`^.+\\.auth\\.local\\.nhost\\.run$`) || Host(`local.auth.nhost.run`))",
"traefik.http.routers.auth.service": "auth",
"traefik.http.routers.auth.tls": "true",
"traefik.http.routers.auth.tls": "false",
"traefik.http.services.auth.loadbalancer.server.port": "4000",
},
Ports: nil,
@@ -216,7 +216,7 @@ func TestAuth(t *testing.T) {
{
name: "default",
cfg: getConfig,
useTlS: true,
useTlS: false,
exposePort: 0,
expected: expectedAuth,
},
@@ -227,11 +227,11 @@ func TestAuth(t *testing.T) {
cfg.Auth.Version = ptr("0.21.3")
return cfg
},
useTlS: true,
useTlS: false,
exposePort: 0,
expected: func() *Service {
svc := expectedAuth()
svc.Image = "nhost/auth:0.21.3"
svc.Image = "nhost/hasura-auth:0.21.3"
svc.Labels["traefik.http.middlewares.replace-auth.replacepathregex.regex"] = "/v1(/|$$)(.*)"
svc.Labels["traefik.http.middlewares.replace-auth.replacepathregex.replacement"] = "/$$2"
svc.Labels["traefik.http.routers.auth.middlewares"] = "replace-auth"
@@ -243,7 +243,7 @@ func TestAuth(t *testing.T) {
{
name: "custom port",
cfg: getConfig,
useTlS: true,
useTlS: false,
exposePort: 8080,
expected: func() *Service {
svc := expectedAuth()

View File

@@ -49,7 +49,7 @@ func storage( //nolint:funlen
}
return &Service{
Image: "nhost/storage:" + *cfg.GetStorage().GetVersion(),
Image: "nhost/hasura-storage:" + *cfg.GetStorage().GetVersion(),
DependsOn: map[string]DependsOn{
"minio": {
Condition: "service_started",

View File

@@ -9,7 +9,7 @@ import (
func expectedStorage() *Service {
return &Service{
Image: "nhost/storage:0.2.5",
Image: "nhost/hasura-storage:0.2.5",
DependsOn: map[string]DependsOn{
"graphql": {Condition: "service_healthy"},
"minio": {Condition: "service_started"},

View File

@@ -1,11 +1,12 @@
package main
import (
"context"
"errors"
"fmt"
"log"
"os"
"github.com/Yamashou/gqlgenc/clientv2"
"github.com/nhost/nhost/cli/clienv"
"github.com/nhost/nhost/cli/cmd/config"
"github.com/nhost/nhost/cli/cmd/configserver"
@@ -17,8 +18,7 @@ import (
"github.com/nhost/nhost/cli/cmd/secrets"
"github.com/nhost/nhost/cli/cmd/software"
"github.com/nhost/nhost/cli/cmd/user"
docs "github.com/urfave/cli-docs/v3"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v2"
)
var Version string
@@ -29,11 +29,11 @@ func main() {
panic(err)
}
app := &cli.Command{ //nolint: exhaustruct
Name: "nhost",
EnableShellCompletion: true,
Version: Version,
Description: "Nhost CLI tool",
app := &cli.App{ //nolint: exhaustruct
Name: "nhost",
EnableBashCompletion: true,
Version: Version,
Description: "Nhost CLI tool",
Commands: []*cli.Command{
config.Command(),
configserver.Command(),
@@ -50,7 +50,18 @@ func main() {
secrets.Command(),
software.Command(),
user.CommandLogin(),
markdownDocs(),
{
Name: "docs",
Hidden: true,
Action: func(ctx *cli.Context) error {
s, err := ctx.App.ToMarkdown()
if err != nil {
return fmt.Errorf("failed to generate docs: %w", err)
}
fmt.Println(s) //nolint:forbidigo
return nil
},
},
},
Metadata: map[string]any{
"Author": "Nhost",
@@ -59,29 +70,13 @@ func main() {
Flags: flags,
}
if err := app.Run(context.Background(), os.Args); err != nil {
if err := app.Run(os.Args); err != nil {
var graphqlErr *clientv2.ErrorResponse
if errors.As(err, &graphqlErr) {
log.Fatal(graphqlErr.GqlErrors)
}
log.Fatal(err)
}
}
func markdownDocs() *cli.Command {
return &cli.Command{ //nolint:exhaustruct
Name: "docs",
Usage: "Generate markdown documentation for the CLI",
Action: func(_ context.Context, cmd *cli.Command) error {
md, err := docs.ToMarkdown(cmd.Root())
if err != nil {
return cli.Exit("failed to generate markdown documentation: "+err.Error(), 1)
}
fmt.Println("---") //nolint:forbidigo
fmt.Println("title: Nhost CLI Reference") //nolint:forbidigo
fmt.Println("icon: terminal") //nolint:forbidigo
fmt.Println("---") //nolint:forbidigo
fmt.Println() //nolint:forbidigo
fmt.Println(md) //nolint:forbidigo
return nil
},
}
}

Some files were not shown because too many files have changed in this diff Show More