From 3129f6495ccf23186dcbc2602b3eb7df0be1aad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Tue, 15 Jul 2014 11:05:42 +0200 Subject: [PATCH] Rename `models.json` to `model-config.json` The name `models.json` was potentially confusing since there are no models defined in that file. --- index.js | 10 +++++----- lib/compiler.js | 2 +- lib/config-loader.js | 4 ++-- test/compiler.test.js | 10 +++++----- .../browser-app/{models.json => model-config.json} | 0 .../simple-app/{models.json => model-config.json} | 0 test/helpers/appdir.js | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) rename test/fixtures/browser-app/{models.json => model-config.json} (100%) rename test/fixtures/simple-app/{models.json => model-config.json} (100%) diff --git a/index.js b/index.js index 1c1b426..f6d8cbd 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,7 @@ var addInstructionsToBrowserify = require('./lib/bundler'); * 1. Creates DataSources from the `datasources.json` file in the application * 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. * * 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()`. * * **NOTE:** The version 2.0 of loopback-boot changed the way how models - * are created. The `models.json` file contains only configuration options like - * dataSource and extra relations. To define a model, create a per-model - * JSON file in `models/` directory. + * are created. The `model-config.json` file contains only configuration + * options like dataSource and extra relations. To define a model, + * create a per-model JSON file in `models/` directory. * * **NOTE:** Mixing `bootLoopBackApp(app, bootConfig)` and * `app.model(name, modelConfig)` in multiple @@ -58,7 +58,7 @@ var addInstructionsToBrowserify = require('./lib/bundler'); * @property {Object} [models] Object containing `Model` configurations. * @property {Object} [dataSources] Object containing `DataSource` definitions. * @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 * `datasources.json`. Defaults to `appRootDir`. * @property {String} [env] Environment type, defaults to `process.env.NODE_ENV` diff --git a/lib/compiler.js b/lib/compiler.js index 9f9b1ac..04f2845 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -78,7 +78,7 @@ function assertIsValidModelConfig(config) { if (unsupported) { 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.'); } } } diff --git a/lib/config-loader.js b/lib/config-loader.js index e218abd..a28be28 100644 --- a/lib/config-loader.js +++ b/lib/config-loader.js @@ -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} env Environment, usually `process.env.NODE_ENV` * @returns {Object} */ ConfigLoader.loadModels = function(rootDir, env) { /*jshint unused:false */ - return tryReadJsonConfig(rootDir, 'models') || {}; + return tryReadJsonConfig(rootDir, 'model-config') || {}; }; /*-- Implementation --*/ diff --git a/test/compiler.test.js b/test/compiler.test.js index ca328b0..e128235 100644 --- a/test/compiler.test.js +++ b/test/compiler.test.js @@ -198,7 +198,7 @@ describe('compiler', function() { it('supports `modelsRootDir` option', function() { appdir.createConfigFilesSync(); - appdir.writeConfigFileSync('custom/models.json', { + appdir.writeConfigFileSync('custom/model-config.json', { foo: { dataSource: 'db' } }); @@ -228,7 +228,7 @@ describe('compiler', function() { 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({}, {}, { foo: { properties: { name: 'string' } } }); @@ -237,7 +237,7 @@ describe('compiler', function() { .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({}, {}, { 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({}, {}, { _meta: { 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({}, {}, { Car: { dataSource: 'db' } }); diff --git a/test/fixtures/browser-app/models.json b/test/fixtures/browser-app/model-config.json similarity index 100% rename from test/fixtures/browser-app/models.json rename to test/fixtures/browser-app/model-config.json diff --git a/test/fixtures/simple-app/models.json b/test/fixtures/simple-app/model-config.json similarity index 100% rename from test/fixtures/simple-app/models.json rename to test/fixtures/simple-app/model-config.json diff --git a/test/helpers/appdir.js b/test/helpers/appdir.js index 4961d07..1a31be5 100644 --- a/test/helpers/appdir.js +++ b/test/helpers/appdir.js @@ -34,7 +34,7 @@ appdir.createConfigFilesSync = function(appConfig, dataSources, models) { models = extend({ }, models); - appdir.writeConfigFileSync ('models.json', models); + appdir.writeConfigFileSync ('model-config.json', models); }; appdir.writeConfigFileSync = function(name, json) {