Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-vulcanize

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-vulcanize - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

test/expected/csp/vulcanized.html

41

Gruntfile.js

@@ -31,20 +31,46 @@ /*

// set up tmp folders
mkdir: {
all: {
options: {
create: ['tmp/default', 'tmp/csp', 'tmp/inline', 'tmp/excludes']
}
}
},
// Configuration to be run (and then tested).
vulcanize: {
default_options: {
default: {
options: {
},
files: {
'tmp/default_options': ['test/fixtures/testing', 'test/fixtures/123'],
'tmp/default/vulcanized.html': ['test/fixtures/index.html'],
},
},
custom_options: {
csp: {
options: {
separator: ': ',
punctuation: ' !!!',
csp: true
},
files: {
'tmp/custom_options': ['test/fixtures/testing', 'test/fixtures/123'],
'tmp/csp/vulcanized.html': ['test/fixtures/index.html'],
},
},
inline: {
options: {
inline: true
},
files: {
'tmp/inline/vulcanized.html': ['test/fixtures/index.html'],
}
},
excludes: {
options: {
excludes: {
imports: ['polymer.html']
}
},
files: {
'tmp/excludes/vulcanized.html': ['test/fixtures/index.html']
}
}
},

@@ -65,2 +91,3 @@

grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-mkdir');
grunt.loadNpmTasks('grunt-contrib-nodeunit');

@@ -70,3 +97,3 @@

// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'vulcanize', 'nodeunit']);
grunt.registerTask('test', ['clean', 'mkdir', 'vulcanize', 'nodeunit']);

@@ -73,0 +100,0 @@ // By default, lint and run all tests.

7

package.json
{
"name": "grunt-vulcanize",
"version": "0.1.0",
"version": "0.1.1",
"description": "Grunt plugin for Polymer's Vulcanize",

@@ -10,3 +10,3 @@ "main": "Gruntfile.js",

"dependencies": {
"vulcanize": "~0.1.4"
"vulcanize": "~0.1.7"
},

@@ -17,3 +17,4 @@ "devDependencies": {

"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-nodeunit": "~0.2.2"
"grunt-contrib-nodeunit": "~0.2.2",
"grunt-mkdir": "~0.1.1"
},

@@ -20,0 +21,0 @@ "scripts": {

@@ -40,19 +40,29 @@ # grunt-vulcanize

#### options.separator
Type: `String`
Default value: `', '`
#### options.csp
Type: `Boolean`
Default value: `false`
A string value that is used to do something with whatever.
Extract inline `<script>` blocks into a separate file. Maps directly to https://github.com/Polymer/vulcanize#content-security-policy
#### options.punctuation
Type: `String`
Default value: `'.'`
#### options.inline
Type: `Boolean`
Default value: `false`
A string value that is used to do something else with whatever else.
The opposite of `csp` mode: inline all scripts and stylesheets.
#### options.excludues.imports
Type: `Array[String]`
Default value: `[]`
An array of strings that will be used as `RegExp`s to filter matching imports from vulcanization.
This option should be used if multiple vulcanizations would share imports, as they could no longer be deduplicated in
their vulcanized forms.
### Usage Examples
#### Default Options
In this example, the default options are used to do something with whatever. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result would be `Testing, 1 2 3.`
In this example, the default options are used to vulcanize `index.html` into `build.html`.
Please see https://github.com/Polymer/vulcanize#example for more information.
```js

@@ -63,3 +73,3 @@ grunt.initConfig({

files: {
'dest/default_options': ['src/testing', 'src/123'],
'build.html': 'index.html'
},

@@ -71,4 +81,6 @@ },

#### Custom Options
In this example, custom options are used to do something else with whatever else. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result in this case would be `Testing: 1 2 3 !!!`
In this example, custom options are used to apply [Content Security Policy](http://en.wikipedia.org/wiki/Content_Security_Policy) settings on the vulcanization of `index.html` into `build-csp.html`.
Please see https://github.com/Polymer/vulcanize#content-security-policy for more information
```js

@@ -78,7 +90,11 @@ grunt.initConfig({

options: {
separator: ': ',
punctuation: ' !!!',
csp: true
excludes: {
inports: [
"polymer.html"
]
}
},
files: {
'dest/default_options': ['src/testing', 'src/123'],
'build-csp.html': 'index.html'
},

@@ -90,5 +106,5 @@ },

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
Contributions to this project must follow the guidlines of the [Contributor License Agreement](https://github.com/Polymer/polymer/blob/master/CONTRIBUTING.md)
## Release History
_(Nothing yet)_

@@ -17,7 +17,10 @@ /*

grunt.registerMultiTask('vulcanize', 'Your task description goes here.', function() {
grunt.registerMultiTask('vulcanize', 'Inline HTML Imports', function() {
// Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
csp: false,
inline: false
inline: false,
excludes: {
imports: []
}
});

@@ -24,0 +27,0 @@

@@ -30,20 +30,41 @@ 'use strict';

},
default_options: function(test) {
default: function(test) {
test.expect(1);
var actual = grunt.file.read('tmp/default_options');
var expected = grunt.file.read('test/expected/default_options');
test.equal(actual, expected, 'should describe what the default behavior is.');
var actual = grunt.file.read('tmp/default/vulcanized.html');
var expected = grunt.file.read('test/expected/default/vulcanized.html');
test.equal(actual, expected);
test.done();
},
custom_options: function(test) {
csp: function(test) {
test.expect(2);
var actual_html = grunt.file.read('tmp/csp/vulcanized.html');
var actual_js = grunt.file.read('tmp/csp/vulcanized.js');
var expected_html = grunt.file.read('test/expected/csp/vulcanized.html');
var expected_js = grunt.file.read('test/expected/csp/vulcanized.js');
test.equal(actual_html, expected_html);
test.equal(actual_js, expected_js);
test.done();
},
inline: function(test) {
test.expect(1);
var actual = grunt.file.read('tmp/custom_options');
var expected = grunt.file.read('test/expected/custom_options');
test.equal(actual, expected, 'should describe what the custom option(s) behavior is.');
var actual = grunt.file.read('tmp/inline/vulcanized.html');
var expected = grunt.file.read('test/expected/inline/vulcanized.html');
test.equal(actual, expected);
test.done();
},
excludes: function(test) {
test.expect(1);
var actual = grunt.file.read('tmp/excludes/vulcanized.html');
var expected = grunt.file.read('test/expected/excludes/vulcanized.html');
test.equal(actual, expected);
test.done();
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc