Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidated updates #51

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 143 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Default values
defaults: &defaults
docker:
- image: circleci/node:6-browsers
working_directory: ~/ember-cli-react
- image: circleci/node:10-browsers
working_directory: ~/ember-cli-react-fork

version: 2
jobs:
Expand All @@ -20,17 +20,17 @@ jobs:
- checkout
# Download and cache dependencies
- restore_cache:
name: Restore Yarn Package Cache
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Install Packages
command: npm install
command: yarn install --frozen-lockfile
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- ~/.cache/yarn
- persist_to_workspace:
root: .
paths:
Expand Down Expand Up @@ -126,6 +126,105 @@ jobs:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-3.2 --skip-cleanup=true

test_lts_3_4:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-lts-3.4 --skip-cleanup=true

test_3_6:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-3.6 --skip-cleanup=true

test_lts_3_8:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-lts-3.8 --skip-cleanup=true

test_lts_3_12:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-lts-3.12 --skip-cleanup=true

test_3_13:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-3.13 --skip-cleanup=true

test_3_14:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-3.14 --skip-cleanup=true

test_3_15:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-3.15 --skip-cleanup=true

test_lts_3_16:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-lts-3.16 --skip-cleanup=true

test_lts_3_20:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-lts-3.20 --skip-cleanup=true

test_lts_3_24:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-lts-3.24 --skip-cleanup=true

test_lts_3_28:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-lts-3.28 --skip-cleanup=true

test_release:
<<: *defaults
steps:
Expand All @@ -135,7 +234,6 @@ jobs:
name: Run Tests
command: ./node_modules/.bin/ember try:one ember-release --skip-cleanup=true


test_beta:
<<: *defaults
steps:
Expand Down Expand Up @@ -189,12 +287,45 @@ workflows:
- test_3_2:
requires:
- setup_environment
- test_release:
- test_lts_3_4:
requires:
- setup_environment
- test_3_6:
requires:
- setup_environment
- test_lts_3_8:
requires:
- setup_environment
- test_lts_3_12:
requires:
- setup_environment
- test_3_13:
requires:
- setup_environment
- test_3_14:
requires:
- setup_environment
- test_3_15:
requires:
- setup_environment
- test_lts_3_16:
requires:
- setup_environment
- test_lts_3_20:
requires:
- setup_environment
- test_beta:
- test_lts_3_24:
requires:
- setup_environment
- test_canary:
- test_lts_3_28:
requires:
- setup_environment
- test_release:
requires:
- setup_environment
# - test_beta:
# requires:
# - setup_environment
# - test_canary:
# requires:
# - setup_environment
34 changes: 32 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 8,
ecmaFeatures: {
jsx: true,
},
sourceType: 'module',
},
extends: ['eslint:recommended', 'prettier'],
plugins: ['react', 'prettier'],
plugins: ['ember', 'react', 'prettier'],
extends: ['eslint:recommended', 'plugin:ember/recommended', 'prettier'],
env: {
es6: true,
node: true,
Expand All @@ -21,4 +22,33 @@ module.exports = {

'react/jsx-uses-vars': 'error',
},
overrides: [
// node files
{
files: [
'index.js',
'testem.js',
'ember-cli-build.js',
'config/**/*.js',
'tests/dummy/config/**/*.js',
],
excludedFiles: ['app/**', 'addon/**', '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
}
),
},
],
};
7 changes: 6 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
.bowerrc
.editorconfig
.ember-cli
.gitignore
.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
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
## [Unreleased]

## [2.0.1] - 2021-09-11

- Try importing Ember internals one by one instead of using hardcoded version number.

## [2.0.0] - 2021-09-09

- **Breaking change:** bump minimum NodeJS to v10
- **Breaking change:** replace `broccoli-react` with `broccoli-babel-transpiler` [#50](https://github.com/AltSchool/ember-cli-react/pull/50)
- **Breaking change:** rename npm package to `ember-cli-react-fork`
- Support React v17 as peer dependency

## [1.0.4] - 2018-12-10

- Switch back to yarn for now

## [1.0.3] - 2019-12-10

- Support Ember 3.6 [#48](https://github.com/AltSchool/ember-cli-react/pull/48)

## [1.0.2] - 2018-10-08

- Support React v16 as peer dependency [#41](https://github.com/AltSchool/ember-cli-react/pull/41)
Expand Down
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
**Experimental Addon**
**Note:** This is a fork of https://github.com/AltSchool/ember-cli-react due to its inactivity.
It uses the same addon name so it is almost a drop-in replacement.

This was built as a prototype to evaluate using React inside of our Ember apps.
We are not yet using it in production. PRs and constructive questions and
comments via [GitHub
issues](https://github.com/AltSchool/ember-cli-react/issues/new) are highly
encouraged.
# ember-cli-react-fork

# ember-cli-react

[![Circle CI](https://circleci.com/gh/AltSchool/ember-cli-react.svg?style=shield)](https://circleci.com/gh/AltSchool/ember-cli-react)
[![Circle CI](https://circleci.com/gh/pswai/ember-cli-react-fork.svg?style=shield)](https://circleci.com/gh/pswai/ember-cli-react-fork)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Use clean React component hierarchies inside your Ember app.
Expand All @@ -18,13 +13,9 @@ Use clean React component hierarchies inside your Ember app.
Install the addon in your app:

```
ember install ember-cli-react
```

If you prefer npm/yarn install (the following is similar with above):

```
yarn add --dev ember-cli-react
yarn add --dev ember-cli-react-fork
# OR
npm i -D ember-cli-react-fork

# This triggers addon blueprint to do necessary setup
ember generate ember-cli-react
Expand Down
16 changes: 9 additions & 7 deletions addon/components/react-component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import Ember from 'ember';
import { classify } from '@ember/string';
import { typeOf } from '@ember/utils';
import { reads } from '@ember/object/computed';
import Component from '@ember/component';
import { get } from '@ember/object';
import React from 'react';
import ReactDOM from 'react-dom';
import YieldWrapper from './react-component/yield-wrapper';
Expand All @@ -7,17 +11,15 @@ import getMutableAttributes from 'ember-cli-react/utils/get-mutable-attributes';
import hasBlock from 'ember-cli-react/utils/has-block';
import lookupFactory from 'ember-cli-react/utils/lookup-factory';

const { get } = Ember;

const ReactComponent = Ember.Component.extend({
const ReactComponent = Component.extend({
/**
The React component that this Ember component should wrap.

@property reactComponent
@type React.Component | Function | String
@default null
*/
reactComponent: Ember.computed.reads('_reactComponent'),
reactComponent: reads('_reactComponent'),

didRender: function() {
this.renderReactComponent();
Expand All @@ -27,14 +29,14 @@ const ReactComponent = Ember.Component.extend({
const componentClassOrName = get(this, 'reactComponent');
let componentClass;

if (Ember.typeOf(componentClassOrName) === 'string') {
if (typeOf(componentClassOrName) === 'string') {
componentClass = lookupFactory(
this,
`react-component:${componentClassOrName}`
);

// Set `displayName` so that it is visible in React devtools
componentClass.displayName = Ember.String.classify(componentClassOrName);
componentClass.displayName = classify(componentClassOrName);
} else {
componentClass = componentClassOrName;
}
Expand Down
7 changes: 3 additions & 4 deletions addon/resolver.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Ember from 'ember';
import { classify } from '@ember/string';
import { get } from '@ember/object';
import Resolver from 'ember-resolver';

import ReactComponent from 'ember-cli-react/components/react-component';

const { get } = Ember;

export default Resolver.extend({
// `resolveComponent` is triggered when rendering a component in template.
// For example, having `{{foo-bar}}` in a template will trigger `resolveComponent`
Expand Down Expand Up @@ -51,7 +50,7 @@ export default Resolver.extend({

// Convert the compnent name while preserving namespaces
const parts = originalName.split('/');
parts[parts.length - 1] = Ember.String.classify(parts[parts.length - 1]);
parts[parts.length - 1] = classify(parts[parts.length - 1]);
const newName = parts.join('/');

const parsedNameWithPascalCase = Object.assign({}, parsedName, {
Expand Down
Loading