Commit Graph

400 Commits

Author SHA1 Message Date
Miroslav Bajtoš f222be477e Merge pull request #17 from strongloop/feature/fix-executor
Fix references to loopback; fix jshint warnings
2014-06-26 14:54:42 +02:00
Miroslav Bajtoš 92455f569c test: fix jshint warnings 2014-06-26 14:54:07 +02:00
Miroslav Bajtoš a3c347d073 compiler: fix references to loopback 2014-06-26 14:53:47 +02:00
Miroslav Bajtoš d5cd0a3b50 Merge branch 'master' into 2.0
Conflicts:
	README.md
	docs/configuration.md
	lib/executor.js
	package.json

Changes in the docs were merged manually and updated to correctly
describe the 2.x layout.
2014-06-26 14:40:24 +02:00
Miroslav Bajtoš af9c4d8cc6 Merge tag 'v1.1.0'
1.1.0
2014-06-26 11:00:26 +02:00
Miroslav Bajtoš c70b8ac413 Merge branch 'release/1.1.0' into production 2014-06-26 11:00:19 +02:00
Miroslav Bajtoš edd41be02f 1.1.0 2014-06-26 10:59:49 +02:00
Miroslav Bajtoš b9b338ddde Merge pull request #15 from strongloop/feature/remove-last-require-loopback
executor: remove direct reference to loopback
2014-06-26 10:58:01 +02:00
Miroslav Bajtoš 18e1b3b4f5 Merge pull request #14 from strongloop/feature/add-more-meat-to-readme
docs: move hand-written content to README.md
2014-06-26 10:31:26 +02:00
Miroslav Bajtoš 961e04b379 docs: move hand-written content to README.md 2014-06-26 10:31:05 +02:00
Miroslav Bajtoš 2cc5a88699 Merge pull request #13 from strongloop/rename-app-json-to-config-json
Rename `app.json` to `config.json`
2014-06-26 10:28:44 +02:00
Miroslav Bajtoš 230360ef28 executor: remove direct reference to loopback
Modify the executor to access the loopback object via `app.loopback`.

Fall back to `require('loopback')` only when `app.loopback` is not set
(loopback versions before 1.9).
2014-06-25 14:12:53 +02:00
Miroslav Bajtoš ac16d92a8b Rename `app.json` to `config.json`
The new loopback project layout adds a concept of components like
'rest server' and 'isomorphic client', each component having its own set
of boot files. The name `app.json` is confusing, since it is configuring
a component, not the app (which is the whole project).
2014-06-25 08:18:04 +02:00
Rand McKinney 4b5f57a7df Update link to doc 2014-06-24 17:00:54 -07:00
Miroslav Bajtoš 0a0a6f5d01 Merge branch 'master' into 2.0
Conflicts:
	index.js
	package.json
2014-06-16 19:49:45 +02:00
Miroslav Bajtoš 2eab6bf32a Merge pull request #11 from strongloop/model-boot-improvements
[2.0] Model boot improvements
2014-06-16 19:47:10 +02:00
Miroslav Bajtoš 57e96b0d38 compiler: Sort models topologically
Sort models topologically using Base->Model as edges. This way
the base models are defined before the models extending them.
2014-06-16 19:45:34 +02:00
Miroslav Bajtoš a0d5dafd99 Merge pull request #12 from strongloop/feature/drop-peer-dep-on-loopback
Drop peer dep on loopback; add a runtime check
2014-06-16 19:43:24 +02:00
Miroslav Bajtoš ef72efa70b executor: Split model boot into two phases
In the first phase, all models are defined.

In the second phase, models are configured, attached to data-sources
and exposed on the app object.

This way when the `attached` Model event is emitted, all models are
already defined and thus a listener can get reference of any other
model used in the app.
2014-06-16 16:41:12 +02:00
Miroslav Bajtoš b887b33b57 compiler: Move model-sources cfg to models.json
Remove `modelSources` option from `boot()` options, add `_meta.sources`
to `models.json`.

```json
{
  "_meta": {
    "sources": ["./custom/path/to/models"]
  },
  "Car": {
    "dataSource": "db"
  }
}
```
2014-06-16 16:41:12 +02:00
Miroslav Bajtoš a9a401ad56 package: Bump up the version to 2.0.0-dev 2014-06-16 16:38:28 +02:00
Miroslav Bajtoš bad5b60623 package: Fix repository url 2014-06-16 15:27:54 +02:00
Miroslav Bajtoš c3a9a09941 Drop peer dep on loopback; add a runtime check
Replace peerDependency with a run-time check based on
`app.loopback.version`.
2014-06-16 15:23:32 +02:00
Miroslav Bajtoš e5e8f29d30 Wrap too long lines
... introduced by the previous commit.
2014-06-16 15:15:36 +02:00
Miroslav Bajtoš e22ecd39ce Merge pull request #10 from strongloop/auto-require-model-definitions
[2.0] Rework model configuration
2014-06-14 09:37:21 +02:00
Miroslav Bajtoš a204fdc1c9 Rework model configuration
Rework the way how models are configured, the goal is to allow
loopback-boot to automatically determine the correct order
of the model definitions to ensure base models are defined
before they are extended.

 1. The model .js file no longer creates the model, it exports
 a config function instead:

  ```js
  module.exports = function(Car, Base) {
    // Car is the model constructor
    // Base is the parent model (e.g. loopback.PersistedModel)

    Car.prototype.honk = function(duration, cb) {
      // make some noise for `duration` seconds
      cb();
    };
  };
  ```

 2. The model is created by loopback-boot from model .json file.
  The .js file must have the same base file name.

 3. The `boot()` function has a new parameter `modelSources` to
  specify the list of directories where to look for model definitions.
  The parameter defaults to `['./models']`.

As a side effect, only models configured in `models.json` and their
base clases are defined. This should keep the size of the browserified
bundle small, because unused models are not included.
2014-06-13 19:40:52 +02:00
Miroslav Bajtoš fccc6e147a Merge pull request #9 from strongloop/configure-models
Configure models
2014-06-10 10:27:19 +02:00
Miroslav Bajtoš 43993bf975 Remove auto-attach.
Breaking change.

The bootstrapper no longer calls `loopback.autoAttach`. Applications
have to explicitly configure datasources for their models
via `models.json`.
2014-06-10 09:24:16 +02:00
Miroslav Bajtoš 47b5bb5f5c Change models.json to configure existing models
Breaking change.

In the new 2.x project layout, definition of loopback Models is out of
scope of the boot process. The bootstrapper only configures existing
models - attaches them to a dataSource and the app object.
2014-06-10 09:21:15 +02:00
crandmck 18bc572c20 Add disclaimer to JSDoc and small correction. 2014-06-06 10:11:46 -07:00
Miroslav Bajtoš 7c255f089e Merge tag 'v1.0.0'
v1.0.0
2014-06-05 09:15:43 +02:00
Miroslav Bajtoš e0ccb67886 Merge branch 'release/1.0.0' into production 2014-06-05 09:15:31 +02:00
Miroslav Bajtoš 33261d33f1 README: add short usage info 2014-06-05 09:14:13 +02:00
Miroslav Bajtoš 0647c95e99 Merge pull request #6 from strongloop/feature/browserify-support
Implement compileToBrowserify and bootBrowserApp
2014-06-04 08:36:32 +02:00
Miroslav Bajtoš 5f85971d11 Implement compileToBrowserify and bootBrowserApp
Hide `compile` and `execute` and provide a better API for browserified
applications:

 - `boot.compileToBrowserify(options, bundler)` calls `compile` under
   the hood and adds all instructions and scripts to the bundler.

 - `bootBrowserApp(app)` is exported by loopback-boot when the module
   is loaded in a browser, the function loads the instructions as
   bundled by `compileToBrowserify`.

This new API hides all implementation details from the user and makes
it easy to add loopback-boot to any build script.
2014-06-03 14:08:34 +02:00
Miroslav Bajtoš f3207f6451 Merge pull request #5 from strongloop/feature/two-step-boot-for-browserify
Feature/two step boot for browserify
2014-06-03 08:13:27 +02:00
Miroslav Bajtoš b14800416a Split the boot process into two steps
Split bootLoopBackApp into two steps:
 - compile
 - execute

Most of the changes are just shuffling the existing code around.

What has changed:

 - `loopback.autoAttach()` is called after `models/*` are required.
   The calls were made in the opposite order before this commit.
2014-06-03 08:13:14 +02:00
Miroslav Bajtoš 1bf94a1b49 Start strong-docs API docs.
Add docs.json with strong-docs configuration.

Extract the example of `models.json` into docs/configuration.md.
2014-06-02 10:40:13 +02:00
Miroslav Bajtoš 76d379afbc Merge pull request #3 from strongloop/feature/support-loopback-2.x
Change loopback peer dep to "1.x || 2.x"
2014-05-28 16:06:56 +02:00
Miroslav Bajtoš 6196054a8b Change loopback peer dep to "1.x || 2.x"
Support the upcoming 2.x version of LoopBack.

The devDependency is intentionally kept at 1.x to ensure the module
supports LoopBack 1.x too.
2014-05-28 16:03:56 +02:00
Miroslav Bajtoš 32ccacfbf7 Merge pull request #1 from strongloop/feature/extract-app-boot
Initial implementation
2014-05-28 15:56:24 +02:00
Miroslav Bajtoš 1f1bc7aeab fixup! change debug logger name to 'loopback:boot' 2014-05-28 09:44:06 +02:00
Miroslav Bajtoš 255217f6a7 Ignore models/ and boot/ subdirs without index
Sub-directories of `models/` and `boot/` that cannot be required
(they don't have an index.js file) are silently skipped now.

This enables developers to put test files into `models/test/`.
2014-05-27 16:44:21 +02:00
Miroslav Bajtoš a716cdbf7b Start CHANGES.md 2014-05-27 16:18:09 +02:00
Miroslav Bajtoš 3ba43e1197 Pass `app` to fn exported by auto-required script
When a script in `models/` or `boot/` exports a function which is not
a loopback.Model constructor, the bootstrapper immediatelly calls
this exported function wit the current `app` object.

This is providing a dependency injection mechanism for boot scripts,
so that they no longer need to know where to find the `app` object.

Note: the dependency injection is optional. Existing code getting
`app` reference via `require('../app')` will continue to work.
2014-05-27 16:11:54 +02:00
Miroslav Bajtoš 9930934686 cleanup: remove unused code in requireDir()
No changes in functionality.
2014-05-27 16:05:43 +02:00
Miroslav Bajtoš 2a619773d4 Custom rootDir for models and datasources
Support custom project layouts where model & datasource config files
are located in a different place from the app config.

Example:

    # API server
    server/app.config.json
    server/datasources.json

    # shared between server & client
    models.json
    models/

    # isomorphic client
    client/app.config.json
    client/datasources.json
2014-05-27 14:49:11 +02:00
Miroslav Bajtoš c1743dc2ff Load datasources and app cfg from multiple files
Modify loading of `appConfig` and `dataSourceConfig` to look for
the following files:

  - app.json
  - app.local.{js|json}
  - app.{$env}.{js|json}

  - datasources.json
  - datasources.local.{js|json}
  - datasources.{$env}.{js|json}

where $env is the value of `app.get('env')`, which usually defaults
to `process.env.NODE_ENV`.

The values in the additional files are applied to the config object,
overwritting any existing values. The new values must be value types
like String or Number; Object and Array are not supported.

Additional datasource config files cannot define new datasources,
only modify existing ones.

The commit includes refactoring of the config-loading code into
a standalone file.
2014-05-27 14:08:58 +02:00
Miroslav Bajtoš a4402a3979 Initial implementation
Move `app.boot()` and its tests from loopback.

Fix jshint warnings.

Clean up unit tests - remove dependency on global variables created
by loopback's test/support.js
2014-05-23 16:50:40 +02:00
Miroslav Bajtoš cda7eec295 Initial commit 2014-05-23 15:51:20 +02:00