Skip to content

Commit

Permalink
Merge pull request #91 from jacobq/update-ember-cli
Browse files Browse the repository at this point in the history
Update ember-cli
  • Loading branch information
quaertym committed Jul 16, 2018
2 parents 680dc7d + 614de60 commit 8b6378a
Show file tree
Hide file tree
Showing 32 changed files with 2,886 additions and 2,056 deletions.
16 changes: 16 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/

# misc
/coverage/

# ember-try
/.node_modules.ember-try/
41 changes: 39 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,47 @@ module.exports = {
ecmaVersion: 6,
sourceType: 'module'
},
extends: 'eslint:recommended',
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
node: true
},
rules: {
}
},
overrides: [
// node files
{
files: [
'ember-cli-build.js',
'index.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'addon/**',
'addon-test-support/**',
'app/**',
'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
})
}
]
};
17 changes: 9 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/dist/
/tmp/

# dependencies
/node_modules
/bower_components/
/node_modules/
!tests/fixtures/**/node_modules
/bower_components

# misc
/.sass-cache
/connect.lock
/coverage/*
/coverage/
/libpeerconnection.log
npm-debug.log
testem.log
/npm-debug.log*
/testem.log
/yarn-error.log
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ vendor/
.bowerrc
.editorconfig
.ember-cli
.gitignore
.travis.yml
.npmignore
.watchmanconfig
**/.gitkeep
bower.json
ember-cli-build.js
testem.json
testem.js*
appveyor.yml
yarn.lock
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
language: node_js
node_js:
- "4"
- "6"
- "8"
- "9"
- "10"

sudo: false

Expand All @@ -14,12 +13,8 @@ cache:
matrix:
fast_finish: true

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

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

script:
- yarn test
7 changes: 3 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "9"
- nodejs_version: "10"

# Install scripts. (runs after repo cloning)
install:
- ps: Install-Product node $env:nodejs_version
- appveyor-retry yarn --no-lockfile --non-interactive

- appveyor-retry yarn --frozen-lockfile --non-interactive

cache:
- '%LOCALAPPDATA%\Yarn'
Expand All @@ -25,7 +24,7 @@ test_script:
# Output useful info for debugging.
- yarn --version
- git rev-parse HEAD
- cmd: yarn test
- yarn test

# Don't actually build.
build: off
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';

var Reporter = require('./lib/reporter');
var DependencyChecker = require('./lib/dependency-checker');
const Reporter = require('./lib/reporter');
const DependencyChecker = require('./lib/dependency-checker');

module.exports = {
name: 'ember-cli-dependency-checker',
init: function() {
this._super.init && this._super.init.apply(this, arguments);
var reporter = new Reporter();
var dependencyChecker = new DependencyChecker(this.project, reporter);

const reporter = new Reporter();
const dependencyChecker = new DependencyChecker(this.project, reporter);
dependencyChecker.checkDependencies();
}
};
78 changes: 39 additions & 39 deletions lib/dependency-checker.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use strict';

var path = require('path');
var resolve = require('resolve');
var fs = require('fs');
var findYarnWorkspaceRoot = require('find-yarn-workspace-root');
var readFile = fs.readFileSync;
var readDir = fs.readdirSync;
var fileExists = fs.existsSync;
var Package = require('./package');
var buildBowerPackagePath = require('./utils/build-bower-package-path');
var isTarGz = require('./utils/is-tar-gz');
var unknownVersion = require('./utils/unknown-version');

var alreadyChecked = false;
const path = require('path');
const resolve = require('resolve');
const fs = require('fs');
const findYarnWorkspaceRoot = require('find-yarn-workspace-root');
const readFile = fs.readFileSync;
const readDir = fs.readdirSync;
const fileExists = fs.existsSync;
const Package = require('./package');
const buildBowerPackagePath = require('./utils/build-bower-package-path');
const isTarGz = require('./utils/is-tar-gz');
const unknownVersion = require('./utils/unknown-version');

let alreadyChecked = false;

function isUnsatisfied(pkg) {
return !!pkg.needsUpdate;
Expand Down Expand Up @@ -40,18 +40,18 @@ EmberCLIDependencyChecker.prototype.checkDependencies = function() {
return;
}

var bowerDeps = this.readBowerDependencies();
const bowerDeps = this.readBowerDependencies();
this.reporter.unsatisifedPackages('bower', bowerDeps.filter(isUnsatisfied));

var npmDeps = this.readNPMDependencies();
var filteredDeps = npmDeps.filter(isUnsatisfied);
var unsatisfiedDeps = filteredDeps.filter(isNotSymlinked);
var symlinkedDeps = filteredDeps.filter(isSymlinked);
const npmDeps = this.readNPMDependencies();
const filteredDeps = npmDeps.filter(isUnsatisfied);
const unsatisfiedDeps = filteredDeps.filter(isNotSymlinked);
const symlinkedDeps = filteredDeps.filter(isSymlinked);

var yarnPath = path.join(this.project.root, 'yarn.lock');
var yarnWorkspacePath = findYarnWorkspaceRoot(this.project.root);
const yarnPath = path.join(this.project.root, 'yarn.lock');
const yarnWorkspacePath = findYarnWorkspaceRoot(this.project.root);

var packageManagerName = 'npm';
let packageManagerName = 'npm';
if (fileExists(yarnPath) || yarnWorkspacePath) {
packageManagerName = 'yarn';
}
Expand All @@ -60,7 +60,7 @@ EmberCLIDependencyChecker.prototype.checkDependencies = function() {
this.reporter.unsatisifedPackages(packageManagerName, unsatisfiedDeps);

if (unsatisfiedDeps.length === 0) {
var shrinkWrapDeps = this.readShrinkwrapDeps();
const shrinkWrapDeps = this.readShrinkwrapDeps();
this.reporter.unsatisifedPackages('npm-shrinkwrap', shrinkWrapDeps.filter(isUnsatisfied));
}

Expand All @@ -70,11 +70,11 @@ EmberCLIDependencyChecker.prototype.checkDependencies = function() {
};

EmberCLIDependencyChecker.prototype.readShrinkwrapDeps = function() {
var filePath = path.join(this.project.root, 'npm-shrinkwrap.json');
const filePath = path.join(this.project.root, 'npm-shrinkwrap.json');
if (fileExists(filePath)) {
var ShrinkWrapChecker = require('./shrinkwrap-checker');
var shrinkWrapBody = readFile(filePath);
var shrinkWrapJSON = {};
const ShrinkWrapChecker = require('./shrinkwrap-checker');
const shrinkWrapBody = readFile(filePath);
let shrinkWrapJSON = {};
try {
shrinkWrapJSON = JSON.parse(shrinkWrapBody);
} catch(e) {
Expand All @@ -88,22 +88,22 @@ EmberCLIDependencyChecker.prototype.readShrinkwrapDeps = function() {

EmberCLIDependencyChecker.prototype.lookupNodeModule = function(name, versionSpecified) {
try {
var nodePackage = resolve.sync(path.join(name, 'package.json'), { basedir: this.project.root });
var version = this.lookupPackageVersion(nodePackage, versionSpecified);
const nodePackage = resolve.sync(path.join(name, 'package.json'), { basedir: this.project.root });
const version = this.lookupPackageVersion(nodePackage, versionSpecified);
return { version: version, path: path.dirname(nodePackage) };
} catch(err) {
return { version: null, path: null };
}
};

EmberCLIDependencyChecker.prototype.lookupBowerPackageVersion = function(name) {
var packageDirectory = path.resolve(this.project.root, this.project.bowerDirectory, name);
var version = null;
const packageDirectory = path.resolve(this.project.root, this.project.bowerDirectory, name);
let version = null;
if (fileExists(packageDirectory) && readDir(packageDirectory).length > 0) {
var dotBowerFile = path.join(packageDirectory, '.bower.json');
const dotBowerFile = path.join(packageDirectory, '.bower.json');
version = this.lookupPackageVersion(dotBowerFile);
if (!version) {
var bowerFile = path.join(packageDirectory, 'bower.json');
const bowerFile = path.join(packageDirectory, 'bower.json');
version = this.lookupPackageVersion(bowerFile) || '*';
}
}
Expand All @@ -112,10 +112,10 @@ EmberCLIDependencyChecker.prototype.lookupBowerPackageVersion = function(name) {

EmberCLIDependencyChecker.prototype.lookupPackageVersion = function(path, versionSpecified) {
if (fileExists(path)) {
var pkg = readFile(path);
var version = null;
const pkg = readFile(path);
let version = null;
try {
var pkgContent = JSON.parse(pkg);
const pkgContent = JSON.parse(pkg);
version = pkgContent.version || null;
if (isTarGz(versionSpecified)) {
version = pkgContent._from || unknownVersion;
Expand All @@ -139,16 +139,16 @@ EmberCLIDependencyChecker.prototype.readNPMDependencies = function() {

EmberCLIDependencyChecker.prototype.readDependencies = function(dependencies, type) {
return Object.keys(dependencies).map(function(name) {
var versionSpecified = dependencies[name];
const versionSpecified = dependencies[name];
if (type === 'npm') {
var result = this.lookupNodeModule(name, versionSpecified);
const result = this.lookupNodeModule(name, versionSpecified);
return new Package(name, versionSpecified, result.version, result.path);
} else {
var versionInstalled = this.lookupBowerPackageVersion(name);
let versionInstalled = this.lookupBowerPackageVersion(name);
if (isTarGz(versionSpecified)) {
versionInstalled = unknownVersion;
}
var path = buildBowerPackagePath(this.project, name);
const path = buildBowerPackagePath(this.project, name);
return new Package(name, versionSpecified, versionInstalled, path);
}
}, this);
Expand Down
8 changes: 4 additions & 4 deletions lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ Package.prototype.init = function(name, versionSpecified, versionInstalled, path
this.path = path;
this.versionSpecified = versionSpecified;
this.versionInstalled = versionInstalled;

try {
this.needsUpdate = this.updateRequired();
this.isSymlinked = this.symlinked();
} catch(e) {
var versionText = '(version specified: ' + versionSpecified + ', version installed: ' + versionInstalled + '): ';
const versionText = '(version specified: ' + versionSpecified + ', version installed: ' + versionInstalled + '): ';
e.message = 'Failed processing module "' + name + '" ' + versionText + e.message;
throw e;
}
};

Package.prototype.updateRequired = function() {
var VersionChecker = require('./version-checker');
const VersionChecker = require('./version-checker');
return !VersionChecker.satisfies(this.versionSpecified, this.versionInstalled);
};

Package.prototype.symlinked = function() {
var isSymlink = require('./utils/is-symlink');
const isSymlink = require('./utils/is-symlink');
return isSymlink(this.path);
};

Expand Down

0 comments on commit 8b6378a

Please sign in to comment.