Skip to content

Commit

Permalink
octane migration
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelcobain committed Oct 3, 2020
1 parent 51e90fa commit 0fd43ef
Show file tree
Hide file tree
Showing 37 changed files with 16,315 additions and 9,927 deletions.
10 changes: 7 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
},
plugins: [
'ember'
Expand All @@ -15,6 +19,7 @@ module.exports = {
browser: true
},
rules: {
'ember/no-jquery': 'error'
},
overrides: [
// node files
Expand All @@ -37,8 +42,7 @@ module.exports = {
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
sourceType: 'script'
},
env: {
browser: false,
Expand Down
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
# misc
/.bowerrc
/.editorconfig
/.ember-cli
/.ember-cli.js
/.env*
/.eslintignore
/.eslintrc.js
/.git/
/.gitignore
/.template-lintrc.js
/.travis.yml
Expand Down
26 changes: 7 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ addons:
chrome: stable

cache:
yarn: true
directories:
- $HOME/.npm

env:
global:
Expand All @@ -35,33 +36,20 @@ jobs:

- stage: "Tests"
name: "Tests"
install:
- yarn install --non-interactive
script:
- yarn lint:hbs
- yarn lint:js
- yarn test

- name: "Floating Dependencies"
script:
- yarn test
- npm run lint:hbs
- npm run lint:js
- npm test

# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- stage: "Additional Tests"
- env: EMBER_TRY_SCENARIO=ember-lts-2.18
- env: EMBER_TRY_SCENARIO=ember-lts-3.4
env: EMBER_TRY_SCENARIO=ember-lts-3.4
- env: EMBER_TRY_SCENARIO=ember-lts-3.8
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH

install:
- yarn install --no-lockfile --non-interactive

script:
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
1 change: 1 addition & 0 deletions addon/components/node.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{yield (component "node" parent=this)}}
100 changes: 100 additions & 0 deletions addon/components/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import Component from '@glimmer/component';

export default class Node extends Component {
children = new Set();
_didSetup = false;

constructor() {
super(...arguments);

if (this.args.parent) {
// register with parent
this.args.parent.registerChild(this);
}
}

willDestroy() {
super.willDestroy(...arguments);

if (this.args.parent) {
this.args.parent.unregisterChild(this);
}
// this hook will be called depth-first from the top-level component
// since we must destroy childs first, the first parent will
// be responsible for destroying the children. `this._didSetup` guards
// that we don't redestroy already destroyed children
if (this._didSetup) {
this.children.forEach(c => c.willDestroyNode());
this.teardown();
this._didSetup = false;
}
}

/**
* Method invoked by the child components to register themselves with their parent
* @param {Component} child
*/
registerChild(child) {
this.children.add(child);

if (this._didSetup) {
child.setup();
}
}

/**
* Method invoked by the child components to unregister themselves with their parent
* @param {Component} child
*/
unregisterChild(child) {
this.children.delete(child);
}

/**
* method responsible for setting up itself plus its children
* it is called by the root initially and recursively to its children
* @param {HTMLElement} element the root element
*/
didInsertNode(element) {
this.setup(element);

this.children.forEach(c => c.didInsertNode(element));
}

/**
* method responsible for tearing down its children plus itself
* it is called by the root initially and recursively to its children
* @param {HTMLElement} element the root element
*/
willDestroyNode(element) {
this.children.forEach(c => c.willDestroyNode(element));

this.teardown(element);
}

/**
* The actualy setup logic
* @param {HTMLElement} element
*/
setup(element) {
// library setup code goes here
if (typeof this.args.didInsertParent === 'function') {
this.args.didInsertParent(element);
}

this._didSetup = true;
}

/**
* The actualy teardown logic
* @param {HTMLElement} element
*/
teardown(element) {
// library teardown code goes here
if (typeof this.args.willDestroyParent === 'function') {
this.args.willDestroyParent(element);
}

this._didSetup = false;
}
}
7 changes: 7 additions & 0 deletions addon/components/root.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div
{{did-insert (action this.didInsertNode)}}
{{will-destroy (action this.willDestroyNode)}}
...attributes
>
{{yield (component "node" parent=this)}}
</div>
4 changes: 4 additions & 0 deletions addon/components/root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Node from './node';

export default class Root extends Node {
}
3 changes: 0 additions & 3 deletions addon/index.js

This file was deleted.

75 changes: 0 additions & 75 deletions addon/mixins/child.js

This file was deleted.

91 changes: 0 additions & 91 deletions addon/mixins/parent.js

This file was deleted.

Loading

0 comments on commit 0fd43ef

Please sign in to comment.