Skip to content

Commit af09fb8

Browse files
authored
Merge pull request #20 from StatelessSoftware/v0.2.0
V0.2.0
2 parents 11cda0e + 78ceff5 commit af09fb8

5 files changed

Lines changed: 123 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog - html-to-app
22

3+
## [0.2.0] - 2018-03-27
4+
5+
### Additions
6+
7+
- [Issue #18] - App directory
8+
- [Issue #17] - Readme
9+
10+
### Fixes
11+
12+
- [Issue #19] - Remove testing tag from config
13+
314
## [0.1.1] - 2018-03-26
415

516
### Fixes

README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,98 @@
11
# html-to-app
22
Convert HTML flat file sites to Apps
3+
4+
## Installation
5+
6+
`
7+
npm i -g StatelessSoftware/html-to-app
8+
`
9+
10+
## Preparation
11+
12+
You should have a flat-file html site, and possibly an app directory containing your app (the code will be merged with the build on each run).
13+
14+
If you would like to customize the build, create a config file by typing:
15+
16+
`
17+
html-to-app -c
18+
`
19+
20+
## Usage
21+
22+
To build your app, simply type:
23+
24+
`
25+
html-to-app
26+
`
27+
28+
### Force a new build
29+
30+
To clean the build and rebuild, run
31+
32+
`
33+
html-to-app -f
34+
`
35+
36+
### Configuration
37+
38+
The configuration consists of 4 top-level build-chain objects: importer, converter, builder, and exporter. All paths are relative to the current working directory. Filenames do not contain the directory, as it is deduced from it's parent build-chain object.
39+
40+
## Importer
41+
42+
- **dirHTML** - The location of the HTML flat-files, relative to the current working directory.
43+
- **dirImages** - The location of asset images in the flat-file site.
44+
- **dirCSS** - The location of css (css, less, sass, etc) files to copy
45+
- **dirJS** - The location of js (js, ts, etc) files to copy
46+
- **typeCSS** - The type of CSS to copy to the build (css, scss, less, etc)
47+
- **typeJS** - The type of JS to copy to the build (js, ts, etc)
48+
- **layoutFile** - The location of the HTML layout file.
49+
- **ignoreViews** - An array of HTML filenames to skip.
50+
- **precmd** - A shell command to be run before the importer.
51+
- **postcmd** - A shell command to run after the importer.
52+
53+
## Converter
54+
55+
- **layout**
56+
- **target** DOM string pointing to the html content of the page. Normally should be document.documentElement.outerHTML to grab the entire document
57+
- **remove** Query selector to match elements to remove. i.e. "script, #hello, .mine" will remove all `script` tags, any element with the ID `hello`, and any element with the class `mine`
58+
- **prepend** - String to prepend to the document. Default for layouts should be the document type, as this is stripped in the target process.
59+
- **append** - String to append to the document
60+
- **remap** - Array of remaps. Remaps "remap" the folder structure of tags in your HTML files to resemble the build.
61+
- **tag** - Tag to match
62+
- **from** - String or regex to replace the href or src from
63+
- **to** - String to replace the href or src to
64+
- **prepend** - A string to prepend to the path
65+
- **append** - A string to append to the path
66+
- **view**
67+
- **target** DOM string pointing to the html content of the view. Normally should be document.body.innerHTML to grab only the `<body>` inner
68+
- **remove** Query selector to match elements to remove. i.e. "script, #hello, .mine" will remove all `script` tags, any element with the ID `hello`, and any element with the class `mine`
69+
- **prepend** - String to prepend to the document. Default for layouts should be the document type, as this is stripped in the target process.
70+
- **append** - String to append to the document
71+
- **remap** - Array of remaps. Remaps "remap" the folder structure of tags in your HTML files to resemble the build.
72+
- **tag** - Tag to match
73+
- **from** - String or regex to replace the href or src from
74+
- **to** - String to replace the href or src to
75+
- **prepend** - A string to prepend to the path
76+
- **append** - A string to append to the path
77+
- **precmd** - Shell command to run before the convert
78+
- **postcmd** - Shell command to run after the convert
79+
80+
## Builder
81+
82+
- **dirBuild** - Build directory
83+
- **installCmd** - Command to install the app (e.g. `express`)
84+
- **cleanupCmd** - Command to run after the app installs (inside the build directory)
85+
- **precmd** - Shell command to run before the build
86+
- **postcmd** - Shell command to run after the build
87+
88+
## Exporter
89+
90+
- **dirBuild** - Export directory (can be seperate from the build directory)
91+
- **dirMerge** - App directory to merge with the build
92+
- **dirViews** - Directory to export views to (inside the build)
93+
- **dirImages** - Directory to copy images to (inside the build)
94+
- **dirCSS** - Directory to copy css to
95+
- **dirJS** - Directory to copy js to
96+
- **viewExtension** - Extension to convert the views to
97+
- **precmd** - Shell command to run before the export
98+
- **postcmd** - Shell command to run after the export

config.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"converter": {
2121
"layout": {
2222
"target": "document.documentElement.outerHTML",
23-
"remove": "pingendo",
23+
"remove": "",
2424
"prepend": "<!DOCTYPE html>",
2525
"append": "",
2626
"remap": []
2727
},
2828
"view": {
2929
"target": "document.body.innerHTML",
30-
"remove": "script, pingendo",
30+
"remove": "script",
3131
"prepend": "",
3232
"append": "",
3333
"remap": []
@@ -46,6 +46,7 @@
4646
},
4747
"exporter": {
4848
"dirBuild": "./dist",
49+
"dirMerge": "./app",
4950
"dirViews": "./views",
5051
"dirImages": "./public/images",
5152
"dirCSS": "./public/stylesheets",

lib/chainlinks/builder.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ let Builder = function() {
4949
this.binCmd("mkdir " + buildPath, false);
5050
}
5151

52+
// Check for an app directory to merge
53+
if (this.dirMerge && this.dirMerge.length &&
54+
fs.existsSync(this.dirMerge)) {
55+
56+
// Create app directory path
57+
let mergePath = path.normalize(this.dirMerge);
58+
59+
// Merge the directory
60+
shell.execSync("cp -rf " + mergePath + " " + buildPath);
61+
62+
}
63+
5264
// Install
5365
if (
5466
this.binCmd(this.installCmd) &&

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html-to-app",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Convert HTML flat file sites to Apps",
55
"main": "lib/index.js",
66
"bin": {

0 commit comments

Comments
 (0)