Skip to content

Commit

Permalink
This adds the ability of generating addons using the module unificati…
Browse files Browse the repository at this point in the history
…on layout.

MODULE_UNIFICATION=true ember addon my-addon
MODULE_UNIFICATION=true ember addon my-addon --yarn
  • Loading branch information
cibernox committed Mar 6, 2018
1 parent 15f86e1 commit e0f4ce5
Show file tree
Hide file tree
Showing 64 changed files with 975 additions and 5 deletions.
3 changes: 1 addition & 2 deletions blueprints/addon/index.js
Expand Up @@ -37,7 +37,7 @@ module.exports = {
let contents = JSON.parse(content);

contents.name = this.locals(this.options).addonName;
contents.description = description;
contents.description = this.description;
delete contents.private;
contents.scripts = contents.scripts || {};
contents.keywords = contents.keywords || [];
Expand Down Expand Up @@ -139,7 +139,6 @@ module.exports = {

files() {
let appFiles = this.lookupBlueprint('app').files();

let addonFilesPath = this.filesPath(this.options);
let addonFiles = walkSync(addonFilesPath);

Expand Down
20 changes: 20 additions & 0 deletions blueprints/module-unification-addon/files/.editorconfig
@@ -0,0 +1,20 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false

[*.{diff,md}]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions blueprints/module-unification-addon/files/.ember-cli
@@ -0,0 +1,9 @@
{
/**
Ember CLI sends analytics information by default. The data is completely
anonymous, but there are times when you might want to disable this behavior.

Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": false
}
47 changes: 47 additions & 0 deletions blueprints/module-unification-addon/files/.eslintrc.js
@@ -0,0 +1,47 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
browser: true
},
rules: {
},
overrides: [
// node files
{
files: [
'index.js',
'testem.js',
'ember-cli-build.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'src/**',
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
}
]
};
47 changes: 47 additions & 0 deletions blueprints/module-unification-addon/files/.travis.yml
@@ -0,0 +1,47 @@
---
language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "4"

sudo: false
dist: trusty

addons:
chrome: stable

cache:
directories:
- $HOME/.npm

env:
global:
# See https://git.io/vdao3 for details.
- JOBS=1
matrix:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-lts-2.16
- EMBER_TRY_SCENARIO=ember-lts-2.18
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
- npm config set spin false
- npm install -g npm@4
- npm --version

script:
- npm run lint:js
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
9 changes: 9 additions & 0 deletions blueprints/module-unification-addon/files/LICENSE.md
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) <%= year %>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50 changes: 50 additions & 0 deletions blueprints/module-unification-addon/files/README.md
@@ -0,0 +1,50 @@
<%= addonName %>
==============================================================================

[Short description of the addon.]

Installation
------------------------------------------------------------------------------

```
ember install <%= addonName %>
```


Usage
------------------------------------------------------------------------------

[Longer description of how to use the addon in apps.]


Contributing
------------------------------------------------------------------------------

### Installation

* `git clone <repository-url>`
* `cd <%= addonName %>`
* `<% if (yarn) { %>yarn<% } else { %>npm<% } %> install`

### Linting

* `<% if (yarn) { %>yarn lint:js<% } else { %>npm run lint:js<% } %>`
* `<% if (yarn) { %>yarn lint:js --fix<% } else { %>npm run lint:js -- --fix<% } %>`

### Running tests

* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `ember try:each` – Runs the test suite against multiple Ember versions

### Running the dummy application

* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).

License
------------------------------------------------------------------------------

This project is licensed under the [MIT License](LICENSE.md).
@@ -0,0 +1,71 @@
'use strict';

const getChannelURL = require('ember-source-channel-url');

module.exports = function() {
return Promise.all([
getChannelURL('release'),
getChannelURL('beta'),
getChannelURL('canary'),
]).then((urls) => {
return {
<% if (yarn) { %>useYarn: true,
<% } %>scenarios: [
{
name: 'ember-lts-2.12',
npm: {
devDependencies: {
'ember-source': '~2.12.0'
}
}
},
{
name: 'ember-lts-2.16',
npm: {
devDependencies: {
'ember-source': '~2.16.0'
}
}
},
{
name: 'ember-lts-2.18',
npm: {
devDependencies: {
'ember-source': '~2.18.0'
}
}
},
{
name: 'ember-release',
npm: {
devDependencies: {
'ember-source': urls[0]
}
}
},
{
name: 'ember-beta',
npm: {
devDependencies: {
'ember-source': urls[1]
}
}
},
{
name: 'ember-canary',
npm: {
devDependencies: {
'ember-source': urls[2]
}
}
},
{
name: 'ember-default',
npm: {
devDependencies: {}
}
}
]
};
});
};
@@ -0,0 +1,5 @@
'use strict';

module.exports = function(/* environment, appConfig */) {
return { };
};
18 changes: 18 additions & 0 deletions blueprints/module-unification-addon/files/ember-cli-build.js
@@ -0,0 +1,18 @@
'use strict';

const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function (defaults) {
let app = new EmberAddon(defaults, {
// Add options here
});

/*
This build file specifies the options for the dummy test app of this
addon, located in `/tests/dummy`
This build file does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's build file
*/

return app.toTree();
};
5 changes: 5 additions & 0 deletions blueprints/module-unification-addon/files/index.js
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
name: '<%= addonName %>'
};
21 changes: 21 additions & 0 deletions blueprints/module-unification-addon/files/npmignore
@@ -0,0 +1,21 @@
/bower_components
/config/ember-try.js
/dist
/tests
/tmp
**/.gitkeep
.bowerrc
.editorconfig
.ember-cli
.eslintrc.js
.gitignore
.watchmanconfig
.travis.yml
bower.json
ember-cli-build.js
testem.js

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
Empty file.
Empty file.
33 changes: 33 additions & 0 deletions blueprints/module-unification-addon/files/tests/index.html
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Dummy Tests</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

{{content-for "head"}}
{{content-for "test-head"}}

<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">

{{content-for "head-footer"}}
{{content-for "test-head-footer"}}
</head>
<body>
{{content-for "body"}}
{{content-for "test-body"}}

<script src="/testem.js" integrity=""></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
<script src="{{rootURL}}assets/tests.js"></script>

{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
</body>
</html>
@@ -0,0 +1,8 @@
import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';

setApplication(Application.create(config.APP));

start();
Empty file.
6 changes: 6 additions & 0 deletions blueprints/module-unification-addon/index.js
@@ -0,0 +1,6 @@
'use strict';
const addonBlueprint = require('../addon');

module.exports = Object.assign({}, addonBlueprint, {
description: 'Generates an Ember addon with a module unification layout.',
});
8 changes: 6 additions & 2 deletions lib/commands/new.js
Expand Up @@ -37,8 +37,12 @@ module.exports = Command.extend({
beforeRun: mergeBlueprintOptions,

run(commandOptions, rawArgs) {
if (process.env.MODULE_UNIFICATION === 'true' && commandOptions.blueprint === 'app') {
commandOptions.blueprint = 'module-unification-app';
if (process.env.MODULE_UNIFICATION === 'true') {
if (commandOptions.blueprint === 'app') {
commandOptions.blueprint = 'module-unification-app';
} else if (commandOptions.blueprint === 'addon') {
commandOptions.blueprint = 'module-unification-addon';
}
}

let packageName = rawArgs[0],
Expand Down

0 comments on commit e0f4ce5

Please sign in to comment.