Skip to content

Commit

Permalink
Merge pull request #26 from batchnz/feat/install-script
Browse files Browse the repository at this point in the history
Adds installation script
  • Loading branch information
hatzipanis authored Feb 5, 2021
2 parents 6431364 + f9a7e3b commit 1b51499
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 105 deletions.
25 changes: 25 additions & 0 deletions .docksal/commands/batch/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

## Project Install Command
## Usage: fin batch/install

project=${PWD##*/}
fin rc sed -i "s/craftstarter\.batch/$project\.batch/g" \.docksal/docksal\.env

# Generate an SSL certificate
fin mkcert create

# Start up the Docksal container
fin up

# Install Craft via the CLI
fin exec craft install

# Install the Twigpack plugin
fin exec craft plugin/install twigpack

# Install npm dependencies
fin exec npm install

# Build the asset files
fin exec npm run build
113 changes: 54 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,26 @@
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]



<!-- PROJECT LOGO -->
<br />
<p align="center">
<a href="https://github.com/batchnz/craft">
<img src="https://www.batch.nz/batch-logo.png" alt="Logo" width="80" height="80">
<img src="https://www.batch.nz/batch-logo.png" alt="Batch logo" width="80" height="80">
</a>

<h3 align="center">Batch Craft Starter</h3>

<p align="center">
An opinionated Craft CMS project starter that integrates VueJS and Tailwind CSS and Docksal configuration.
An opinionated Craft CMS project starter that integrates Vue.js, Tailwind CSS and Docksal configuration.
<br />
<a href="https://github.com/batchnz/craft"><strong>Explore the docs »</strong></a>
<br />
<br />
<a href="https://github.com/batchnz/craft/issues">Report Bug</a>
·
<a href="https://github.com/batchnz/craft/issues">Report Bug</a> ·
<a href="https://github.com/batchnz/craft/issues">Request Feature</a>
</p>
</p>



<!-- TABLE OF CONTENTS -->
## Table of Contents

Expand All @@ -51,116 +46,127 @@
<!-- ABOUT THE PROJECT -->
## About The Project

The idea behind this project was to create a CraftCMS starter package that allows us to get up and running and developing on projects quickly.
The idea behind this project was to create a Craft CMS starter that allows us to get up and running and developing on projects quickly.

This starter comes set up, ready for for development with
This starter comes set up, ready for for development with:

* TailwindCSS
* VueJS
* Tailwind CSS
* Vue.js
* [craft-webpack](https://github.com/batchnz/craft-webpack) - our Webpack build configuration
* Craft CMS with Twigpack
* Jest for Frontend testing
* Jest for frontend testing
* Docksal configuration

### Built With

* [CraftCMS](https://craftcms.com/)
* [VueJS](https://vuejs.org/)
* [Craft CMS](https://craftcms.com/)
* [Vue.js](https://vuejs.org/)
* [Tailwind CSS](https://tailwindcss.com/)
* [Webpack](https://webpack.js.org/)
* [Jest](https://jestjs.io/)
* [Docksal](https://docksal.io/)


<!-- GETTING STARTED -->
## Getting Started

To create a new project using this starter, follow these steps
To create a new project using this starter, follow the below steps.

### Prerequisites

In order to use the docksal configuration in this starter, you'll need to have Docksal up and running. You can find instructions at [https://docksal.io/](https://docksal.io/)
In order to use the this starter, you'll need to have Docksal up and running. You can find instructions at [https://docksal.io/](https://docksal.io/).

### Installation

1. Create a new project via composer, replacing 'myproject' with the desired project directory name
#### Create a new project via composer

```sh
fin rc composer create-project batch/craft myproject --remove-vcs
```

Replace 'myproject' with the desired project directory name.

**Note:** We recommend using Docksal's [fin rc](https://docs.docksal.io/fin/fin-help/#run-cli) and [fin exec](https://docs.docksal.io/fin/fin-help/#exec) commands, which will execute the commands on a standalone 'cli' container mapped to the current directory. This ensures the commands will run even if Composer or NPM are not installed locally.

The `--remove-vcs` flag will removes the batch/craft git metadata so this will be ready for use in a project repository.
2. Update the docksal configuration
The `--remove-vcs` flag will removes the batch/craft git metadata so this will be ready for use in a project repository.

Edit `.docksal/docksal.env` and set the Virtual Host domains to match the local host name you want to use eg. craftstarter.batch
#### Run the installer

```
VIRTUAL_HOST="craftstarter.batch"
VIRTUAL_HOST_CERT_NAME="craftstarter.batch"
```
***Note:*** By default Docksal will only automatically resolve .docksal domains. [More info here](https://docs.docksal.io/core/system-dns/)
We include an installer script that will finish setting up your project:

`fin batch/install`

3. Generate an SSL certificate. We recommend using the [mkcert global addon](https://docs.docksal.io/tools/mkcert#setup-and-usage-via-addon) which can be installed with
After executing this and following the prompts your project should be available
at the configured domain, and you should see a demo page to confirm.

`fin addon install --global mkcert`
This command sets up SSL certificates using mkcert, runs the Craft installer, installs the Twigpack plugin and npm dependencies and performs an initial build of the frontend assets. If you wish to do these steps manually, see the instructions below.

### Manual installation

1. Generate an SSL certificate. We recommend using the [mkcert global addon](https://docs.docksal.io/tools/mkcert#setup-and-usage-via-addon) which can be installed with: `fin addon install --global mkcert`

```sh
fin mkcert create
```

4. Reset vhost-proxy to pick-up the new certificate
```sh
fin system reset vhost-proxy
```
2. Start up the Docksal container

5. Start up the docksal containers
```sh
fin up
```

6. Install Craft via the command line installer
3. Install Craft via the CLI

```sh
fin exec craft install
```

7. Install NPM dependencies
4. Install the Twigpack plugin

```sh
fin exec craft plugin/install twigpack
```

5. Install npm dependencies

```sh
fin exec npm install
```

8. Build the asset files
6. Build the asset files

```sh
fin exec npm run build
```

9. That's it!

Your new project should now be available at the configured domain and you should see a demo/Hello World page to confirm.
That's it! Your new project should now be available at the configured domain and you should see a demo page to confirm.

<!-- USAGE EXAMPLES -->
## Usage



### Webpack / Build Tool

Install the depdendencies for the build tool

```sh
fin exec npm install
```

**Production**

```sh
fin exec npm run build
```

**Development**

Run the development pipeline on the docksal container. It will be available at webpack.{yourdomain}
Run the development pipeline on the Docksal container. It will be available at webpack.{yourdomain}

```sh
fin exec npm run dev
```

Use the following commands to specifically generate a *legacy* or *combined* browser build during development

```sh
fin exec npm run dev-legacy
fin exec npm run dev-combined
Expand Down Expand Up @@ -209,15 +215,14 @@ We have provided a set of defaults to alias the src/ paths and additional entry
### Craft Plugins
Use the `fin exec craft plugin/install` command to install any additional plugins.

Twigpack is required, and installed by default. We also include the following common plugins in the composer.json dependencies
Twigpack is required, and installed by default. We also include the following common plugins in the composer.json dependencies:

* [Mailgun](https://github.com/craftcms/mailgun) - `fin exec craft plugin/install mailgun`
* [Redactor](https://github.com/craftcms/redactor) - `fin exec craft plugin/install redactor`
* [SEOMatic](https://github.com/nystudio107/craft-seomatic) - `fin exec craft plugin/install seomatic`
* [Freeform](https://github.com/solspace/craft3-freeform) - `fin exec craft plugin/install freeform`
* [Navigation](https://github.com/verbb/navigation) - `fin exec craft plugin/install navigation`


### Mixing Inline Scripts with Vue
On occasion we've found the need to run vanilla JS inline within a template (e.g. with Craft Commerce) and only run this code when our Vue app has mounted.

Expand All @@ -234,6 +239,7 @@ Example: Subscribing to events
```

Example: Publishing events

```javascript
mounted() {
window.app.emit("vue-mounted");
Expand All @@ -250,13 +256,11 @@ The starter comes with [Jest](https://jestjs.io/) installed and configured, plus

`fin exec npm run test`.


<!-- ROADMAP -->
## Roadmap

See the [open issues](https://github.com/batchnz/craft/issues) for a list of proposed features (and known issues).


<!-- CONTRIBUTING -->
## Contributing

Expand All @@ -268,33 +272,24 @@ Contributions are what make the open source community such an amazing place to b
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request



<!-- LICENSE -->
## License

Distributed under the MIT License. See `LICENSE` for more information.



<!-- CONTACT -->
## Contact

Josh Smith - [@batchnz](https://twitter.com/batchnz) - [email protected]

Jude Reid - [@batchnz](https://twitter.com/batchnz) - [email protected]
- Jude Reid - [@batchnz](https://twitter.com/batchnz) - [email protected]
- Alex Hatzipanis - [@hatzipanis](https://twitter.com/hatzipanis) - [email protected]

Project Link: [https://github.com/batchnz/craft](https://github.com/batchnz/craft)



<!-- ACKNOWLEDGEMENTS -->
## Acknowledgements

Thanks to all the hard work by the teams behind the tools used in this project.



<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/batchnz/craft.svg?style=flat-square
Expand All @@ -309,4 +304,4 @@ Thanks to all the hard work by the teams behind the tools used in this project.
[license-url]: https://github.com/batchnz/craft/blob/master/LICENSE
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/batchnz
[product-screenshot]: images/screenshot.png
[product-screenshot]: images/screenshot.png
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"sort-packages": true,
"optimize-autoloader": true,
"platform": {
"php": "7.0"
"php": "7.2.5"
}
},
"scripts": {
Expand Down
44 changes: 0 additions & 44 deletions config/project/project.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]
},
"dependencies": {
"axios": "^0.20.0",
"axios": "^0.21.1",
"core-js": "3.6.5",
"js-event-bus": "^1.0.3",
"regenerator-runtime": "^0.13.7",
Expand Down

0 comments on commit 1b51499

Please sign in to comment.