diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4e93d0ab..a027c90f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,15 +15,17 @@ Dnote uses [Vagrant](https://github.com/hashicorp/vagrant) to provision a consis * Vagrant ([Download](https://www.vagrantup.com/downloads.html)) * VirtualBox ([Download](https://www.virtualbox.org/)) -Following steps will set up your development environment and install dependencies in a virtual machine. +Run the following command from the project root. It starts the virtual machine and bootstraps the project. -1. Run `vagrant up` to start a virtual machine and bootstrap the development environment. -2. Run `vagrant rsync-auto` to sync the files with the virtual machine. +``` +vagrant up +``` *Workflow* * You can make changes to the source code from the host machine. * Any commands need to be run inside the virtual machine. You can connect to it by running `vagrant ssh`. +* If you want to run tests in a WATCH mode, please do so from the host machine. We cannot watch file changes due to the limitation of file system used in a virtual machine. ## Server @@ -40,8 +42,14 @@ The server consists of the frontend web application and a web server. # Run tests for the frontend web application make test-web +# Run in watch mode +WATCH=true make test-web + # Run tests for API make test-api + +# Run in watch mode +WATCH=true make test-api ``` diff --git a/Vagrantfile b/Vagrantfile index 08f6a390..65dd3db1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -2,9 +2,7 @@ Vagrant.configure("2") do |config| config.vm.box = "ubuntu/bionic64" - config.vm.synced_folder '.', '/go/src/github.com/dnote/dnote', type: "rsync", create: true, - rsync__args: ["--verbose", "--archive", "--delete", "-z"], - rsync__exclude: [".git/", ".vagrant/", "web/public"] + config.vm.synced_folder '.', '/go/src/github.com/dnote/dnote' config.vm.network "forwarded_port", guest: 3000, host: 3000 config.vm.network "forwarded_port", guest: 8080, host: 8080 config.vm.network "forwarded_port", guest: 5432, host: 5433 diff --git a/pkg/server/watcher/main.go b/pkg/server/watcher/main.go index b99c4486..1f45df6c 100644 --- a/pkg/server/watcher/main.go +++ b/pkg/server/watcher/main.go @@ -90,7 +90,7 @@ func main() { e = execCmd() log.Printf("watching %d files", len(w.WatchedFiles())) - if err := w.Start(time.Millisecond * 500); err != nil { + if err := w.Start(time.Millisecond * 1000); err != nil { log.Fatalln(err) } } diff --git a/web/scripts/dev.sh b/web/scripts/dev.sh index 76c47777..4f6d4324 100755 --- a/web/scripts/dev.sh +++ b/web/scripts/dev.sh @@ -38,5 +38,4 @@ set +a devServerPID=$! # run server -(cd "$serverPath" && CompileDaemon \ - -command="$serverPath/server start -port $serverPort") +(cd "$serverPath/watcher" && go run main.go) diff --git a/web/webpack/dev.config.js b/web/webpack/dev.config.js index cdd44960..ba190b54 100644 --- a/web/webpack/dev.config.js +++ b/web/webpack/dev.config.js @@ -44,6 +44,9 @@ module.exports = env => { production: false, test: isTest }), - externals + externals, + watchOptions: { + poll: 2500 + } }; };