Rename `models.json` to `model-config.json`

The name `models.json` was potentially confusing since there are no
models defined in that file.
This commit is contained in:
Miroslav Bajtoš 2014-07-15 11:05:42 +02:00
parent 3522f117c0
commit 3129f6495c
7 changed files with 14 additions and 14 deletions

View File

@ -20,7 +20,7 @@ var addInstructionsToBrowserify = require('./lib/bundler');
* 1. Creates DataSources from the `datasources.json` file in the application * 1. Creates DataSources from the `datasources.json` file in the application
* root directory. * root directory.
* *
* 2. Configures Models from the `models.json` file in the application * 2. Configures Models from the `model-config.json` file in the application
* root directory. * root directory.
* *
* If the argument is an object, then it looks for `models`, `dataSources`, * If the argument is an object, then it looks for `models`, `dataSources`,
@ -37,9 +37,9 @@ var addInstructionsToBrowserify = require('./lib/bundler');
* `/boot` subdirectory of the application root directory with `require()`. * `/boot` subdirectory of the application root directory with `require()`.
* *
* **NOTE:** The version 2.0 of loopback-boot changed the way how models * **NOTE:** The version 2.0 of loopback-boot changed the way how models
* are created. The `models.json` file contains only configuration options like * are created. The `model-config.json` file contains only configuration
* dataSource and extra relations. To define a model, create a per-model * options like dataSource and extra relations. To define a model,
* JSON file in `models/` directory. * create a per-model JSON file in `models/` directory.
* *
* **NOTE:** Mixing `bootLoopBackApp(app, bootConfig)` and * **NOTE:** Mixing `bootLoopBackApp(app, bootConfig)` and
* `app.model(name, modelConfig)` in multiple * `app.model(name, modelConfig)` in multiple
@ -58,7 +58,7 @@ var addInstructionsToBrowserify = require('./lib/bundler');
* @property {Object} [models] Object containing `Model` configurations. * @property {Object} [models] Object containing `Model` configurations.
* @property {Object} [dataSources] Object containing `DataSource` definitions. * @property {Object} [dataSources] Object containing `DataSource` definitions.
* @property {String} [modelsRootDir] Directory to use when loading * @property {String} [modelsRootDir] Directory to use when loading
* `models.json`. Defaults to `appRootDir`. * `model-config.json`. Defaults to `appRootDir`.
* @property {String} [dsRootDir] Directory to use when loading * @property {String} [dsRootDir] Directory to use when loading
* `datasources.json`. Defaults to `appRootDir`. * `datasources.json`. Defaults to `appRootDir`.
* @property {String} [env] Environment type, defaults to `process.env.NODE_ENV` * @property {String} [env] Environment type, defaults to `process.env.NODE_ENV`

View File

@ -78,7 +78,7 @@ function assertIsValidModelConfig(config) {
if (unsupported) { if (unsupported) {
throw new Error( throw new Error(
'The data in models.json is in the unsupported 1.x format.'); 'The data in model-config.json is in the unsupported 1.x format.');
} }
} }
} }

View File

@ -24,14 +24,14 @@ ConfigLoader.loadDataSources = function(rootDir, env) {
}; };
/** /**
* Load models config from `models.json` and friends. * Load model config from `model-config.json` and friends.
* @param {String} rootDir Directory where to look for files. * @param {String} rootDir Directory where to look for files.
* @param {String} env Environment, usually `process.env.NODE_ENV` * @param {String} env Environment, usually `process.env.NODE_ENV`
* @returns {Object} * @returns {Object}
*/ */
ConfigLoader.loadModels = function(rootDir, env) { ConfigLoader.loadModels = function(rootDir, env) {
/*jshint unused:false */ /*jshint unused:false */
return tryReadJsonConfig(rootDir, 'models') || {}; return tryReadJsonConfig(rootDir, 'model-config') || {};
}; };
/*-- Implementation --*/ /*-- Implementation --*/

View File

@ -198,7 +198,7 @@ describe('compiler', function() {
it('supports `modelsRootDir` option', function() { it('supports `modelsRootDir` option', function() {
appdir.createConfigFilesSync(); appdir.createConfigFilesSync();
appdir.writeConfigFileSync('custom/models.json', { appdir.writeConfigFileSync('custom/model-config.json', {
foo: { dataSource: 'db' } foo: { dataSource: 'db' }
}); });
@ -228,7 +228,7 @@ describe('compiler', function() {
expect(instructions.files).to.not.have.property('models'); expect(instructions.files).to.not.have.property('models');
}); });
it('throws when models.json contains `properties` from 1.x', function() { it('throws when models-config.json contains 1.x `properties`', function() {
appdir.createConfigFilesSync({}, {}, { appdir.createConfigFilesSync({}, {}, {
foo: { properties: { name: 'string' } } foo: { properties: { name: 'string' } }
}); });
@ -237,7 +237,7 @@ describe('compiler', function() {
.to.throw(/unsupported 1\.x format/); .to.throw(/unsupported 1\.x format/);
}); });
it('throws when models.json contains `options.base` from 1.x', function() { it('throws when model-config.json contains 1.x `options.base`', function() {
appdir.createConfigFilesSync({}, {}, { appdir.createConfigFilesSync({}, {}, {
Customer: { options: { base: 'User' } } Customer: { options: { base: 'User' } }
}); });
@ -268,7 +268,7 @@ describe('compiler', function() {
}); });
}); });
it('supports `sources` option in `models.json`', function() { it('supports `sources` option in `model-config.json`', function() {
appdir.createConfigFilesSync({}, {}, { appdir.createConfigFilesSync({}, {}, {
_meta: { _meta: {
sources: ['./custom-models'] sources: ['./custom-models']
@ -313,7 +313,7 @@ describe('compiler', function() {
}]); }]);
}); });
it('excludes models not listed in `models.json`', function() { it('excludes models not listed in `model-config.json`', function() {
appdir.createConfigFilesSync({}, {}, { appdir.createConfigFilesSync({}, {}, {
Car: { dataSource: 'db' } Car: { dataSource: 'db' }
}); });

View File

@ -34,7 +34,7 @@ appdir.createConfigFilesSync = function(appConfig, dataSources, models) {
models = extend({ models = extend({
}, models); }, models);
appdir.writeConfigFileSync ('models.json', models); appdir.writeConfigFileSync ('model-config.json', models);
}; };
appdir.writeConfigFileSync = function(name, json) { appdir.writeConfigFileSync = function(name, json) {