README.md 4.74 KB
Newer Older
Philipp Nowinski's avatar
Philipp Nowinski committed
1 2
[![sgalinski Internet Services](http://www.sgalinski.de/_Resources/Static/Packages/SGalinski.SgalinskiDe/Images/logo.png  "sgalinski Internet Services")](http://www.sgalinski.de/)

Philipp Nowinski's avatar
Philipp Nowinski committed
3
# sgalinski command line interface
Philipp Nowinski's avatar
Philipp Nowinski committed
4

Philipp Nowinski's avatar
Philipp Nowinski committed
5 6
> **Please note:**
> The sgc currently only supports Linux and OSX operating systems. The CLI is intended to be used with bash or zsh.
Philipp Nowinski's avatar
Philipp Nowinski committed
7

Philipp Nowinski's avatar
Philipp Nowinski committed
8
## Installation
Philipp Nowinski's avatar
Philipp Nowinski committed
9

10
Move the 'sgc-core' folder inside your project root and execute the install script.
Philipp Nowinski's avatar
Philipp Nowinski committed
11 12

```bash
13 14 15 16 17 18 19 20 21
./sgc-core/install.sh
```

### Local Installation

If you don't want to install the sgc command globally (e.g. in a server environment), just pass the --local flag to the install script.

```bash
./sgc-core/install.sh --local
Philipp Nowinski's avatar
Philipp Nowinski committed
22 23 24 25
```

## Configuration

26
To configure the frontend build process to you needs, you will have to modify the config.json inside the sgc-core/gulp folder.
Philipp Nowinski's avatar
Philipp Nowinski committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

### directories

Holds the paths to the css, sass, javascript, images, sprites and inline-svgs, relative to the extensions root.

### abovethefold

Configuration for the critical path css.

* template: *path to the src template*
* dest: *path to the destination*

### js

* libraryPaths: *additional locations that should be searched when resolving CommonJS requires*
* excludeFromQa: *glob patterns with locations that hold JavaScript that does not need to be linted (vendor stuff)

### images

* optimize: *locations of user uploaded images that should be optimized*

### extensions

A list of extensions that should be included in the watch task. Please note, that the very first extension in this list is expected to be your project_theme.

## Usage
You can run a specific task on a specific component, or start a watcher that will fire up BrowserSync and run tasks when
source files change. Extensions that will be watched are defined in [config.json](gulp/config.json).

If you run a specific task, you need to specify the extension you want the task to run on with the --ext parameter.

```bash
Philipp Nowinski's avatar
Philipp Nowinski committed
59
sgc css --ext project_base
Philipp Nowinski's avatar
Philipp Nowinski committed
60 61 62 63 64 65 66
```

There are a few available tasks you need to remember:

### default/watch task

```bash
Philipp Nowinski's avatar
Philipp Nowinski committed
67
sgc
Philipp Nowinski's avatar
Philipp Nowinski committed
68 69 70 71 72 73 74 75 76
```
Starts a project wide watcher that will trigger the css/javascript task when you change any .scss, or .js-file and opens
the website in your browser, as a browsersync session (changed js and css will automatically get injected when recompiled).

*Hint:* If you already have a browsersync instance open in your browser, you can pass the argument -s to restart the session without opening a browser.

### sprite task

```bash
Philipp Nowinski's avatar
Philipp Nowinski committed
77
sgc sprites --ext [extensions name]
Philipp Nowinski's avatar
Philipp Nowinski committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
```

Triggers sprite generation inside the given directory.

Assumptions:

* all sprite images are inside images/sprites, relative to the given path.
* all sprite images are PNGs.
* there is a sass directory, next to the images folder.

This task will generate a png inside the images folder, containing all the sprites and a .scss file inside the sass
folder, which will provide the necessary mixins. To use the sprites inside your SASS code, import the _sprite.scss file.
You can then use the following mixins:

```scss
// will output css for a sprite image 'box.png'
.element {
Philipp Nowinski's avatar
Philipp Nowinski committed
95
	@include sprite ($box);
Philipp Nowinski's avatar
Philipp Nowinski committed
96 97 98 99
}
```

The @sprite mixin already contains width and height. If you need these values for something else, use the @sprite-width
Philipp Nowinski's avatar
Philipp Nowinski committed
100
and @sprite-height functions.
Philipp Nowinski's avatar
Philipp Nowinski committed
101 102 103 104

### css task

```bash
Philipp Nowinski's avatar
Philipp Nowinski committed
105
sgc css --ext [extension name]
Philipp Nowinski's avatar
Philipp Nowinski committed
106 107 108 109 110 111 112 113 114 115 116 117
```

Triggers css compilation inside the given directory. Note, that this task will also run the sprite task before it starts.

Assumptions:

* all scss files are inside the sass directory, relative to the given path.
* all css files go into the stylesheets directory, relative to the given path.

### images task

```bash
Philipp Nowinski's avatar
Philipp Nowinski committed
118
sgc images --ext [extension name]
Philipp Nowinski's avatar
Philipp Nowinski committed
119 120 121 122 123 124 125 126 127 128 129
```

Optimizes all images for the given path.

Assumptions:

* all images are inside the image directory, relative to the given path.

### optimize images in fileadmin and uploads

```bash
Philipp Nowinski's avatar
Philipp Nowinski committed
130
sgc images:uploaded
Philipp Nowinski's avatar
Philipp Nowinski committed
131 132
```

Philipp Nowinski's avatar
Philipp Nowinski committed
133
This tasks optimizes all images (png, jpg, gif) inside the folders you specified in the config.json file. You might want to
Philipp Nowinski's avatar
Philipp Nowinski committed
134 135
run this task on a regular basis to compress user uploaded media.

Philipp Nowinski's avatar
Philipp Nowinski committed
136 137
# Extending the sgc with your own modules

138
You can easily extend the sgc functionality by writing your own modules. Simply create a sgc-scripts folder next to sgc-core
Philipp Nowinski's avatar
Philipp Nowinski committed
139 140 141 142 143
and put your custom scripts in there. Right now only shell-scripts with are supported, other languages might follow in the future.

Execute your custom scripts by calling sgc <scriptName>

```
144 145
+ sgc-core
+ sgc-scripts
Philipp Nowinski's avatar
Philipp Nowinski committed
146 147 148 149 150 151 152 153 154
    - updateInstance.sh
    - updateDeployData.sh
```


```bash
sgc updateInstance
```

Philipp Nowinski's avatar
Philipp Nowinski committed
155 156
# Troubleshooting

Philipp Nowinski's avatar
Philipp Nowinski committed
157 158 159 160 161
## Timeouts of the registry while installing the toolchain

Please try to remove the npm-shrinkgwrap.json file and execute the following commands:

```bash
162
cd sgc-core
Philipp Nowinski's avatar
Philipp Nowinski committed
163 164 165 166
rm -rf node_modules
npm set registry http://registry.npmjs.org/
npm install
```