Skip to content

Commit

Permalink
1.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
JayCanuck committed Mar 13, 2018
2 parents 5405865 + 3e6a0d3 commit 8d42351
Show file tree
Hide file tree
Showing 35 changed files with 1,206 additions and 681 deletions.
58 changes: 20 additions & 38 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
module.exports = {
globals: {
'window': true
},
env: {
'es6': true, // sets the "ecmaVersion" parser option to 6
'node': true
es6: true, // sets the 'ecmaVersion' parser option to 6
node: true
},
extends: ['eslint:recommended'],
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
plugins: ['import'],
rules: {
'comma-dangle': 2,
'no-console': 0,
'no-control-regex': 0,
'no-debugger': 1,
'no-empty': 0,
'no-negated-in-lhs': 2,
'no-regex-spaces': 0,
'no-unexpected-multiline': 0,
'block-scoped-var': 1,
'dot-location': [1, 'property'],
'eqeqeq': [1, 'smart'],
eqeqeq: [1, 'smart'],
'no-caller': 2,
'no-div-regex': 1,
'no-eval': 1,
'no-extra-bind': 1,
'no-floating-decimal': 1,
'no-implied-eval': 1,
'no-iterator': 2,
'no-labels': 2,
Expand All @@ -33,50 +27,38 @@ module.exports = {
'no-new': 1,
'no-octal-escape': 1,
'no-proto': 2,
'no-redeclare': [2, {'builtinGlobals': true}],
'no-redeclare': [2, {builtinGlobals: true}],
'no-return-assign': [2, 'except-parens'],
'no-self-compare': 2,
'no-sequences': 2,
'no-throw-literal': 2,
'no-unused-expressions': [1, {'allowShortCircuit': true, 'allowTernary': true}],
'no-unused-expressions': [1, {allowShortCircuit: true, allowTernary: true}],
'no-useless-call': 2,
'no-useless-return': 1,
'no-with': 2,
'radix': [1, 'as-needed'],
'wrap-iife': [2, 'inside'],
radix: [1, 'as-needed'],
'no-catch-shadow': 2,
'no-label-var': 2,
'no-shadow-restricted-names': 2,
'no-shadow': [2, {'builtinGlobals': true, 'hoist': 'all', 'allow': ['context']}],
'no-use-before-define': [2, {'functions': false}],
'array-bracket-spacing': 1,
'brace-style': [1, '1tbs', {'allowSingleLine': true }],
'comma-spacing': 1,
'comma-style': 1,
'computed-property-spacing': 1,
'eol-last': 1,
'indent': [1, 'tab', {'SwitchCase': 1, 'CallExpression': {'arguments': 2}, 'MemberExpression': 'off', "flatTernaryExpressions": true}],
'jsx-quotes': 1,
'no-shadow': [2, {builtinGlobals: true, hoist: 'all', allow: ['context']}],
'no-use-before-define': [2, {functions: false}],
'linebreak-style': 1,
'new-cap': [2, {'newIsCap': true, 'capIsNew': false}],
'new-parens': 1,
'new-cap': [2, {newIsCap: true, capIsNew: false}],
'no-array-constructor': 2,
'no-lonely-if': 1,
'no-mixed-spaces-and-tabs': 1,
'no-new-object': 1,
'func-call-spacing': 1,
'no-trailing-spaces': 1,
'no-unneeded-ternary': 1,
'operator-linebreak': [1, 'before', {'overrides': {'=':'after'}}],
'quotes': [1, 'single', {'avoidEscape':true}],
'space-before-function-paren': [1, 'never'],
'space-infix-ops': 0,
'space-unary-ops': [1, {'words': true, 'nonwords': false}],
'spaced-comment': [1, 'always', {'markers': ['*']}],
'arrow-spacing': 1,
'spaced-comment': [1, 'always', {markers: ['*']}],
'require-yield': 0,
'no-var': 1,
'prefer-const': 1,
'prefer-arrow-callback': [1, {'allowNamedFunctions': true}]
'prefer-arrow-callback': [1, {allowNamedFunctions: true}],
'import/no-unresolved': [2, {commonjs: true, caseSensitive: true}],
'import/named': 2,
'import/first': 1,
'import/no-duplicates': 2,
'import/extensions': [1, 'always', {js: 'never', json: 'always'}],
'import/newline-after-import': 1,
'import/order': [1, {'newlines-between': 'never'}]
}
};
21 changes: 16 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
## 0.5.0
## 1.0.0 (March 13, 2018)

* Added basic documentation.
* Top-level exports are now loaded/parsed on-demand when accessed.
* Support dynamic output path with framework mixin.
* Remove unneeded `main` package detection.
* Fix root `package.json` detection on Windows platform.
* Fix iLib localedata/moonstone ResBundle detection on Windows platform.
* Ensure moonstone ResBundle is correctly included when running tests within moonstone itself.
* Improved source code formatting/validation via `eslint-plugin-import` along with `eslint-plugin-prettier`.

## 0.5.0 (January 9, 2018)

* Added a new plugin for webpack, EnzymeAdapterPlugin, which automates the Enzyme initialization of an adapter. Whenever an app imports/requires Enzyme, a small proxy will intervene and ensure the desired Enzyme adapter is configured and used. This allows easier Enzyme usage within karma-webpack, for example.
* PrerenderPlugin inline script to initialize root `fontSize` now considers window height in addition to window width.
* Deep linking support in a prerendered page will now default to empty content, inserting prerendered app HTML as needed.

## 0.4.0 (Nov. 6, 2017)
## 0.4.0 (November 6, 2017)

* Unify PrerenderPlugin and LocaleHtmlPlugin into a single general-purpose plugin
* Defaults to `en-US` locale but supports all the same locale option as LocaleHtmlPlugin (json files, literal objects, presets, etc.).
Expand All @@ -24,22 +35,22 @@
* Fixed screentype detection when not using an identifiable theme like moonstone.
* Fixed browserslist support when using Electron browser to auto-determine webpack should use `electron-main` environment.

## 0.3.0 (Oct. 30, 2017)
## 0.3.0 (October 30, 2017)

* Added support for targetted builds using the `BROWSERSLIST` browser [standard format](https://github.com/ai/browserslist).
* Added `core-js` polyfill support to vdom rendering to allow for modern APIs.
* Fixed loader detection from loader filepaths.
* Changed default scope of browser support to ignore IE and IE Mobile.
* Changed to generalized `package.json` requirements for greater flexibility and sharing or dependencies between packages.

## 0.2.0 (Oct. 5, 2017)
## 0.2.0 (October 5, 2017)

* Added an `option-parser` module to parse and store the Enact build options from the `package.json` and to handle intertwined values and fallbacks to do with `fontGenerator`, `screenTypes`, `ri`, `theme`, `target`, etc.
* Added support for a CommonJS font generator to generate localized font CSS (deprecating the previous global prerender hook).
* Added support for dynamic replacement of main entrypoint to `config-helper`.
* Updated `package-root` to now throw an error when no root is found.
* Updated dependencies.

## 0.1.0 (Sept. 28, 2017)
## 0.1.0 (September 28, 2017)

* Initial code migration from `enact-dev`
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,56 @@
# enact-dev-utils
# @enact/dev-utils [![Travis](https://img.shields.io/travis/enactjs/dev-utils.svg?style=flat-square)](https://travis-ci.org/enactjs/dev-utils) [![npm (scoped)](https://img.shields.io/npm/v/@enact/dev-utils.svg?style=flat-square)](https://www.npmjs.com/package/@enact/dev-utils)

> A collection of development utilities for Enact apps.
### Installation

```
npm install --save-dev @enact/dev-utils
```

### Features and Utilities

#### [Mixins](./mixins/README.md)

#### Plugins

- [EnactFrameworkPlugin & EnactFrameworkRefPlugin](./plugins/dll/README.md)
- [EnzymeAdapterPlugin](./plugins/EnzymeAdapterPlugin/README.md)
- [GracefulFsPlugin](./plugins/GracefulFsPlugin/README.md)
- [ILibPlugin](./plugins/ILibPlugin/README.md)
- [PrerenderPlugin](./plugins/PrerenderPlugin/README.md)
- [SnapshotPlugin](./plugins/SnapshotPlugin/README.md)
- [WebOSMetaPlugin](./plugins/WebOSMetaPlugin/README.md)

#### `config-helper`

Contains a collection of webpack configuration manipulation functions. Able to find a webpack project root as well as manipulate entrypoints, loaders, and plugins.

#### `option-parser`

Detects the `enact` object within the root `package.json` and autodetects/resolves omitted options.

#### `package-root`

Resolves the active package root path and metadata.

### Copyright and License Information

Unless otherwise specified, all content, including all source code files and
documentation files in this repository are:

Copyright (c) 2016-2018 LG Electronics

Unless otherwise specified or set forth in the NOTICE file, all content,
including all source code files and documentation files in this repository are:
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this content except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
65 changes: 36 additions & 29 deletions config-helper.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,56 @@
const pkgRoot = require('./package-root');

let rootCache;

module.exports = {
appRoot: function() {
return (rootCache ? rootCache : (rootCache=pkgRoot().path));
return rootCache ? rootCache : (rootCache = pkgRoot().path);
},
injectEntry: function(config, entry, opts = {}) {
if(typeof config.entry === 'string') {
if (typeof config.entry === 'string') {
config.entry = [config.entry];
}
if(Array.isArray(config.entry)) {
if(opts.first) {
if (Array.isArray(config.entry)) {
if (opts.first) {
config.entry.unshift(entry);
} else if(opts.last || opts.main) {
} else if (opts.last || opts.main) {
config.entry.push(entry);
} else {
config.entry.splice(-1, 0, entry);
}
} else if(typeof config.entry === 'object') {
const o = {entry:config.entry[opts.chunk || 'main']};
} else if (typeof config.entry === 'object') {
const o = {entry: config.entry[opts.chunk || 'main']};
this.injectEntry(o, entry, opts);
config.entry[opts.chunk || 'main'] = o.entry;
}
},
mainEntry: function(config, opts = {}) {
if(typeof config.entry === 'string') {
if (typeof config.entry === 'string') {
return config.entry;
} else if(Array.isArray(config.entry)) {
return config.entry[config.entry.length-1];
} else if(typeof config.entry === 'object') {
return this.mainEntry({entry:config.entry[opts.chunk || 'main']}, opts);
} else if (Array.isArray(config.entry)) {
return config.entry[config.entry.length - 1];
} else if (typeof config.entry === 'object') {
return this.mainEntry({entry: config.entry[opts.chunk || 'main']}, opts);
}
},
replaceMain: function(config, replacement, opts = {}) {
if(typeof config.entry === 'string') {
if (typeof config.entry === 'string') {
config.entry = replacement;
} else if(Array.isArray(config.entry)) {
config.entry[config.entry.length-1] = replacement;
} else if(typeof config.entry === 'object') {
this.replaceMain({entry:config.entry[opts.chunk || 'main']}, replacement, opts);
} else if (Array.isArray(config.entry)) {
config.entry[config.entry.length - 1] = replacement;
} else if (typeof config.entry === 'object') {
this.replaceMain({entry: config.entry[opts.chunk || 'main']}, replacement, opts);
}
},
findLoader: function(config, name) {
let index = -1;
if(config && config.module && config.module.rules && name) {
for(let i=0; i<config.module.rules.length; i++) {
if(config.module.rules[i].loader) {
if(config.module.rules[i].loader === name + '-loader'
|| new RegExp('node_modules[\\\\/]' + name + '-loader').test(config.module.rules[i].loader)) {
if (config && config.module && config.module.rules && name) {
for (let i = 0; i < config.module.rules.length; i++) {
if (config.module.rules[i].loader) {
if (
config.module.rules[i].loader === name + '-loader' ||
new RegExp('node_modules[\\\\/]' + name + '-loader').test(config.module.rules[i].loader)
) {
index = i;
break;
}
Expand All @@ -57,16 +60,20 @@ module.exports = {
return index;
},
getLoaderByName: function(config, name) {
if(config && config.module && config.module.rules && name) {
if (config && config.module && config.module.rules && name) {
return config.module.rules[this.findLoader(config, name)];
}
},
findPlugin: function(config, name) {
let index = -1;
if(config && config.plugins && name) {
for(let i=0; i<config.plugins.length; i++) {
if(config.plugins[i] && config.plugins[i].constructor
&& config.plugins[i].constructor.name && config.plugins[i].constructor.name===name) {
if (config && config.plugins && name) {
for (let i = 0; i < config.plugins.length; i++) {
if (
config.plugins[i] &&
config.plugins[i].constructor &&
config.plugins[i].constructor.name &&
config.plugins[i].constructor.name === name
) {
index = i;
break;
}
Expand All @@ -75,13 +82,13 @@ module.exports = {
return index;
},
getPluginByName: function(config, name) {
if(config && config.plugins && name) {
if (config && config.plugins && name) {
return config.plugins[this.findPlugin(config, name)];
}
},
removePlugin: function(config, name) {
const i = this.findPlugin(config, name);
if(i>=0) {
if (i >= 0) {
config.plugins.splice(i, 1);
}
}
Expand Down
34 changes: 29 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
module.exports = Object.assign({
mixins: require('./mixins'),
configHelper: require('./config-helper'),
packageRoot: require('./package-root')
}, require('./plugins'));
const exportOnDemand = obj => {
Object.keys(obj).forEach(name => {
Object.defineProperty(module.exports, name, {
configurable: false,
enumerable: true,
get: obj[name]
});
});
};

// Export the general mixins and dev utilities.
exportOnDemand({
mixins: () => require('./mixins'),
configHelper: () => require('./config-helper'),
packageRoot: () => require('./package-root'),
optionParser: () => require('./option-parser')
});

// Export the Webpack plugins.
exportOnDemand({
EnactFrameworkPlugin: () => require('./plugins/dll/EnactFrameworkPlugin'),
EnactFrameworkRefPlugin: () => require('./plugins/dll/EnactFrameworkRefPlugin'),
EnzymeAdapterPlugin: () => require('./plugins/EnzymeAdapterPlugin'),
GracefulFsPlugin: () => require('./plugins/GracefulFsPlugin'),
ILibPlugin: () => require('./plugins/ILibPlugin'),
PrerenderPlugin: () => require('./plugins/PrerenderPlugin'),
SnapshotPlugin: () => require('./plugins/SnapshotPlugin'),
WebOSMetaPlugin: () => require('./plugins/WebOSMetaPlugin')
});
Loading

0 comments on commit 8d42351

Please sign in to comment.