Skip to content

Commit

Permalink
0.8.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
JayCanuck committed May 31, 2017
2 parents b0166a4 + 67be890 commit 59a2d4c
Show file tree
Hide file tree
Showing 17 changed files with 229 additions and 74 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## 0.8.1 (May 31, 2017)

### create

* Template updated for Enact 1.2.2

### pack

* Fixed prerendering of apps that use lazy loaded chunks.
* Support for moonstone internal localization.

### serve

* Disable host checks to allow IP serving.

### test

* Added Array.from to the list of polyfills used with Phantomjs in tests.

### license

* Added license checker command to detect all licenses used by content within an app.

## 0.8.0 (April 21, 2017)

With the exception of webpack2-related packages, all dependencies have been updated to their current releases.
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ Runs the Enact configuration of Eslint on the project for syntax analysis.

These tasks will execute all valid tests (files that end in `-specs.js`) that are within the project directory. The `test` is a standard execution pass, `test-json` uses a json reporter for output, and `test-watch` will set up a watcher to re-execute tests when files change.

### `npm run license`

Outputs a JSON representation of the licenses for modules referenced by the current project as well as any licenses of modules used by `enact-dev` that may be included in a production build of an app.


## Enact Build Options

Expand Down
1 change: 1 addition & 0 deletions bin/enact.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if (process.argv.indexOf('-v') >= 0 || process.argv.indexOf('--version') >= 0) {
case 'clean':
case 'test':
case 'lint':
case 'license':
var task = require('../global-cli/' + command);
task(process.argv.slice(3));
break;
Expand Down
2 changes: 2 additions & 0 deletions config/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = function(karma) {
files: [
require.resolve('./polyfills'),
require.resolve('string.prototype.repeat'),
require.resolve('phantomjs-polyfill-array-from'),
require.resolve('es6-map/implement'),
require.resolve('./proptype-checker'),
'./!(node_modules|dist|build)/**/*-specs.js'
Expand All @@ -39,6 +40,7 @@ module.exports = function(karma) {
'./!(node_modules|dist|build)/**/*.js': ['webpack'],
[require.resolve('./polyfills')]: ['webpack'],
[require.resolve('string.prototype.repeat')]: ['webpack'],
[require.resolve('phantomjs-polyfill-array-from')]: ['webpack'],
[require.resolve('es6-map/implement')]: ['webpack'],
[require.resolve('./proptype-checker')]: ['webpack']
},
Expand Down
1 change: 1 addition & 0 deletions docs/loading-existing-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ NPM tasks vary by package and are defined within a `scripts` object in the **pac
* `npm run test` - Builds and executes any test spec files within the project.
* `npm run lint `- Lints the project's JavaScript files according to the Enact ESLint configuration settings.
* `npm run clean` - Deletes the **./dist** directory
* `npm run license` - Outputs a list of licenses used by modules required by the project
70 changes: 70 additions & 0 deletions global-cli/license.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
var
minimist = require('minimist'),
checker = require('license-checker'),
path = require('path');

function displayHelp() {
console.log(' Usage');
console.log(' enact license [options] [<module>]');
console.log();
console.log(' Arguments');
console.log(' module Optional module path');
console.log(' (default: <current directory>');
console.log();
console.log(' Options');
console.log(' -h, --help Display help information');
console.log();
process.exit(0);
}

// The following modules reside in `enact-dev` but end up in production builds of apps
const enactDevProdModules = [
'babel-core',
'string.fromcodepoint',
'string.prototype.codepointat',
'whatwg-fetch',
'object-assign',
'promise'
];

let output = {};

module.exports = function(args) {
const opts = minimist(args, {
boolean: ['h', 'help'],
alias: {h:'help'}
});

opts.help && displayHelp();

let modules = [];

if (opts._.length) {
modules = modules.concat(opts._);
} else {
modules = [...resolveModulePath(enactDevProdModules), '.'];
}

modules.forEach(package => {
checker.init({
start: package
}, function(err, json) {
if (err) {
console.warn(`Unable to process licenses for ${path}: `, err);
} else {
output = Object.assign(output, json);
}
});
});
};

process.on('exit', () => {
if (Object.keys(output).length) {
console.log(output);
}
});

// Resolve module directories relative to `enact-dev`
function resolveModulePath(modules) {
return modules.map(mod => path.dirname(require.resolve(mod)));
}
13 changes: 12 additions & 1 deletion global-cli/modifiers/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var
path = require('path'),
exists = require('path-exists').sync,
helper = require('./util/config-helper'),
SnapshotPlugin = require('./util/SnapshotPlugin');
SnapshotPlugin = require('./util/SnapshotPlugin'),
IgnorePlugin = require('webpack').IgnorePlugin;

module.exports = function(config, opts) {
if(!opts.framework) {
Expand All @@ -27,4 +28,14 @@ module.exports = function(config, opts) {
// Disabled temporarily until effectiveness is proven
// append: (opts.framework ? '\nenact_framework.load();\n' : undefined)
}));

var ssHelperDeps = [
'@enact/i18n',
'@enact/moonstone'
];
for(var i=0; i<ssHelperDeps.length; i++) {
if(!exists(path.join(process.cwd(), 'node_modules', ssHelperDeps[i]))) {
config.plugins.push(new IgnorePlugin(new RegExp(ssHelperDeps[i])));
}
}
};
19 changes: 8 additions & 11 deletions global-cli/modifiers/util/LocaleHtmlPlugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var
path = require('path'),
fs = require('fs'),
vdomRender = require('./vdom-server-render');
vdomServer = require('./vdom-server-render');

// Determine if it's a NodeJS output filesystem or if it's a foreign/virtual one.
function isNodeOutputFS(compiler) {
Expand Down Expand Up @@ -244,14 +244,6 @@ function localizedHtml(i, locales, status, html, compilation, htmlPlugin, callba
}
}

/*
function debug(locales, status) {
for(var i=0; i<locales.length; i++) {
console.log(i + '\t' + locales[i] + '\t' + status.alias[i]);
}
}
*/

function emitAsset(compilation, file, data) {
compilation.assets[file] = {
size: function() { return data.length; },
Expand Down Expand Up @@ -281,17 +273,22 @@ LocaleHtmlPlugin.prototype.apply = function(compiler) {
// Determine the target locales and load up the startup scripts.
locales = parseLocales(compiler.options.context, opts.locales);

// Ensure that any async chunk-loading jsonp functions are isomorphically compatible.
compilation.mainTemplate.plugin('bootstrap', function(source) {
return source.replace(/window/g, '(function() { return this; }())');
});

// Prerender each locale desired and output an error on failure.
compilation.plugin('chunk-asset', function(chunk, file) {
if(file === opts.chunk) {
compilation.applyPlugins('prerender-chunk', {chunk:opts.chunk, locales:locales});
var src = compilation.assets[opts.chunk].source(), locStr;
var src = vdomServer.prepare(compilation.assets[opts.chunk].source(), opts), locStr;
for(var i=0; i<locales.length; i++) {
try {
// Prerender the locale.
locStr = locCode(locales[i]);
compilation.applyPlugins('prerender-localized', {chunk:opts.chunk, locale:locStr});
var appHtml = vdomRender({
var appHtml = vdomServer.render({
server: opts.server,
code: src,
locale: locStr,
Expand Down
11 changes: 8 additions & 3 deletions global-cli/modifiers/util/PrerenderPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var
fs = require('fs'),
path = require('path'),
chalk = require('chalk'),
vdomRender = require('./vdom-server-render');
vdomServer = require('./vdom-server-render');

// Determine if it's a NodeJS output filesystem or if it's a foreign/virtual one.
function isNodeOutputFS(compiler) {
Expand Down Expand Up @@ -37,13 +37,18 @@ PrerenderPlugin.prototype.apply = function(compiler) {
// Prerender the desired chunk asset when it's created.
compiler.plugin('compilation', function(compilation) {
if(isNodeOutputFS(compiler)) {
// Ensure that any async chunk-loading jsonp functions are isomorphically compatible.
compilation.mainTemplate.plugin('bootstrap', function(source) {
return source.replace(/window/g, '(function() { return this; }())');
});

compilation.plugin('chunk-asset', function(chunk, file) {
if(file === opts.chunk) {
try {
compilation.applyPlugins('prerender-chunk', {chunk:opts.chunk});
status.prerender = vdomRender({
status.prerender = vdomServer.render({
server: opts.server,
code: compilation.assets[opts.chunk].source(),
code: vdomServer.prepare(compilation.assets[opts.chunk].source(), opts),
file: opts.chunk,
externals: opts.externals
});
Expand Down
16 changes: 12 additions & 4 deletions global-cli/modifiers/util/locales-tv.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"bg/BG",
"bn/IN",
"bs/Latn/BA",
"bs/ME",
"bs/Latn/ME",
"cs/CZ",
"da/DK",
"de/AT",
Expand All @@ -42,17 +42,20 @@
"en/CN",
"en/ET",
"en/GB",
"en/GE",
"en/GH",
"en/GM",
"en/HK",
"en/IE",
"en/IN",
"en/IS",
"en/JP",
"en/KE",
"en/LK",
"en/LR",
"en/MM",
"en/MW",
"en/MX",
"en/MY",
"en/NG",
"en/NZ",
Expand All @@ -71,6 +74,7 @@
"en/ZM",
"es/AR",
"es/BO",
"es/CA",
"es/CL",
"es/CO",
"es/CR",
Expand Down Expand Up @@ -147,6 +151,7 @@
"nl/NL",
"or/IN",
"pa/IN",
"pa/PK",
"pl/PL",
"pt/AO",
"pt/BR",
Expand All @@ -160,16 +165,17 @@
"ru/KZ",
"ru/RU",
"ru/UA",
"si/LK",
"sk/SK",
"sl/SI",
"sq/AL",
"sq/ME",
"sr/Latn/RS",
"sr/ME",
"sr/Latn/ME",
"sv/FI",
"sv/SE",
"sw/Latn/KE",
"ta/IN",
"ta/SG",
"te/IN",
"th/TH",
"tr/AM",
Expand All @@ -178,12 +184,14 @@
"tr/TR",
"uk/UA",
"ur/IN",
"ur/PK",
"uz/Latn/UZ",
"uz/Cyrl/UZ",
"vi/VN",
"zh/Hans/CN",
"zh/Hans/MY",
"zh/Hans/SG",
"zh/Hant/HK",
"zh/Hant/MY",
"zh/Hant/TW"
]
}
2 changes: 1 addition & 1 deletion global-cli/modifiers/util/prerendered-startup.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

(function() {
// Initialize font scaling for resolution independence.
var screenTypes = %SCREENTYPES%;
var screenTypes = %SCREENTYPES% || [];
var defaultType = {name: 'standard', pxPerRem: 16, width: window.innerWidth, height: window.innerHeight, aspectRatioName: 'standard', base: true};
if(screenTypes.length===0) {
screenTypes.push(defaultType);
Expand Down
40 changes: 29 additions & 11 deletions global-cli/modifiers/util/snapshot-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
* launch-time issues when using code created in a snapshot blob.
*/

function handleException(e) {
// We allow 'Cannot find module' errors, which throw when the libraries are not used in the app.
// @enact/i18n and @enact/moonstone are considered optional dependencies.
if(!e.code || e.code!=='MODULE_NOT_FOUND') {
throw e;
}
}

global.updateEnvironment = function() {
// Update fbjs to have the correct execution environment for the active window.
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
Expand All @@ -16,17 +24,27 @@ global.updateEnvironment = function() {
ExecutionEnvironment.canUseViewport = canUseDOM && !!window.screen;
ExecutionEnvironment.isInWorker = !canUseDOM; // For now, this is true - might change in the future.

// Mark the iLib localestorage cache as needing re-validation.
var ilib = require('@enact/i18n/ilib/lib/ilib');
if (ilib._load) {
ilib._load._cacheValidated = false;
}
try {
// Mark the iLib localestorage cache as needing re-validation.
var ilib = require('@enact/i18n/ilib/lib/ilib');
if (ilib && ilib._load) {
ilib._load._cacheValidated = false;
}

// Clear the active resBundle and string cache.
var resBundle = require('@enact/i18n/src/resBundle');
resBundle.clearResBundle();
// Clear the active resBundle and string cache.
var resBundle = require('@enact/i18n/src/resBundle');
resBundle.clearResBundle();
try {
var moonstoneBundle = require('@enact/moonstone/internal/$L');
moonstoneBundle.clearResBundle();
} catch(e2) {
handleException(e2);
}

// Update the iLib/Enact locale to the active window's locale.
var locale = require('@enact/i18n/locale');
locale.updateLocale();
// Update the iLib/Enact locale to the active window's locale.
var locale = require('@enact/i18n/locale');
locale.updateLocale();
} catch(e1) {
handleException(e1);
}
};
Loading

0 comments on commit 59a2d4c

Please sign in to comment.