diff --git a/benchmark/CHANGELOG.md b/benchmark/CHANGELOG.md index 1bd15770b69e..b5dd8490efd8 100644 --- a/benchmark/CHANGELOG.md +++ b/benchmark/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.7](https://github.com/strongloop/loopback-next/compare/@loopback/benchmark@1.1.6...@loopback/benchmark@1.1.7) (2019-01-14) + +**Note:** Version bump only for package @loopback/benchmark + + + + + ## [1.1.6](https://github.com/strongloop/loopback-next/compare/@loopback/benchmark@1.1.5...@loopback/benchmark@1.1.6) (2018-12-20) **Note:** Version bump only for package @loopback/benchmark diff --git a/benchmark/package.json b/benchmark/package.json index 41a7c57cb2c8..a183c9c0ebe0 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/benchmark", - "version": "1.1.6", + "version": "1.1.7", "private": true, "description": "Benchmarks measuring performance of our framework.", "keywords": [ @@ -35,9 +35,9 @@ "src" ], "dependencies": { - "@loopback/example-todo": "^1.3.1", - "@loopback/openapi-spec-builder": "^1.0.3", - "@loopback/rest": "^1.5.1", + "@loopback/example-todo": "^1.4.0", + "@loopback/openapi-spec-builder": "^1.0.4", + "@loopback/rest": "^1.5.2", "@types/byline": "^4.2.31", "@types/debug": "0.0.31", "@types/p-event": "^1.3.0", @@ -50,8 +50,8 @@ "request-promise-native": "^1.0.5" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", "@types/mocha": "^5.0.0", "@types/node": "^10.11.2", "mocha": "^5.1.1", diff --git a/bin/sync-dev-deps.js b/bin/sync-dev-deps.js new file mode 100755 index 000000000000..493b6b3a7a8a --- /dev/null +++ b/bin/sync-dev-deps.js @@ -0,0 +1,63 @@ +#!/usr/bin/env node +// Copyright IBM Corp. 2017,2018. All Rights Reserved. +// Node module: loopback-next +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + +/** + * This is an internal script to synchronize versions of dev-dependencies + * from monorepo's package.json to individual example packages. + */ +'use strict'; + +const path = require('path'); +const fs = require('fs'); + +const Project = require('@lerna/project'); + +async function syncDevDeps() { + const project = new Project(process.cwd()); + const packages = await project.getPackages(); + + const rootPath = project.rootPath; + + // Load dependencies from `packages/build/package.json` + const buildDeps = require(path.join(rootPath, 'packages/build/package.json')) + .dependencies; + + const masterDeps = { + typescript: buildDeps.typescript, + tslint: buildDeps.tslint, + }; + + // Update typescript & tslint dependencies in individual packages + for (const pkg of packages) { + const data = readJsonFile(pkg.manifestLocation); + let modified = false; + for (const dep in masterDeps) { + if (data.devDependencies && dep in data.devDependencies) { + data.devDependencies[dep] = masterDeps[dep]; + modified = true; + } + } + if (!modified) continue; + writeJsonFile(pkg.manifestLocation, data); + } + + // Update dependencies in monorepo root + const rootPackage = path.join(rootPath, 'package.json'); + const data = readJsonFile(rootPackage); + Object.assign(data.devDependencies, masterDeps); + writeJsonFile(rootPackage, data); +} + +if (require.main === module) syncDevDeps(); + +function readJsonFile(filePath) { + return JSON.parse(fs.readFileSync(filePath, 'utf-8')); +} + +function writeJsonFile(filePath, data) { + fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n', 'utf-8'); + console.log('%s has been updated.', filePath); +} diff --git a/bin/travis.sh b/bin/travis.sh index 4f4a46437b48..21c7da01fb0a 100755 --- a/bin/travis.sh +++ b/bin/travis.sh @@ -4,7 +4,7 @@ set -e # Running Code Linter -- Requires @loopback/build so it's bootstrapped if [ $TASK = "code-lint" ]; then echo "TASK => LINTING CODE" - lerna bootstrap --scope @loopback/build + lerna bootstrap --scope @loopback/build --scope @loopback/tslint-config npm run lint # Commit Message Linter diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 05f810b8ea2e..abad7a2c7bc9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.7.0](https://github.com/strongloop/loopback-next/compare/@loopback/docs@1.6.0...@loopback/docs@1.7.0) (2019-01-14) + + +### Bug Fixes + +* **cli:** add descriptions to features ([8a94f8f](https://github.com/strongloop/loopback-next/commit/8a94f8f)) +* **docs:** fix a typo ([c2f8cdd](https://github.com/strongloop/loopback-next/commit/c2f8cdd)) +* **docs:** fix example for using --config option ([5a670ef](https://github.com/strongloop/loopback-next/commit/5a670ef)) + + +### Features + +* always include tslint and typescript in project dev-dependencies ([e0df285](https://github.com/strongloop/loopback-next/commit/e0df285)) +* **cli:** add strict prompt to model generator ([a68d78b](https://github.com/strongloop/loopback-next/commit/a68d78b)) + + + + + # [1.6.0](https://github.com/strongloop/loopback-next/compare/@loopback/docs@1.5.0...@loopback/docs@1.6.0) (2018-12-20) diff --git a/docs/package.json b/docs/package.json index e64824d63b22..46d7fe1001c0 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/docs", - "version": "1.6.0", + "version": "1.7.0", "description": "Documentation for LoopBack 4", "homepage": "https://github.com/strongloop/loopback-next/tree/master/docs", "author": { @@ -22,7 +22,7 @@ "clean": "lb-clean loopback-docs*.tgz package api-docs site/readmes" }, "devDependencies": { - "@loopback/build": "^1.1.0" + "@loopback/build": "^1.2.0" }, "publishConfig": { "access": "public" diff --git a/docs/site/BelongsTo-relation.md b/docs/site/BelongsTo-relation.md index 17c372337f3f..60bfcba5f278 100644 --- a/docs/site/BelongsTo-relation.md +++ b/docs/site/BelongsTo-relation.md @@ -179,3 +179,49 @@ with the name following the pattern `__{methodName}__{relationName}__` (e.g. `Order.__get__customer`). While we recommend to create a new controller for each hasMany relation in LoopBack 4, we also think it's best to use the main CRUD controller as the place where to explose `belongsTo` API. + +## Handling recursive relations + +Given an e-commerce system has many `Category`, each `Category` may have several +sub-categories, and may belong to 1 parent-category. + +```ts +export class Category extends Entity { + @property({ + type: 'number', + id: true, + generated: true, + }) + id?: number; + + @belongsTo(() => Category) + parentId: number; + + constructor(data?: Partial) { + super(data); + } +} +``` + +The `CategoryRepository` must be declared like below + +```ts +export class CategoryRepository extends DefaultCrudRepository< + Category, + typeof Category.prototype.id +> { + public readonly parent: BelongsToAccessor; + constructor(@inject('datasources.db') dataSource: DbDataSource) { + super(Category, dataSource); + this.parent = this._createBelongsToAccessorFor( + 'parent', + Getter.fromValue(this), + ); // for recursive relationship + } +} +``` + +DO NOT declare +`@repository.getter(CategoryRepository) protected categoryRepositoryGetter: Getter` +on constructor to avoid "Circular dependency" error (see +[issue #2118](https://github.com/strongloop/loopback-next/issues/2118)) diff --git a/docs/site/DEVELOPING.md b/docs/site/DEVELOPING.md index 8c462395d404..1de5c87348c9 100644 --- a/docs/site/DEVELOPING.md +++ b/docs/site/DEVELOPING.md @@ -22,6 +22,7 @@ See [Monorepo overview](./MONOREPO.md) for a list of all packages. - [Making breaking changes](#making-breaking-changes) - [Releasing new versions](#releasing-new-versions) - [Adding a new package](#adding-a-new-package) +- [Upgrading TypeScript/tslint](#upgrading-typescripttslint) - [How to test infrastructure changes](#how-to-test-infrastructure-changes) ## Setting up development environment @@ -437,6 +438,27 @@ Please register the new package in the following files: [@raymondfeng](https://github.com/raymondfeng) to enlist the new package on . +## Upgrading TypeScript/tslint + +In order to support tslint extensions with a peer dependency on tslint, we have +to specify `typescript` and `tslint` dependency in multiple places in our +monorepo. + +Steps to upgrade `typescript` or `tslint` to a newer version: + +1. Update the dependencies in `@loopback/build`, this is the source of truth for + the rest of the monorepo. + + ```shell + $ (cd packages/build && npm update typescript tslint) + ``` + +2. Propagate the change to other places to keep everything consistent. + + ```shell + $ node bin/sync-dev-deps + ``` + ## How to test infrastructure changes When making changes to project infrastructure, e.g. modifying `tsc` or `tslint` @@ -488,3 +510,25 @@ configuration, it's important to verify that all usage scenarios keep working. 5. Test integration with supported IDEs: - [VS Code](./VSCODE.md#how-to-verify-tslint-setup) + +### tsconfig files + +In the [`loopback-next`](https://github.com/strongloop/loopback-next) monorepo, +`TypeScript` is set up in two places: + +1. When using VS Code, the `TypeScript` engine views `loopback-next` as a single + big project. + + This enables the "refactor - rename" command to change all places using the + renamed symbol, and also makes "go to definition" command jump to `.ts` files + containing the original source code. Otherwise "refactor - rename" works + within the same package only and "go to definition" jumps to `.d.ts` files. + +2. When building the monorepo, we need to build the packages individually, so + that one `dist` directory is created for each package. + +This is why we have two sets of `tsconfig` files: + +- At monorepo root, there is `tsconfig.json` used by VS Code. +- Inside each package, there is `tsconfig.build.json` used by `npm run build` + command. diff --git a/docs/site/Decorators_repository.md b/docs/site/Decorators_repository.md index 32238e174b7d..ab5b0a30f4d5 100644 --- a/docs/site/Decorators_repository.md +++ b/docs/site/Decorators_repository.md @@ -106,7 +106,7 @@ If the model or datasource is already bound to the app, you can create the repository by providing their names instead of the classes. For example: ```ts -// with `datasource` and `Todo` already defined. +// with `db` and `Todo` already defined. app.bind('datasources.db').to(db); app.bind('models.Todo').to(Todo); @@ -119,9 +119,6 @@ export class TodoController { ### Relation Decorators -_This feature has not yet been released in alpha form. Documentation will be -added here as this feature progresses._ - The relation decorator defines the nature of a relationship between two models. #### Relation Decorator @@ -133,19 +130,137 @@ Register a general relation. _This feature has not yet been released in alpha form. Documentation will be added here as this feature progresses._ -#### Specific Relation Decorator +#### BelongsTo Decorator + +Syntax: +`@belongsTo(targetResolver: EntityResolver, definition?: Partial)` + +Many-to-one or one-to-one connection between models e.g. a `Todo` model belongs +to a `TodoList` model. See [BelongsTo relation](BelongsTo-relation.md) for more +details. + +{% include code-caption.html content="todo.model.ts" %} + +```ts +import {belongsTo} from '@loopback/repository'; +import {TodoList} from './todo-list.model'; + +export class Todo extends Entity { + // properties + + @belongsTo(() => TodoList) + todoListId: number; + + // etc +} +``` + +#### HasOne Decorator + +Syntax: +`@hasOne(targetResolver: EntityResolver, definition?: Partial)` + +One-to-one connection between models e.g. a `TodoList` model has one +`TodoListImage` model. See [HasOne relation](hasOne-relation.md) for more +details. + +{% include code-caption.html content="todo-list.model.ts" %} + +```ts +import {hasOne} from '@loopback/repository'; +import {TodoListImage} from './todo-list-image.model'; + +export class TodoList extends Entity { + @property({ + type: 'number', + id: true, + }) + id?: number; + + // other properties + + @hasOne(() => TodoListImage) + image: TodoListImage; + + // etc +} +``` + +{% include code-caption.html content="todo-list-image.model.ts" %} + +```ts +import {belongsTo} from '@loopback/repository'; +import {TodoList} from './todo-list.model'; + +export class TodoListImage extends Entity { + @property({ + type: 'number', + id: true, + }) + id: number; + + // other properties + + @belongsTo(() => TodoList) + todoListId?: number; + + // etc +} +``` + +#### HasMany Decorator Syntax: +`@hasMany(targetResolver: EntityResolver, definition?: Partial)` + +One-to-many connection between models e.g. a `TodoList` model has many of the +`Todo` model. See [HasMany relation](HasMany-relation.md) for more details. + +{% include code-caption.html content="todo-list.model.ts" %} + +```ts +import {hasMany} from '@loopback/repository'; +import {Todo} from './todo.model'; + +export class TodoList extends Entity { + @property({ + type: 'number', + id: true, + }) + id?: number; + + // other properties + + @hasMany(() => Todo) + todos: Todo[]; + + // etc +} +``` + +{% include code-caption.html content="todo.model.ts" %} + +```ts +import {belongsTo} from '@loopback/repository'; +import {TodoList} from './todo-list.model'; + +export class Todo extends Entity { + // other properties + + @belongsTo(() => TodoList) + todoListId?: number; + + // etc +} +``` + +#### Other Decorators + +The following decorators are not implemented yet. To see their progress, please +go to the +[Relations epic](https://github.com/strongloop/loopback-next/issues/1450). -- `@belongsTo` -- `@hasOne` -- `@hasMany` - `@embedsOne` - `@embedsMany` - `@referencesOne` - `@referencesMany` - -Register a specific relation. - -_This feature has not yet been released in alpha form. Documentation will be -added here as this feature progresses._ diff --git a/docs/site/Deploying-with-pm2-and-nginx.md b/docs/site/Deploying-with-pm2-and-nginx.md index b2656153af51..2a3cbcd70eda 100644 --- a/docs/site/Deploying-with-pm2-and-nginx.md +++ b/docs/site/Deploying-with-pm2-and-nginx.md @@ -9,8 +9,8 @@ permalink: /doc/en/lb4/deploying-with-pm2-and-nginx.html This is a basic guide for deploying a LoopBack 4 (LB4) app using [pm2](https://www.npmjs.com/package/pm2) behind nginx reverse proxy. -PM2 is a Production Runtime and Process Manager for Node.js applications with a -built-in Load Balancer. It allows you to keep applications alive forever, to +`pm2` is a Production Runtime and Process Manager for Node.js applications with +a built-in Load Balancer. It allows you to keep applications alive forever, to reload them without downtime and facilitate common Devops tasks. NGINX is open source software for web serving, reverse proxying, caching, load @@ -30,7 +30,7 @@ already. ### Loopback app -Before we start with deployment, let's get our app ready. If you have loopback +Before we start with deployment, let's get our app ready. If you have Loopback cli installed, run the following command to create a new app: ```sh @@ -44,8 +44,8 @@ section of documentation for detailed instructions. ### pm2 setup > You might find yourself in a situation in which you do not have access to the -> CLI to start your Node.js applications. In such a situation, pm2 must be added -> as a dependency and must be called with the start script. +> CLI to start your Node.js applications. In such a situation, `pm2` must be +> added as a dependency and must be called with the start script. 1. Generate an ecosystem.config.js template with: @@ -53,7 +53,7 @@ section of documentation for detailed instructions. $ pm2 init ``` -2. Modify the generated file to match loopback requirements: +2. Modify the generated file to match Loopback requirements: {% include code-caption.html content="/ecosystem.config.js" %} @@ -78,7 +78,7 @@ section of documentation for detailed instructions. }; ``` -3. Add pm2 as a dependency to your projet using following command +3. Add `pm2` as a dependency to your project using the following command ```sh $ npm install pm2 --save @@ -98,16 +98,15 @@ section of documentation for detailed instructions. ## Deployment -1. Register and start your application with pm2 using following command at the - app root directory: +1. Register and start your application with `pm2` using the following command at + the app root directory: ```sh $ npm start ``` - This creates a dist folder which containes the transpiled code. At you app - root level, you already have an `index.js` which can be user to run the - application using pm2. + This creates a dist folder which contains the transpiled code. Use `index.js` + at your app's root level for starting the server using `pm2`. Now you can visit [http://127.0.0.1:3000/](http://127.0.0.1:3000/) to check your newly deployed API. @@ -128,10 +127,10 @@ section of documentation for detailed instructions. 3. All set! Now you can hit your localhost at `http://localhost:3000/fooapi` (assuming nginx is listening to port 80) and your requests will be passed on - to pm2 process running your loopback application. + to `pm2` process running your Loopback application. **NOTE**: This is one of the many ways to expose your APIs. If you notice, there are three main components to this recipe. A node application, a process manager -and a reverse proxy server. Since loopback is the node application in our +and a reverse proxy server. Since Loopback is the node application in our context, this will be a constant thing. You can choose any process manager for node and any server instead of `pm2` and `nginx`. diff --git a/docs/site/FAQ.md b/docs/site/FAQ.md index 7daa2b364a46..f48802eae86e 100644 --- a/docs/site/FAQ.md +++ b/docs/site/FAQ.md @@ -60,7 +60,7 @@ reasons: scalability is the reason TypeScript exists and is gaining traction. - **Improved extensibility** and flexibility. LoopBack 4's core is simpler than LoopBack 3.x with well-defined extension points. A lot of responsibility will - be shifted to extensions (componnets), which can be JavaScript or TypeScript. + be shifted to extensions (components), which can be JavaScript or TypeScript. - Unified tooling. TypeScript developers all use the same IDE: Visual Studio Code. The LoopBack ecosystem could someday be filled with useful best practices around that IDE and even great developer plugins. Right now that diff --git a/docs/site/Getting-started.md b/docs/site/Getting-started.md index c4a96a3ae9b0..d549f14ad67a 100644 --- a/docs/site/Getting-started.md +++ b/docs/site/Getting-started.md @@ -42,13 +42,13 @@ Answer the prompts as follows: ? Project root directory: (getting-started) ? Application class name: StarterApplication ? Select features to enable in the project: -❯◉ Enable tslint - ◉ Enable prettier - ◉ Enable mocha - ◉ Enable loopbackBuild - ◉ Enable vscode - ◉ Enable repositories - ◉ Enable services +❯◉ Enable tslint: add a linter with pre-configured lint rules + ◉ Enable prettier: add new npm scripts to facilitate consistent code formatting + ◉ Enable mocha: install mocha to assist with running tests + ◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-tslint) + ◉ Enable vscode: add VSCode config files + ◉ Enable repositories: include repository imports and RepositoryMixin + ◉ Enable services: include service-proxy imports and ServiceMixin ``` ### Starting the project diff --git a/docs/site/Model-generator.md b/docs/site/Model-generator.md index e0e276e0b980..5cd799a718f5 100644 --- a/docs/site/Model-generator.md +++ b/docs/site/Model-generator.md @@ -41,11 +41,16 @@ The tool will prompt you for: been supplied with a valid model class name, the prompt is skipped. It will present you with a list of available models from `src/models` including the **Entity** and **Model** at the top of the list. + - An **Entity** is a persisted model with an identity (ID). - A **Model** is a business domain object. - For more information, see [here](https://loopback.io/doc/en/lb4/Model.html#overview). +- **Allow additonal properties.** _(allowAdditionalProperties)_ Defaults to + **false**. To allow arbitrary properties in addition to well-defined + properties, disable strict mode. + The tool will next recursively prompt you for the model's properties until a blank one is entered. Properties will be prompted for as follows: diff --git a/docs/site/Model.md b/docs/site/Model.md index bcd2166d547a..29ca59b6fa59 100644 --- a/docs/site/Model.md +++ b/docs/site/Model.md @@ -127,8 +127,8 @@ persistence layer respects this constraint and configures underlying PersistedModel classes to enforce `strict` mode. To create a model that allows both well-defined but also arbitrary extra -properties, you need to disable `strict` mode in model settings and tell -TypeScript to allow arbitrary additional properties to be set on model +properties, you need to disable `strict` mode in model settings through the CLI +and tell TypeScript to allow arbitrary additional properties to be set on model instances. ```ts diff --git a/docs/site/Preparing-the-API-for-consumption.shelved.md b/docs/site/Preparing-the-API-for-consumption.shelved.md index 78956086473b..f7fab2caab10 100644 --- a/docs/site/Preparing-the-API-for-consumption.shelved.md +++ b/docs/site/Preparing-the-API-for-consumption.shelved.md @@ -37,11 +37,11 @@ environment to test the API endpoints defined by the raw spec found at flavour at " %} -{% include image.html file="lb4/10000000.png" alt="" %} +![10000000.png](./imgs/10000000.png) The Swagger UI displays all of the endpoints defined in your application. -{% include image.html file="lb4/10000001.png" alt="" %} +![10000001.png](./imgs/10000001.png) Clicking on one of the endpoints will show the endpoint's documentation as defined in your API spec. Next, click on `Try It Out` to send a request to the @@ -49,7 +49,7 @@ endpoint. If the endpoint takes parameters, assign the values before the request is sent. If the parameter involves a body, a template is given for you to edit as specified in your spec. Click `Execute` to send the request: -{% include image.html file="lb4/10000002.png" alt="" %} +![10000002.png](./imgs/10000002.png) The response to the request can be seen below the `Execute` button, where the response code and the body are displayed. Ideally, each endpoint should be diff --git a/docs/site/Testing-your-application.md b/docs/site/Testing-your-application.md index 80d116e0d86e..d6bae0f58f8f 100644 --- a/docs/site/Testing-your-application.md +++ b/docs/site/Testing-your-application.md @@ -138,6 +138,28 @@ export async function givenEmptyDatabase() { } ``` +In case a repository includes a relation to another repository, ie. Product +belongs to Category, include it in the repository call, for example: + +{% include code-caption.html content="test/helpers/database.helpers.ts" %} + +```ts +import {Getter} from '@loopback/context'; +import {ProductRepository, CategoryRepository} from '../../src/repositories'; +import {testdb} from '../fixtures/datasources/testdb.datasource'; + +export async function givenEmptyDatabase() { + const categoryRepository = new CategoryRepository(testdb); + const productRepository = new ProductRepository( + testdb, + Getter.fromValue(categoryRepository), + ); + + await productRepository.deleteAll(); + await categoryRepository.deleteAll(); +} +``` + {% include code-caption.html content="test/integration/controllers/product.controller.integration.ts" %} ```ts diff --git a/docs/site/includes/CLI-std-options.md b/docs/site/includes/CLI-std-options.md index af13d4f78280..e4e1332eb6f6 100644 --- a/docs/site/includes/CLI-std-options.md +++ b/docs/site/includes/CLI-std-options.md @@ -20,7 +20,7 @@ For example, ```sh lb4 app --config config.json -lb4 app --config {"name":"my-app"} +lb4 app --config '{"name":"my-app"}' cat config.json | lb4 app --config stdin lb4 app --config stdin < config.json lb4 app --config stdin << EOF diff --git a/docs/site/soap-calculator-tutorial-scaffolding.md b/docs/site/soap-calculator-tutorial-scaffolding.md index 2a07b6defca9..f199fa17ef16 100644 --- a/docs/site/soap-calculator-tutorial-scaffolding.md +++ b/docs/site/soap-calculator-tutorial-scaffolding.md @@ -42,13 +42,13 @@ the application. ```sh ? Select features to enable in the project: -❯◉ Enable tslint - ◉ Enable prettier - ◉ Enable mocha - ◉ Enable loopbackBuild - ◉ Enable vscode - ◉ Enable repositories - ◉ Enable services +❯◉ Enable tslint: add a linter with pre-configured lint rules + ◉ Enable prettier: add new npm scripts to facilitate consistent code formatting + ◉ Enable mocha: install mocha to assist with running tests + ◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-tslint) + ◉ Enable vscode: add VSCode config files + ◉ Enable repositories: include repository imports and RepositoryMixin + ◉ Enable services: include service-proxy imports and ServiceMixin ``` #### Run the Application diff --git a/docs/site/todo-list-tutorial-model.md b/docs/site/todo-list-tutorial-model.md index 425debc961b5..146e58958585 100644 --- a/docs/site/todo-list-tutorial-model.md +++ b/docs/site/todo-list-tutorial-model.md @@ -32,6 +32,8 @@ for us as follows: $ lb4 model ? Model class name: TodoList ? Please select the model base class Entity +? Allow additional (free-form) properties? No + Let's add a property to TodoList Enter an empty property name when done diff --git a/docs/site/todo-tutorial-model.md b/docs/site/todo-tutorial-model.md index 950fad2f5118..32aaa84b58e4 100644 --- a/docs/site/todo-tutorial-model.md +++ b/docs/site/todo-tutorial-model.md @@ -49,6 +49,7 @@ these steps: lb4 model ? Model class name: todo ? Please select the model base class: Entity +? Allow additional (free-form) properties? No Let's add a property to Todo Enter an empty property name when done diff --git a/docs/site/todo-tutorial-scaffolding.md b/docs/site/todo-tutorial-scaffolding.md index 4597414af9c1..3f8a904d0396 100644 --- a/docs/site/todo-tutorial-scaffolding.md +++ b/docs/site/todo-tutorial-scaffolding.md @@ -23,13 +23,13 @@ $ lb4 app ? Project root directory: (todo-list) ? Application class name: (TodoListApplication) ? Select features to enable in the project: -❯◉ Enable tslint - ◉ Enable prettier - ◉ Enable mocha - ◉ Enable loopbackBuild - ◉ Enable vscode - ◉ Enable repositories - ◉ Enable services +❯◉ Enable tslint: add a linter with pre-configured lint rules + ◉ Enable prettier: add new npm scripts to facilitate consistent code formatting + ◉ Enable mocha: install mocha to assist with running tests + ◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-tslint) + ◉ Enable vscode: add VSCode config files + ◉ Enable repositories: include repository imports and RepositoryMixin + ◉ Enable services: include service-proxy imports and ServiceMixin # npm will install dependencies now Application todo-list was created in todo-list. ``` diff --git a/examples/hello-world/CHANGELOG.md b/examples/hello-world/CHANGELOG.md index 7033a33f4f13..4299a9ce2260 100644 --- a/examples/hello-world/CHANGELOG.md +++ b/examples/hello-world/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/strongloop/loopback-next/compare/@loopback/example-hello-world@1.0.8...@loopback/example-hello-world@1.1.0) (2019-01-14) + + +### Features + +* always include tslint and typescript in project dev-dependencies ([e0df285](https://github.com/strongloop/loopback-next/commit/e0df285)) + + + + + ## [1.0.8](https://github.com/strongloop/loopback-next/compare/@loopback/example-hello-world@1.0.7...@loopback/example-hello-world@1.0.8) (2018-12-20) **Note:** Version bump only for package @loopback/example-hello-world diff --git a/examples/hello-world/package.json b/examples/hello-world/package.json index e3400d24237e..7a7fe7548a2e 100644 --- a/examples/hello-world/package.json +++ b/examples/hello-world/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-hello-world", - "version": "1.0.8", + "version": "1.1.0", "description": "A simple hello-world Application using LoopBack 4", "main": "index.js", "engines": { @@ -36,14 +36,16 @@ }, "license": "MIT", "dependencies": { - "@loopback/core": "^1.1.3", - "@loopback/rest": "^1.5.1" + "@loopback/core": "^1.1.4", + "@loopback/rest": "^1.5.2" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", - "@types/node": "^10.11.2" + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", + "@types/node": "^10.11.2", + "tslint": "^5.12.0", + "typescript": "^3.2.2" }, "keywords": [ "loopback", diff --git a/examples/log-extension/CHANGELOG.md b/examples/log-extension/CHANGELOG.md index 8f9a56343b41..824255c43eda 100644 --- a/examples/log-extension/CHANGELOG.md +++ b/examples/log-extension/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/strongloop/loopback-next/compare/@loopback/example-log-extension@1.0.8...@loopback/example-log-extension@1.1.0) (2019-01-14) + + +### Features + +* always include tslint and typescript in project dev-dependencies ([e0df285](https://github.com/strongloop/loopback-next/commit/e0df285)) + + + + + ## [1.0.8](https://github.com/strongloop/loopback-next/compare/@loopback/example-log-extension@1.0.7...@loopback/example-log-extension@1.0.8) (2018-12-20) **Note:** Version bump only for package @loopback/example-log-extension diff --git a/examples/log-extension/package.json b/examples/log-extension/package.json index 37ed01daa47d..afc7404adf20 100644 --- a/examples/log-extension/package.json +++ b/examples/log-extension/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-log-extension", - "version": "1.0.8", + "version": "1.1.0", "description": "An example extension project for LoopBack 4", "main": "index.js", "engines": { @@ -41,17 +41,19 @@ }, "homepage": "https://github.com/strongloop/loopback-next/tree/master/examples/log-extension", "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/debug": "0.0.30", - "@types/node": "^10.11.2" + "@types/node": "^10.11.2", + "tslint": "^5.12.0", + "typescript": "^3.2.2" }, "dependencies": { - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", - "@loopback/openapi-v3": "^1.1.5", - "@loopback/rest": "^1.5.1", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", + "@loopback/openapi-v3": "^1.1.6", + "@loopback/rest": "^1.5.2", "chalk": "^2.3.2", "debug": "^4.0.1" } diff --git a/examples/rpc-server/CHANGELOG.md b/examples/rpc-server/CHANGELOG.md index 8fa2d9c04691..623e290c372f 100644 --- a/examples/rpc-server/CHANGELOG.md +++ b/examples/rpc-server/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/strongloop/loopback-next/compare/@loopback/example-rpc-server@1.0.6...@loopback/example-rpc-server@1.1.0) (2019-01-14) + + +### Bug Fixes + +* remove multiple application start calls ([1db1dad](https://github.com/strongloop/loopback-next/commit/1db1dad)) + + +### Features + +* always include tslint and typescript in project dev-dependencies ([e0df285](https://github.com/strongloop/loopback-next/commit/e0df285)) + + + + + ## [1.0.6](https://github.com/strongloop/loopback-next/compare/@loopback/example-rpc-server@1.0.5...@loopback/example-rpc-server@1.0.6) (2018-12-20) **Note:** Version bump only for package @loopback/example-rpc-server diff --git a/examples/rpc-server/package.json b/examples/rpc-server/package.json index 0a9fc0a81128..f6fb29d79fc9 100644 --- a/examples/rpc-server/package.json +++ b/examples/rpc-server/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-rpc-server", - "version": "1.0.6", + "version": "1.1.0", "description": "A basic RPC server using a made-up protocol.", "keywords": [ "loopback-application", @@ -38,17 +38,19 @@ "author": "", "license": "MIT", "dependencies": { - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", "express": "^4.16.3", "p-event": "^2.1.0" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/express": "^4.11.1", "@types/node": "^10.11.2", - "@types/p-event": "^1.3.0" + "@types/p-event": "^1.3.0", + "tslint": "^5.12.0", + "typescript": "^3.2.2" } } diff --git a/examples/rpc-server/src/index.ts b/examples/rpc-server/src/index.ts index 0da55061ee70..10f4e1be02db 100644 --- a/examples/rpc-server/src/index.ts +++ b/examples/rpc-server/src/index.ts @@ -13,7 +13,3 @@ export async function main(options: ApplicationConfig = {}) { console.log(`Server is running on port ${app.options.port}`); return app; } - -main().catch(err => { - console.error('Unhandled exception!'); -}); diff --git a/examples/soap-calculator/CHANGELOG.md b/examples/soap-calculator/CHANGELOG.md index 80cdfaa4230f..a0b90b61b510 100644 --- a/examples/soap-calculator/CHANGELOG.md +++ b/examples/soap-calculator/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.3.0](https://github.com/strongloop/loopback-next/compare/@loopback/example-soap-calculator@1.2.4...@loopback/example-soap-calculator@1.3.0) (2019-01-14) + + +### Features + +* always include tslint and typescript in project dev-dependencies ([e0df285](https://github.com/strongloop/loopback-next/commit/e0df285)) + + + + + ## [1.2.4](https://github.com/strongloop/loopback-next/compare/@loopback/example-soap-calculator@1.2.3...@loopback/example-soap-calculator@1.2.4) (2018-12-20) **Note:** Version bump only for package @loopback/example-soap-calculator diff --git a/examples/soap-calculator/package.json b/examples/soap-calculator/package.json index 46c6b7f86f3c..42acba29e5f9 100644 --- a/examples/soap-calculator/package.json +++ b/examples/soap-calculator/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-soap-calculator", - "version": "1.2.4", + "version": "1.3.0", "description": "Integrate a SOAP webservice with LoopBack 4", "keywords": [ "loopback", @@ -40,23 +40,25 @@ }, "license": "MIT", "dependencies": { - "@loopback/boot": "^1.0.8", - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", - "@loopback/openapi-v3": "^1.1.5", - "@loopback/repository": "^1.1.1", - "@loopback/rest": "^1.5.1", - "@loopback/rest-explorer": "^1.1.4", - "@loopback/service-proxy": "^1.0.5", + "@loopback/boot": "^1.0.9", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", + "@loopback/openapi-v3": "^1.1.6", + "@loopback/repository": "^1.1.2", + "@loopback/rest": "^1.5.2", + "@loopback/rest-explorer": "^1.1.5", + "@loopback/service-proxy": "^1.0.6", "loopback-connector-soap": "^5.0.0" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/mocha": "^5.0.0", "@types/node": "^10.11.2", "mocha": "^5.1.1", - "source-map-support": "^0.5.5" + "source-map-support": "^0.5.5", + "tslint": "^5.12.0", + "typescript": "^3.2.2" } } diff --git a/examples/todo-list/CHANGELOG.md b/examples/todo-list/CHANGELOG.md index 5fab52e25121..8082a03d9954 100644 --- a/examples/todo-list/CHANGELOG.md +++ b/examples/todo-list/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.4.0](https://github.com/strongloop/loopback-next/compare/@loopback/example-todo-list@1.3.1...@loopback/example-todo-list@1.4.0) (2019-01-14) + + +### Features + +* always include tslint and typescript in project dev-dependencies ([e0df285](https://github.com/strongloop/loopback-next/commit/e0df285)) + + + + + ## [1.3.1](https://github.com/strongloop/loopback-next/compare/@loopback/example-todo-list@1.3.0...@loopback/example-todo-list@1.3.1) (2018-12-20) **Note:** Version bump only for package @loopback/example-todo-list diff --git a/examples/todo-list/package.json b/examples/todo-list/package.json index b8e8ca871caa..5ed91550235a 100644 --- a/examples/todo-list/package.json +++ b/examples/todo-list/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-todo-list", - "version": "1.3.1", + "version": "1.4.0", "description": "Continuation of the todo example using relations in LoopBack 4.", "main": "index.js", "engines": { @@ -35,25 +35,27 @@ }, "license": "MIT", "dependencies": { - "@loopback/boot": "^1.0.8", - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", - "@loopback/openapi-v3": "^1.1.5", - "@loopback/openapi-v3-types": "^1.0.3", - "@loopback/repository": "^1.1.1", - "@loopback/rest": "^1.5.1", - "@loopback/rest-explorer": "^1.1.4", - "@loopback/service-proxy": "^1.0.5", + "@loopback/boot": "^1.0.9", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", + "@loopback/openapi-v3": "^1.1.6", + "@loopback/openapi-v3-types": "^1.0.4", + "@loopback/repository": "^1.1.2", + "@loopback/rest": "^1.5.2", + "@loopback/rest-explorer": "^1.1.5", + "@loopback/service-proxy": "^1.0.6", "loopback-connector-rest": "^3.1.1" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/http-caching-proxy": "^1.0.3", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/http-caching-proxy": "^1.0.4", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/lodash": "^4.14.109", "@types/node": "^10.11.2", - "lodash": "^4.17.10" + "lodash": "^4.17.10", + "tslint": "^5.12.0", + "typescript": "^3.2.2" }, "keywords": [ "loopback", diff --git a/examples/todo/CHANGELOG.md b/examples/todo/CHANGELOG.md index bc3d99be6b5b..71d6ea040e33 100644 --- a/examples/todo/CHANGELOG.md +++ b/examples/todo/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.4.0](https://github.com/strongloop/loopback-next/compare/@loopback/example-todo@1.3.1...@loopback/example-todo@1.4.0) (2019-01-14) + + +### Features + +* always include tslint and typescript in project dev-dependencies ([e0df285](https://github.com/strongloop/loopback-next/commit/e0df285)) + + + + + ## [1.3.1](https://github.com/strongloop/loopback-next/compare/@loopback/example-todo@1.3.0...@loopback/example-todo@1.3.1) (2018-12-20) **Note:** Version bump only for package @loopback/example-todo diff --git a/examples/todo/package.json b/examples/todo/package.json index d17332fa7451..d47830c90d2c 100644 --- a/examples/todo/package.json +++ b/examples/todo/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-todo", - "version": "1.3.1", + "version": "1.4.0", "description": "Tutorial example on how to build an application with LoopBack 4.", "main": "index.js", "engines": { @@ -35,25 +35,27 @@ }, "license": "MIT", "dependencies": { - "@loopback/boot": "^1.0.8", - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", - "@loopback/openapi-v3": "^1.1.5", - "@loopback/openapi-v3-types": "^1.0.3", - "@loopback/repository": "^1.1.1", - "@loopback/rest": "^1.5.1", - "@loopback/rest-explorer": "^1.1.4", - "@loopback/service-proxy": "^1.0.5", + "@loopback/boot": "^1.0.9", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", + "@loopback/openapi-v3": "^1.1.6", + "@loopback/openapi-v3-types": "^1.0.4", + "@loopback/repository": "^1.1.2", + "@loopback/rest": "^1.5.2", + "@loopback/rest-explorer": "^1.1.5", + "@loopback/service-proxy": "^1.0.6", "loopback-connector-rest": "^3.1.1" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/http-caching-proxy": "^1.0.3", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/http-caching-proxy": "^1.0.4", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/lodash": "^4.14.109", "@types/node": "^10.11.2", - "lodash": "^4.17.10" + "lodash": "^4.17.10", + "tslint": "^5.12.0", + "typescript": "^3.2.2" }, "keywords": [ "loopback", diff --git a/package.json b/package.json index 8c915eab0e3a..fe89b0e1020d 100644 --- a/package.json +++ b/package.json @@ -17,13 +17,16 @@ "coveralls": "^3.0.0", "cz-conventional-changelog": "^2.1.0", "husky": "^1.2.0", - "lerna": "^3.5.1" + "lerna": "^3.5.1", + "tslint": "^5.12.0", + "typescript": "^3.2.2" }, "scripts": { "postinstall": "lerna bootstrap", "prerelease": "npm run build:full && npm run mocha && npm run lint", "release": "lerna version && lerna publish from-git --yes", "update-template-deps": "node bin/update-template-deps -f", + "sync-dev-deps": "node bin/sync-dev-deps", "version": "npm run update-template-deps && npm run apidocs", "outdated": "npm outdated --depth 0 && lerna exec --no-bail \"npm outdated --depth 0\"", "apidocs": "node bin/run-lerna run build:apidocs", diff --git a/packages/authentication/CHANGELOG.md b/packages/authentication/CHANGELOG.md index 41a0679b0c72..ec0b4136d90a 100644 --- a/packages/authentication/CHANGELOG.md +++ b/packages/authentication/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.9](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@1.0.8...@loopback/authentication@1.0.9) (2019-01-14) + + +### Bug Fixes + +* optional auth metadata ([6145e54](https://github.com/strongloop/loopback-next/commit/6145e54)) + + + + + ## [1.0.8](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@1.0.7...@loopback/authentication@1.0.8) (2018-12-20) **Note:** Version bump only for package @loopback/authentication diff --git a/packages/authentication/package.json b/packages/authentication/package.json index bb32945d96fc..88dbf363510e 100644 --- a/packages/authentication/package.json +++ b/packages/authentication/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/authentication", - "version": "1.0.8", + "version": "1.0.9", "description": "A LoopBack component for authentication support.", "engines": { "node": ">=8.9" @@ -20,19 +20,19 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", - "@loopback/metadata": "^1.0.3", - "@loopback/openapi-v3": "^1.1.5", - "@loopback/rest": "^1.5.1", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", + "@loopback/metadata": "^1.0.4", + "@loopback/openapi-v3": "^1.1.6", + "@loopback/rest": "^1.5.2", "passport": "^0.4.0", "passport-strategy": "^1.0.0" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/openapi-spec-builder": "^1.0.3", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/openapi-spec-builder": "^1.0.4", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2", "@types/passport": "^0.4.4", "@types/passport-http": "^0.3.6", diff --git a/packages/authentication/src/providers/auth-metadata.provider.ts b/packages/authentication/src/providers/auth-metadata.provider.ts index 5e39bd5085c2..cdf5bad4a268 100644 --- a/packages/authentication/src/providers/auth-metadata.provider.ts +++ b/packages/authentication/src/providers/auth-metadata.provider.ts @@ -15,9 +15,9 @@ import {AuthenticationMetadata, getAuthenticateMetadata} from '../decorators'; export class AuthMetadataProvider implements Provider { constructor( - @inject(CoreBindings.CONTROLLER_CLASS) + @inject(CoreBindings.CONTROLLER_CLASS, {optional: true}) private readonly controllerClass: Constructor<{}>, - @inject(CoreBindings.CONTROLLER_METHOD_NAME) + @inject(CoreBindings.CONTROLLER_METHOD_NAME, {optional: true}) private readonly methodName: string, ) {} @@ -25,6 +25,7 @@ export class AuthMetadataProvider * @returns AuthenticationMetadata */ value(): AuthenticationMetadata | undefined { + if (!this.controllerClass || !this.methodName) return; return getAuthenticateMetadata(this.controllerClass, this.methodName); } } diff --git a/packages/authentication/test/unit/providers/auth-metadata.provider.unit.ts b/packages/authentication/test/unit/providers/auth-metadata.provider.unit.ts index 5f82a0e59169..bfe74652cc36 100644 --- a/packages/authentication/test/unit/providers/auth-metadata.provider.unit.ts +++ b/packages/authentication/test/unit/providers/auth-metadata.provider.unit.ts @@ -65,6 +65,17 @@ describe('AuthMetadataProvider', () => { ); expect(authMetadata).to.be.undefined(); }); + + it('returns undefined when the class or method is missing', async () => { + const context: Context = new Context(); + context + .bind(CoreBindings.CONTROLLER_METHOD_META) + .toProvider(AuthMetadataProvider); + const authMetadata = await context.get( + CoreBindings.CONTROLLER_METHOD_META, + ); + expect(authMetadata).to.be.undefined(); + }); }); }); diff --git a/packages/boot/CHANGELOG.md b/packages/boot/CHANGELOG.md index ad7f26d6d28b..12c762f410c1 100644 --- a/packages/boot/CHANGELOG.md +++ b/packages/boot/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.9](https://github.com/strongloop/loopback-next/compare/@loopback/boot@1.0.8...@loopback/boot@1.0.9) (2019-01-14) + + +### Bug Fixes + +* rework tslint comments disabling "no-unused-variable" rule ([a18a3d7](https://github.com/strongloop/loopback-next/commit/a18a3d7)) + + + + + ## [1.0.8](https://github.com/strongloop/loopback-next/compare/@loopback/boot@1.0.7...@loopback/boot@1.0.8) (2018-12-20) **Note:** Version bump only for package @loopback/boot diff --git a/packages/boot/package.json b/packages/boot/package.json index ca5a80d22949..a57e97336f84 100644 --- a/packages/boot/package.json +++ b/packages/boot/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/boot", - "version": "1.0.8", + "version": "1.0.9", "description": "A collection of Booters for LoopBack 4 Applications", "engines": { "node": ">=8.9" @@ -23,21 +23,21 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", - "@loopback/repository": "^1.1.1", - "@loopback/service-proxy": "^1.0.5", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", + "@loopback/repository": "^1.1.2", + "@loopback/service-proxy": "^1.0.6", "@types/debug": "0.0.30", "@types/glob": "^7.1.1", "debug": "^4.0.1", "glob": "^7.1.2" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/openapi-v3": "^1.1.5", - "@loopback/rest": "^1.5.1", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/openapi-v3": "^1.1.6", + "@loopback/rest": "^1.5.2", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, "files": [ diff --git a/packages/boot/test/fixtures/application.ts b/packages/boot/test/fixtures/application.ts index 6d129389c5c1..f1b2270285ff 100644 --- a/packages/boot/test/fixtures/application.ts +++ b/packages/boot/test/fixtures/application.ts @@ -10,7 +10,7 @@ import {ServiceMixin} from '@loopback/service-proxy'; import {BootMixin} from '../..'; // Force package.json to be copied to `dist` by `tsc` -//tslint:disable-next-line:no-unused-variable +//tslint:disable-next-line:no-unused import * as pkg from './package.json'; export class BooterApp extends BootMixin( diff --git a/packages/build/CHANGELOG.md b/packages/build/CHANGELOG.md index 1e5eb053c876..067ec22a5ea7 100644 --- a/packages/build/CHANGELOG.md +++ b/packages/build/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/strongloop/loopback-next/compare/@loopback/build@1.1.0...@loopback/build@1.2.0) (2019-01-14) + + +### Bug Fixes + +* **build:** fix path lookup in build helpers ([16311c5](https://github.com/strongloop/loopback-next/commit/16311c5)) + + +### Features + +* always include tslint and typescript in project dev-dependencies ([e0df285](https://github.com/strongloop/loopback-next/commit/e0df285)) + + + + + # [1.1.0](https://github.com/strongloop/loopback-next/compare/@loopback/build@1.0.2...@loopback/build@1.1.0) (2018-12-20) diff --git a/packages/build/bin/utils.js b/packages/build/bin/utils.js index 678952e53131..2cefc80b8c94 100644 --- a/packages/build/bin/utils.js +++ b/packages/build/bin/utils.js @@ -99,9 +99,9 @@ function getConfigFile(name, defaultName) { * @param {string} cli */ function resolveCLI(cli) { - const path = './node_modules/' + cli; + const modulePath = './node_modules/' + cli; try { - return require.resolve(path.join(getPackageDir(), path)); + return require.resolve(path.join(getPackageDir(), modulePath)); } catch (e) { return require.resolve(cli); } diff --git a/packages/build/package.json b/packages/build/package.json index c9c7d1068f90..c40d34e4dadd 100644 --- a/packages/build/package.json +++ b/packages/build/package.json @@ -5,7 +5,7 @@ "type": "git", "url": "https://github.com/strongloop/loopback-next.git" }, - "version": "1.1.0", + "version": "1.2.0", "engines": { "node": ">=8.9" }, @@ -13,7 +13,7 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/tslint-config": "^1.0.0", + "@loopback/tslint-config": "^2.0.0", "@types/mocha": "^5.0.0", "@types/node": "^10.11.2", "cross-spawn": "^6.0.5", @@ -26,8 +26,8 @@ "rimraf": "^2.6.2", "source-map-support": "^0.5.5", "strong-docs": "^4.0.0", - "tslint": "^5.9.1", - "typescript": "^3.2.1" + "tslint": "^5.12.0", + "typescript": "^3.2.2" }, "bin": { "lb-tsc": "./bin/compile-package.js", diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index ca931f6485d9..a0853502d479 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -3,6 +3,26 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.5.0](https://github.com/strongloop/loopback-next/compare/@loopback/cli@1.4.0...@loopback/cli@1.5.0) (2019-01-14) + + +### Bug Fixes + +* **cli:** add descriptions to features ([8a94f8f](https://github.com/strongloop/loopback-next/commit/8a94f8f)) +* **cli:** remove license header from test code template ([1fd35f4](https://github.com/strongloop/loopback-next/commit/1fd35f4)) + + +### Features + +* always include tslint and typescript in project dev-dependencies ([e0df285](https://github.com/strongloop/loopback-next/commit/e0df285)) +* use dependency instead of keyword to check loopback projects ([bb6ee51](https://github.com/strongloop/loopback-next/commit/bb6ee51)) +* **cli:** add property modelSettings ([e0f75ac](https://github.com/strongloop/loopback-next/commit/e0f75ac)) +* **cli:** add strict prompt to model generator ([a68d78b](https://github.com/strongloop/loopback-next/commit/a68d78b)) + + + + + # [1.4.0](https://github.com/strongloop/loopback-next/compare/@loopback/cli@1.3.0...@loopback/cli@1.4.0) (2018-12-20) diff --git a/packages/cli/generators/app/index.js b/packages/cli/generators/app/index.js index 8d8f8ec26d8f..c55b325bf19b 100644 --- a/packages/cli/generators/app/index.js +++ b/packages/cli/generators/app/index.js @@ -11,8 +11,14 @@ module.exports = class AppGenerator extends ProjectGenerator { // Note: arguments and options should be defined in the constructor. constructor(args, opts) { super(args, opts); - this.buildOptions.push('repositories'); - this.buildOptions.push('services'); + this.buildOptions.push({ + name: 'repositories', + description: 'include repository imports and RepositoryMixin', + }); + this.buildOptions.push({ + name: 'services', + description: 'include service-proxy imports and ServiceMixin', + }); } _setupGenerator() { diff --git a/packages/cli/generators/app/templates/test/acceptance/home-page.acceptance.ts.ejs b/packages/cli/generators/app/templates/test/acceptance/home-page.acceptance.ts.ejs index 57110fe619ea..c6f52659392a 100644 --- a/packages/cli/generators/app/templates/test/acceptance/home-page.acceptance.ts.ejs +++ b/packages/cli/generators/app/templates/test/acceptance/home-page.acceptance.ts.ejs @@ -1,8 +1,3 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/example-shopping -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - import {Client} from '@loopback/testlab'; import {<%= project.applicationName %>} from '../..'; import {setupApplication} from './test-helper'; diff --git a/packages/cli/generators/example/index.js b/packages/cli/generators/example/index.js index 11382f6364be..0962bffc8cd9 100644 --- a/packages/cli/generators/example/index.js +++ b/packages/cli/generators/example/index.js @@ -10,6 +10,7 @@ const chalk = require('chalk'); const downloadAndExtractExample = require('./downloader'); const path = require('path'); const utils = require('../../lib/utils'); +const fs = require('fs-extra'); const EXAMPLES = { todo: 'Tutorial example on how to build an application with LoopBack 4.', @@ -94,6 +95,10 @@ module.exports = class extends BaseGenerator { const cwd = process.cwd(); const absOutDir = await downloadAndExtractExample(this.exampleName, cwd); this.outDir = path.relative(cwd, absOutDir); + fs.rename( + `${this.outDir}/tsconfig.build.json`, + `${this.outDir}/tsconfig.json`, + ); } install() { diff --git a/packages/cli/generators/model/index.js b/packages/cli/generators/model/index.js index 2ffd46826789..d0d6f048be74 100644 --- a/packages/cli/generators/model/index.js +++ b/packages/cli/generators/model/index.js @@ -66,6 +66,7 @@ module.exports = class ModelGenerator extends ArtifactGenerator { ]; this.artifactInfo.properties = {}; + this.artifactInfo.modelSettings = {}; this.propCounter = 0; this.artifactInfo.modelDir = path.resolve( @@ -154,20 +155,46 @@ module.exports = class ModelGenerator extends ArtifactGenerator { }, ]) .then(props => { - if (typeof props.modelBaseClass === 'object') + if (typeof props.modelBaseClass === 'object') { props.modelBaseClass = props.modelBaseClass.value; + } Object.assign(this.artifactInfo, props); debug(`props after model base class prompt: ${inspect(props)}`); + return props; + }) + .catch(err => { + debug(`Error during model base class prompt: ${err}`); + return this.exit(err); + }); + } + + async promptStrictMode() { + if (this.shouldExit()) return false; + return this.prompt([ + { + name: 'allowAdditionalProperties', + message: 'Allow additional (free-form) properties?', + type: 'confirm', + default: false, + when: !this.artifactInfo.allowAdditionalProperties, + }, + ]) + .then(setting => { + Object.assign(this.artifactInfo, setting); + + if (this.artifactInfo.allowAdditionalProperties) { + Object.assign(this.artifactInfo.modelSettings, {strict: false}); + } + this.log( `Let's add a property to ${chalk.yellow( this.artifactInfo.className, )}`, ); - return props; }) .catch(err => { - debug(`Error during model base class prompt: ${err}`); + debug(`Error during model strict mode prompt: ${err}`); return this.exit(err); }); } diff --git a/packages/cli/generators/model/templates/model.ts.ejs b/packages/cli/generators/model/templates/model.ts.ejs index abbf45ed76d1..ea158fc03cbd 100644 --- a/packages/cli/generators/model/templates/model.ts.ejs +++ b/packages/cli/generators/model/templates/model.ts.ejs @@ -5,7 +5,11 @@ import {model, property} from '@loopback/repository'; import {<%= modelBaseClass %>} from '.'; <% } -%> +<% if(Object.keys(modelSettings).length > 0) { -%> +@model({settings: <%- JSON.stringify(modelSettings) %>}) +<% } else { -%> @model() +<% } -%> export class <%= className %> extends <%= modelBaseClass %> { <% Object.entries(properties).forEach(([key, val]) => { -%> @property({ @@ -18,6 +22,13 @@ export class <%= className %> extends <%= modelBaseClass %> { <%= key %><%if (!val.required) {%>?<% } %>: <%= val.tsType %>; <% }) -%> +<% if(allowAdditionalProperties) { -%> + // Define well-known properties here + + // Indexer property to allow additional data + [prop: string]: any; +<% } -%> + constructor(data?: Partial<<%= className %>>) { super(data); } diff --git a/packages/cli/generators/project/templates/package.json.ejs b/packages/cli/generators/project/templates/package.json.ejs index a7ab4202122f..c30c45f0320a 100644 --- a/packages/cli/generators/project/templates/package.json.ejs +++ b/packages/cli/generators/project/templates/package.json.ejs @@ -93,6 +93,10 @@ "@loopback/build": "<%= project.dependencies['@loopback/build'] -%>", "@loopback/testlab": "<%= project.dependencies['@loopback/testlab'] -%>", "@loopback/tslint-config": "<%= project.dependencies['@loopback/tslint-config'] -%>", - "@types/node": "<%= project.dependencies['@types/node'] -%>" + "@types/node": "<%= project.dependencies['@types/node'] -%>", + <% if (project.tslint) { -%> + "tslint": "<%= project.dependencies['tslint'] -%>", + <% } -%> + "typescript": "<%= project.dependencies['typescript'] -%>" } } diff --git a/packages/cli/lib/base-generator.js b/packages/cli/lib/base-generator.js index 8450a128f325..adb2fc3eb0fd 100644 --- a/packages/cli/lib/base-generator.js +++ b/packages/cli/lib/base-generator.js @@ -305,14 +305,14 @@ module.exports = class BaseGenerator extends Generator { /** * Checks if current directory is a LoopBack project by checking for - * keyword 'loopback' under 'keywords' attribute in package.json. - * 'keywords' is an array + * "@loopback/core" package in the dependencies section of the + * package.json. */ async checkLoopBackProject() { debug('Checking for loopback project'); if (this.shouldExit()) return false; const pkg = this.fs.readJSON(this.destinationPath('package.json')); - const key = 'loopback'; + if (!pkg) { const err = new Error( 'No package.json found in ' + @@ -323,9 +323,18 @@ module.exports = class BaseGenerator extends Generator { this.exit(err); return; } - if (!pkg.keywords || !pkg.keywords.includes(key)) { + + this.packageJson = pkg; + + const projectDeps = pkg.dependencies || {}; + const projectDevDeps = pkg.devDependencies || {}; + + const dependentPackage = '@loopback/core'; + const projectDepsNames = Object.keys(projectDeps); + + if (!projectDepsNames.includes(dependentPackage)) { const err = new Error( - 'No `loopback` keyword found in ' + + 'No `@loopback/core` package found in the "dependencies" section of ' + this.destinationPath('package.json') + '. ' + 'The command must be run in a LoopBack project.', @@ -333,10 +342,6 @@ module.exports = class BaseGenerator extends Generator { this.exit(err); return; } - this.packageJson = pkg; - - const projectDeps = pkg.dependencies || {}; - const projectDevDeps = pkg.devDependencies || {}; const cliPkg = require('../package.json'); const templateDeps = cliPkg.config.templateDependencies; diff --git a/packages/cli/lib/project-generator.js b/packages/cli/lib/project-generator.js index bb640e756438..51a2eb395df4 100644 --- a/packages/cli/lib/project-generator.js +++ b/packages/cli/lib/project-generator.js @@ -6,6 +6,7 @@ 'use strict'; const BaseGenerator = require('./base-generator'); const utils = require('./utils'); +const chalk = require('chalk'); module.exports = class ProjectGenerator extends BaseGenerator { // Note: arguments and options should be defined in the constructor. @@ -15,11 +16,24 @@ module.exports = class ProjectGenerator extends BaseGenerator { // This list gets shown to users to let them select the appropriate // build settings for their project. this.buildOptions = [ - 'tslint', - 'prettier', - 'mocha', - 'loopbackBuild', - 'vscode', + { + name: 'tslint', + description: 'add a linter with pre-configured lint rules', + }, + { + name: 'prettier', + description: + 'add new npm scripts to facilitate consistent code formatting', + }, + { + name: 'mocha', + description: 'install mocha to assist with running tests', + }, + { + name: 'loopbackBuild', + description: 'use @loopback/build helpers (e.g. lb-tslint)', + }, + {name: 'vscode', description: 'add VSCode config files'}, ]; } @@ -101,6 +115,9 @@ module.exports = class ProjectGenerator extends BaseGenerator { this.buildOptions, ); this.projectOptions.forEach(n => { + if (typeof n === 'object') { + n = n.name; + } if (this.options[n]) { this.projectInfo[n] = this.options[n]; } @@ -158,10 +175,11 @@ module.exports = class ProjectGenerator extends BaseGenerator { if (this.shouldExit()) return false; const choices = []; this.buildOptions.forEach(f => { - if (!this.options[f]) { + if (!this.options[f.name]) { choices.push({ - name: 'Enable ' + f, - key: f, + name: `Enable ${f.name}: ${chalk.gray(f.description)}`, + key: f.name, + short: `Enable ${f.name}`, checked: true, }); } @@ -177,11 +195,11 @@ module.exports = class ProjectGenerator extends BaseGenerator { }, ]; return this.prompt(prompts).then(props => { - const settings = props.settings || choices.map(c => c.name); + const settings = props.settings || choices.map(c => c.short); const features = choices.map(c => { return { key: c.key, - value: settings.indexOf(c.name) !== -1, + value: settings.indexOf(c.short) !== -1, }; }); features.forEach(f => (this.projectInfo[f.key] = f.value)); diff --git a/packages/cli/package.json b/packages/cli/package.json index 8e743ac56b00..d79d66c7f8ef 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/cli", - "version": "1.4.0", + "version": "1.5.0", "description": "Yeoman generator for LoopBack 4", "homepage": "https://github.com/strongloop/loopback-next/tree/master/packages/cli", "author": { @@ -24,9 +24,9 @@ "yeoman-generator" ], "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/ejs": "^2.6.0", "@types/node": "^10.11.2", "glob": "^7.1.2", @@ -85,36 +85,36 @@ "rimraf": "^2.6.2", "source-map-support": "^0.5.5", "strong-docs": "^4.0.0", - "tslint": "^5.9.1", - "typescript": "^3.2.1", - "@loopback/authentication": "^1.0.8", - "@loopback/boot": "^1.0.8", - "@loopback/build": "^1.1.0", - "@loopback/cli": "^1.4.0", - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", - "@loopback/metadata": "^1.0.3", - "@loopback/openapi-spec-builder": "^1.0.3", - "@loopback/openapi-v3-types": "^1.0.3", - "@loopback/openapi-v3": "^1.1.5", - "@loopback/repository-json-schema": "^1.2.5", - "@loopback/repository": "^1.1.1", - "@loopback/rest": "^1.5.1", - "@loopback/testlab": "^1.0.3", - "@loopback/docs": "^1.6.0", + "tslint": "^5.12.0", + "typescript": "^3.2.2", + "@loopback/authentication": "^1.0.9", + "@loopback/boot": "^1.0.9", + "@loopback/build": "^1.2.0", + "@loopback/cli": "^1.5.0", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", + "@loopback/metadata": "^1.0.4", + "@loopback/openapi-spec-builder": "^1.0.4", + "@loopback/openapi-v3-types": "^1.0.4", + "@loopback/openapi-v3": "^1.1.6", + "@loopback/repository-json-schema": "^1.2.6", + "@loopback/repository": "^1.1.2", + "@loopback/rest": "^1.5.2", + "@loopback/testlab": "^1.0.4", + "@loopback/docs": "^1.7.0", "glob": "^7.1.2", - "@loopback/example-hello-world": "^1.0.8", - "@loopback/example-log-extension": "^1.0.8", - "@loopback/example-rpc-server": "^1.0.6", - "@loopback/example-todo": "^1.3.1", - "@loopback/example-soap-calculator": "^1.2.4", - "@loopback/service-proxy": "^1.0.5", - "@loopback/http-caching-proxy": "^1.0.3", - "@loopback/http-server": "^1.1.2", - "@loopback/example-todo-list": "^1.3.1", + "@loopback/example-hello-world": "^1.1.0", + "@loopback/example-log-extension": "^1.1.0", + "@loopback/example-rpc-server": "^1.1.0", + "@loopback/example-todo": "^1.4.0", + "@loopback/example-soap-calculator": "^1.3.0", + "@loopback/service-proxy": "^1.0.6", + "@loopback/http-caching-proxy": "^1.0.4", + "@loopback/http-server": "^1.1.3", + "@loopback/example-todo-list": "^1.4.0", "@loopback/dist-util": "^0.4.0", - "@loopback/rest-explorer": "^1.1.4", - "@loopback/tslint-config": "^1.0.0" + "@loopback/rest-explorer": "^1.1.5", + "@loopback/tslint-config": "^2.0.0" } }, "copyright.owner": "IBM Corp.", diff --git a/packages/cli/test/acceptance/app-run.acceptance.js b/packages/cli/test/acceptance/app-run.acceptance.js index d1b4ced9f6b8..d894f30a5276 100644 --- a/packages/cli/test/acceptance/app-run.acceptance.js +++ b/packages/cli/test/acceptance/app-run.acceptance.js @@ -61,7 +61,10 @@ describe('app-generator (SLOW)', function() { }); }); - after(() => { + after(function() { + // Increase the timeout to accommodate slow CI build machines + this.timeout(30 * 1000); + process.chdir(rootDir); build.clean(['node', 'run-clean', sandbox]); process.chdir(cwd); diff --git a/packages/cli/test/integration/generators/controller.integration.js b/packages/cli/test/integration/generators/controller.integration.js index 962ef98825d2..54968fa7552d 100644 --- a/packages/cli/test/integration/generators/controller.integration.js +++ b/packages/cli/test/integration/generators/controller.integration.js @@ -56,15 +56,15 @@ describe('lb4 controller', () => { ).to.be.rejectedWith(/No package.json found in/); }); - it('does not run without the loopback keyword', () => { + it('does not run without "@loopback/core" as a dependency', () => { return expect( testUtils .executeGenerator(generator) .inDir(SANDBOX_PATH, () => - testUtils.givenLBProject(SANDBOX_PATH, {excludeKeyword: true}), + testUtils.givenLBProject(SANDBOX_PATH, {excludeLoopbackCore: true}), ) .withPrompts(basicCLIInput), - ).to.be.rejectedWith(/No `loopback` keyword found in/); + ).to.be.rejectedWith(/No `@loopback\/core` package found/); }); describe('basic controller', () => { diff --git a/packages/cli/test/integration/generators/datasource.integration.js b/packages/cli/test/integration/generators/datasource.integration.js index dad3c04815bb..8aa44663cd34 100644 --- a/packages/cli/test/integration/generators/datasource.integration.js +++ b/packages/cli/test/integration/generators/datasource.integration.js @@ -86,15 +86,15 @@ describe('lb4 datasource integration', () => { ).to.be.rejectedWith(/No package.json found in/); }); - it('does not run without the loopback keyword', () => { + it('does not run without the "@loopback/core" dependency', () => { return expect( testUtils .executeGenerator(generator) .inDir(SANDBOX_PATH, () => - testUtils.givenLBProject(SANDBOX_PATH, {excludeKeyword: true}), + testUtils.givenLBProject(SANDBOX_PATH, {excludeLoopbackCore: true}), ) .withPrompts(basicCLIInput), - ).to.be.rejectedWith(/No `loopback` keyword found in/); + ).to.be.rejectedWith(/No `@loopback\/core` package found/); }); describe('basic datasource', () => { diff --git a/packages/cli/test/integration/generators/model.integration.js b/packages/cli/test/integration/generators/model.integration.js index c0890bf36295..670d969ba1cc 100644 --- a/packages/cli/test/integration/generators/model.integration.js +++ b/packages/cli/test/integration/generators/model.integration.js @@ -49,15 +49,15 @@ describe('lb4 model integration', () => { ).to.be.rejectedWith(/No package.json found in/); }); - it('does not run without the loopback keyword', () => { + it('does not run without the "@loopback/core" dependency', () => { return expect( testUtils .executeGenerator(generator) .inDir(SANDBOX_PATH, () => - testUtils.givenLBProject(SANDBOX_PATH, {excludeKeyword: true}), + testUtils.givenLBProject(SANDBOX_PATH, {excludeLoopbackCore: true}), ) .withPrompts(basicCLIInput), - ).to.be.rejectedWith(/No `loopback` keyword found in/); + ).to.be.rejectedWith(/No `@loopback\/core` package found/); }); it('does not run if passed an invalid model from command line', () => { @@ -65,7 +65,7 @@ describe('lb4 model integration', () => { testUtils .executeGenerator(generator) .inDir(SANDBOX_PATH, () => - testUtils.givenLBProject(SANDBOX_PATH, {excludeKeyword: false}), + testUtils.givenLBProject(SANDBOX_PATH, {excludeLoopbackCore: false}), ) .withArguments('myNewModel --base InvalidModel'), ).to.be.rejectedWith(/Model was not found in/); @@ -92,6 +92,7 @@ describe('lb4 model integration', () => { name: 'test', propName: null, modelBaseClass: 'Model', + allowAdditionalProperties: false, }); assert.file(expectedModelFile); @@ -136,6 +137,35 @@ describe('lb4 model integration', () => { ); }); + it('scaffolds model with strict setting disabled', async () => { + await testUtils + .executeGenerator(generator) + .inDir(SANDBOX_PATH, () => testUtils.givenLBProject(SANDBOX_PATH)) + .withPrompts({ + name: 'test', + propName: null, + modelBaseClass: 'Entity', + allowAdditionalProperties: true, + }); + + assert.file(expectedModelFile); + assert.file(expectedIndexFile); + + assert.fileContent( + expectedModelFile, + /import {Entity, model, property} from '@loopback\/repository';/, + ); + assert.fileContent( + expectedModelFile, + /@model\({settings: {"strict":false}}\)/, + ); + assert.fileContent( + expectedModelFile, + /export class Test extends Entity {/, + ); + assert.fileContent(expectedModelFile, /\[prop: string\]: any;/); + }); + it('scaffolds correct files with args', async () => { await testUtils .executeGenerator(generator) diff --git a/packages/cli/test/integration/lib/artifact-generator.js b/packages/cli/test/integration/lib/artifact-generator.js index 98c9b21c2013..d80500b2a5e4 100644 --- a/packages/cli/test/integration/lib/artifact-generator.js +++ b/packages/cli/test/integration/lib/artifact-generator.js @@ -74,22 +74,20 @@ module.exports = function(artiGenerator) { undefined, /No package.json found/, ); + testCheckLoopBack( - 'throws an error if "keywords" key does not exist', - {foobar: 'test'}, - /No `loopback` keyword found/, - ); - testCheckLoopBack( - 'throws an error if "keywords" key does not map to an array with "loopback" as a member', - {keywords: ['foobar', 'test']}, - /No `loopback` keyword found/, + 'throws an error if "@loopback/core" is not a dependency', + {dependencies: {}}, + /No `@loopback\/core` package found/, ); testCheckLoopBack( 'throws an error if dependencies have incompatible versions', { - keywords: ['loopback'], - dependencies: {'@loopback/context': '^0.0.0'}, + dependencies: { + '@loopback/context': '^0.0.0', + '@loopback/core': '^0.0.0', + }, }, /Incompatible dependencies/, ); @@ -97,7 +95,6 @@ module.exports = function(artiGenerator) { testCheckLoopBack( 'allows */x/X for version range', { - keywords: ['loopback'], devDependencies: {'@types/node': '*'}, dependencies: { '@loopback/context': 'x.x', @@ -107,8 +104,7 @@ module.exports = function(artiGenerator) { // No expected error here ); - it('passes if "keywords" maps to "loopback"', async () => { - gen.fs.readJSON.returns({keywords: ['test', 'loopback']}); + it('passes if "@loopback/core" is a dependency', async () => { await gen.checkLoopBackProject(); }); diff --git a/packages/cli/test/integration/lib/project-generator.js b/packages/cli/test/integration/lib/project-generator.js index b3570e2e2833..ca399e61de53 100644 --- a/packages/cli/test/integration/lib/project-generator.js +++ b/packages/cli/test/integration/lib/project-generator.js @@ -249,11 +249,12 @@ module.exports = function(projGenerator, props, projectType) { assert.jsonFileContent('package.json', props); assert.fileContent([ ['package.json', '@loopback/build'], + ['package.json', '"typescript"'], + ['package.json', '"tslint"'], ['tslint.json', '@loopback/tslint-config'], ['tsconfig.json', '@loopback/build'], ]); assert.noFileContent([ - ['package.json', '"typescript"'], ['tslint.json', '"rules"'], ['tsconfig.json', '"compilerOptions"'], ]); @@ -423,6 +424,7 @@ module.exports = function(projGenerator, props, projectType) { assert.noFile(['tslint.json', 'tslint.build.json']); assert.noFileContent([ ['package.json', '@loopback/build'], + ['package.json', '"tslint"'], ['tsconfig.json', '@loopback/build'], ]); assert.fileContent([ diff --git a/packages/cli/test/test-utils.js b/packages/cli/test/test-utils.js index 866aed6793c3..014979f7c789 100644 --- a/packages/cli/test/test-utils.js +++ b/packages/cli/test/test-utils.js @@ -54,7 +54,7 @@ exports.executeGenerator = function(GeneratorOrNamespace, settings) { * * @param {string} rootDir Root directory in which to create the project * @param {Object} options - * @property {boolean} excludeKeyword Excludes the 'loopback' keyword in package.json + * @property {boolean} excludeLoopbackCore Excludes the '@loopback/core' dependency in package.json * @property {boolean} excludePackageJSON Excludes package.json * @property {boolean} excludeYoRcJSON Excludes .yo-rc.json * @property {boolean} excludeControllersDir Excludes the controllers directory @@ -70,9 +70,16 @@ exports.givenLBProject = function(rootDir, options) { options = options || {}; const sandBoxFiles = options.additionalFiles || []; - const content = {}; - if (!options.excludeKeyword) { - content.keywords = ['loopback']; + const content = { + dependencies: { + '@loopback/core': '*', + }, + }; + + // We infer if a project is loopback by checking whether its dependencies includes @loopback/core or not. + // This flag is created for testing invalid loopback projects. + if (options.excludeLoopbackCore) { + delete content.dependencies['@loopback/core']; } if (!options.excludePackageJSON) { diff --git a/packages/context/CHANGELOG.md b/packages/context/CHANGELOG.md index 8b3b56b1d059..a9e7cd779558 100644 --- a/packages/context/CHANGELOG.md +++ b/packages/context/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.4.1](https://github.com/strongloop/loopback-next/compare/@loopback/context@1.4.0...@loopback/context@1.4.1) (2019-01-14) + + +### Bug Fixes + +* rework tslint comments disabling "no-unused-variable" rule ([a18a3d7](https://github.com/strongloop/loopback-next/commit/a18a3d7)) + + + + + # [1.4.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@1.3.0...@loopback/context@1.4.0) (2018-12-20) diff --git a/packages/context/package.json b/packages/context/package.json index ba0b0cb6bc87..ab50faf62cb2 100644 --- a/packages/context/package.json +++ b/packages/context/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/context", - "version": "1.4.0", + "version": "1.4.1", "description": "LoopBack's container for Inversion of Control", "engines": { "node": ">=8.9" @@ -19,14 +19,14 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/metadata": "^1.0.3", + "@loopback/metadata": "^1.0.4", "debug": "^4.0.1", "uuid": "^3.2.1" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/bluebird": "^3.5.20", "@types/debug": "^0.0.30", "@types/node": "^10.11.2", diff --git a/packages/context/src/binding-key.ts b/packages/context/src/binding-key.ts index c271af585829..02837d5a9a1d 100644 --- a/packages/context/src/binding-key.ts +++ b/packages/context/src/binding-key.ts @@ -5,7 +5,7 @@ export type BindingAddress = string | BindingKey; -// tslint:disable-next-line:no-unused-variable +// tslint:disable-next-line:no-unused export class BindingKey { static readonly PROPERTY_SEPARATOR = '#'; diff --git a/packages/context/src/resolution-session.ts b/packages/context/src/resolution-session.ts index e72b0151f53a..0a682c02f5b8 100644 --- a/packages/context/src/resolution-session.ts +++ b/packages/context/src/resolution-session.ts @@ -13,7 +13,7 @@ const debugSession = debugModule('loopback:context:resolver:session'); const getTargetName = DecoratorFactory.getTargetName; // NOTE(bajtos) The following import is required to satisfy TypeScript compiler -// tslint:disable-next-line:no-unused-variable +// tslint:disable-next-line:no-unused import {BindingKey} from './binding-key'; /** diff --git a/packages/context/test/unit/inject.unit.ts b/packages/context/test/unit/inject.unit.ts index acbd71151afd..75c4a3dd74d2 100644 --- a/packages/context/test/unit/inject.unit.ts +++ b/packages/context/test/unit/inject.unit.ts @@ -12,7 +12,7 @@ import { describe('function argument injection', () => { it('can decorate class constructor arguments', () => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class TestClass { constructor(@inject('foo') foo: string) {} } @@ -29,7 +29,7 @@ describe('function argument injection', () => { }); it('can retrieve information about injected method arguments', () => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class TestClass { test(@inject('foo') foo: string) {} } @@ -97,7 +97,7 @@ describe('function argument injection', () => { describe('property injection', () => { it('can decorate properties', () => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class TestClass { @inject('foo') foo: string; @@ -126,7 +126,7 @@ describe('property injection', () => { it('cannot decorate static properties', () => { expect(() => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class TestClass { @inject('foo') static foo: string; @@ -136,7 +136,7 @@ describe('property injection', () => { it('cannot decorate a method', () => { expect(() => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class TestClass { @inject('bar') foo() {} diff --git a/packages/context/test/unit/resolution-session.unit.ts b/packages/context/test/unit/resolution-session.unit.ts index 02aad9f45942..73c248804666 100644 --- a/packages/context/test/unit/resolution-session.unit.ts +++ b/packages/context/test/unit/resolution-session.unit.ts @@ -8,7 +8,7 @@ import {ResolutionSession, Binding, Injection, inject} from '../..'; describe('ResolutionSession', () => { class MyController { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused constructor(@inject('b') private b: string) {} } function givenInjection(): Injection { diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 5280372339ee..3668dccdddfd 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.4](https://github.com/strongloop/loopback-next/compare/@loopback/core@1.1.3...@loopback/core@1.1.4) (2019-01-14) + +**Note:** Version bump only for package @loopback/core + + + + + ## [1.1.3](https://github.com/strongloop/loopback-next/compare/@loopback/core@1.1.2...@loopback/core@1.1.3) (2018-12-20) **Note:** Version bump only for package @loopback/core diff --git a/packages/core/package.json b/packages/core/package.json index 901c49f401fb..8680a01ac206 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/core", - "version": "1.1.3", + "version": "1.1.4", "description": "", "engines": { "node": ">=8.9" @@ -20,12 +20,12 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/context": "^1.4.0" + "@loopback/context": "^1.4.1" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, "files": [ diff --git a/packages/http-caching-proxy/CHANGELOG.md b/packages/http-caching-proxy/CHANGELOG.md index 5057f6665b17..2d1bb132b85e 100644 --- a/packages/http-caching-proxy/CHANGELOG.md +++ b/packages/http-caching-proxy/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.4](https://github.com/strongloop/loopback-next/compare/@loopback/http-caching-proxy@1.0.3...@loopback/http-caching-proxy@1.0.4) (2019-01-14) + +**Note:** Version bump only for package @loopback/http-caching-proxy + + + + + ## [1.0.3](https://github.com/strongloop/loopback-next/compare/@loopback/http-caching-proxy@1.0.2...@loopback/http-caching-proxy@1.0.3) (2018-12-20) **Note:** Version bump only for package @loopback/http-caching-proxy diff --git a/packages/http-caching-proxy/package.json b/packages/http-caching-proxy/package.json index a74c3a9f961e..b711418389dc 100644 --- a/packages/http-caching-proxy/package.json +++ b/packages/http-caching-proxy/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/http-caching-proxy", - "version": "1.0.3", + "version": "1.0.4", "description": "A caching HTTP proxy for integration tests. NOT SUITABLE FOR PRODUCTION USE!", "engines": { "node": ">=8.9" @@ -25,9 +25,9 @@ "rimraf": "^2.6.2" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/debug": "^0.0.30", "@types/node": "^10.11.2", "@types/p-event": "^1.3.0", diff --git a/packages/http-server/CHANGELOG.md b/packages/http-server/CHANGELOG.md index 3850e5d3a16f..a548f689a625 100644 --- a/packages/http-server/CHANGELOG.md +++ b/packages/http-server/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.3](https://github.com/strongloop/loopback-next/compare/@loopback/http-server@1.1.2...@loopback/http-server@1.1.3) (2019-01-14) + +**Note:** Version bump only for package @loopback/http-server + + + + + ## [1.1.2](https://github.com/strongloop/loopback-next/compare/@loopback/http-server@1.1.1...@loopback/http-server@1.1.2) (2018-12-20) **Note:** Version bump only for package @loopback/http-server diff --git a/packages/http-server/package.json b/packages/http-server/package.json index 25efc15c13ee..04c748de5dec 100644 --- a/packages/http-server/package.json +++ b/packages/http-server/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/http-server", - "version": "1.1.2", + "version": "1.1.3", "description": "A wrapper for creating HTTP/HTTPS servers", "engines": { "node": ">=8.9" @@ -20,10 +20,10 @@ "p-event": "^2.0.0" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/core": "^1.1.3", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/core": "^1.1.4", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2", "@types/p-event": "^1.3.0", "@types/request-promise-native": "^1.0.15", diff --git a/packages/metadata/CHANGELOG.md b/packages/metadata/CHANGELOG.md index 69d3722d558b..9e1c3158c4d5 100644 --- a/packages/metadata/CHANGELOG.md +++ b/packages/metadata/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.4](https://github.com/strongloop/loopback-next/compare/@loopback/metadata@1.0.3...@loopback/metadata@1.0.4) (2019-01-14) + + +### Bug Fixes + +* rework tslint comments disabling "no-unused-variable" rule ([a18a3d7](https://github.com/strongloop/loopback-next/commit/a18a3d7)) + + + + + ## [1.0.3](https://github.com/strongloop/loopback-next/compare/@loopback/metadata@1.0.2...@loopback/metadata@1.0.3) (2018-12-20) **Note:** Version bump only for package @loopback/metadata diff --git a/packages/metadata/package.json b/packages/metadata/package.json index 510d7e37a007..03656db39fd6 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/metadata", - "version": "1.0.3", + "version": "1.0.4", "description": "LoopBack's metadata utilities for reflection and decoration", "engines": { "node": ">=8.9" @@ -24,9 +24,9 @@ "reflect-metadata": "^0.1.10" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/debug": "^0.0.30", "@types/lodash": "^4.14.106", "@types/node": "^10.11.2" diff --git a/packages/metadata/src/types.ts b/packages/metadata/src/types.ts index aa66d5f1235f..073e287830ed 100644 --- a/packages/metadata/src/types.ts +++ b/packages/metadata/src/types.ts @@ -17,6 +17,7 @@ export type DecoratorType = * @typeparam T Type of the metadata value * @typeparam D Type of the decorator */ +// tslint:disable-next-line:no-unused export class MetadataAccessor { private constructor(public readonly key: string) {} diff --git a/packages/metadata/test/unit/decorator-factory.unit.ts b/packages/metadata/test/unit/decorator-factory.unit.ts index b5a9cee90369..dc0755554c2a 100644 --- a/packages/metadata/test/unit/decorator-factory.unit.ts +++ b/packages/metadata/test/unit/decorator-factory.unit.ts @@ -113,7 +113,7 @@ describe('ClassDecoratorFactory', () => { expect(() => { @classDecorator({x: 1}) @classDecorator({y: 2}) - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class MyController {} }).to.throw( /Decorator cannot be applied more than once on class MyController/, @@ -352,7 +352,7 @@ describe('PropertyDecoratorFactory', () => { it('throws if applied more than once on the same property', () => { expect(() => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class MyController { @propertyDecorator({x: 1}) @propertyDecorator({y: 2}) @@ -400,7 +400,7 @@ describe('PropertyDecoratorFactory for static properties', () => { it('throws if applied more than once on the same static property', () => { expect(() => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class MyController { @propertyDecorator({x: 1}) @propertyDecorator({y: 2}) @@ -448,7 +448,7 @@ describe('MethodDecoratorFactory', () => { it('throws if applied more than once on the same method', () => { expect(() => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class MyController { @methodDecorator({x: 1}) @methodDecorator({y: 2}) @@ -496,7 +496,7 @@ describe('MethodDecoratorFactory for static methods', () => { it('throws if applied more than once on the same static method', () => { expect(() => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class MyController { @methodDecorator({x: 1}) @methodDecorator({y: 2}) @@ -545,7 +545,7 @@ describe('ParameterDecoratorFactory', () => { it('throws if applied more than once on the same parameter', () => { expect(() => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class MyController { myMethod( @parameterDecorator({x: 1}) @@ -634,7 +634,7 @@ describe('ParameterDecoratorFactory for a static method', () => { it('throws if applied more than once on the same parameter', () => { expect(() => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class MyController { static myMethod( @parameterDecorator({x: 1}) @@ -695,7 +695,7 @@ describe('MethodParameterDecoratorFactory with invalid decorations', () => { it('reports error if the # of decorations exceeeds the # of params', () => { expect(() => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class MyController { @methodParameterDecorator({x: 1}) // Causing error @methodParameterDecorator({x: 2}) // For a diff --git a/packages/openapi-spec-builder/CHANGELOG.md b/packages/openapi-spec-builder/CHANGELOG.md index 54c179933e59..c67f2d2d40e7 100644 --- a/packages/openapi-spec-builder/CHANGELOG.md +++ b/packages/openapi-spec-builder/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.4](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-spec-builder@1.0.3...@loopback/openapi-spec-builder@1.0.4) (2019-01-14) + +**Note:** Version bump only for package @loopback/openapi-spec-builder + + + + + ## [1.0.3](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-spec-builder@1.0.2...@loopback/openapi-spec-builder@1.0.3) (2018-12-20) **Note:** Version bump only for package @loopback/openapi-spec-builder diff --git a/packages/openapi-spec-builder/package.json b/packages/openapi-spec-builder/package.json index ca55db7c273d..366d1295fe80 100644 --- a/packages/openapi-spec-builder/package.json +++ b/packages/openapi-spec-builder/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/openapi-spec-builder", - "version": "1.0.3", + "version": "1.0.4", "description": "Make it easy to create OpenAPI (Swagger) specification documents in your tests using the builder pattern.", "engines": { "node": ">=8.9" @@ -22,11 +22,11 @@ "Testing" ], "dependencies": { - "@loopback/openapi-v3-types": "^1.0.3" + "@loopback/openapi-v3-types": "^1.0.4" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, "files": [ diff --git a/packages/openapi-v3-types/CHANGELOG.md b/packages/openapi-v3-types/CHANGELOG.md index 8a17735179ee..fc350431d5da 100644 --- a/packages/openapi-v3-types/CHANGELOG.md +++ b/packages/openapi-v3-types/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.4](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3-types@1.0.3...@loopback/openapi-v3-types@1.0.4) (2019-01-14) + + +### Bug Fixes + +* rework tslint comments disabling "no-unused-variable" rule ([a18a3d7](https://github.com/strongloop/loopback-next/commit/a18a3d7)) + + + + + ## [1.0.3](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3-types@1.0.2...@loopback/openapi-v3-types@1.0.3) (2018-12-20) **Note:** Version bump only for package @loopback/openapi-v3-types diff --git a/packages/openapi-v3-types/package.json b/packages/openapi-v3-types/package.json index d8d0ad566ea6..123b99fc1604 100644 --- a/packages/openapi-v3-types/package.json +++ b/packages/openapi-v3-types/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/openapi-v3-types", - "version": "1.0.3", + "version": "1.0.4", "description": "TypeScript type definitions for OpenAPI Specifications.", "engines": { "node": ">=8.9" @@ -9,9 +9,9 @@ "openapi3-ts": "^1.0.0" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, "scripts": { diff --git a/packages/openapi-v3-types/test/unit/openapi-v3-spec-types.unit.ts b/packages/openapi-v3-types/test/unit/openapi-v3-spec-types.unit.ts index 73848d1461ef..32038995165d 100644 --- a/packages/openapi-v3-types/test/unit/openapi-v3-spec-types.unit.ts +++ b/packages/openapi-v3-types/test/unit/openapi-v3-spec-types.unit.ts @@ -57,7 +57,7 @@ describe('openapi-v3-types unit tests', () => { * original OAS 3 definition. (Though some interfaces allow for extensibility). */ - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class TestObject implements ExampleObject { summary: 'test object'; description: 'test object'; @@ -66,12 +66,12 @@ describe('openapi-v3-types unit tests', () => { randomProperty: 'extension value'; } - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class ReferenceTestObject implements ReferenceObject { $ref: '#def/reference-object'; } - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class DiscriminatorTestObject implements DiscriminatorObject { propertyName: 'test'; mapping: { @@ -79,7 +79,7 @@ describe('openapi-v3-types unit tests', () => { }; } - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class XMLTestObject implements XmlObject { name: 'test'; namespace: 'test'; @@ -88,13 +88,13 @@ describe('openapi-v3-types unit tests', () => { wrapped: false; } - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class TestExternalDocumentationObject implements ExternalDocumentationObject { url: 'https://test.com/test.html'; } - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class TestISpecificationExtension implements ISpecificationExtension { test: 'test'; } diff --git a/packages/openapi-v3/CHANGELOG.md b/packages/openapi-v3/CHANGELOG.md index c1193821aace..ec1efeaa6394 100644 --- a/packages/openapi-v3/CHANGELOG.md +++ b/packages/openapi-v3/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.6](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.1.5...@loopback/openapi-v3@1.1.6) (2019-01-14) + + +### Bug Fixes + +* rework tslint comments disabling "no-unused-variable" rule ([a18a3d7](https://github.com/strongloop/loopback-next/commit/a18a3d7)) + + + + + ## [1.1.5](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.1.4...@loopback/openapi-v3@1.1.5) (2018-12-20) **Note:** Version bump only for package @loopback/openapi-v3 diff --git a/packages/openapi-v3/package.json b/packages/openapi-v3/package.json index e437c615318b..85c10c1e359f 100644 --- a/packages/openapi-v3/package.json +++ b/packages/openapi-v3/package.json @@ -1,16 +1,16 @@ { "name": "@loopback/openapi-v3", - "version": "1.1.5", + "version": "1.1.6", "description": "Processes openapi v3 related metadata", "engines": { "node": ">=8.9" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/openapi-spec-builder": "^1.0.3", - "@loopback/repository": "^1.1.1", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/openapi-spec-builder": "^1.0.4", + "@loopback/repository": "^1.1.2", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/debug": "0.0.30", "@types/lodash": "^4.14.106", "@types/node": "^10.11.2" @@ -49,9 +49,9 @@ "url": "https://github.com/strongloop/loopback-next.git" }, "dependencies": { - "@loopback/context": "^1.4.0", - "@loopback/openapi-v3-types": "^1.0.3", - "@loopback/repository-json-schema": "^1.2.5", + "@loopback/context": "^1.4.1", + "@loopback/openapi-v3-types": "^1.0.4", + "@loopback/repository-json-schema": "^1.2.6", "debug": "^4.0.1", "lodash": "^4.17.5" } diff --git a/packages/openapi-v3/test/unit/decorators/param/param.decorator.unit.ts b/packages/openapi-v3/test/unit/decorators/param/param.decorator.unit.ts index 8d0a8e1aca43..0f273b4a6ea2 100644 --- a/packages/openapi-v3/test/unit/decorators/param/param.decorator.unit.ts +++ b/packages/openapi-v3/test/unit/decorators/param/param.decorator.unit.ts @@ -164,7 +164,7 @@ describe('Routing metadata for parameters', () => { it('reports error if an array parameter type is not Array', () => { expect.throws( () => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class MyController { @get('/greet') greet( diff --git a/packages/repository-json-schema/CHANGELOG.md b/packages/repository-json-schema/CHANGELOG.md index ecd33a483f11..b6dce17d02ea 100644 --- a/packages/repository-json-schema/CHANGELOG.md +++ b/packages/repository-json-schema/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.2.6](https://github.com/strongloop/loopback-next/compare/@loopback/repository-json-schema@1.2.5...@loopback/repository-json-schema@1.2.6) (2019-01-14) + + +### Bug Fixes + +* rework tslint comments disabling "no-unused-variable" rule ([a18a3d7](https://github.com/strongloop/loopback-next/commit/a18a3d7)) + + + + + ## [1.2.5](https://github.com/strongloop/loopback-next/compare/@loopback/repository-json-schema@1.2.4...@loopback/repository-json-schema@1.2.5) (2018-12-20) **Note:** Version bump only for package @loopback/repository-json-schema diff --git a/packages/repository-json-schema/package.json b/packages/repository-json-schema/package.json index 5f19b80cc729..6706f68d6b3a 100644 --- a/packages/repository-json-schema/package.json +++ b/packages/repository-json-schema/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/repository-json-schema", - "version": "1.2.5", + "version": "1.2.6", "description": "Converts TS classes into JSON Schemas using TypeScript's reflection API", "engines": { "node": ">=8.9" @@ -24,15 +24,15 @@ "access": "public" }, "dependencies": { - "@loopback/context": "^1.4.0", - "@loopback/metadata": "^1.0.3", - "@loopback/repository": "^1.1.1", + "@loopback/context": "^1.4.1", + "@loopback/metadata": "^1.0.4", + "@loopback/repository": "^1.1.2", "@types/json-schema": "^7.0.1" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2", "ajv": "^6.5.0" }, diff --git a/packages/repository-json-schema/test/unit/json-schema.unit.ts b/packages/repository-json-schema/test/unit/json-schema.unit.ts index 32bb1dcd823e..e4547d144603 100644 --- a/packages/repository-json-schema/test/unit/json-schema.unit.ts +++ b/packages/repository-json-schema/test/unit/json-schema.unit.ts @@ -15,7 +15,7 @@ describe('JSON Schema type', () => { * Inspired by https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/json-schema/json-schema-tests.ts */ - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused const testSchema: JsonSchema = { $id: 'test', $ref: 'test/sub', diff --git a/packages/repository/CHANGELOG.md b/packages/repository/CHANGELOG.md index 689f08298933..a1f4ec1e2bf0 100644 --- a/packages/repository/CHANGELOG.md +++ b/packages/repository/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.2](https://github.com/strongloop/loopback-next/compare/@loopback/repository@1.1.1...@loopback/repository@1.1.2) (2019-01-14) + + +### Bug Fixes + +* add nin operator to query typing and builder ([#2215](https://github.com/strongloop/loopback-next/issues/2215)) ([c38bd4e](https://github.com/strongloop/loopback-next/commit/c38bd4e)) +* rework tslint comments disabling "no-unused-variable" rule ([a18a3d7](https://github.com/strongloop/loopback-next/commit/a18a3d7)) + + + + + ## [1.1.1](https://github.com/strongloop/loopback-next/compare/@loopback/repository@1.1.0...@loopback/repository@1.1.1) (2018-12-20) **Note:** Version bump only for package @loopback/repository diff --git a/packages/repository/examples/controllers/customer-with-constructor-di.controller.ts b/packages/repository/examples/controllers/customer-with-constructor-di.controller.ts index 64d09d162b8a..2f60e0f677aa 100644 --- a/packages/repository/examples/controllers/customer-with-constructor-di.controller.ts +++ b/packages/repository/examples/controllers/customer-with-constructor-di.controller.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -// tslint:disable:no-unused-variable +// tslint:disable:no-unused import {EntityCrudRepository, repository} from '../..'; import {Customer} from '../models/customer.model'; @@ -15,7 +15,7 @@ import {Customer} from '../models/customer.model'; export class CustomerController { constructor( // Use constructor dependency injection - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused @repository('Customer', 'mongodbDataSource') private _repository: EntityCrudRepository, ) {} diff --git a/packages/repository/examples/controllers/customer-with-property-di.controller.ts b/packages/repository/examples/controllers/customer-with-property-di.controller.ts index 7dc2f9f9431c..01067217a5bf 100644 --- a/packages/repository/examples/controllers/customer-with-property-di.controller.ts +++ b/packages/repository/examples/controllers/customer-with-property-di.controller.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -// tslint:disable:no-unused-variable +// tslint:disable:no-unused import {EntityCrudRepository, repository} from '../..'; import {Customer} from '../models/customer.model'; diff --git a/packages/repository/examples/models/order.model.ts b/packages/repository/examples/models/order.model.ts index 47a72c71cba9..bf48dc85196c 100644 --- a/packages/repository/examples/models/order.model.ts +++ b/packages/repository/examples/models/order.model.ts @@ -6,7 +6,7 @@ import {belongsTo, Entity, model, property} from '../..'; import {Customer} from './customer.model'; -// tslint:disable:no-unused-variable +// tslint:disable:no-unused @model() class Order extends Entity { diff --git a/packages/repository/package.json b/packages/repository/package.json index 10fde6df8ec0..4677f15a9e80 100644 --- a/packages/repository/package.json +++ b/packages/repository/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/repository", - "version": "1.1.1", + "version": "1.1.2", "description": "Repository based persistence for LoopBack 4", "engines": { "node": ">=8.9" @@ -19,15 +19,15 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/lodash": "^4.14.108", "@types/node": "^10.11.2" }, "dependencies": { - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", "@types/debug": "0.0.30", "debug": "^4.0.1", "lodash": "^4.17.10", diff --git a/packages/repository/src/query.ts b/packages/repository/src/query.ts index a0209233929c..99cb3a0d7e03 100644 --- a/packages/repository/src/query.ts +++ b/packages/repository/src/query.ts @@ -30,6 +30,7 @@ export type Operators = | 'lt' // < | 'lte' // <= | 'inq' // IN + | 'nin' // NOT IN | 'between' // BETWEEN [val1, val2] | 'exists' | 'and' // AND @@ -51,6 +52,7 @@ export type PredicateComparison = { lt?: PT; lte?: PT; inq?: PT[]; + nin?: PT[]; between?: [PT, PT]; exists?: boolean; like?: PT; @@ -373,6 +375,17 @@ export class WhereBuilder { return this.add(w); } + /** + * Add a `nin` condition + * @param key Property name + * @param val An array of property values + */ + nin>(key: K, val: MT[K][]): this { + const w: Where = {}; + w[key] = {nin: val}; + return this.add(w); + } + /** * Add a `between` condition * @param key Property name diff --git a/packages/repository/src/repositories/repository.ts b/packages/repository/src/repositories/repository.ts index 5077bf52145a..31a24a132c9b 100644 --- a/packages/repository/src/repositories/repository.ts +++ b/packages/repository/src/repositories/repository.ts @@ -18,7 +18,7 @@ import {CrudConnector} from '../connectors'; import {Filter, Where} from '../query'; import {EntityNotFoundError} from '../errors'; -// tslint:disable:no-unused-variable +// tslint:disable:no-unused export interface Repository {} @@ -333,7 +333,7 @@ export class CrudRepositoryImpl ); } else { // FIXME: populate inst with all properties - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused const inst = data; const where = this.entityClass.buildWhereForId(id); const result = await this.updateAll(data, where, options); diff --git a/packages/repository/test/acceptance/has-one.relation.acceptance.ts b/packages/repository/test/acceptance/has-one.relation.acceptance.ts index 18313c6d324e..0343a41443e4 100644 --- a/packages/repository/test/acceptance/has-one.relation.acceptance.ts +++ b/packages/repository/test/acceptance/has-one.relation.acceptance.ts @@ -5,7 +5,6 @@ import {Application} from '@loopback/core'; import {expect, toJSON} from '@loopback/testlab'; -import * as _ from 'lodash'; import { ApplicationWithRepositories, juggler, diff --git a/packages/repository/test/unit/decorator/model-and-relation.decorator.unit.ts b/packages/repository/test/unit/decorator/model-and-relation.decorator.unit.ts index 31dfe10f8ba7..ea6a2e678289 100644 --- a/packages/repository/test/unit/decorator/model-and-relation.decorator.unit.ts +++ b/packages/repository/test/unit/decorator/model-and-relation.decorator.unit.ts @@ -351,7 +351,7 @@ describe('model decorator', () => { it('throws when @property.array is used on a non-array property', () => { expect.throws( () => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class Oops { @property.array(Product) product: Product; diff --git a/packages/repository/test/unit/decorator/relation.decorator.unit.ts b/packages/repository/test/unit/decorator/relation.decorator.unit.ts index e30f19e5fd2d..ec7cb9cf3a18 100644 --- a/packages/repository/test/unit/decorator/relation.decorator.unit.ts +++ b/packages/repository/test/unit/decorator/relation.decorator.unit.ts @@ -115,7 +115,7 @@ describe('relation decorator', () => { province: string; } - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class AddressBook extends Entity { id: number; @property.array(Entity) diff --git a/packages/repository/test/unit/decorator/repository.decorator.unit.ts b/packages/repository/test/unit/decorator/repository.decorator.unit.ts index 84d91949386e..fa05cb4c0ac1 100644 --- a/packages/repository/test/unit/decorator/repository.decorator.unit.ts +++ b/packages/repository/test/unit/decorator/repository.decorator.unit.ts @@ -80,7 +80,7 @@ describe('repository decorator', () => { it('throws not implemented for class-level @repository', () => { expect(() => { @repository('noteRepo') - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class Controller1 {} }).to.throw(/not implemented/); }); diff --git a/packages/repository/test/unit/model/model.unit.ts b/packages/repository/test/unit/model/model.unit.ts index 59f43be780bd..3680fbfe4125 100644 --- a/packages/repository/test/unit/model/model.unit.ts +++ b/packages/repository/test/unit/model/model.unit.ts @@ -96,7 +96,7 @@ describe('model', () => { } } - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused class User extends Entity { static definition = userDef; id: string; diff --git a/packages/repository/test/unit/query/query-builder.unit.ts b/packages/repository/test/unit/query/query-builder.unit.ts index 5700c9167921..3026b9a1245f 100644 --- a/packages/repository/test/unit/query/query-builder.unit.ts +++ b/packages/repository/test/unit/query/query-builder.unit.ts @@ -44,6 +44,15 @@ describe('WhereBuilder', () => { expect(where).to.eql({x: {inq: [1, 2, 3]}, y: {inq: ['a', 'b']}}); }); + it('builds where object with nin', () => { + const whereBuilder = new WhereBuilder(); + const where = whereBuilder + .nin('x', [1, 2, 3]) + .nin('y', ['a', 'b']) + .build(); + expect(where).to.eql({x: {nin: [1, 2, 3]}, y: {nin: ['a', 'b']}}); + }); + it('builds where object with neq', () => { const whereBuilder = new WhereBuilder(); const where = whereBuilder.neq('x', 1).build(); diff --git a/packages/repository/test/unit/repositories/relation.repository.unit.ts b/packages/repository/test/unit/repositories/relation.repository.unit.ts index 81a86610ee3f..ea242f63c22d 100644 --- a/packages/repository/test/unit/repositories/relation.repository.unit.ts +++ b/packages/repository/test/unit/repositories/relation.repository.unit.ts @@ -17,7 +17,6 @@ import { DefaultCrudRepository, DefaultHasManyRepository, Entity, - EntityCrudRepository, Filter, HasManyRepository, juggler, @@ -36,12 +35,9 @@ describe('relation repository', () => { * interface. The TS Compiler will complain if the interface changes. */ - // tslint:disable-next-line:no-unused-variable - class testHasManyEntityCrudRepository< - T extends Entity, - ID, - TargetRepository extends EntityCrudRepository - > implements HasManyRepository { + // tslint:disable-next-line:no-unused + class testHasManyEntityCrudRepository + implements HasManyRepository { create( targetModelData: DataObject, options?: AnyObject | undefined, diff --git a/packages/rest-explorer/CHANGELOG.md b/packages/rest-explorer/CHANGELOG.md index 59b470e35161..b51ef78f92eb 100644 --- a/packages/rest-explorer/CHANGELOG.md +++ b/packages/rest-explorer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.5](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@1.1.4...@loopback/rest-explorer@1.1.5) (2019-01-14) + +**Note:** Version bump only for package @loopback/rest-explorer + + + + + ## [1.1.4](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@1.1.3...@loopback/rest-explorer@1.1.4) (2018-12-20) **Note:** Version bump only for package @loopback/rest-explorer diff --git a/packages/rest-explorer/package.json b/packages/rest-explorer/package.json index 219b714af18d..1143fe753d4c 100644 --- a/packages/rest-explorer/package.json +++ b/packages/rest-explorer/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/rest-explorer", - "version": "1.1.4", + "version": "1.1.5", "description": "LoopBack's API Explorer", "engines": { "node": ">=8.9" @@ -17,16 +17,16 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", - "@loopback/rest": "^1.5.1", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", + "@loopback/rest": "^1.5.2", "ejs": "^2.6.1", "swagger-ui-dist": "^3.20.0" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/ejs": "^2.6.0", "@types/node": "^10.1.1" }, diff --git a/packages/rest/CHANGELOG.md b/packages/rest/CHANGELOG.md index bfd085110558..ee0498187ec9 100644 --- a/packages/rest/CHANGELOG.md +++ b/packages/rest/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.5.2](https://github.com/strongloop/loopback-next/compare/@loopback/rest@1.5.1...@loopback/rest@1.5.2) (2019-01-14) + + +### Bug Fixes + +* rework tslint comments disabling "no-unused-variable" rule ([a18a3d7](https://github.com/strongloop/loopback-next/commit/a18a3d7)) + + + + + ## [1.5.1](https://github.com/strongloop/loopback-next/compare/@loopback/rest@1.5.0...@loopback/rest@1.5.1) (2018-12-20) **Note:** Version bump only for package @loopback/rest diff --git a/packages/rest/package.json b/packages/rest/package.json index 3f896e62dadc..96176166964c 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/rest", - "version": "1.5.1", + "version": "1.5.2", "description": "", "engines": { "node": ">=8.9" @@ -20,11 +20,11 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", - "@loopback/http-server": "^1.1.2", - "@loopback/openapi-v3": "^1.1.5", - "@loopback/openapi-v3-types": "^1.0.3", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", + "@loopback/http-server": "^1.1.3", + "@loopback/openapi-v3": "^1.1.6", + "@loopback/openapi-v3-types": "^1.0.4", "@types/body-parser": "^1.17.0", "@types/cors": "^2.8.3", "@types/express": "^4.11.1", @@ -49,11 +49,11 @@ "validator": "^10.4.0" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/openapi-spec-builder": "^1.0.3", - "@loopback/repository": "^1.1.1", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/openapi-spec-builder": "^1.0.4", + "@loopback/repository": "^1.1.2", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/debug": "0.0.30", "@types/js-yaml": "^3.11.1", "@types/lodash": "^4.14.106", diff --git a/packages/rest/test/acceptance/bootstrapping/rest.acceptance.ts b/packages/rest/test/acceptance/bootstrapping/rest.acceptance.ts index d5f71f2fa194..818f880586ab 100644 --- a/packages/rest/test/acceptance/bootstrapping/rest.acceptance.ts +++ b/packages/rest/test/acceptance/bootstrapping/rest.acceptance.ts @@ -76,7 +76,7 @@ async function startServerCheck(app: Application) { } function sequenceHandler( - {request, response}: RequestContext, + {response}: RequestContext, sequence: DefaultSequence, ) { sequence.send(response, 'hello world'); diff --git a/packages/rest/test/acceptance/routing/routing.acceptance.ts b/packages/rest/test/acceptance/routing/routing.acceptance.ts index dc75a3c6bd85..407bad662f12 100644 --- a/packages/rest/test/acceptance/routing/routing.acceptance.ts +++ b/packages/rest/test/acceptance/routing/routing.acceptance.ts @@ -692,7 +692,7 @@ describe('Routing', () => { it('provides httpHandler compatible with HTTP server API', async () => { const app = new RestApplication(); - app.handler(({request, response}, sequence) => response.end('hello')); + app.handler(({response}, sequence) => response.end('hello')); await createClientForHandler(app.requestHandler) .get('/') diff --git a/packages/rest/test/acceptance/sequence/sequence.acceptance.ts b/packages/rest/test/acceptance/sequence/sequence.acceptance.ts index bf74fe666992..ae94a70fddd2 100644 --- a/packages/rest/test/acceptance/sequence/sequence.acceptance.ts +++ b/packages/rest/test/acceptance/sequence/sequence.acceptance.ts @@ -44,7 +44,7 @@ describe('Sequence', () => { }); it('allows users to define a custom sequence as a function', () => { - server.handler(({request, response}, sequence) => { + server.handler(({response}, sequence) => { sequence.send(response, 'hello world'); }); return whenIRequest() @@ -98,7 +98,7 @@ describe('Sequence', () => { class MySequence implements SequenceHandler { constructor(@inject(SequenceActions.SEND) protected send: Send) {} - async handle({request, response}: RequestContext) { + async handle({response}: RequestContext) { this.send(response, 'MySequence was invoked.'); } } diff --git a/packages/rest/test/unit/re-export.unit.ts b/packages/rest/test/unit/re-export.unit.ts index 0a5395e7db1e..69da8f13fef3 100644 --- a/packages/rest/test/unit/re-export.unit.ts +++ b/packages/rest/test/unit/re-export.unit.ts @@ -6,7 +6,7 @@ import {get} from '../..'; describe('re-export controller decorators', () => { it('exports functions from @loopback/openapi-v3', async () => { - /* tslint:disable-next-line:no-unused-variable */ + /* tslint:disable-next-line:no-unused */ class Test { // Make sure the decorators are exported @get('/test') diff --git a/packages/rest/test/unit/rest.application/rest.application.unit.ts b/packages/rest/test/unit/rest.application/rest.application.unit.ts index 028387fdce80..b6789ec24a2f 100644 --- a/packages/rest/test/unit/rest.application/rest.application.unit.ts +++ b/packages/rest/test/unit/rest.application/rest.application.unit.ts @@ -14,7 +14,7 @@ import {expect} from '@loopback/testlab'; describe('RestApplication', () => { describe('throws', () => { it('when attempting to bind another server', () => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused const app = new RestApplication(); expect.throws( () => { @@ -26,7 +26,7 @@ describe('RestApplication', () => { }); it('when attempting to bind an array of servers', () => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused const app = new RestApplication(); expect.throws( () => { @@ -41,7 +41,7 @@ describe('RestApplication', () => { class OtherRestComponent extends RestComponent {} expect.throws( () => { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused const app = new RestApplication(); app.component(RestComponent); app.component(OtherRestComponent); diff --git a/packages/service-proxy/CHANGELOG.md b/packages/service-proxy/CHANGELOG.md index 25921c6047ef..ba7747117ccc 100644 --- a/packages/service-proxy/CHANGELOG.md +++ b/packages/service-proxy/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.6](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@1.0.5...@loopback/service-proxy@1.0.6) (2019-01-14) + +**Note:** Version bump only for package @loopback/service-proxy + + + + + ## [1.0.5](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@1.0.4...@loopback/service-proxy@1.0.5) (2018-12-20) **Note:** Version bump only for package @loopback/service-proxy diff --git a/packages/service-proxy/package.json b/packages/service-proxy/package.json index c13c35d5ccbf..8730bcd17ebb 100644 --- a/packages/service-proxy/package.json +++ b/packages/service-proxy/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/service-proxy", - "version": "1.0.5", + "version": "1.0.6", "description": "Service integration for LoopBack 4", "engines": { "node": ">=8.9" @@ -24,14 +24,14 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/testlab": "^1.0.3", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/testlab": "^1.0.4", + "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, "dependencies": { - "@loopback/context": "^1.4.0", - "@loopback/core": "^1.1.3", + "@loopback/context": "^1.4.1", + "@loopback/core": "^1.1.4", "loopback-datasource-juggler": "^4.0.0" }, "files": [ diff --git a/packages/testlab/CHANGELOG.md b/packages/testlab/CHANGELOG.md index f73f83aeb469..d1115159010a 100644 --- a/packages/testlab/CHANGELOG.md +++ b/packages/testlab/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.4](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@1.0.3...@loopback/testlab@1.0.4) (2019-01-14) + + +### Bug Fixes + +* rework tslint comments disabling "no-unused-variable" rule ([a18a3d7](https://github.com/strongloop/loopback-next/commit/a18a3d7)) +* **testlab:** add api docs during build ([5b5018d](https://github.com/strongloop/loopback-next/commit/5b5018d)) + + + + + ## [1.0.3](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@1.0.2...@loopback/testlab@1.0.3) (2018-12-20) **Note:** Version bump only for package @loopback/testlab diff --git a/packages/testlab/docs.json b/packages/testlab/docs.json new file mode 100644 index 000000000000..8dc032ac89a3 --- /dev/null +++ b/packages/testlab/docs.json @@ -0,0 +1,7 @@ +{ + "content": [ + "index.ts", + "src/*.ts" + ], + "codeSectionDepth": 4 +} diff --git a/packages/testlab/package.json b/packages/testlab/package.json index 825b485705ba..a5499f193ace 100644 --- a/packages/testlab/package.json +++ b/packages/testlab/package.json @@ -1,12 +1,13 @@ { "name": "@loopback/testlab", - "version": "1.0.3", + "version": "1.0.4", "description": "A collection of test utilities we use to write LoopBack tests.", "engines": { "node": ">=8.9" }, "scripts": { "build": "lb-tsc es2017 --outDir dist", + "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-testlab*.tgz dist package api-docs", "pretest": "npm run build", "test": "lb-mocha \"dist/test\"", @@ -16,22 +17,22 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@types/express": "^4.11.1", - "@types/fs-extra": "^5.0.1", - "@types/shot": "^3.4.0", - "@types/sinon": "^5.0.2", - "@types/supertest": "^2.0.4", - "express": "^4.16.3", - "fs-extra": "^7.0.0", - "oas-validator": "^1.1.9", - "shot": "^4.0.5", - "should": "^13.2.1", - "sinon": "^6.3.4", - "supertest": "^3.0.0" + "@types/express": "^4.16.0", + "@types/fs-extra": "^5.0.4", + "@types/shot": "^4.0.0", + "@types/sinon": "^7.0.2", + "@types/supertest": "^2.0.7", + "express": "^4.16.4", + "fs-extra": "^7.0.1", + "oas-validator": "^2.0.0", + "shot": "^4.0.7", + "should": "^13.2.3", + "sinon": "^7.2.2", + "supertest": "^3.3.0" }, "devDependencies": { - "@loopback/build": "^1.1.0", - "@loopback/tslint-config": "^1.0.0", + "@loopback/build": "^1.2.0", + "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, "files": [ diff --git a/packages/testlab/test/unit/to-json.test.ts b/packages/testlab/test/unit/to-json.test.ts index ab1e8d1838f9..726dd0ef6574 100644 --- a/packages/testlab/test/unit/to-json.test.ts +++ b/packages/testlab/test/unit/to-json.test.ts @@ -64,7 +64,7 @@ describe('toJSON', () => { it('handles classes with custom toJSON', () => { class Customer { - // tslint:disable-next-line:no-unused-variable + // tslint:disable-next-line:no-unused private __data: object; constructor(public id: string, public email: string) { diff --git a/packages/tslint-config/CHANGELOG.md b/packages/tslint-config/CHANGELOG.md index 603c02e6b627..84ec22eb05a2 100644 --- a/packages/tslint-config/CHANGELOG.md +++ b/packages/tslint-config/CHANGELOG.md @@ -3,6 +3,29 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.0.0](https://github.com/strongloop/loopback-next/compare/@loopback/tslint-config@1.0.0...@loopback/tslint-config@2.0.0) (2019-01-14) + + +### Bug Fixes + +* make the tslint-config repo public ([9ba4550](https://github.com/strongloop/loopback-next/commit/9ba4550)) + + +### Features + +* **build:** remove "no-unused-variable", add "no-unused" ([78c9d36](https://github.com/strongloop/loopback-next/commit/78c9d36)) + + +### BREAKING CHANGES + +* **build:** The rule "no-unused-variable" has been replaced with +"no-unused" rule. Code comments disabling "no-unused-variable" rule will +no longer work and must be changed to disable "no-unused" rule instead. + + + + + # 1.0.0 (2018-12-20) diff --git a/packages/tslint-config/package.json b/packages/tslint-config/package.json index e55569885171..40e94170a1fa 100644 --- a/packages/tslint-config/package.json +++ b/packages/tslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/tslint-config", - "version": "1.0.0", + "version": "2.0.0", "description": "", "engines": { "node": ">=8.9" @@ -8,6 +8,9 @@ "author": "IBM", "copyright.owner": "IBM Corp.", "license": "MIT", + "dependencies": { + "tslint-consistent-codestyle": "^1.14.1" + }, "peerDependencies": { "tslint": ">=5.11.0" }, @@ -19,5 +22,8 @@ "repository": { "type": "git", "url": "https://github.com/strongloop/loopback-next.git" + }, + "publishConfig": { + "access": "public" } } diff --git a/packages/tslint-config/tslint.build.json b/packages/tslint-config/tslint.build.json index 819a34736d9c..6906febfa0aa 100644 --- a/packages/tslint-config/tslint.build.json +++ b/packages/tslint-config/tslint.build.json @@ -17,7 +17,8 @@ // tell tslint that it's ok to `await` such promises. "await-promise": [true, "PromiseLike", "RequestPromise"], "no-floating-promises": [true, "PromiseLike", "RequestPromise"], - "no-unused-variable": true, + // Explicitly disable this rule, we are using "no-unused" rule instead + "no-unused-variable": false, "no-void-expression": [true, "ignore-arrow-function-shorthand"] } } diff --git a/packages/tslint-config/tslint.common.json b/packages/tslint-config/tslint.common.json index 78d35a3e62f3..ecd294e152b7 100644 --- a/packages/tslint-config/tslint.common.json +++ b/packages/tslint-config/tslint.common.json @@ -1,4 +1,8 @@ { + "$schema": "http://json.schemastore.org/tslint", + "rulesDirectory": [ + "tslint-consistent-codestyle" + ], // See https://palantir.github.io/tslint/rules/ "rules": { // These rules find errors related to TypeScript features. @@ -19,6 +23,7 @@ "no-misused-new": true, "no-shadowed-variable": true, "no-string-throw": true, + "no-unused": [true, "ignore-parameters"], "no-unused-expression": true, "no-var-keyword": true, "triple-equals": [true, "allow-null-check", "allow-undefined-check"] diff --git a/sandbox/example/CHANGELOG.md b/sandbox/example/CHANGELOG.md index 5b362aa246b0..3440f5508f9e 100644 --- a/sandbox/example/CHANGELOG.md +++ b/sandbox/example/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.2](https://github.com/strongloop/loopback-next/compare/@loopback/sandbox-example@1.0.1...@loopback/sandbox-example@1.0.2) (2019-01-14) + +**Note:** Version bump only for package @loopback/sandbox-example + + + + + ## [1.0.1](https://github.com/strongloop/loopback-next/compare/@loopback/sandbox-example@1.0.0...@loopback/sandbox-example@1.0.1) (2018-12-20) **Note:** Version bump only for package @loopback/sandbox-example diff --git a/sandbox/example/package.json b/sandbox/example/package.json index 82826bc68ee5..640cd2763e91 100644 --- a/sandbox/example/package.json +++ b/sandbox/example/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/sandbox-example", - "version": "1.0.1", + "version": "1.0.2", "description": "Sample project for sandbox", "main": "index.js", "private": true, @@ -18,6 +18,6 @@ "url": "https://github.com/strongloop/loopback-next.git" }, "devDependencies": { - "@loopback/tslint-config": "^1.0.0" + "@loopback/tslint-config": "^2.0.0" } }