-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
515 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: GloriaJS | ||
description: Documentation for testing with gloriaJS | ||
permalink: tests/ | ||
layout: blog | ||
--- | ||
<h2>Tests</h2> | ||
<p>Tests are not only possible, but desirable.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
const logger = require('../../utils/logger'); | ||
const config = require('../../core/project.config'); | ||
const _collect = require('../../commands/collect'); | ||
const _extract = require('../../commands/extract'); | ||
const _prebuild = require('../../commands/prebuild'); | ||
const _build = require('../../commands/build'); | ||
const _css_tailwind = require('../../commands/css.tailwind'); | ||
const fs = require('fs'); | ||
const upath = require('upath'); | ||
const _write_html = require('../../commands/write.html'); | ||
|
||
/** | ||
* work in progress, always add on top of existing ways and prevent | ||
* backwards compatibility issues | ||
* | ||
* Default include-paths are pages and posts. | ||
* | ||
* This method | ||
* @param {string} argv.dest If present, write result to destination file | ||
* @param {string} argv.folder If present writes files to folder | ||
* @param {string} argv.write If false, skips writing files to disk | ||
* | ||
* @return {object} information like content and medatata from every coollected path | ||
*/ | ||
const build = (argv) => { | ||
const project = { | ||
config: config.get(), | ||
collected: {}, | ||
content: {}, | ||
extracted: {}, | ||
prebuilt: { | ||
files: {}, | ||
styles: {}, | ||
scripts: {}, | ||
}, | ||
html: [], | ||
}; | ||
|
||
_collect | ||
.run(project) | ||
.then((project) => _extract.run(project)) | ||
.then((project) => _prebuild.run(project)) | ||
.then((project) => _build.run(project)) | ||
.then((prochecto) => { | ||
const { config, html } = prochecto; | ||
|
||
if (argv.dest) { | ||
const dest = `./${argv.dest}/built.${config._hash}.json`; | ||
const ztring = JSON.stringify(prochecto); | ||
fs.writeFileSync(dest, ztring); | ||
} | ||
|
||
return _write_html.run(prochecto); | ||
}) | ||
.then((project) => _css_tailwind.run(project)) | ||
.then((project) => { | ||
logger.log({ ...project }); | ||
}) | ||
.catch((e) => { | ||
logger.error({ e }); | ||
}); | ||
}; | ||
|
||
const options = { | ||
dest: { | ||
default: null, | ||
description: `Destination for stylesheet.`, | ||
}, | ||
}; | ||
|
||
/** | ||
* Command to compile html files | ||
*/ | ||
module.exports = { | ||
command: `css:tailwind [dest]`, | ||
aliases: ['tailwind'], | ||
describe: `Reads the html output and creates a tailwind stylesheet. | ||
The command will fail if _config.yml is invalid or not present.`, | ||
builder: options, | ||
handler: build, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const logger = require('../utils/logger'); | ||
const tailwind = require("tailwindcss"); | ||
const postcss = require("postcss"); | ||
const fs = require('fs'); | ||
|
||
/** | ||
* Creates the resulting CSS by reading all the pages and getting the tailwind classes | ||
* | ||
* @param {*} project | ||
* @returns project | ||
*/ | ||
const run = (project) => { | ||
const promise = new Promise((resolve, reject) => { | ||
const { html, config } = project; | ||
if (!html) { | ||
logger.error('Missing html data at css step'); | ||
return reject(); | ||
} | ||
|
||
(async () => { | ||
const result = await postcss([ | ||
tailwind({ | ||
//...config, | ||
content: [`${config.dest}/**/*.{html,js}`], | ||
}), | ||
]).process(`@tailwind base;@tailwind components;@tailwind utilities;`, { | ||
from: undefined, | ||
}); | ||
|
||
fs.writeFileSync(`${config.dest}/main.css`, result.css); | ||
})(); | ||
|
||
return resolve(project); | ||
}); | ||
|
||
return promise; | ||
}; | ||
|
||
module.exports = { | ||
run, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const logger = require('../utils/logger'); | ||
const upath = require('upath'); | ||
const fs = require('fs'); | ||
|
||
/** | ||
* Writes the HTHL property from the project to disk | ||
* | ||
* @param {*} project | ||
* @returns project | ||
*/ | ||
const run = (project) => { | ||
const promise = new Promise((resolve, reject) => { | ||
const { html, config } = project; | ||
|
||
if (!html) { | ||
logger.error('Missing html data at css step'); | ||
return reject(); | ||
} | ||
|
||
|
||
html.map((file) => { | ||
if (!fs.existsSync(config.dest)) { | ||
fs.mkdirSync(config.dest, { recursive: true }); | ||
} | ||
|
||
const destination = upath.normalize(`${config.dest}/${file.destination}`); | ||
|
||
const parsed = upath.parse(destination); | ||
|
||
if (!fs.existsSync(parsed.dir)) { | ||
fs.mkdirSync(parsed.dir, { recursive: true }); | ||
} | ||
|
||
fs.writeFileSync(destination, file.content); | ||
}); | ||
|
||
return resolve(project); | ||
}); | ||
|
||
return promise; | ||
}; | ||
|
||
module.exports = { | ||
run, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.