Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Oct 2, 2018
2 parents eeac6b1 + 0dd0c0e commit 2805962
Show file tree
Hide file tree
Showing 22 changed files with 213 additions and 56 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ jobs:
- env: EMBER_CLI_PACKAGER=true
- env: EMBER_CLI_MODULE_UNIFICATION=true
- env: EMBER_CLI_DELAYED_TRANSPILATION=true
- env: EMBER_CLI_BROCCOLI_2=true
- env:
- EMBER_CLI_SYSTEM_TEMP=true
- EMBER_CLI_BROCCOLI_2=true
- env: EMBER_CLI_BROCCOLI_2=false
- env: EMBER_CLI_SYSTEM_TEMP=false

- stage: deploy
script: ./.travis/deploy.sh
Expand Down
2 changes: 1 addition & 1 deletion blueprints/app/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"ember-cli-htmlbars": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-qunit": "^4.3.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-template-lint": "^1.0.0-beta.1",
"ember-cli-uglify": "^2.1.0",
"ember-data": "~3.5.0-beta.1",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^3.4.1",
"ember-resolver": "^5.0.1",
"ember-source": "~3.5.0-beta.1<% if (welcome) { %>",
"ember-welcome-page": "^3.2.0<% } %>",
Expand Down
2 changes: 1 addition & 1 deletion blueprints/module-unification-app/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"ember-cli-htmlbars": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-qunit": "^4.3.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-template-lint": "^1.0.0-beta.1",
"ember-cli-uglify": "^2.1.0",
"ember-data": "~3.5.0-beta.1",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^3.4.1",
"ember-resolver": "^5.0.1",
"ember-source": "https://s3.amazonaws.com/builds.emberjs.com/canary/shas/caa2c70d40dbfeffb0e6c9ac15ff6d72c8e24bae.tgz<% if (welcome) { %>",
"ember-welcome-page": "^3.2.0<% } %>",
Expand Down
23 changes: 17 additions & 6 deletions lib/experiments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

const CliError = require('../errors/cli');

const availableExperiments = [
const availableExperiments = Object.freeze([
'PACKAGER',
'MODULE_UNIFICATION',
'DELAYED_TRANSPILATION',
'BROCCOLI_2',
'SYSTEM_TEMP',
];
]);

const enabledExperiments = Object.freeze([
'BROCCOLI_2',
]);

function isExperimentEnabled(experimentName) {
if (availableExperiments.indexOf(experimentName) < 0) {
if (!availableExperiments.includes(experimentName)) {
return false;
}

Expand All @@ -20,11 +24,18 @@ function isExperimentEnabled(experimentName) {
}

let experimentEnvironmentVariable = `EMBER_CLI_${experimentName}`;
if (process.env[experimentEnvironmentVariable]) {
let experimentValue = process.env[experimentEnvironmentVariable];
if (enabledExperiments.includes(experimentName)) {
return experimentValue !== 'false';
} else if (
experimentName === 'SYSTEM_TEMP' &&
experimentValue === undefined &&
isExperimentEnabled('BROCCOLI_2')
) {
return true;
} else {
return experimentValue !== undefined && experimentValue !== 'false';
}

return false;
}

// SYSTEM_TEMP can only be used with BROCCOLI_2
Expand Down
21 changes: 16 additions & 5 deletions lib/models/blueprint.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const EOL = require('os').EOL;
const bowEpParser = require('bower-endpoint-parser');
const logger = require('heimdalljs-logger')('ember-cli:blueprint');
const normalizeEntityName = require('ember-cli-normalize-entity-name');
const isAddon = require('../utilities/is-addon');

const Promise = RSVP.Promise;
const stat = RSVP.denodeify(fs.stat);
Expand Down Expand Up @@ -400,9 +401,7 @@ let Blueprint = CoreObject.extend({
}

if (options.in) {
addon = findAddonByPath(this.project, options.in);

if (!addon) {
if (!ensureTargetDirIsAddon(options.in)) {
throw new SilentError(`You specified the 'in' flag, but the ` +
`in repo addon '${options.in}' does not exist. Please check the name and try again.`);
}
Expand Down Expand Up @@ -1513,8 +1512,20 @@ function findAddonByName(addonOrProject, name) {
return addonOrProject.addons.find(addon => findAddonByName(addon, name));
}

function findAddonByPath(project, addonPath) {
return project.addons.find(addon => addon.root === addonPath);
function ensureTargetDirIsAddon(addonPath) {
let projectInfo;

try {
projectInfo = require(path.join(addonPath, 'package.json'));
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
throw new Error(`The directory ${addonPath} does not appear to be a valid addon directory.`);
} else {
throw err;
}
}

return isAddon(projectInfo.keywords);
}

/**
Expand Down
22 changes: 11 additions & 11 deletions lib/models/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class Builder extends CoreObject {
constructor(options) {
super(options);

this.broccoli2 = isExperimentEnabled('BROCCOLI_2');
this.systemTemp = isExperimentEnabled('SYSTEM_TEMP');

this.setupBroccoliBuilder();

this._instantiationStack = (new Error()).stack.replace(/[^\n]*\n/, '');
Expand All @@ -50,12 +47,12 @@ class Builder extends CoreObject {
process.env.EMBER_ENV = process.env.EMBER_ENV || this.environment;

let broccoli, options = {};
if (this.broccoli2) {
if (isExperimentEnabled('BROCCOLI_2')) {
broccoli = require('broccoli');
let tmpDir;

// If not using system temp dir, compatability mode with broccoli-builder, tmp in root
if (!this.systemTemp) {
if (!isExperimentEnabled('SYSTEM_TEMP')) {
tmpDir = `${this.project.root}/tmp`;
if (!fs.existsSync(tmpDir)) {
fs.mkdir(tmpDir);
Expand All @@ -66,7 +63,7 @@ class Builder extends CoreObject {
};
} else {
broccoli = require('broccoli-builder');
if (this.systemTemp) {
if (isExperimentEnabled('SYSTEM_TEMP')) {
console.warn('EMBER_CLI_SYSTEM_TEMP only works in combination with EMBER_CLI_BROCCOLI_2');
}
}
Expand Down Expand Up @@ -173,18 +170,18 @@ class Builder extends CoreObject {
build(addWatchDirCallback, resultAnnotation) {
this.project._instrumentation.start('build');

if (!this.systemTemp) {
if (!isExperimentEnabled('SYSTEM_TEMP')) {
attemptNeverIndex('tmp');
}

if (addWatchDirCallback && this.broccoli2) {
if (addWatchDirCallback && isExperimentEnabled('BROCCOLI_2')) {
for (let path of this.builder.watchedPaths) {
addWatchDirCallback(path);
}
}

return this.processAddonBuildSteps('preBuild')
.then(() => this.builder.build(this.broccoli2 ? null : addWatchDirCallback))
.then(() => this.builder.build(isExperimentEnabled('BROCCOLI_2') ? null : addWatchDirCallback))
.then(this.compatNode.bind(this), this.compatBroccoliPayload.bind(this))
.then(this.processAddonBuildSteps.bind(this, 'postBuild'))
.then(this.processBuildResult.bind(this))
Expand Down Expand Up @@ -271,7 +268,7 @@ class Builder extends CoreObject {
* @param node The node returned from Broccoli builder
*/
compatNode(node) {
if (this.broccoli2) {
if (isExperimentEnabled('BROCCOLI_2')) {
return {
directory: this.builder.outputPath,
graph: this.builder.outputNodeWrapper,
Expand Down Expand Up @@ -304,7 +301,10 @@ class Builder extends CoreObject {
};
}
if (!broccoliPayload.versions) {
let builderVersion = this.broccoli2 ? require('broccoli/package').version : require('broccoli-builder/package').version;
let builderVersion = isExperimentEnabled('BROCCOLI_2')
? require('broccoli/package').version
: require('broccoli-builder/package').version;

broccoliPayload.versions = {
'broccoli-builder': builderVersion,
node: process.version,
Expand Down
6 changes: 2 additions & 4 deletions lib/models/package-info-cache/package-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require('path');
const ErrorList = require('./error-list');
const Errors = require('./errors');
const AddonInfo = require('../addon-info');
const isAddon = require('../../utilities/is-addon');

function lexicographically(a, b) {
const aIsString = typeof a.name === 'string';
Expand Down Expand Up @@ -218,10 +219,7 @@ class PackageInfo {
}

isAddon() {
let val =
Array.isArray(this.pkg.keywords) &&
this.pkg.keywords.indexOf('ember-addon') >= 0;
return val;
return isAddon(this.pkg.keywords);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/models/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ class Project {
Generate test file contents.
This method is supposed to be overwritten by test framework addons
like `ember-cli-qunit` and `ember-cli-mocha`.
like `ember-qunit` and `ember-mocha`.
@public
@method generateTestFile
Expand Down
6 changes: 6 additions & 0 deletions lib/utilities/is-addon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

module.exports = function isAddon(keywords) {
return Array.isArray(keywords) &&
keywords.indexOf('ember-addon') >= 0;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"babel-plugin-transform-es2015-modules-amd": "^6.24.1",
"bower-config": "^1.3.0",
"bower-endpoint-parser": "0.2.2",
"broccoli": "^2.0.0-beta.3",
"broccoli": "^2.0.0",
"broccoli-amd-funnel": "^2.0.1",
"broccoli-babel-transpiler": "^6.5.0",
"broccoli-builder": "^0.18.14",
Expand Down
26 changes: 26 additions & 0 deletions tests/acceptance/in-option-generate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ describe('Acceptance: ember generate with --in option', function() {
return remove(tmproot);
});

function removeAddonPath() {
let packageJsonPath = path.join(process.cwd(), 'package.json');
let packageJson = fs.readJsonSync(packageJsonPath);

delete packageJson['ember-addon'].paths;

return fs.writeJsonSync(packageJsonPath, packageJson);
}

it('generate blueprint foo using lib', function() {
// build an app with an in-repo addon in a non-standard path
return initApp()
Expand Down Expand Up @@ -94,4 +103,21 @@ describe('Acceptance: ember generate with --in option', function() {
})
);
});

it('generate blueprint foo using sibling path', function() {
// build an app with an in-repo addon in a non-standard path
return initApp()
.then(() => fs.mkdirp('../sibling'))
.then(() => generateUtils.inRepoAddon('../sibling'))
// we want to ensure the project has no awareness of the in-repo addon via `ember-addon.paths`, so we remove it
.then(removeAddonPath)
// generate in project blueprint to allow easier testing of in-repo generation
.then(() => generateUtils.tempBlueprint())
// confirm that we can generate into the non-lib path
.then(() =>
ember(['generate', 'foo', 'bar', '--in=../sibling']).then(function() {
expect(file('../sibling/addon/foos/bar.js')).to.exist;
})
);
});
});
2 changes: 1 addition & 1 deletion tests/fixtures/addon/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
"ember-cli-htmlbars": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-qunit": "^4.3.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-template-lint": "^1.0.0-beta.1",
"ember-cli-uglify": "^2.1.0",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^3.4.1",
"ember-resolver": "^5.0.1",
"ember-source": "~3.5.0-beta.1",
"ember-source-channel-url": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/addon/yarn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
"ember-cli-htmlbars": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-qunit": "^4.3.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-template-lint": "^1.0.0-beta.1",
"ember-cli-uglify": "^2.1.0",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^3.4.1",
"ember-resolver": "^5.0.1",
"ember-source": "~3.5.0-beta.1",
"ember-source-channel-url": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/app/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"ember-cli-htmlbars": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-qunit": "^4.3.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-template-lint": "^1.0.0-beta.1",
"ember-cli-uglify": "^2.1.0",
"ember-data": "~3.5.0-beta.1",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^3.4.1",
"ember-resolver": "^5.0.1",
"ember-source": "~3.5.0-beta.1",
"eslint-plugin-ember": "^5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/app/yarn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"ember-cli-htmlbars": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-qunit": "^4.3.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-template-lint": "^1.0.0-beta.1",
"ember-cli-uglify": "^2.1.0",
"ember-data": "~3.5.0-beta.1",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^3.4.1",
"ember-resolver": "^5.0.1",
"ember-source": "~3.5.0-beta.1",
"ember-welcome-page": "^3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/module-unification-addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
"ember-cli-htmlbars": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.0",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-qunit": "^4.1.1",
"ember-cli-sri": "^2.1.0",
"ember-cli-template-lint": "^1.0.0-beta.1",
"ember-cli-uglify": "^2.0.0",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^3.4.1",
"ember-resolver": "^5.0.1",
"ember-source": "https://s3.amazonaws.com/builds.emberjs.com/canary/shas/caa2c70d40dbfeffb0e6c9ac15ff6d72c8e24bae.tgz",
"ember-source-channel-url": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/module-unification-app/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"ember-cli-htmlbars": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
"ember-cli-inject-live-reload": "^1.8.2",
"ember-cli-qunit": "^4.3.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-template-lint": "^1.0.0-beta.1",
"ember-cli-uglify": "^2.1.0",
"ember-data": "~3.5.0-beta.1",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^3.4.1",
"ember-resolver": "^5.0.1",
"ember-source": "https://s3.amazonaws.com/builds.emberjs.com/canary/shas/caa2c70d40dbfeffb0e6c9ac15ff6d72c8e24bae.tgz",
"eslint-plugin-ember": "^5.2.0",
Expand Down

0 comments on commit 2805962

Please sign in to comment.