Skip to content

Commit

Permalink
0.4.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
JayCanuck committed Dec 5, 2016
2 parents 58b35b4 + 9706154 commit 2826518
Show file tree
Hide file tree
Showing 19 changed files with 592 additions and 378 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
## 0.4.0

### create

* Renamed `init` command to `create` for clarity of purpose.

### transpile

* Fixed fs-extra depreciation warning about using a RegExp in copying

### pack

* Fixes App rendering in isomorphic code layout, where apps exported as ES6 default would fail to render.

### test

* Properly ignore ./dist and ./build directories when searching for tests.
* Removed sourcemap support as it was causing issues.


## 0.3.0 (November 7, 2016)

### init

* Sanitizes directory name so only valid characters are included as the package name.
* Template updated for Enact 1.0.0-alpha.3

### pack

Expand All @@ -29,6 +50,7 @@
* Verifies the user has a compatible Node version.
* Verifies the destination directory is safe to create a project in.
* Template now include webOS meta files (appinfo.json, icons.png, etc.).
* Template updated for Enact 1.0.0-alpha.2
* The package.json and appinfo.json will update their respective `name`/`id` to the project directory's name.
* Added `--verbose` flag option to provide detailed logging.
* Added `--link` flag option to link any dependencies that have been `npm link` rathen than install.
Expand Down
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ npm install -g enyojs/enact-dev
The only time you're ever want to directly use the Enact CLI is when you want to create a new project.

```sh
enact init [directory]
enact create [directory]
```

This will generate a basic App template, complete with npm scripts and dependencies setup. If no directory path is specified, it will be generated within the working directory.
Expand Down Expand Up @@ -52,6 +52,31 @@ 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.


## Enact Build Options

The enact-dev tool will check the project's `package.json` looking for an optional `enact` object for a few customization options:

* `template` _[string]_ - Filepath to an alternate HTML template to use with the [Webpack html-webpack-plugin](https://github.com/ampedandwired/html-webpack-plugin).
* `isomorphic` _[boolean|string]_ - If `true`, it indicates the default entrypoint is isomorphic-compatible (and can be built via the `--isomorphic` enact-dev flag). If the value is a string, then it will use that value as a filepath to a custom isomorphic-compatible entrypoint.
* `title` _[string]_ - Title text that should be put within the HTML's `<title></title>` tags. Note: if this is a webOS-project, the title by default will be auto-detected from the appinfo.json content.
* `ri` _[object]_ - Resolution independence options to be forwarded to the [LESS plugin](https://github.com/enyojs/less-plugin-resolution-independence).
* `proxy` _[string]_ - Proxy target during project `serve` to be used within the [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware).

For example:
```js
{
...
"enact": {
"isomorphic": true,
"ri": {
"baseSize":24
}
}
...
}
```


## Displaying Lint Output in the Editor

Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint.
Expand Down
10 changes: 8 additions & 2 deletions bin/enact.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ if(process.argv.indexOf('-v')>=0 || process.argv.indexOf('--version')>=0) {
console.log();
} else {
var command = process.argv[2];

switch(command) {
case 'init':
var chalk = require('chalk');
console.log(chalk.gray('Warning: \'enact init\' is depreciated.'
+ ' Please use \'enact create\''));
command = 'create';
case 'create':
case 'serve':
case 'transpile':
case 'pack':
Expand All @@ -21,7 +27,7 @@ if(process.argv.indexOf('-v')>=0 || process.argv.indexOf('--version')>=0) {
task(process.argv.slice(3));
break;
default:
var init = require('../global-cli/init');
init(['--help']);
var create = require('../global-cli/create');
create(['--help']);
}
}
16 changes: 8 additions & 8 deletions config/.babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"presets": ["es2015", "stage-0", "react"],
"plugins": ["dev-expression"],
"env": {
"production": {
"plugins": ["transform-react-inline-elements","transform-react-constant-elements"]
}
}
{
"presets": ["es2015", "stage-0", "react"],
"plugins": ["dev-expression"],
"env": {
"production": {
"plugins": ["transform-react-inline-elements","transform-react-constant-elements"]
}
}
}
208 changes: 104 additions & 104 deletions config/EnactFrameworkPlugin.js
Original file line number Diff line number Diff line change
@@ -1,104 +1,104 @@
var
path = require('path'),
fs = require('fs'),
DllEntryPlugin = require('webpack/lib/DllEntryPlugin'),
DllModule = require('webpack/lib/DllModule'),
RawSource = require("webpack/lib/RawSource");

var pkgCache = {};
var checkPkgMain = function(dir) {
if(pkgCache[dir]) {
return pkgCache[dir].main;
} else {
try {
var text = fs.readFileSync(path.join(dir, 'package.json'), {encoding:'utf8'});
pkgCache[dir] = JSON.parse(text);
return pkgCache[dir].main;
} catch(e) {
return undefined;
}
}
};

function normalizeModuleID(id) {
var parent = path.dirname(id);
var main = checkPkgMain(parent);
if(main && path.resolve(id)===path.resolve(path.join(parent, main))) {
id = parent;
}
id = id.replace(/\\/g, '/');

// Remove any leading ./node_modules prefix
var nodeModulesPrefix = './node_modules/';
if(id.indexOf(nodeModulesPrefix)===0) {
id = id.substring(nodeModulesPrefix.length);
}
if(id.indexOf('node_modules')===-1) {
// Remove any js file extension
if(id.indexOf('.js')===id.length-3) {
id = id.substring(0, id.length-3);
}
// Remove any /index suffix as we want the user-accessible ID
if(id.indexOf('/index')===id.length-6 && id.length>6) {
id = id.substring(0, id.length-6);
}
}
return id;
}

DllModule.prototype.source = function() {
var header = '';
if(DllModule.entries[this.name]) {
header += '__webpack_require__.load = function(loader) {\n';
header += '\tloader = loader || __webpack_require__;'
for(var i=0; i<DllModule.entries[this.name].length; i++) {
header += '\tloader(\'' + DllModule.entries[this.name][i] + '\');\n';
}
header += '};\n';
}
return new RawSource(header + 'module.exports = __webpack_require__;');
};

function EnactFrameworkPlugin(options) {
this.options = options || {};
}
module.exports = EnactFrameworkPlugin;
EnactFrameworkPlugin.prototype.apply = function(compiler) {
// Map entries to the DLLEntryPlugin
DllModule.entries = {};
compiler.plugin('entry-option', function(context, entry) {
function itemToPlugin(item, name) {
if(Array.isArray(item)) {
DllModule.entries[name] = [];
for(var i=0; i<item.length; i++) {
DllModule.entries[name].push(normalizeModuleID('./node_modules/' + item[i]));
}
return new DllEntryPlugin(context, item, name);
} else {
throw new Error('EnactFrameworkPlugin: supply an Array as entry');
}
}
if(typeof entry === 'object') {
Object.keys(entry).forEach(function(name) {
compiler.apply(itemToPlugin(entry[name], name));
});
} else {
compiler.apply(itemToPlugin(entry, 'main'));
}
return true;
});

// Format the internal module ID to a usable named descriptor
compiler.plugin('compilation', function(compilation) {
compilation.plugin('before-module-ids', function(modules) {
modules.forEach(function(module) {
if(module.id === null && module.libIdent) {
module.id = module.libIdent({
context: this.options.context || compiler.options.context
});
module.id = normalizeModuleID(module.id)
}
}, this);
}.bind(this));
}.bind(this));
};
var
path = require('path'),
fs = require('fs'),
DllEntryPlugin = require('webpack/lib/DllEntryPlugin'),
DllModule = require('webpack/lib/DllModule'),
RawSource = require("webpack/lib/RawSource");

var pkgCache = {};
var checkPkgMain = function(dir) {
if(pkgCache[dir]) {
return pkgCache[dir].main;
} else {
try {
var text = fs.readFileSync(path.join(dir, 'package.json'), {encoding:'utf8'});
pkgCache[dir] = JSON.parse(text);
return pkgCache[dir].main;
} catch(e) {
return undefined;
}
}
};

function normalizeModuleID(id) {
var parent = path.dirname(id);
var main = checkPkgMain(parent);
if(main && path.resolve(id)===path.resolve(path.join(parent, main))) {
id = parent;
}
id = id.replace(/\\/g, '/');

// Remove any leading ./node_modules prefix
var nodeModulesPrefix = './node_modules/';
if(id.indexOf(nodeModulesPrefix)===0) {
id = id.substring(nodeModulesPrefix.length);
}
if(id.indexOf('node_modules')===-1) {
// Remove any js file extension
if(id.indexOf('.js')===id.length-3) {
id = id.substring(0, id.length-3);
}
// Remove any /index suffix as we want the user-accessible ID
if(id.indexOf('/index')===id.length-6 && id.length>6) {
id = id.substring(0, id.length-6);
}
}
return id;
}

DllModule.prototype.source = function() {
var header = '';
if(DllModule.entries[this.name]) {
header += '__webpack_require__.load = function(loader) {\n';
header += '\tloader = loader || __webpack_require__;'
for(var i=0; i<DllModule.entries[this.name].length; i++) {
header += '\tloader(\'' + DllModule.entries[this.name][i] + '\');\n';
}
header += '};\n';
}
return new RawSource(header + 'module.exports = __webpack_require__;');
};

function EnactFrameworkPlugin(options) {
this.options = options || {};
}
module.exports = EnactFrameworkPlugin;
EnactFrameworkPlugin.prototype.apply = function(compiler) {
// Map entries to the DLLEntryPlugin
DllModule.entries = {};
compiler.plugin('entry-option', function(context, entry) {
function itemToPlugin(item, name) {
if(Array.isArray(item)) {
DllModule.entries[name] = [];
for(var i=0; i<item.length; i++) {
DllModule.entries[name].push(normalizeModuleID('./node_modules/' + item[i]));
}
return new DllEntryPlugin(context, item, name);
} else {
throw new Error('EnactFrameworkPlugin: supply an Array as entry');
}
}
if(typeof entry === 'object') {
Object.keys(entry).forEach(function(name) {
compiler.apply(itemToPlugin(entry[name], name));
});
} else {
compiler.apply(itemToPlugin(entry, 'main'));
}
return true;
});

// Format the internal module ID to a usable named descriptor
compiler.plugin('compilation', function(compilation) {
compilation.plugin('before-module-ids', function(modules) {
modules.forEach(function(module) {
if(module.id === null && module.libIdent) {
module.id = module.libIdent({
context: this.options.context || compiler.options.context
});
module.id = normalizeModuleID(module.id)
}
}, this);
}.bind(this));
}.bind(this));
};
Loading

0 comments on commit 2826518

Please sign in to comment.