Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.0-beta.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmccallister committed Jun 1, 2020
2 parents 5167e13 + 8d9ad03 commit 4edb937
Show file tree
Hide file tree
Showing 20 changed files with 659 additions and 97 deletions.
75 changes: 41 additions & 34 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,75 @@

### Unreleased

### 1.0.0-beta.7 - 2020-05-27
## 1.0.0-beta.8 - 2020-06-01

## Fixed
### Fixed
- Fixed an error that could remove mounted sites. ([#162](https://github.com/craftcms/nitro/issues/162))
- Fixed a bug where the `apply` command wasn’t removing deleted sites’ hostnames from the hosts file. ([#161](https://github.com/craftcms/nitro/issues/161))
- Fixed a bug where the `apply` command wasn’t removing deleted sites’ Nginx configurations from the virtual machine.

## 1.0.0-beta.7 - 2020-05-27

### Fixed
- Fixed a bug where keys transferred into the machine did not have the proper permissions. ([#154](https://github.com/craftcms/nitro/issues/154))
- Fixed a bug where the `init` command was not editing the hosts file. ([#155](https://github.com/craftcms/nitro/issues/155)) ([#156](https://github.com/craftcms/nitro/issues/156))
- Fixed a bug where the `db import` command was not working on PostgreSQL.

### 1.0.0-beta.6 - 2020-05-26
## 1.0.0-beta.6 - 2020-05-26

## Changed
### Changed
- Removed an unnecessary debug command.

### 1.0.0-beta.5 - 2020-05-26
## 1.0.0-beta.5 - 2020-05-26

## Added
### Added
- Added Windows support.
- Added support for MySQL 8.0. ([#97](https://github.com/craftcms/nitro/issues/97))
- The PostgreSQL and MySQL client tools are now installed on new machines. ([#54](https://github.com/craftcms/nitro/issues/54), [#139](https://github.com/craftcms/nitro/issues/139))
- Added the `install postgres`, `install mysql`, `install composer`, and `install mailhog` commands.

## Changed
### Changed
- New machines now use Ubuntu 20 LTS.
- Renamed the `--no-backups` option to `--skip-backup` for the `destroy` command.
- Composer is no longer installed on machines by default, but can be installed by running `nitro install composer`.
- The `init` command now sets the default CPU count based on the number of CPUs on the host machine.
- MySQL 5 and 8 now use version-specific configuration directories (`/home/ubuntu/.nitro/databases/mysql/conf.d/<version>/`).
- Removed the `xdebug configure` command, and moved its logic into the `xdebug on` command.

## Fixed
### Fixed
- Fixed a bug where Nitro wasn’t removing Nginx server configs when removing sites.
- Fixed a bug where the `apply` command wasn’t removing deleted mounts’ root directories within the machine. ([#96](https://github.com/craftcms/nitro/issues/96))
- Fixed a bug where the `init` command could return an exit code of 100. ([#96](https://github.com/craftcms/nitro/issues/96))
- The OPcache extension is no longer installed by default. ([#129](https://github.com/craftcms/nitro/issues/129))

### 1.0.0-beta.4 - 2020-05-21
## 1.0.0-beta.4 - 2020-05-21

## Added
### Added
- Added the `keys` command which prompts which keys should be imported into a machine. ([#141](https://github.com/craftcms/nitro/issues/141))
- Added the `--no-backups` flag to `destroy` which will skip database backups.
- Added `completion` commands for `bash` and `zshrc`.

## Changed
### Changed
- The `destroy` command creates individual databases backups. ([#146](https://github.com/craftcms/nitro/issues/146))
- The `mysql` system database is no longer backed up using `db backup` or `destroy`. ([#147](https://github.com/craftcms/nitro/issues/147))

## Fixed
### Fixed
- Fixed a bug where the `refresh` command was failing silently.
- Fixed a permissions issue. ([#145](https://github.com/craftcms/nitro/issues/145))
- Fixed an issue when importing mysql databases using `db import`.
- Fixed an issue installing composer on new machines. ([#149](https://github.com/craftcms/nitro/issues/149))

### 1.0.0-beta.3 - 2020-05-19
## 1.0.0-beta.3 - 2020-05-19

## Added
### Added
- Added the `--skip-hosts` option to the `apply` command. ([#110](https://github.com/craftcms/nitro/issues/110))
- The `add` command will now prompt to create a machine if it does not exist. ([#103](https://github.com/craftcms/nitro/issues/103))
- The `init` command will edit the hosts file if sites are present in the config. ([#123](https://github.com/craftcms/nitro/issues/123))
- Added the `db restart`, `db stop`, `db add`, `db remove`, and `db backup` commands. The `import` command has also been renamed to `db import`.
- Added the `refresh` command, which helps keep scripts and configs updated between versions of Nitro.
- Databases now support custom configuration files. ([#133](https://github.com/craftcms/nitro/issues/133))

## Changed
### Changed
- Nginx is now configured to allow file uploads up to 100MB. ([#126](https://github.com/craftcms/nitro/issues/126))
- Databases are now backed up automatically when a machine is destroyed. ([#136](https://github.com/craftcms/nitro/issues/136))
- When creating a new machine, the `DB_USER` and `DB_PASSWORD` are automatically set in the environment. ([#119](https://github.com/craftcms/nitro/issues/119))
Expand All @@ -74,57 +81,57 @@
- The `apply` command now provides more information. ([#95](https://github.com/craftcms/nitro/issues/95))
- The `init` command now checks if the machine already exists before prompting for input ([#102](https://github.com/craftcms/nitro/issues/102))

## Fixed
### Fixed
- Fixed a bug where the `self-update` command would non-interactively prompt to initialize the primary machine. ([#115](https://github.com/craftcms/nitro/issues/115))
- Fixed a bug where `import --help` didn’t show the required SQL file argument in the usage example. ([#124](https://github.com/craftcms/nitro/issues/124))
- Fixed a bug where the `apply` command wasn’t applying changes to sites’ webroots. ([#113](https://github.com/craftcms/nitro/issues/113))

### 1.0.0-beta.2 - 2020-05-06
## 1.0.0-beta.2 - 2020-05-06

## Fixed
### Fixed
- Fixed an error when using the select prompt. ([#104](https://github.com/craftcms/nitro/issues/104))

### 1.0.0-beta.1 - 2020-05-05
## 1.0.0-beta.1 - 2020-05-05

## Changed
### Changed
- Improved the `init` command workflow.
- Changed the input package to use [pixelandtonic/prompt](https://github.com/pixelandtonic/prompt).

## Removed
### Removed
- Removed MySQL 8.0 support for now.
- Removed PHP 7.0 and 7.1 support.

## Fixed
### Fixed
- Fixed a potential permission error when installing/updating.

### 0.11.4 - 2020-05-04
## 0.11.4 - 2020-05-04

## Fixed
### Fixed
- Fixed a broken test which prevented a release.

### 0.11.3 - 2020-05-04
## 0.11.3 - 2020-05-04

## Changed
### Changed
- The [GMP](https://www.php.net/manual/en/book.gmp.php) and [BCMath](https://www.php.net/manual/en/book.bc.php) PHP extensions are now installed by default.
- Composer is now installed globally on machines. ([#92](https://github.com/craftcms/nitro/issues/92))

## Fixed
### Fixed
- Fixed a permission error when provisioning a PostgreSQL database.
- Fix a bug where the `import` command wasn’t importing.
- Fixed an issue where the machine DNS was not resolving in some environments. ([#91](https://github.com/craftcms/nitro/issues/91))
- Fixed an error when trying to create a database during PostgreSQL import. ([#94](https://github.com/craftcms/nitro/issues/94))

### 0.11.2 - 2020-04-09
## 0.11.2 - 2020-04-09

## Changed
### Changed
- The `init` command now prompts for how many CPU cores should be assigned to the machine.

### 0.11.0 - 2020-04-29
## 0.11.0 - 2020-04-29

## Added
### Added
- Added the `rename` command to allow users to quickly rename sites.

## Changed
### Changed
- The `destroy` command now has a `--clean` option which will delete a config file after destroying the machine.
- The `nitro` database user now has root privileges for `mysql` and `postgres` databases. ([#79](https://github.com/craftcms/nitro/issues/79))
- Added the `php` option back to the config file.
Expand All @@ -135,7 +142,7 @@
- The `init` command will use an existing config file and recreate the entire environment.
- Commands now output more _statuses_ where possible to provide the user more feedback.

## Fixed
### Fixed
- When using the `add` command, the config file checks for duplicate sites and mounts. ([#86](https://github.com/craftcms/nitro/issues/86))
- Fixed an issue when using some commands on Windows. ([#88](https://github.com/craftcms/nitro/issues/88))
- Fixed an issue in the `apply` command that would not detect new changes to the config file.
Expand All @@ -145,7 +152,7 @@
> **Warning:** This release contains breaking changes. See the [upgrade notes](UPGRADE.md#upgrading-to-nitro-0100)
> for details.
## Added
### Added
- Added the `init` command, which initializes new machines.
- Added the `remove` command, which removes a site from a machine.

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: install
VERSION ?= 1.0.0-beta.4
VERSION ?= 1.0.0-beta.7

build:
go build -ldflags="-s -w -X 'github.com/craftcms/nitro/internal/cmd.Version=${VERSION}'" -o nitro ./cmd/cli
Expand Down
58 changes: 58 additions & 0 deletions cmd/test/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package main

import (
"bufio"
"fmt"
"os/exec"
"strings"

"github.com/craftcms/nitro/config"
"github.com/craftcms/nitro/internal/scripts"
)

func main() {
machine := "nitro-dev"
multipass, err := exec.LookPath("multipass")
if err != nil {
fmt.Println(err)
return
}

script := scripts.New(multipass, machine)

var confs []string
if output, err := script.Run(false, `ls /etc/nginx/sites-enabled`); err == nil {
sc := bufio.NewScanner(strings.NewReader(output))
for sc.Scan() {
if sc.Text() == "default" {
continue
}

confs = append(confs, strings.TrimSpace(sc.Text()))
}
}

var sites []config.Site
for _, conf := range confs {
s := config.Site{}
// get the webroot
if output, err := script.Run(false, fmt.Sprintf(scripts.FmtNginxSiteWebroot, conf)); err == nil {
s.Webroot = output
}

// get the server_name
if output, err := script.Run(false, fmt.Sprintf(`grep "server_name " /etc/nginx/sites-available/%s | while read -r line; do echo "$line"; done`, conf)); err == nil {
sp := strings.Fields(output)
if len(sp) >= 2 {
s.Hostname = sp[1]
}
}

// get the hostname
if s.Webroot != "" && s.Hostname != "" {
sites = append(sites, s)
}
}

fmt.Println(sites)
}
39 changes: 39 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"gopkg.in/yaml.v2"

"github.com/craftcms/nitro/internal/helpers"
"github.com/craftcms/nitro/internal/resolve"
)

type Config struct {
Expand All @@ -33,6 +34,44 @@ func (c *Config) GetSites() []Site {
return c.Sites
}

// AlreadyMounted takes a new mount and will check if the
// mount source is already mounted to the virtual machine
// and will also check if the new mount is a parent mount
func (c *Config) AlreadyMounted(mount Mount) bool {
// get the home directory
home, err := homedir.Dir()
if err != nil {
return false
}

// get the local path of the mount
newLocal, err := resolve.AbsPath(mount.Source, home)
if err != nil {
return false
}

// check each of the mounts in the config
for _, m := range c.Mounts {
// get the abs path of the existing mount
existingLocal, err := resolve.AbsPath(m.Source, home)
if err != nil {
continue
}

// if it is an exact match
if existingLocal == newLocal {
return true
}

// if it is a sub folder of the mount
if strings.Contains(newLocal, existingLocal) {
return true
}
}

return false
}

// GetExpandedMounts will take all of the mounts in a config file
// and "expand" or get the full path mount source and return
// a slice of mounts
Expand Down
Loading

0 comments on commit 4edb937

Please # to comment.