Skip to content

Commit

Permalink
Merge pull request #6 from InDIOS/development
Browse files Browse the repository at this point in the history
Bump to version 0.1.2
  • Loading branch information
InDIOS authored Aug 16, 2018
2 parents f48162a + 41ba801 commit 618e726
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 28 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.1.2
- Added default include pattern to every file with extension html in rollup plugin.
- Added a validator property to component attributes definition.
- Component plugins are store globally now.
- Ignore html files inside node_modules folder by default in cli mode.
- Fixed bug in output path in cli mode.

0.1.1
- Fixed issue with file location in cli mode.

0.1.0
- Added ability to work with `SVG` elements.
- Added ability to iterate over number and range with `$for` attribute.
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trebor",
"version": "0.1.1",
"version": "0.1.2",
"description": "A node js module to make standalone web components.",
"main": "./build/index.js",
"bin": {
Expand Down Expand Up @@ -30,13 +30,13 @@
"html-entities": "^1.2.1",
"html-tag-names": "^1.1.3",
"loader-utils": "^1.1.0",
"parse5": "^5.0.0",
"parse5": "^5.1.0",
"rollup-pluginutils": "^2.3.1",
"svg-tag-names": "^1.1.1",
"tslib": "^1.9.3",
"typescript": "^3.0.1",
"uglify-es": "^3.3.9",
"uglify-js": "^3.4.6",
"uglify-js": "^3.4.7",
"yargs": "^12.0.1"
},
"devDependencies": {
Expand All @@ -48,7 +48,7 @@
"@types/glob": "^5.0.35",
"@types/html-entities": "^1.2.16",
"@types/html-tag-names": "^1.1.0",
"@types/node": "^10.5.7",
"@types/node": "^10.7.1",
"@types/parse5": "^5.0.0",
"@types/uglify-js": "^3.0.3",
"eslint-plugin-html": "^4.0.5",
Expand Down
2 changes: 1 addition & 1 deletion plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { kebabToCamelCases, capitalize } = require('./build/utilities/tools');

module.exports = function ({ include, exclude, comments }) {
const format = 'es';
const filter = createFilter(include, exclude);
const filter = createFilter(include || './**/*.html', exclude);
return {
name: 'rollup-plugin-trebor',
transform(code, id) {
Expand Down
8 changes: 3 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function compileFile(options: CompilerOptions) {
options.moduleName = options.moduleName || moduleName;
const fileName = `${file}.${options.format}.js`;
if (!options.out) {
options.out = join(dir, fileName);
options.out = dir;
}
const { compilerOptions, uglifyOptions } = getOptions(options);
const {imports, source} = genSource(html, options);
Expand Down Expand Up @@ -198,10 +198,8 @@ export default function cli(options: CompilerOptions) {
compileFile(options);
} else if (info.isDirectory()) {
glob(`${options.input}/**/*.html`, (err, files) => {
if (err) {
throw err;
}
files.forEach(file => {
if (err) throw err;
files.filter(f => !f.includes('node_modules')).forEach(file => {
compileFile({ ...options, ...{ input: file } });
});
});
Expand Down
24 changes: 16 additions & 8 deletions tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ interface DirectiveDefObject {
}

interface AttrDefinition {
required?: boolean;
required?: boolean;
type: string | Function;
validator?(value: any): boolean;
default?: AttrTypes | (() => AttrTypes | Object);
}

Expand Down Expand Up @@ -89,7 +90,7 @@ export function _$CompCtr(attrs: AttrParams, template: TemplateFn, options: Comp
const opts: ComponentOptions = self.$options;
if (!opts.attrs) opts.attrs = {};
if (!opts.children) opts.children = {};
_$e(<{ options: ObjectLike<any>, fn: PluginFn }[]>_$CompCtr['_plugins'], (plugin) => {
_$e(<{ options: ObjectLike<any>, fn: PluginFn }[]>window['__trebor_plugins__'], (plugin) => {
plugin.fn.call(self, _$CompCtr, plugin.options);
});
if (opts.filters) _$assign(self.$filters, opts.filters);
Expand All @@ -108,12 +109,19 @@ export function _$CompCtr(attrs: AttrParams, template: TemplateFn, options: Comp
if (value === void 0 && _$hasProp(attrOps, 'default')) {
const def = (<AttrDefinition>attrOps).default;
value = _$isType(def, 'function') ? (<Function>def)() : def;
}
}
const typ = (<AttrDefinition>attrOps).type;
if (typ && !_$isType(value, typ) && (<AttrDefinition>attrOps).required) {
return console.error(`Attribute '${key}' must be type '${typ}'.`);
}
return _$toType(value, value === void 0 ? 'undefined' : typ, self, <string>key);
return console.error(`Attribute '${key}' must be type '${typ}'.`);
}
value = _$toType(value, value === void 0 ? 'undefined' : typ, self, <string>key);
if (_$hasProp(attrOps, 'validator')) {
const validator = (<AttrDefinition>attrOps).validator;
if (_$isType(validator, 'function') && !validator(value)) {
return console.error(`Attribute '${key}' with value '${JSON.stringify(value)}' is not valid.`);
}
}
return value;
}
}
},
Expand Down Expand Up @@ -171,8 +179,8 @@ export function _$CompCtr(attrs: AttrParams, template: TemplateFn, options: Comp
});
}
export function _$plugin(fn: Function, options?: ObjectLike<any>) {
_$CompCtr['_plugins'] = _$CompCtr['_plugins'] || [];
_$CompCtr['_plugins'].push({ options, fn });
window['__trebor_plugins__'] = window['__trebor_plugins__'] || [];
window['__trebor_plugins__'].push({ options, fn });
}
_$assign(_$CompCtr.prototype, {
$get(path: string) {
Expand Down

0 comments on commit 618e726

Please sign in to comment.