amphora-html 6.0.1-dev.0 → 7.0.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/README.md +17 -0
- package/index.js +2 -0
- package/lib/clone-deep.js +181 -0
- package/lib/files.js +66 -0
- package/lib/media.js +83 -79
- package/lib/render.js +44 -19
- package/lib/setup.js +55 -28
- package/lib/styleguide.js +40 -15
- package/lib/utils.js +127 -0
- package/package.json +21 -44
- package/.circleci/config.yml +0 -44
- package/.eslintrc +0 -75
- package/.github/workflows/push.yml +0 -26
- package/.istanbul.yml +0 -51
- package/__mocks__/fileMock.js +0 -3
- package/docs/README.md +0 -31
- package/docs/integration.md +0 -93
- package/docs/intro.md +0 -21
- package/docs/style.md +0 -47
- package/lib/log.test.js +0 -42
- package/lib/media.test.js +0 -908
- package/lib/render.test.js +0 -295
- package/lib/setup.test.js +0 -153
- package/lib/styleguide.test.js +0 -268
- package/test/setupFile.js +0 -3
- package/website/README.md +0 -114
- package/website/core/Footer.js +0 -55
- package/website/package.json +0 -16
- package/website/pages/en/index.js +0 -103
- package/website/pages/en/versions.js +0 -92
- package/website/sidebars.json +0 -13
- package/website/siteConfig.js +0 -66
- package/website/static/css/custom.css +0 -16
- package/website/static/img/logo.svg +0 -13
- package/website/versioned_docs/version-4.0.0/integration.md +0 -94
- package/website/versioned_docs/version-4.0.0/intro.md +0 -22
- package/website/versioned_docs/version-4.0.0/style.md +0 -48
- package/website/versioned_sidebars/version-4.0.0-sidebars.json +0 -13
- package/website/versions.json +0 -3
package/lib/setup.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const path = require('path'),
|
|
4
|
-
_ = require('lodash'),
|
|
5
|
-
glob = require('glob'),
|
|
6
4
|
fs = require('fs'),
|
|
7
5
|
render = require('./render'),
|
|
6
|
+
{ toList } = require('./utils'),
|
|
8
7
|
nymagHbs = require('clayhandlebars'),
|
|
9
8
|
hbs = nymagHbs(),
|
|
10
9
|
TEMPLATE_NAME = 'template';
|
|
@@ -24,19 +23,19 @@ function init() {
|
|
|
24
23
|
function getRenderableItems() {
|
|
25
24
|
const items = [];
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
for (const cmpt of toList(getComponents())) {
|
|
28
27
|
items.push({
|
|
29
28
|
name: cmpt,
|
|
30
29
|
path: getComponentPath(cmpt)
|
|
31
30
|
});
|
|
32
|
-
}
|
|
31
|
+
}
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
for (const layout of toList(getLayouts())) {
|
|
35
34
|
items.push({
|
|
36
35
|
name: layout,
|
|
37
36
|
path: getLayoutPath(layout)
|
|
38
37
|
});
|
|
39
|
-
}
|
|
38
|
+
}
|
|
40
39
|
|
|
41
40
|
return items;
|
|
42
41
|
}
|
|
@@ -47,47 +46,56 @@ function getRenderableItems() {
|
|
|
47
46
|
* @param {Array} items
|
|
48
47
|
*/
|
|
49
48
|
function registerPartials(items) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
isHandlebars =
|
|
53
|
-
templateFileContents,
|
|
54
|
-
modifiedTemplateFile;
|
|
49
|
+
for (const item of items) {
|
|
50
|
+
const templateFile = getPossibleTemplates(item.path, TEMPLATE_NAME),
|
|
51
|
+
isHandlebars = typeof templateFile === 'string' && (templateFile.includes('.handlebars') || templateFile.includes('.hbs'));
|
|
55
52
|
|
|
56
53
|
if (isHandlebars) {
|
|
57
|
-
templateFileContents = fs.readFileSync(templateFile, 'utf8')
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
const templateFileContents = fs.readFileSync(templateFile, 'utf8'),
|
|
55
|
+
// this wrapper guarantees we'll never render a component in a partial if it doesn't have a _ref
|
|
56
|
+
modifiedTemplateFile = nymagHbs.wrapPartial(item.name, templateFileContents);
|
|
60
57
|
|
|
61
58
|
hbs.registerPartial(item.name, modifiedTemplateFile);
|
|
62
59
|
}
|
|
63
|
-
}
|
|
60
|
+
}
|
|
64
61
|
|
|
65
|
-
// Compile all the loaded partials
|
|
66
|
-
|
|
67
|
-
if (
|
|
62
|
+
// Compile all the loaded partials (inherited ones too, as lodash's forIn did)
|
|
63
|
+
for (const key in hbs.partials) {
|
|
64
|
+
if (typeof hbs.partials[key] === 'string') {
|
|
68
65
|
// preventIndent:true solve issue with <pre> tag/white-space: pre
|
|
69
66
|
// see http://handlebarsjs.com/reference.html compile() options
|
|
70
|
-
hbs.partials[key] = hbs.compile(
|
|
67
|
+
hbs.partials[key] = hbs.compile(hbs.partials[key], { preventIndent: true });
|
|
71
68
|
}
|
|
72
|
-
}
|
|
69
|
+
}
|
|
73
70
|
|
|
74
71
|
module.exports.hbs = hbs;
|
|
75
72
|
}
|
|
76
73
|
|
|
77
74
|
/**
|
|
78
75
|
* Grab the possible template files based on the name.
|
|
79
|
-
* Returns a path to the file so that it can be read
|
|
76
|
+
* Returns a path to the file so that it can be read: the first
|
|
77
|
+
* `<templateName>.*` file, in the order glob used to sort them.
|
|
80
78
|
*
|
|
81
79
|
* @param {String} filePath
|
|
82
80
|
* @param {String} templateName
|
|
83
81
|
* @return {String}
|
|
84
82
|
*/
|
|
85
83
|
function getPossibleTemplates(filePath, templateName) {
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
if (typeof filePath === 'string') {
|
|
85
|
+
const dir = path.dirname(path.join(filePath, `${templateName}.*`));
|
|
86
|
+
let names;
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
names = fs.readdirSync(dir);
|
|
90
|
+
} catch (e) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
89
93
|
|
|
90
|
-
|
|
94
|
+
return names
|
|
95
|
+
.filter((name) => name.startsWith(`${templateName}.`))
|
|
96
|
+
.map((name) => path.join(dir, name))
|
|
97
|
+
.sort((a, b) => a.localeCompare(b, 'en'))[0];
|
|
98
|
+
}
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
/**
|
|
@@ -96,10 +104,11 @@ function getPossibleTemplates(filePath, templateName) {
|
|
|
96
104
|
* @param {Object} payload
|
|
97
105
|
*/
|
|
98
106
|
function addHelpers(payload) {
|
|
99
|
-
|
|
107
|
+
// inherited helpers too, as lodash's forIn did
|
|
108
|
+
for (const key in payload) { // eslint-disable-line guard-for-in
|
|
100
109
|
// set up handlebars helpers that rely on internal services
|
|
101
|
-
hbs.registerHelper(`${key}`,
|
|
102
|
-
}
|
|
110
|
+
hbs.registerHelper(`${key}`, payload[key]);
|
|
111
|
+
}
|
|
103
112
|
}
|
|
104
113
|
|
|
105
114
|
/**
|
|
@@ -143,6 +152,24 @@ module.exports.renderSettings = undefined;
|
|
|
143
152
|
module.exports.resolveMedia = undefined;
|
|
144
153
|
module.exports.plugins = [];
|
|
145
154
|
|
|
155
|
+
/**
|
|
156
|
+
* The Handlebars environment amphora-html renders with: clayhandlebars' helpers and
|
|
157
|
+
* partials, the helpers given to `addHelpers`, and a partial for each component and
|
|
158
|
+
* layout. It is the `handlebars` module clayhandlebars itself requires, so it is
|
|
159
|
+
* shared with anything else in the process that uses that module.
|
|
160
|
+
*
|
|
161
|
+
* @type {Object}
|
|
162
|
+
*/
|
|
163
|
+
module.exports.handlebars = hbs;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* What every component and layout template is wrapped in before it is registered
|
|
167
|
+
* as a partial: clayhandlebars' `wrapPartial(name, template)`.
|
|
168
|
+
*
|
|
169
|
+
* @type {Function}
|
|
170
|
+
*/
|
|
171
|
+
module.exports.wrapPartial = nymagHbs.wrapPartial;
|
|
172
|
+
|
|
146
173
|
// Setup functions
|
|
147
174
|
module.exports.init = init;
|
|
148
175
|
module.exports.addHelpers = addHelpers;
|
package/lib/styleguide.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
files = require('nymag-fs'),
|
|
3
|
+
const clayUtils = require('clayutils'),
|
|
4
|
+
files = require('./files'),
|
|
6
5
|
path = require('path'),
|
|
7
|
-
|
|
6
|
+
{ isObject, assignValue, memoize } = require('./utils');
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Looks for CSS files associated with a component's variation
|
|
@@ -15,7 +14,7 @@ const _ = require('lodash'),
|
|
|
15
14
|
function findVariationFiles(styleguide) {
|
|
16
15
|
const stylePath = `styleguides/${styleguide}/components`,
|
|
17
16
|
stylesheets = files.getFiles(stylePath),
|
|
18
|
-
variations =
|
|
17
|
+
variations = stylesheets.filter(function (file) {
|
|
19
18
|
// checks for underscores which denotes variations and make sure it's a
|
|
20
19
|
// css file
|
|
21
20
|
return file.includes('_') && file.includes('.css');
|
|
@@ -37,20 +36,45 @@ function findVariationFiles(styleguide) {
|
|
|
37
36
|
* component and its variations
|
|
38
37
|
*/
|
|
39
38
|
function getVariations(styleguide = '_default') {
|
|
40
|
-
const foundVariations = styleguide !== '_default' ?
|
|
39
|
+
const foundVariations = styleguide !== '_default' ? [...new Set(findVariationFiles(styleguide).concat(findVariationFiles('_default')))] : findVariationFiles('_default'),
|
|
41
40
|
componentVariations = {};
|
|
42
41
|
|
|
43
42
|
if (foundVariations.length) {
|
|
44
|
-
|
|
43
|
+
for (const variant of foundVariations) {
|
|
45
44
|
let component = variant.split('_')[0],
|
|
46
45
|
variantName = path.basename(variant, '.css');
|
|
47
46
|
|
|
48
47
|
(componentVariations[component] || (componentVariations[component] = [])).push(variantName);
|
|
49
|
-
}
|
|
48
|
+
}
|
|
50
49
|
}
|
|
51
50
|
return componentVariations;
|
|
52
51
|
}
|
|
53
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Call `visit` with every value in `node`, depth first, as traverse's forEach did:
|
|
55
|
+
* an object's keys are read before it is visited (so keys `visit` adds are not
|
|
56
|
+
* walked), functions are not walked, and an object found inside itself is
|
|
57
|
+
* visited but not walked again.
|
|
58
|
+
*
|
|
59
|
+
* @param {*} node
|
|
60
|
+
* @param {Function} visit
|
|
61
|
+
* @param {Object[]} [parents] the objects being walked
|
|
62
|
+
*/
|
|
63
|
+
function walk(node, visit, parents = []) {
|
|
64
|
+
const isWalked = typeof node === 'object' && node !== null,
|
|
65
|
+
keys = isWalked ? Object.keys(node) : [];
|
|
66
|
+
|
|
67
|
+
visit(node);
|
|
68
|
+
|
|
69
|
+
if (isWalked && !parents.includes(node)) {
|
|
70
|
+
parents.push(node);
|
|
71
|
+
for (const key of keys) {
|
|
72
|
+
walk(node[key], visit, parents);
|
|
73
|
+
}
|
|
74
|
+
parents.pop();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
54
78
|
/**
|
|
55
79
|
* Goes through page data and sets a default for components
|
|
56
80
|
*
|
|
@@ -71,25 +95,26 @@ function setDefaultVariations(_data, state) {
|
|
|
71
95
|
[topLevelVariation || layoutOrSelf]: true
|
|
72
96
|
};
|
|
73
97
|
|
|
74
|
-
|
|
98
|
+
walk(_data, function (val) {
|
|
75
99
|
let componentName, componentVariations;
|
|
76
100
|
|
|
77
|
-
if (!
|
|
101
|
+
if (!isObject(val) || !val._ref) {
|
|
78
102
|
return; // we only care about components' root data
|
|
79
103
|
}
|
|
80
104
|
|
|
81
105
|
componentName = clayUtils.getComponentName(val._ref);
|
|
82
|
-
|
|
106
|
+
// a name like `constructor` finds what the object inherits, which is not a list
|
|
107
|
+
componentVariations = Array.isArray(variations[componentName]) ? variations[componentName] : [];
|
|
83
108
|
|
|
84
|
-
if (val.componentVariation && !
|
|
109
|
+
if (val.componentVariation && !componentVariations.includes(val.componentVariation)) {
|
|
85
110
|
// component has a variation set, but it doesn't exist in the site's styleguide or the default styleguide!
|
|
86
111
|
// render the component with the default variation
|
|
87
|
-
|
|
112
|
+
assignValue(val, 'componentVariation', componentName);
|
|
88
113
|
usedVariations[`${componentName}`] = true;
|
|
89
114
|
} else if (!val.componentVariation) {
|
|
90
115
|
// component has no variation set!
|
|
91
116
|
// render the component with the default variation
|
|
92
|
-
|
|
117
|
+
assignValue(val, 'componentVariation', componentName);
|
|
93
118
|
usedVariations[`${componentName}`] = true;
|
|
94
119
|
} else {
|
|
95
120
|
usedVariations[`${val.componentVariation}`] = true;
|
|
@@ -98,5 +123,5 @@ function setDefaultVariations(_data, state) {
|
|
|
98
123
|
state._usedVariations = Object.keys(usedVariations);
|
|
99
124
|
}
|
|
100
125
|
|
|
101
|
-
exports.getVariations =
|
|
126
|
+
exports.getVariations = memoize(getVariations);
|
|
102
127
|
exports.setDefaultVariations = setDefaultVariations;
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// The few behaviors of lodash that amphora-html depends on, in native code.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Whether a value is an object or a function, as lodash's isObject
|
|
7
|
+
*
|
|
8
|
+
* @param {*} value
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*/
|
|
11
|
+
function isObject(value) {
|
|
12
|
+
return value !== null && (typeof value === 'object' || typeof value === 'function');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Set a property the way lodash's assign and set did: nothing is written when
|
|
17
|
+
* the object already has that value, a `__proto__` key becomes a property of
|
|
18
|
+
* its own instead of replacing the prototype, and a property that can't be
|
|
19
|
+
* written is left as it is instead of throwing.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} object
|
|
22
|
+
* @param {string|symbol} key
|
|
23
|
+
* @param {*} value
|
|
24
|
+
*/
|
|
25
|
+
function assignValue(object, key, value) {
|
|
26
|
+
const current = object[key];
|
|
27
|
+
|
|
28
|
+
// SameValueZero, like lodash's eq
|
|
29
|
+
if (Object.hasOwn(object, key) && (current === value || Number.isNaN(current) && Number.isNaN(value))) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (key === '__proto__') {
|
|
34
|
+
Object.defineProperty(object, key, { configurable: true, enumerable: true, value, writable: true });
|
|
35
|
+
} else {
|
|
36
|
+
Reflect.set(object, key, value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Copy the own enumerable properties of `source` onto `target`, as lodash's assign
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} target
|
|
44
|
+
* @param {*} source
|
|
45
|
+
* @returns {Object} target
|
|
46
|
+
*/
|
|
47
|
+
function assign(target, source) {
|
|
48
|
+
for (const key of Object.keys(Object(source))) {
|
|
49
|
+
assignValue(target, key, source[key]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return target;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The properties of `object` with these names, as lodash's pick: a name is
|
|
57
|
+
* picked when it is `in` the object, inherited or not, except the ones that
|
|
58
|
+
* would reach a prototype.
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} object
|
|
61
|
+
* @param {string[]|string} keys
|
|
62
|
+
* @returns {Object}
|
|
63
|
+
*/
|
|
64
|
+
function pick(object, keys) {
|
|
65
|
+
const picked = {};
|
|
66
|
+
|
|
67
|
+
for (const key of [].concat(keys)) {
|
|
68
|
+
if (object != null && key in Object(object) && key !== '__proto__' && key !== 'constructor' && key !== 'prototype') {
|
|
69
|
+
picked[key] = object[key];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return picked;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The items of a collection, as lodash's map and each see them: nothing for
|
|
78
|
+
* null or undefined, every index of an array or anything with a length
|
|
79
|
+
* (holes included), the own values of anything else.
|
|
80
|
+
*
|
|
81
|
+
* @param {*} collection
|
|
82
|
+
* @returns {Array}
|
|
83
|
+
*/
|
|
84
|
+
function toList(collection) {
|
|
85
|
+
if (collection == null) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (typeof collection !== 'function' && Number.isSafeInteger(collection.length) && collection.length >= 0) {
|
|
90
|
+
return Array.from({ length: collection.length }, (item, index) => collection[index]);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return Object.values(Object(collection));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Remember what `fn` returns for each first argument, as lodash's memoize:
|
|
98
|
+
* the cache is read from `memoized.cache` on every call, so it can be cleared
|
|
99
|
+
* or replaced with anything that has `get`, `set` and `has`.
|
|
100
|
+
*
|
|
101
|
+
* @param {Function} fn
|
|
102
|
+
* @returns {Function}
|
|
103
|
+
*/
|
|
104
|
+
function memoize(fn) {
|
|
105
|
+
function memoized(key) {
|
|
106
|
+
const cache = memoized.cache;
|
|
107
|
+
|
|
108
|
+
if (cache.has(key)) {
|
|
109
|
+
return cache.get(key);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const result = fn.apply(this, arguments);
|
|
113
|
+
|
|
114
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
memoized.cache = new Map();
|
|
119
|
+
return memoized;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports.isObject = isObject;
|
|
123
|
+
module.exports.assignValue = assignValue;
|
|
124
|
+
module.exports.assign = assign;
|
|
125
|
+
module.exports.pick = pick;
|
|
126
|
+
module.exports.toList = toList;
|
|
127
|
+
module.exports.memoize = memoize;
|
package/package.json
CHANGED
|
@@ -1,62 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amphora-html",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "An HTML renderer for component data",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js",
|
|
8
|
+
"lib",
|
|
9
|
+
"!**/*.test.js"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=26.12.1"
|
|
13
|
+
},
|
|
6
14
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
15
|
+
"lint": "eslint --max-warnings 0",
|
|
16
|
+
"test-local": "node --test \"lib/*.test.js\" \"test/*.test.js\"",
|
|
17
|
+
"test": "npm run lint && node --test --experimental-test-coverage --test-coverage-exclude=\"**/*.test.js\" --test-coverage-lines=100 --test-coverage-branches=100 --test-coverage-functions=100 \"lib/*.test.js\" \"test/*.test.js\""
|
|
10
18
|
},
|
|
11
19
|
"dependencies": {
|
|
12
|
-
"amphora-fs": "^
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"clayutils": "^
|
|
16
|
-
"glob": "^7.1.1",
|
|
17
|
-
"js-yaml": "^3.8.2",
|
|
18
|
-
"lodash": "^4.17.5",
|
|
19
|
-
"nymag-fs": "^1.0.1",
|
|
20
|
-
"traverse": "^0.6.6"
|
|
20
|
+
"amphora-fs": "^3.0.0",
|
|
21
|
+
"clay-log": "^1.6.0",
|
|
22
|
+
"clayhandlebars": "^6.0.0",
|
|
23
|
+
"clayutils": "^4.0.0"
|
|
21
24
|
},
|
|
22
25
|
"devDependencies": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"eslint": "^3.19.0",
|
|
26
|
-
"jest": "23.6.0"
|
|
27
|
-
},
|
|
28
|
-
"peerDependencies": {
|
|
29
|
-
"handlebars": "4",
|
|
30
|
-
"clayhandlebars": "5"
|
|
26
|
+
"@eslint/js": "^10.0.1",
|
|
27
|
+
"eslint": "^10.14.0"
|
|
31
28
|
},
|
|
32
29
|
"repository": {
|
|
33
30
|
"type": "git",
|
|
34
|
-
"url": "git+https://github.com/
|
|
35
|
-
},
|
|
36
|
-
"jest": {
|
|
37
|
-
"clearMocks": true,
|
|
38
|
-
"restoreMocks": true,
|
|
39
|
-
"collectCoverageFrom": [
|
|
40
|
-
"<rootDir>/lib/**/*.js"
|
|
41
|
-
],
|
|
42
|
-
"coverageReporters": [
|
|
43
|
-
"lcov",
|
|
44
|
-
"text-summary"
|
|
45
|
-
],
|
|
46
|
-
"moduleFileExtensions": [
|
|
47
|
-
"js"
|
|
48
|
-
],
|
|
49
|
-
"setupFiles": [
|
|
50
|
-
"<rootDir>/test/setupFile.js"
|
|
51
|
-
],
|
|
52
|
-
"moduleNameMapper": {
|
|
53
|
-
"\\.(hbs)$": "<rootDir>/__mocks__/fileMock.js"
|
|
54
|
-
}
|
|
31
|
+
"url": "git+https://github.com/clay/amphora-html.git"
|
|
55
32
|
},
|
|
56
33
|
"author": "",
|
|
57
34
|
"license": "MIT",
|
|
58
35
|
"bugs": {
|
|
59
|
-
"url": "https://github.com/
|
|
36
|
+
"url": "https://github.com/clay/amphora-html/issues"
|
|
60
37
|
},
|
|
61
|
-
"homepage": "https://github.com/
|
|
38
|
+
"homepage": "https://github.com/clay/amphora-html#readme"
|
|
62
39
|
}
|
package/.circleci/config.yml
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
version: 2
|
|
2
|
-
|
|
3
|
-
# Set defaults to reuse
|
|
4
|
-
defaults: &defaults
|
|
5
|
-
working_directory: ~/repo
|
|
6
|
-
docker:
|
|
7
|
-
- image: circleci/node:8.10.0
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
<<: *defaults
|
|
12
|
-
steps:
|
|
13
|
-
- checkout
|
|
14
|
-
|
|
15
|
-
- restore_cache:
|
|
16
|
-
keys:
|
|
17
|
-
- v2-dependencies-{{ checksum "package.json" }}
|
|
18
|
-
# fallback to using the latest cache if no exact match is found
|
|
19
|
-
- v2-dependencies-
|
|
20
|
-
|
|
21
|
-
- run: npm install
|
|
22
|
-
- run:
|
|
23
|
-
name: Run tests
|
|
24
|
-
command: npm test
|
|
25
|
-
- run:
|
|
26
|
-
name: Send to Coveralls
|
|
27
|
-
command: cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
|
|
28
|
-
- save_cache:
|
|
29
|
-
paths:
|
|
30
|
-
- node_modules
|
|
31
|
-
key: v2-dependencies-{{ checksum "package.json" }}
|
|
32
|
-
|
|
33
|
-
- persist_to_workspace:
|
|
34
|
-
root: ~/repo
|
|
35
|
-
paths: .
|
|
36
|
-
|
|
37
|
-
workflows:
|
|
38
|
-
version: 2
|
|
39
|
-
test-deploy:
|
|
40
|
-
jobs:
|
|
41
|
-
- test:
|
|
42
|
-
filters:
|
|
43
|
-
tags:
|
|
44
|
-
only: /^v[0-9]+\.[0-9]+\.[0-9]+/
|
package/.eslintrc
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": false,
|
|
4
|
-
"node": true,
|
|
5
|
-
"mocha": true,
|
|
6
|
-
"es6": true
|
|
7
|
-
},
|
|
8
|
-
// enable the es6 features supported by our browsers / iojs
|
|
9
|
-
"ecmaFeatures": {
|
|
10
|
-
"arrowFunctions": true,
|
|
11
|
-
"blockBindings": true,
|
|
12
|
-
"forOf": true,
|
|
13
|
-
"objectLiteralDuplicateProperties": true,
|
|
14
|
-
"objectLiteralShorthandProperties": true,
|
|
15
|
-
"objectLiteralShorthandMethods": true,
|
|
16
|
-
"octalLiterals": true,
|
|
17
|
-
"binaryLiterals": true,
|
|
18
|
-
"templateStrings": true,
|
|
19
|
-
"generators": false
|
|
20
|
-
},
|
|
21
|
-
"rules": {
|
|
22
|
-
// possible errors
|
|
23
|
-
"no-extra-parens": 1,
|
|
24
|
-
"valid-jsdoc": [1, {
|
|
25
|
-
"requireReturn": false,
|
|
26
|
-
"requireParamDescription": false,
|
|
27
|
-
"requireReturnDescription": false
|
|
28
|
-
}],
|
|
29
|
-
// best practices
|
|
30
|
-
"complexity": [2, 8],
|
|
31
|
-
"default-case": 2,
|
|
32
|
-
"guard-for-in": 2,
|
|
33
|
-
"no-alert": 1,
|
|
34
|
-
"no-floating-decimal": 1,
|
|
35
|
-
"no-self-compare": 2,
|
|
36
|
-
"no-throw-literal": 2,
|
|
37
|
-
"no-void": 2,
|
|
38
|
-
"quote-props": [2, "as-needed"],
|
|
39
|
-
"vars-on-top": 2,
|
|
40
|
-
"wrap-iife": 2,
|
|
41
|
-
// strict mode
|
|
42
|
-
"strict": [2, "global"],
|
|
43
|
-
// variables
|
|
44
|
-
"no-unused-vars": 2,
|
|
45
|
-
// node.js
|
|
46
|
-
"handle-callback-err": [2, "^.*(e|E)rr"],
|
|
47
|
-
"no-mixed-requires": 0,
|
|
48
|
-
"no-new-require": 2,
|
|
49
|
-
"no-path-concat": 2,
|
|
50
|
-
// stylistic issues
|
|
51
|
-
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
|
|
52
|
-
"comma-style": [2, "last"],
|
|
53
|
-
"indent": [2, 2, { "SwitchCase": 1 }],
|
|
54
|
-
"max-nested-callbacks": [2, 4],
|
|
55
|
-
"newline-after-var": [2, "always"],
|
|
56
|
-
"no-nested-ternary": 2,
|
|
57
|
-
"no-spaced-func": 0,
|
|
58
|
-
"no-trailing-spaces": 2,
|
|
59
|
-
"no-underscore-dangle": 0,
|
|
60
|
-
"no-unneeded-ternary": 1,
|
|
61
|
-
"one-var": 0,
|
|
62
|
-
"quotes": [2, "single", "avoid-escape"],
|
|
63
|
-
"semi": [2, "always"],
|
|
64
|
-
"keyword-spacing": 2,
|
|
65
|
-
"space-before-blocks": [2, "always"],
|
|
66
|
-
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
|
|
67
|
-
"space-infix-ops": [1, {"int32Hint": false}],
|
|
68
|
-
"spaced-comment": [2, "always"],
|
|
69
|
-
// es6
|
|
70
|
-
"generator-star-spacing": [2, "before"],
|
|
71
|
-
// legacy jshint rules
|
|
72
|
-
"max-depth": [2, 4],
|
|
73
|
-
"max-params": [2, 4]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
on: push
|
|
2
|
-
name: Deploy to GitHub Pages
|
|
3
|
-
jobs:
|
|
4
|
-
filterBranch:
|
|
5
|
-
name: Filter branch
|
|
6
|
-
runs-on: ubuntu-latest
|
|
7
|
-
steps:
|
|
8
|
-
- uses: actions/checkout@master
|
|
9
|
-
- name: Filter branch
|
|
10
|
-
uses: actions/bin/filter@master
|
|
11
|
-
with:
|
|
12
|
-
args: branch master
|
|
13
|
-
- name: Install
|
|
14
|
-
uses: actions/npm@master
|
|
15
|
-
with:
|
|
16
|
-
args: install --prefix ./website
|
|
17
|
-
- name: Update version
|
|
18
|
-
uses: clay/docusaurus-github-action@master
|
|
19
|
-
with:
|
|
20
|
-
args: version
|
|
21
|
-
- name: Build and push docs
|
|
22
|
-
uses: clay/docusaurus-github-action@master
|
|
23
|
-
env:
|
|
24
|
-
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
25
|
-
with:
|
|
26
|
-
args: deploy
|
package/.istanbul.yml
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
verbose: false
|
|
2
|
-
instrumentation:
|
|
3
|
-
root: .
|
|
4
|
-
default-excludes: true
|
|
5
|
-
excludes: []
|
|
6
|
-
embed-source: false
|
|
7
|
-
variable: __coverage__
|
|
8
|
-
compact: true
|
|
9
|
-
preserve-comments: false
|
|
10
|
-
complete-copy: false
|
|
11
|
-
save-baseline: false
|
|
12
|
-
baseline-file: ./coverage/coverage-baseline.json
|
|
13
|
-
include-all-sources: true
|
|
14
|
-
include-pid: false
|
|
15
|
-
reporting:
|
|
16
|
-
print: summary
|
|
17
|
-
reports:
|
|
18
|
-
- lcov
|
|
19
|
-
dir: ./coverage
|
|
20
|
-
watermarks:
|
|
21
|
-
statements: [98, 100]
|
|
22
|
-
lines: [98, 100]
|
|
23
|
-
functions: [98, 100]
|
|
24
|
-
branches: [98, 100]
|
|
25
|
-
report-config:
|
|
26
|
-
clover: {file: clover.xml}
|
|
27
|
-
cobertura: {file: cobertura-coverage.xml}
|
|
28
|
-
json: {file: coverage-final.json}
|
|
29
|
-
json-summary: {file: coverage-summary.json}
|
|
30
|
-
lcovonly: {file: lcov.info}
|
|
31
|
-
teamcity: {file: null}
|
|
32
|
-
text: {file: null, maxCols: 0}
|
|
33
|
-
text-lcov: {file: lcov.info}
|
|
34
|
-
text-summary: {file: null}
|
|
35
|
-
hooks:
|
|
36
|
-
hook-run-in-context: false
|
|
37
|
-
post-require-hook: null
|
|
38
|
-
handle-sigint: false
|
|
39
|
-
check:
|
|
40
|
-
global:
|
|
41
|
-
statements: 100
|
|
42
|
-
lines: 100
|
|
43
|
-
branches: 100
|
|
44
|
-
functions: 100
|
|
45
|
-
excludes: []
|
|
46
|
-
each:
|
|
47
|
-
statements: 0
|
|
48
|
-
lines: 0
|
|
49
|
-
branches: 0
|
|
50
|
-
functions: 0
|
|
51
|
-
excludes: []
|
package/__mocks__/fileMock.js
DELETED