Skip to content

Commit

Permalink
chore: eliminate usage of Store in DefaultRecordData (emberjs#6162)
Browse files Browse the repository at this point in the history
Also runs prettier --fix for the new printWidth: 120 config
  • Loading branch information
runspired authored Jul 10, 2019
1 parent f37a767 commit 5dfc12f
Show file tree
Hide file tree
Showing 126 changed files with 2,707 additions and 6,138 deletions.
6 changes: 1 addition & 5 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module.exports = {
timeout: 5000,
reporter: 'spec',
spec: [
'node-tests/blueprints/**/*-test.js',
'node-tests/acceptance/**/*-test.js',
'node-tests/unit/**/*-test.js',
],
spec: ['node-tests/blueprints/**/*-test.js', 'node-tests/acceptance/**/*-test.js', 'node-tests/unit/**/*-test.js'],
};
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
singleQuote: true
trailingComma: 'es5'
printWidth: 120
7 changes: 0 additions & 7 deletions .prettierrc.js

This file was deleted.

7 changes: 2 additions & 5 deletions bin/packages-for-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,8 @@ console.log(
chalk.yellow(`The following packages have been generated:\n\r\t✅ `) +
chalk.grey(availablePackages.join('\n\r\t✅ ')) +
'\n\r\n\r' +
chalk.yellow(
`The tarballs for these packages are available within ${chalk.white(tarballDir)}\n\r\n\r`
) +
(!TarballConfig.options.referenceViaVersion &&
TarballConfig.options.hostPath.indexOf('file:') === 0
chalk.yellow(`The tarballs for these packages are available within ${chalk.white(tarballDir)}\n\r\n\r`) +
(!TarballConfig.options.referenceViaVersion && TarballConfig.options.hostPath.indexOf('file:') === 0
? chalk.red('⚠️ They may only be used on this machine.')
: chalk.yellow(
`⚠️ They can be hosted ${
Expand Down
16 changes: 4 additions & 12 deletions bin/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ const packagesDir = path.join(projectRoot, './packages');
const packages = fs.readdirSync(packagesDir);

function cleanProject() {
execWithLog(
`cd ${projectRoot} && rm -rf packages/*/dist packages/*/tmp packages/*/node_modules node_modules`
);
execWithLog(`cd ${projectRoot} && rm -rf packages/*/dist packages/*/tmp packages/*/node_modules node_modules`);
execWithLog(`cd ${projectRoot} && yarn install`);
}

Expand Down Expand Up @@ -117,9 +115,7 @@ function assertGitIsClean() {
chalk.grey('Use ') +
chalk.white('--force') +
chalk.grey(' to ignore this warning and publish anyway\n') +
chalk.yellow(
'⚠️ Publishing from an unclean working state may result in a broken release ⚠️'
)
chalk.yellow('⚠️ Publishing from an unclean working state may result in a broken release ⚠️')
);
process.exit(1);
}
Expand All @@ -139,9 +135,7 @@ function assertGitIsClean() {
chalk.grey('Use ') +
chalk.white('--force') +
chalk.grey(' to ignore this warning and publish anyway\n') +
chalk.yellow(
'⚠️ Publishing from an unsynced working state may result in a broken release ⚠️'
)
chalk.yellow('⚠️ Publishing from an unsynced working state may result in a broken release ⚠️')
);
process.exit(1);
}
Expand All @@ -150,9 +144,7 @@ function assertGitIsClean() {
let expectedChannelBranch = options.distTag === 'canary' ? 'master' : options.distTag;

if (options.channel === 'lts') {
expectedChannelBranch = `lts-${semver.major(options.currentVersion)}-${semver.minor(
options.currentVersion
)}`;
expectedChannelBranch = `lts-${semver.major(options.currentVersion)}-${semver.minor(options.currentVersion)}`;
}

let foundBranch = status.split('\n')[0];
Expand Down
19 changes: 5 additions & 14 deletions bin/test-external-partner-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,17 @@ const skipSmokeTest =
(process.argv[4] && process.argv[4] === '--skip-smoke-test') ||
(process.argv[5] && process.argv[5] === '--skip-smoke-test');
const skipClone =
(process.argv[4] && process.argv[4] === '--skip-clone') ||
(process.argv[5] && process.argv[5] === '--skip-clone');
(process.argv[4] && process.argv[4] === '--skip-clone') || (process.argv[5] && process.argv[5] === '--skip-clone');
// we share this for the build
const cachePath = '../__external-test-cache';
const tempDir = path.join(projectRoot, cachePath);
const projectTempDir = path.join(tempDir, externalProjectName);
const insertTarballsToPackageJson = require('./-tarball-info').insertTarballsToPackageJson;

if (!gitUrl) {
throw new Error(
'No git url provided to `test-external-partner`. An https git url should be the first argument.'
);
throw new Error('No git url provided to `test-external-partner`. An https git url should be the first argument.');
} else if (gitUrl.indexOf('https') !== 0) {
throw new Error(
`The git url provided to \`node test-external-partner\` should use https. Received '${gitUrl}'`
);
throw new Error(`The git url provided to \`node test-external-partner\` should use https. Received '${gitUrl}'`);
}

console.log(
Expand Down Expand Up @@ -103,9 +98,7 @@ try {
execExternal(`${useYarn ? 'yarn install' : 'npm install'}`);
} catch (e) {
debug(e);
throw new Error(
`Unable to complete install of dependencies for external project ${externalProjectName}`
);
throw new Error(`Unable to complete install of dependencies for external project ${externalProjectName}`);
}
execExternal(`ember test`, true);
}
Expand Down Expand Up @@ -139,9 +132,7 @@ try {
if (skipSmokeTest && !commitTestPassed) {
throw new Error('Commit may result in a regression, but the smoke test was skipped.');
} else if (!smokeTestPassed && !commitTestPassed) {
throw new Error(
`Commit may result in a regression, but the smoke test for ${externalProjectName} also failed.`
);
throw new Error(`Commit may result in a regression, but the smoke test for ${externalProjectName} also failed.`);
} else if (smokeTestPassed && !commitTestPassed) {
throw new Error(`Commit results in a regression in ${externalProjectName}`);
} else if (!smokeTestPassed) {
Expand Down
14 changes: 3 additions & 11 deletions packages/-build-infra/src/addon-build-config-for-data-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,11 @@ function addonBuildConfigForDataPackage(PackageName) {
buildBabelOptions() {
let babelOptions = this.options.babel || {};
let existingPlugins = babelOptions.plugins || [];
let customPlugins = require('./stripped-build-plugins')(
process.env.EMBER_ENV,
this.isLocalBuild()
);
let customPlugins = require('./stripped-build-plugins')(process.env.EMBER_ENV, this.isLocalBuild());
let plugins = existingPlugins.map(plugin => {
return Array.isArray(plugin) ? plugin : [plugin];
});
plugins = plugins
.concat(customPlugins.plugins)
.concat(require('./debug-macros')(process.env.EMBER_ENV));
plugins = plugins.concat(customPlugins.plugins).concat(require('./debug-macros')(process.env.EMBER_ENV));

return {
loose: true,
Expand Down Expand Up @@ -140,10 +135,7 @@ function addonBuildConfigForDataPackage(PackageName) {
});

let withoutPrivate = new Funnel(treeWithVersion, {
exclude: [
'-private',
isProductionEnv() && !isInstrumentedBuild() ? '-debug' : false,
].filter(Boolean),
exclude: ['-private', isProductionEnv() && !isInstrumentedBuild() ? '-debug' : false].filter(Boolean),

destDir: PackageName,
});
Expand Down
14 changes: 3 additions & 11 deletions packages/-build-infra/src/stripped-build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ const FeatureFlags = require.resolve('babel-plugin-feature-flags');
const StripClassCallCheck = require.resolve('babel6-plugin-strip-class-callcheck');
const StripFilteredImports = require.resolve('./transforms/babel-plugin-remove-imports');
const TransformBlockScoping = require.resolve('@babel/plugin-transform-block-scoping');
const {
isInstrumentedBuild,
wantsEnabledFeatures,
getManuallyEnabledFeatures,
} = require('./cli-flags');
const { isInstrumentedBuild, wantsEnabledFeatures, getManuallyEnabledFeatures } = require('./cli-flags');

function uniqueAdd(obj, key, values) {
const a = (obj[key] = obj[key] || []);
Expand Down Expand Up @@ -47,13 +43,9 @@ module.exports = function(environment, isLocalBuild) {
if (manuallyEnabled[flag]) {
if (state === true) {
// eslint-disable-next-line no-console
console.warn(
'You specified the in-progress-feature "' + flag + '" but it was already active'
);
console.warn('You specified the in-progress-feature "' + flag + '" but it was already active');
} else if (state === undefined) {
throw new Error(
'You specified the in-progress-feature "' + flag + '" but no such flag exists!'
);
throw new Error('You specified the in-progress-feature "' + flag + '" but no such flag exists!');
} else {
// eslint-disable-next-line no-console
console.warn('Manually Actived in-progress-feature: ' + flag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ module.exports = function(type, baseClass, options) {

let applicationEntityPath;
if (isModuleUnification) {
applicationEntityPath = path.join(
options.project.root,
'src',
'data',
'models',
'application',
`${type}.js`
);
applicationEntityPath = path.join(options.project.root, 'src', 'data', 'models', 'application', `${type}.js`);
} else {
applicationEntityPath = path.join(options.project.root, 'app', `${type}s`, 'application.js');
}
Expand Down
9 changes: 1 addition & 8 deletions packages/-build-infra/src/utilities/rollup-private-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ const Rollup = require('broccoli-rollup');
const BroccoliDebug = require('broccoli-debug');

module.exports = function rollupPrivateModule(tree, options) {
const {
onWarn,
destDir,
babelCompiler,
babelOptions,
externalDependencies,
packageName,
} = options;
const { onWarn, destDir, babelCompiler, babelOptions, externalDependencies, packageName } = options;
const debugTree = BroccoliDebug.buildDebugCallback(`ember-data:${packageName}:rollup-private`);
tree = debugTree(tree, 'input');

Expand Down
10 changes: 2 additions & 8 deletions packages/-build-infra/src/utilities/test-framework-detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,14 @@ module.exports = function(blueprint) {
}
} else if ('ember-cli-qunit' in dependencies) {
let checker = new VersionChecker(this.project);
if (
fs.existsSync(this.path + '/qunit-rfc-232-files') &&
checker.for('ember-cli-qunit', 'npm').gte('4.2.0')
) {
if (fs.existsSync(this.path + '/qunit-rfc-232-files') && checker.for('ember-cli-qunit', 'npm').gte('4.2.0')) {
type = 'qunit-rfc-232';
} else {
type = 'qunit';
}
} else if ('ember-mocha' in dependencies) {
let checker = new VersionChecker(this.project);
if (
fs.existsSync(this.path + '/mocha-rfc-232-files') &&
checker.for('ember-mocha', 'npm').gte('0.14.0')
) {
if (fs.existsSync(this.path + '/mocha-rfc-232-files') && checker.for('ember-mocha', 'npm').gte('0.14.0')) {
type = 'mocha-rfc-232';
} else {
type = 'mocha';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ export default DataAdapter.extend({
}
}
}
assert(
'Cannot find model name. Please upgrade to Ember.js >= 1.13 for Ember Inspector support',
!!modelName
);
assert('Cannot find model name. Please upgrade to Ember.js >= 1.13 for Ember Inspector support', !!modelName);
return this.get('store').peekAll(modelName);
},

Expand Down
7 changes: 1 addition & 6 deletions packages/-ember-data/addon/setup-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import RESTSerializer from '@ember-data/serializer/rest';
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import RESTAdapter from '@ember-data/adapter/rest';

import {
BooleanTransform,
DateTransform,
NumberTransform,
StringTransform,
} from '@ember-data/serializer/transform';
import { BooleanTransform, DateTransform, NumberTransform, StringTransform } from '@ember-data/serializer/transform';

function has(applicationOrRegistry, fullName) {
if (applicationOrRegistry.has) {
Expand Down
6 changes: 1 addition & 5 deletions packages/-ember-data/config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
const getChannelURL = require('ember-source-channel-url');

module.exports = function() {
return Promise.all([
getChannelURL('release'),
getChannelURL('beta'),
getChannelURL('canary'),
]).then(urls => {
return Promise.all([getChannelURL('release'), getChannelURL('beta'), getChannelURL('canary')]).then(urls => {
return {
useYarn: true,
scenarios: [
Expand Down
7 changes: 1 addition & 6 deletions packages/-ember-data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ const addonBaseConfig = addonBuildConfigForDataPackage('ember-data');
module.exports = Object.assign(addonBaseConfig, {
shouldRollupPrivate: true,
externalDependenciesForPrivateModule() {
return [
'ember-data/version',
'@ember-data/store/-private',
'@ember-data/store',
'@ember-data/model',
];
return ['ember-data/version', '@ember-data/store/-private', '@ember-data/store', '@ember-data/model'];
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,8 @@ module('async belongs-to rendering tests', function(hooks) {
await settled();

assert.equal(this.element.textContent.trim(), '');
assert.ok(
shen.get('bestHuman') === null,
"scene 3 - Chris remains no longer Shen's best human"
);
assert.ok(
pirate.get('bestHuman') === null,
'scene 3 - pirate no longer has Chris as best human'
);
assert.ok(shen.get('bestHuman') === null, "scene 3 - Chris remains no longer Shen's best human");
assert.ok(pirate.get('bestHuman') === null, 'scene 3 - pirate no longer has Chris as best human');
assert.ok(bestDog === null, 'scene 3 - Chris has no best dog');
});
});
Expand Down Expand Up @@ -381,9 +375,7 @@ module('async belongs-to rendering tests', function(hooks) {
data: people.dict['5:has-parent-no-children'],
});

adapter.setupPayloads(assert, [
new ServerError([], 'hard error while finding <person>5:has-parent-no-children'),
]);
adapter.setupPayloads(assert, [new ServerError([], 'hard error while finding <person>5:has-parent-no-children')]);

// render
this.set('sedona', sedona);
Expand Down Expand Up @@ -417,41 +409,17 @@ module('async belongs-to rendering tests', function(hooks) {

assert.equal(relationshipState.isAsync, true, 'The relationship is async');
assert.equal(relationshipState.relationshipIsEmpty, false, 'The relationship is not empty');
assert.equal(
relationshipState.hasDematerializedInverse,
true,
'The relationship inverse is dematerialized'
);
assert.equal(relationshipState.hasDematerializedInverse, true, 'The relationship inverse is dematerialized');
assert.equal(
relationshipState.allInverseRecordsAreLoaded,
false,
'The relationship is missing some or all related resources'
);
assert.equal(
relationshipState.hasAnyRelationshipData,
true,
'The relationship knows which record it needs'
);
assert.equal(
!!RelationshipPromiseCache['parent'],
false,
'The relationship has no fetch promise'
);
assert.equal(
relationshipState.hasFailedLoadAttempt === true,
true,
'The relationship has attempted a load'
);
assert.equal(
relationshipState.shouldForceReload === false,
true,
'The relationship will not force a reload'
);
assert.equal(
!!RelationshipProxyCache['parent'],
true,
'The relationship has a promise proxy'
);
assert.equal(relationshipState.hasAnyRelationshipData, true, 'The relationship knows which record it needs');
assert.equal(!!RelationshipPromiseCache['parent'], false, 'The relationship has no fetch promise');
assert.equal(relationshipState.hasFailedLoadAttempt === true, true, 'The relationship has attempted a load');
assert.equal(relationshipState.shouldForceReload === false, true, 'The relationship will not force a reload');
assert.equal(!!RelationshipProxyCache['parent'], true, 'The relationship has a promise proxy');
assert.equal(!!relationshipState.link, false, 'The relationship does not have a link');

try {
Expand Down
Loading

0 comments on commit 5dfc12f

Please sign in to comment.