Skip to content

Commit

Permalink
Require Node.js 8, require Grunt 1, upgrade pageres
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Feb 10, 2019
1 parent 3003f0c commit 2bd423b
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 130 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
yarn.lock
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
os: osx
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
20 changes: 14 additions & 6 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@ module.exports = grunt => {
pageres: {
screenshot: {
options: {
urls: 'yeoman.io',
sizes: ['1000x1000', '100x100'],
dest: 'tmp'
urls: 'https://sindresorhus.com',
sizes: [
'1000x1000',
'100x100'
],
dest: 'temp'
}
},
multipleUrls: {
options: {
urls: ['yeoman.io', 'google.com'],
sizes: ['1000x1000'],
dest: 'tmp'
urls: [
'https://github.com',
'https://google.com'
],
sizes: [
'1000x1000'
],
dest: 'temp'
}
}
}
Expand Down
139 changes: 66 additions & 73 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,75 +1,68 @@
{
"name": "grunt-pageres",
"version": "3.0.0",
"description": "Capture website screenshots",
"license": "MIT",
"repository": "sindresorhus/grunt-pageres",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "Kevin Mårtensson",
"email": "[email protected]",
"url": "github.com/kevva"
}
],
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && grunt && ava && trash tmp"
},
"files": [
"tasks"
],
"keywords": [
"gruntplugin",
"pageres",
"page",
"website",
"site",
"web",
"url",
"resolution",
"size",
"screenshot",
"screenshots",
"screengrab",
"screen",
"snapshot",
"shot",
"responsive",
"gulpfriendly",
"phantom",
"phantomjs",
"image",
"svg",
"render",
"html",
"headless",
"capture",
"pic",
"picture",
"png",
"jpg",
"jpeg"
],
"dependencies": {
"arrify": "^1.0.0",
"pageres": "^4.1.0"
},
"devDependencies": {
"ava": "*",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"path-exists": "^3.0.0",
"trash-cli": "^1.1.0",
"xo": "*"
},
"peerDependencies": {
"grunt": ">=0.4.0"
}
"name": "grunt-pageres",
"version": "3.0.0",
"description": "Capture website screenshots",
"license": "MIT",
"repository": "sindresorhus/grunt-pageres",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && grunt && ava && del-cli temp"
},
"files": [
"tasks"
],
"keywords": [
"gruntplugin",
"pageres",
"page",
"website",
"site",
"web",
"url",
"resolution",
"size",
"screenshot",
"screenshots",
"screengrab",
"screen",
"snapshot",
"shot",
"responsive",
"gulpfriendly",
"puppeteer",
"chrome",
"image",
"svg",
"render",
"html",
"headless",
"capture",
"pic",
"picture",
"png",
"jpg",
"jpeg"
],
"dependencies": {
"arrify": "^1.0.0",
"pageres": "^5.0.1"
},
"devDependencies": {
"ava": "^1.2.0",
"del-cli": "^1.1.0",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"path-exists": "^3.0.0",
"xo": "^0.24.0"
},
"peerDependencies": {
"grunt": ">=1"
}
}
85 changes: 57 additions & 28 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[<img src="https://github.com/sindresorhus/pageres/raw/master/media/logo.png" width="150" align="right">](https://github.com/sindresorhus/pageres)

> Capture website screenshots using [pageres](https://github.com/sindresorhus/pageres)
> Capture website screenshots using [`pageres`](https://github.com/sindresorhus/pageres)
*Issues should be opened on the pageres [issue tracker](https://github.com/sindresorhus/pageres/issues).*

Expand All @@ -15,27 +15,36 @@
$ npm install --save-dev grunt-pageres
```

*PhantomJS, which is used for generating the screenshots, is installed automagically, but in some [rare cases](https://github.com/Obvious/phantomjs/issues/102) it might fail to and you'll get an `Error: spawn EACCES` error. [Download](http://phantomjs.org/download.html) PhantomJS manually and reinstall this task if that happens.*
Note to Linux users: If you get a "No usable sandbox!" error, you need to enable [system sandboxing](https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#setting-up-chrome-linux-sandbox).


## Usage

```js
require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks
require('load-grunt-tasks')(grunt);

grunt.initConfig({
pageres: {
screenshot: {
options: {
urls: 'yeoman.io',
sizes: ['1200x800', '800x600'],
urls: 'https://sindresorhus.com',
sizes: [
'1200x800',
'800x600'
],
dest: 'dist'
}
},
multipleUrls: {
options: {
urls: ['todomvc.com', 'google.com'],
sizes: ['800x1000', '400x1000'],
urls: [
'https://sindresorhus.com',
'https://google.com'
],
sizes: [
'800x1000',
'400x1000'
],
dest: 'dist',
crop: true
}
Expand All @@ -52,14 +61,14 @@ grunt.registerTask('default', ['pageres']);
### urls

*Required*<br>
Type: `string`, `array`
Type: `string | string[]`

One or more URLs or local paths to the websites you want to screenshot.

### sizes

*Required*<br>
Type: `array`
Type: `string[]`

Use a `<width>x<height>` notation or a keyword.

Expand All @@ -81,6 +90,13 @@ Delay capturing the screenshot.

Useful when the site does things after load that you want to capture.

### timeout

Type: `number` *(seconds)*<br>
Default: `60`

Number of seconds after which the request is aborted.

### crop

Type: `boolean`<br>
Expand All @@ -94,43 +110,55 @@ Type: `string`

Apply custom CSS to the webpage. Specify some CSS or the path to a CSS file.

### cookies
### script

Type: `array` of `string`, `object`
Type: `string`

A string with the same format as a [browser cookie](http://en.wikipedia.org/wiki/HTTP_cookie) or an object of what [`phantomjs.addCookie`](http://phantomjs.org/api/phantom/method/add-cookie.html) accepts.
Apply custom JavaScript to the webpage. Specify some JavaScript or the path to a file.

#### Tip
### cookies

Go to the website you want a cookie for and copy-paste it from Dev Tools.
Type: `Array<string | Object>`

A string with the same format as a [browser cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) or [an object](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetcookiecookies).

Tip: Go to the website you want a cookie for and [copy-paste it from DevTools](https://stackoverflow.com/a/24961735/64949).

### filename

Type: `string`

Define a customized filename using [Lo-Dash templates](http://lodash.com/docs#template). For example `{{date}} - {{url}}-{{size}}{{crop}}`.
Define a customized filename using [Lo-Dash templates](https://lodash.com/docs#template).<br>
For example `<%= date %> - <%= url %>-<%= size %><%= crop %>`.

Available variables:

- `url`: The URL in [slugified](https://github.com/ogt/slugify-url) form, eg. `http://yeoman.io/blog/` becomes `yeoman.io!blog`
- `url`: The URL in [slugified](https://github.com/sindresorhus/filenamify-url) form, eg. `http://yeoman.io/blog/` becomes `yeoman.io!blog`
- `size`: Specified size, eg. `1024x1000`
- `width`: Width of the specified size, eg. `1024`
- `height`: Height of the specified size, eg. `1000`
- `crop`: Outputs `-cropped` when the crop option is true
- `date`: The current date (Y-M-d), eg. 2015-05-18
- `time`: The current time (h-m-s), eg. 21-15-11

### incrementalName

Type: `boolean`<br>
Default: `false`

When a file exists, append an incremental number.

### selector

Type: `string`

Capture a specific DOM element.
Capture a specific DOM element matching a CSS selector.

### hide

Type: `array`
Type: `string[]`

Hide an array of DOM elements.
Hide an array of DOM elements matching CSS selectors.

### username

Expand All @@ -146,9 +174,10 @@ Password for authenticating with HTTP auth.

### scale

Type: `number`
Type: `number`<br>
Default: `1`

Scale webpage `n` of times.
Scale webpage `n` times.

### format

Expand All @@ -164,18 +193,18 @@ Type: `string`

Custom user agent.

### transparent
### headers

Type: `Boolean`<br>
Default: `false`
Type: `Object`

Set background color to `transparent` instead of `white` if no background is set.
Custom HTTP request headers.

### headers
### transparent

Type: `object`
Type: `boolean`<br>
Default: `false`

Custom HTTP request headers.
Set background color to `transparent` instead of `white` if no background is set.


## License
Expand Down
Loading

0 comments on commit 2bd423b

Please sign in to comment.