Skip to content

Commit

Permalink
feat: nitric core v1 support
Browse files Browse the repository at this point in the history
* enhanced tree output for up/down commands
* v1 contracts compatibility, including new and updated resource support
* local architecture visualizations
* enhanced `start` command which independently executes services
* all references to functions/exec units consistently named 'services'
* fix storage access in local dashboard
* replace local storage plugin for improved start up performance
* new stack file naming and improved selection UI
* new nitric.yaml format support
* update go to version 1.21
* allow multiple locally running nitric instances
* replace templates with examples

---------

Co-authored-by: Tim Holm <[email protected]>
Co-authored-by: David Moore <[email protected]>
Co-authored-by: Ryan Cartwright <[email protected]>
  • Loading branch information
4 people authored Feb 20, 2024
1 parent 9f2839f commit 2bdd23b
Show file tree
Hide file tree
Showing 368 changed files with 22,076 additions and 21,633 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/aws-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21

- name: Build Nitric
run: |
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21

- name: Build Nitric
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cli-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.20.4
go-version: 1.21
- name: Download go modules
run: go mod download
- name: Run Lint
Expand Down Expand Up @@ -67,6 +67,6 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.20.4
go-version: 1.21
- name: Build
run: make build
16 changes: 8 additions & 8 deletions .github/workflows/dashboard-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ concurrency:
env:
GOPROXY: https://proxy.golang.org
FATHOM_SITE: FAKE1234
NITRIC_HTTP_PROXY_PORT: 8000

jobs:
nitric-dashboard:
Expand All @@ -30,7 +31,7 @@ jobs:
node-version: current

- name: Lint Dashboard
working-directory: cli/dashboard
working-directory: cli/pkg/dashboard/frontend
run: |
yarn install
yarn format:check
Expand All @@ -39,7 +40,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21

- name: Build Nitric
run: |
Expand All @@ -49,27 +50,26 @@ jobs:
- name: Run nitric start with test-app in the background
run: |
cd ${{ github.workspace }}/cli/dashboard/test-app
cd ${{ github.workspace }}/cli/pkg/dashboard/frontend/test-app
yarn install
nitric start --ci &
yarn dev:functions &
nitric start &
- name: Run Tests
uses: cypress-io/github-action@v5
with:
install: false
wait-on: "http://localhost:49152"
working-directory: cli/dashboard
working-directory: cli/pkg/dashboard/frontend
browser: chrome

- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: cli/dashboard/cypress/screenshots
path: cli/pkg/dashboard/frontend/cypress/screenshots

- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-videos
path: cli/dashboard/cypress/videos
path: cli/pkg/dashboard/frontend/cypress/videos
16 changes: 9 additions & 7 deletions .github/workflows/local-run.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
name: Test nitric run

on:
push:
branches:
- main
- develop
pull_request:
# disabled test for now
on: false
# on:
# push:
# branches:
# - main
# - develop
# pull_request:

concurrency:
group: ci-local-tests-${{ github.ref_name }}
Expand Down Expand Up @@ -34,7 +36,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21

- name: Build Nitric
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ go.work
.vscode/

dist/

# Ignore nitric temp files
.nitric/
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@ export LDFLAGS="-X $(VERSION_URI).Version=${BUILD_VERSION} \
-X $(VERSION_URI).BuildTime=$(shell date +%Y-%m-%dT%H:%M:%S%z)"

.PHONY: build
build: generate
build: generate build-cli

.PHONY: build-cli
build-cli:
$(BUILD_ENV) go build -ldflags $(LDFLAGS) -o bin/nitric$(EXECUTABLE_EXT) ./main.go

.PHONY: build-dashboard
build-dashboard:
yarn --cwd ./dashboard install
yarn --cwd ./dashboard build
yarn --cwd ./pkg/dashboard/frontend install
yarn --cwd ./pkg/dashboard/frontend build

.PHONY: generate
generate: build-dashboard
@go run github.com/golang/mock/mockgen github.com/nitrictech/cli/pkg/containerengine ContainerEngine > mocks/mock_containerengine/mock_containerengine.go
@go run github.com/golang/mock/mockgen github.com/nitrictech/cli/pkg/utils GetterClient > mocks/mock_utils/mock_getter.go
# @go run github.com/golang/mock/mockgen github.com/nitrictech/cli/pkg/containerengine ContainerEngine > mocks/mock_containerengine/mock_containerengine.go
@go run github.com/golang/mock/mockgen github.com/nitrictech/cli/pkg/project/templates GetterClient > mocks/mock_utils/mock_getter.go
@go run ./hack/readmegen/ README.md

.PHONY: fmt
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ nitric new --help

Documentation for all available commands:

- nitric feedback : Provide feedback on your experience with nitric
- nitric info : Gather information about Nitric and the environment
- nitric build : Build a Nitric project
- nitric new [projectName] [templateName] : Create a new project
- nitric run : Run your project locally for development and testing
- nitric stack : Manage stacks (the deployed app containing multiple resources e.g. collection, bucket, topic)
- nitric stack : Manage stacks (the deployed app containing multiple resources e.g. services, buckets and topics)
- nitric stack down [-s stack] : Undeploy a previously deployed stack, deleting resources
(alias: nitric down)
- nitric stack list : List all stacks in the project
- nitric stack new [stackName] [providerName] : Create a new Nitric stack
- nitric stack update [-s stack] : Create or update a deployed stack
(alias: nitric up)
Expand All @@ -81,3 +81,8 @@ Documentation for all available commands:
## Get Started

Check out the [Nitric docs](https://nitric.io/docs) to see how to get started using Nitric.
lto:maintainers@nitric.io)

## Get Started

Check out the [Nitric docs](https://nitric.io/docs) to see how to get started using Nitric.
52 changes: 52 additions & 0 deletions cmd/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright Nitric Pty Ltd.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
"github.com/spf13/afero"
"github.com/spf13/cobra"

"github.com/nitrictech/cli/pkg/project"
"github.com/nitrictech/cli/pkg/view/tui"
"github.com/nitrictech/cli/pkg/view/tui/commands/build"
"github.com/nitrictech/cli/pkg/view/tui/teax"
)

var buildCmd = &cobra.Command{
Use: "build",
Short: "Build a Nitric project",
Long: `Build all services in a nitric project as docker container images`,
Run: func(cmd *cobra.Command, args []string) {
// info.Run(cmd.Context())
fs := afero.NewOsFs()

proj, err := project.FromFile(fs, "")
tui.CheckErr(err)

updates, err := proj.BuildServices(fs)
tui.CheckErr(err)

prog := teax.NewProgram(build.NewModel(updates))
// blocks but quits once the above updates channel is closed by the build process
_, err = prog.Run()
tui.CheckErr(err)
},
}

func init() {
rootCmd.AddCommand(buildCmd)
}
37 changes: 0 additions & 37 deletions cmd/feedback.go

This file was deleted.

36 changes: 0 additions & 36 deletions cmd/info.go

This file was deleted.

17 changes: 12 additions & 5 deletions cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import (
"fmt"

tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/afero"
"github.com/spf13/cobra"

"github.com/nitrictech/cli/pkg/operations/project_new"
"github.com/nitrictech/cli/pkg/utils"
"github.com/nitrictech/cli/pkg/view/tui"
"github.com/nitrictech/cli/pkg/view/tui/commands/project"
"github.com/nitrictech/cli/pkg/view/tui/teax"
)

var force bool
Expand All @@ -48,14 +50,19 @@ nitric new hello-world "official/TypeScript - Starter" `,
templateName = args[1]
}

if !utils.IsTerminal() && (templateName == "" || projectName == "") {
if !tui.IsTerminal() && (templateName == "" || projectName == "") {
return fmt.Errorf(`non-interactive environment detected, please provide all mandatory arguments e.g. nitric new hello-world "official/TypeScript - Starter"`)
}

if _, err := tea.NewProgram(project_new.New(project_new.Args{
projectModel, err := project.New(afero.NewOsFs(), project.Args{
ProjectName: projectName,
TemplateName: templateName,
}), tea.WithANSICompressor()).Run(); err != nil {
Force: force,
})
tui.CheckErr(err)

// TODO add --force
if _, err := teax.NewProgram(projectModel, tea.WithANSICompressor()).Run(); err != nil {
return err
}

Expand Down
Loading

0 comments on commit 2bdd23b

Please sign in to comment.