diff --git a/.github/stale.yml b/.github/stale.yml index 4d21cc0d439b..0f05d49a96da 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -12,6 +12,7 @@ exemptLabels: - critical - p1 - major + - good first issue # Label to use when marking an issue as stale staleLabel: stale # Comment to post when marking an issue as stale. Set to `false` to disable diff --git a/.nycrc b/.nycrc index 736832778af9..a4002961feff 100644 --- a/.nycrc +++ b/.nycrc @@ -5,9 +5,9 @@ "examples/*/dist" ], "exclude": [ - "packages/*/dist/test/", + "packages/*/dist/__tests__/", "packages/cli/test/", - "examples/*/dist/test/", + "examples/*/dist/__tests__/", "**/.sandbox/" ], "extension": [ diff --git a/.travis.yml b/.travis.yml index 967a82d81bb8..a77695e496d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,3 +31,4 @@ matrix: branches: only: - master + - /^greenkeeper/.*$/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 8f47306af72a..11796409be2a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,7 +13,7 @@ "args": [ "--opts", "${workspaceRoot}/test/mocha.opts", - "packages/*/dist/test/**/*.js", + "packages/*/dist/__tests__/**/*.js", "-t", "0" ] diff --git a/README.md b/README.md index 2f7ef2865d2c..38af366098d7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![Travis Build Status](https://travis-ci.org/strongloop/loopback-next.svg?branch=master)](https://travis-ci.org/strongloop/loopback-next) [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/q8vp7wrdn2ak6801/branch/master?svg=true)](https://ci.appveyor.com/project/strongloop/loopback-next/branch/master) [![Coverage Status](https://coveralls.io/repos/github/strongloop/loopback-next/badge.svg?branch=master)](https://coveralls.io/github/strongloop/loopback-next?branch=master) +[![Greenkeeper badge](https://badges.greenkeeper.io/strongloop/loopback-next.svg)](https://greenkeeper.io/) LoopBack makes it easy to build modern applications that require complex integrations. @@ -92,8 +93,8 @@ You can join the team by posting a comment to | [![b-admike]](http://github.com/b-admike) | [![dhmlau]](http://github.com/dhmlau) | [![jannyhou]](http://github.com/jannyHou) | | Hage Yaapa | Nora Abdelgadir | Mario Estrada | | [![hacksparrow]](https://github.com/hacksparrow) | [![nabdelgadir]](https://github.com/nabdelgadir) | [![marioestradarosa]](https://github.com/marioestradarosa) | -| Hugo Da Roit | | | -| [![yaty]](https://github.com/yaty) | | | +| Hugo Da Roit | Dominique Emond | | +| [![yaty]](https://github.com/yaty) | [![emonddr]](https://github.com/emonddr) | | See [all contributors](https://github.com/strongloop/loopback-next/graphs/contributors). @@ -112,3 +113,4 @@ See [nabdelgadir]: https://avatars0.githubusercontent.com/u/42985749?v=3&s=60 [marioestradarosa]: https://avatars2.githubusercontent.com/u/4633823?v=3&s=60 [yaty]: https://avatars3.githubusercontent.com/u/11981803?v=3&s=60 +[emonddr]: https://avatars0.githubusercontent.com/u/6864736??v=3&s=60 diff --git a/benchmark/CHANGELOG.md b/benchmark/CHANGELOG.md index f6c048f9d02a..c86d885f8e6d 100644 --- a/benchmark/CHANGELOG.md +++ b/benchmark/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.10](https://github.com/strongloop/loopback-next/compare/@loopback/benchmark@1.1.9...@loopback/benchmark@1.1.10) (2019-02-08) + + +### Bug Fixes + +* **benchmark:** set TypeScript's rootDir to src ([51cba45](https://github.com/strongloop/loopback-next/commit/51cba45)) + + + + + ## [1.1.9](https://github.com/strongloop/loopback-next/compare/@loopback/benchmark@1.1.8...@loopback/benchmark@1.1.9) (2019-01-28) **Note:** Version bump only for package @loopback/benchmark diff --git a/benchmark/package.json b/benchmark/package.json index f8d366b77060..2c9d09bcf18a 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/benchmark", - "version": "1.1.9", + "version": "1.1.10", "private": true, "description": "Benchmarks measuring performance of our framework.", "keywords": [ @@ -16,9 +16,9 @@ "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean dist", "pretest": "npm run clean && npm run build", - "test": "lb-mocha \"dist/test\"", + "test": "lb-mocha \"dist/__tests__\"", "prestart": "npm run build", - "benchmark:routing": "node ./dist/src/rest-routing/routing-table", + "benchmark:routing": "node ./dist/rest-routing/routing-table", "start": "node ." }, "repository": { @@ -30,28 +30,28 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "dependencies": { - "@loopback/example-todo": "^1.4.2", - "@loopback/openapi-spec-builder": "^1.0.5", - "@loopback/rest": "^1.5.4", + "@loopback/example-todo": "^1.4.3", + "@loopback/openapi-spec-builder": "^1.0.6", + "@loopback/rest": "^1.5.5", "@types/byline": "^4.2.31", - "@types/debug": "0.0.31", + "@types/debug": "^4.1.0", "@types/p-event": "^1.3.0", "@types/request-promise-native": "^1.0.15", "autocannon": "^3.0.0", "byline": "^5.0.0", "debug": "^4.0.1", - "path-to-regexp": "^2.4.0", + "path-to-regexp": "^3.0.0", "request": "^2.88.0", "request-promise-native": "^1.0.5" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@types/mocha": "^5.0.0", "@types/node": "^10.11.2", "mocha": "^5.1.1", diff --git a/benchmark/test/benchmark.integration.ts b/benchmark/src/__tests__/benchmark.integration.ts similarity index 96% rename from benchmark/test/benchmark.integration.ts rename to benchmark/src/__tests__/benchmark.integration.ts index eaa9f7f6bb19..d6d919077f74 100644 --- a/benchmark/test/benchmark.integration.ts +++ b/benchmark/src/__tests__/benchmark.integration.ts @@ -6,7 +6,7 @@ import {expect} from '@loopback/testlab'; import * as request from 'request-promise-native'; import {Benchmark} from '..'; -import {Autocannon, EndpointStats} from '../src/autocannon'; +import {Autocannon, EndpointStats} from '../autocannon'; const debug = require('debug')('test'); diff --git a/benchmark/test/mocha.opts b/benchmark/src/__tests__/mocha.opts similarity index 100% rename from benchmark/test/mocha.opts rename to benchmark/src/__tests__/mocha.opts diff --git a/benchmark/tsconfig.build.json b/benchmark/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/benchmark/tsconfig.build.json +++ b/benchmark/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/bin/update-greenkeeper-json.js b/bin/update-greenkeeper-json.js new file mode 100755 index 000000000000..795f1f1d27bc --- /dev/null +++ b/bin/update-greenkeeper-json.js @@ -0,0 +1,102 @@ +#!/usr/bin/env node +// Copyright IBM Corp. 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 update `greenkeeper.json` with lerna packages. + */ +'use strict'; + +const path = require('path'); +const fs = require('fs'); + +const Project = require('@lerna/project'); + +async function updateGreenKeeperJson() { + const project = new Project(process.cwd()); + const packages = await project.getPackages(); + const rootPath = project.rootPath; + const packageJsonPaths = packages.map(p => + path.relative(rootPath, p.manifestLocation), + ); + const greenKeeperJson = { + groups: { + default: { + packages: ['package.json'], + }, + }, + }; + + for (const p of packageJsonPaths) { + greenKeeperJson.groups.default.packages.push(p); + } + + const greenKeeperJsonFile = path.join(rootPath, 'greenkeeper.json'); + let currentConfig = {}; + if (fs.existsSync(greenKeeperJsonFile)) { + currentConfig = readJsonFile(greenKeeperJsonFile); + } + + let updateRequired = false; + if ( + !( + currentConfig.groups && + currentConfig.groups.default && + Array.isArray(currentConfig.groups.default.packages) + ) + ) { + // Current config does not exist + updateRequired = true; + } + + if (!updateRequired) { + // Check if packages are the same + updateRequired = !arraysContainSameElements( + currentConfig.groups.default.packages, + greenKeeperJson.groups.default.packages, + ); + } + + if (!updateRequired) { + console.log('%s is up to date.', 'greenkeeper.json'); + return; + } + + if (process.argv[2] === '-f') { + // Update `greenkeeper.json` + writeJsonFile(greenKeeperJsonFile, greenKeeperJson); + } else { + // Print out `greenkeeper.json` + console.error('%s is out of date.', 'greenkeeper.json'); + console.log(JSON.stringify(greenKeeperJson, null, 2)); + } +} + +if (require.main === module) updateGreenKeeperJson(); + +/** + * Test if two arrays contain the same set of elements + * @param {Array} actual + * @param {Array} expected + */ +function arraysContainSameElements(actual, expected) { + return ( + // Same size + actual.length == expected.length && + // `expected` contains all elements of `actual` + actual.every(e => expected.includes(e)) && + // `actual` contains all elements of `expected` + expected.every(e => actual.includes(e)) + ); +} + +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/docs/CHANGELOG.md b/docs/CHANGELOG.md index 934be3cd670a..c3c842a811e3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.7.3](https://github.com/strongloop/loopback-next/compare/@loopback/docs@1.7.2...@loopback/docs@1.7.3) (2019-02-08) + + +### Bug Fixes + +* **docs:** remove .ts from imports ([c601c4c](https://github.com/strongloop/loopback-next/commit/c601c4c)) +* **docs:** update link in todo-tutorial-geocoding-service ([e6a8d73](https://github.com/strongloop/loopback-next/commit/e6a8d73)) +* **docs:** update test paths to `src/__tests__` ([75731f9](https://github.com/strongloop/loopback-next/commit/75731f9)) + + + + + ## [1.7.2](https://github.com/strongloop/loopback-next/compare/@loopback/docs@1.7.1...@loopback/docs@1.7.2) (2019-01-28) **Note:** Version bump only for package @loopback/docs diff --git a/docs/package.json b/docs/package.json index 00e64c49be44..fd8be3bf2c1f 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/docs", - "version": "1.7.2", + "version": "1.7.3", "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.2.1" + "@loopback/build": "^1.3.0" }, "publishConfig": { "access": "public" diff --git a/docs/site/Application-generator.md b/docs/site/Application-generator.md index 9d087fecb2d7..7607d291cc6e 100644 --- a/docs/site/Application-generator.md +++ b/docs/site/Application-generator.md @@ -76,6 +76,7 @@ the following files and directories: ```text . ├── src/ +| ├── __tests__/ | ├── controllers/ | | └── ping.controller.ts | ├── datasources/ @@ -84,7 +85,6 @@ the following files and directories: | ├── application.ts | ├── index.ts | └── sequence.ts -├── test/ └── package.json ``` diff --git a/docs/site/Controllers.md b/docs/site/Controllers.md index 483f3bd4ff31..8570ee662afa 100644 --- a/docs/site/Controllers.md +++ b/docs/site/Controllers.md @@ -239,11 +239,11 @@ codes is found The example below shows the previous controller revamped with `HttpErrors` along with a test to verify that the error is thrown properly. -{% include code-caption.html content="test/integration/controllers/hello.controller.integration.ts" %} +{% include code-caption.html content="src/__tests__/integration/controllers/hello.controller.integration.ts" %} ```ts -import {HelloController} from '../../../src/controllers'; -import {HelloRepository} from '../../../src/repositories'; +import {HelloController} from '../../../controllers'; +import {HelloRepository} from '../../../repositories'; import {testdb} from '../../fixtures/datasources/testdb.datasource'; import {expect} from '@loopback/testlab'; import {HttpErrors} from '@loopback/rest'; diff --git a/docs/site/Crafting-LoopBack-4.md b/docs/site/Crafting-LoopBack-4.md index 3e4d04b80cc5..2a164cdab2dd 100644 --- a/docs/site/Crafting-LoopBack-4.md +++ b/docs/site/Crafting-LoopBack-4.md @@ -473,7 +473,7 @@ There are several key pillars to make extensibility a reality for LoopBack 4. - [Context](Context.md), the IoC container to manage services - [Dependency injection](Dependency-injection.md) to facilitate composition - [Decorators](Decorators.md) to supply metadata using annotations -- [Component](Component.md) as the packaging model to bundle extensions +- [Component](Using-components.md) as the packaging model to bundle extensions Please check out [Extending LoopBack 4](Extending-LoopBack-4.md). diff --git a/docs/site/DEVELOPING.md b/docs/site/DEVELOPING.md index 1de5c87348c9..09026d83dac7 100644 --- a/docs/site/DEVELOPING.md +++ b/docs/site/DEVELOPING.md @@ -148,9 +148,9 @@ tests (unit, acceptance and integration), with the convention Examples are: ``` -test/acceptance/application.acceptance.ts -test/integration/user.controller.integration.ts -test/unit/application.unit.ts +src/__tests__/acceptance/application.acceptance.ts +src/__tests__/integration/user.controller.integration.ts +src/__tests__/unit/application.unit.ts ``` ## API Documentation @@ -466,7 +466,7 @@ configuration, it's important to verify that all usage scenarios keep working. ### Verify TypeScript setup -1. Open any existing TypeScript file, e.g. `packages/src/index.ts` +1. Open any existing TypeScript file, e.g. `packages/core/src/index.ts` 2. Add a small bit of code to break TypeScript's type checks, for example: @@ -479,10 +479,6 @@ configuration, it's important to verify that all usage scenarios keep working. 4. Verify that the build failed and the compiler error message shows a path relative to monorepo root, e.g. `packages/src/index.ts`. - _(This is does not work now, `tsc` is reporting paths relative to individual - package directories. See - )_ - 5. Test integration with supported IDEs: - [VS Code](./VSCODE.md#how-to-verify-typescript-setup) diff --git a/docs/site/Defining-the-API-using-design-first-approach.shelved.md b/docs/site/Defining-the-API-using-design-first-approach.shelved.md index d1728b7ead56..89dc7564a798 100644 --- a/docs/site/Defining-the-API-using-design-first-approach.shelved.md +++ b/docs/site/Defining-the-API-using-design-first-approach.shelved.md @@ -408,7 +408,7 @@ module provides a helper function for checking whether a specification conforms to OpenAPI Spec. Just add a new Mocha test that calls this helper function to the test suite: -{% include code-caption.html content="test/acceptance/api-spec.acceptance.ts" %} +{% include code-caption.html content="src/__tests__/acceptance/api-spec.acceptance.ts" %} ```ts import {validateApiSpec} from '@loopback/testlab'; diff --git a/docs/site/HasMany-relation.md b/docs/site/HasMany-relation.md index edf47c6aefd5..55a3bb947aba 100644 --- a/docs/site/HasMany-relation.md +++ b/docs/site/HasMany-relation.md @@ -166,6 +166,14 @@ factory `orders` for instances of `customerRepository`: instance ([API Docs](https://apidocs.strongloop.com/@loopback%2fdocs/repository.html#HasManyRepository.prototype.patch)) +For **updating** (full replace of all properties on a `PUT` endpoint for +instance) a target model you have to directly use this model repository. In this +case, the caller must provide both the foreignKey value and the primary key +(id). Since the caller already has access to the primary key of the target +model, there is no need to go through the relation repository and the operation +can be performed directly on `DefaultCrudRepository` for the target model +(`OrderRepository` in our example). + ## Using hasMany constrained repository in a controller The same pattern used for ordinary repositories to expose their CRUD APIs via diff --git a/docs/site/Implementing-features.shelved.md b/docs/site/Implementing-features.shelved.md index 901fa0eb3fcc..237c9e862d2d 100644 --- a/docs/site/Implementing-features.shelved.md +++ b/docs/site/Implementing-features.shelved.md @@ -35,7 +35,8 @@ search for a given product name, and verify that expected products were returned. This verifies that all parts of your application are correctly wired together. -Create `test/acceptance/product.acceptance.ts` with the following contents: +Create `src/__tests__/acceptance/product.acceptance.ts` with the following +contents: ```ts import {HelloWorldApp} from '../..'; @@ -163,7 +164,7 @@ Run `npm test` and watch the test fail with a helpful error message: ```text TSError: ⨯ Unable to compile TypeScript -test/unit/product-controller.test.ts (13,40): Property 'getDetails' does not exist on type 'ProductController'. (2339) +src/__tests__/unit/product-controller.test.ts (13,40): Property 'getDetails' does not exist on type 'ProductController'. (2339) ``` Now it's time to write the first implementation of the `getDetails` method. @@ -412,8 +413,8 @@ Examine the acceptance test first. A quick review of the source code should tell us what's the problem - the test is relying on `givenEmptyDatabase` and `givenProduct` helpers, but these helpers are not fully implemented yet. Fix that by reusing the helpers from the integration test: Move the helpers to -`test/helpers/database.helpers.ts` and update both the acceptance and the -integration tests to import the helpers from there. +`src/__tests__/helpers/database.helpers.ts` and update both the acceptance and +the integration tests to import the helpers from there. To find out why the API smoke test is failing, you can start the application via `node .` and request the tested endpoint for example using `curl`. You will see diff --git a/docs/site/Repository-generator.md b/docs/site/Repository-generator.md index eb9c0efb9e61..6f597b4346e7 100644 --- a/docs/site/Repository-generator.md +++ b/docs/site/Repository-generator.md @@ -29,6 +29,10 @@ src/datasources model. If you supply this value, the CLI will not try to infer this value from the selected model file. +`--repositoryBaseClass` : _(Optional)_ _(Default: DefaultCrudRepository)_ name +of the base class the repository will inherit. If no value was supplied, +**DefaultCrudRepository** will be used. + ### Configuration file This generator supports a config file with the following format, see the @@ -40,7 +44,8 @@ file. "name": "repositoryNameToBeGenerated", "datasource": "validDataSourceName", "model": "validDModelName", - "id": "anOptionalNameForID" + "id": "anOptionalNameForID", + "repositoryBaseClass": "validRepositoryBaseClass" } ``` @@ -82,6 +87,14 @@ The tool will prompt you for: **NOTE:** The tool will inspect each of the selected models and try to find the name of the property serving as **ID** for the model. +- **Please select the repository base class.** _(repository)_ if the name of a + valid base class has been supplied from the command line, the prompt is + skipped, otherwise it will present you a list of repositories. The default + repository is infered from the datasource type. + + Any repository in the `src/repository` folder with the file format + `*.repository.base.ts` will be added to the list too. + - **Please enter the name of the ID property for _modelName_.** _(id)_ If the CLI cannot find the corresponding ID property name for the model, it will prompt you to enter a name here. If you don't specify any name, it will use diff --git a/docs/site/Testing-Your-Extensions.md b/docs/site/Testing-Your-Extensions.md index 76ad54ce5c52..20c3882b0d6d 100644 --- a/docs/site/Testing-Your-Extensions.md +++ b/docs/site/Testing-Your-Extensions.md @@ -84,7 +84,7 @@ export class PingController { } ``` -{% include code-caption.html content="test/unit/controllers/ping.controller.unit.ts" %} +{% include code-caption.html content="src/__tests__/unit/controllers/ping.controller.unit.ts" %} ```ts import {PingController} from '../../..'; @@ -145,7 +145,7 @@ export function getTestMetadata( } ``` -{% include code-caption.html content="test/unit/decorators/test.decorator.unit.ts" %} +{% include code-caption.html content="src/__tests__/unit/decorators/test.decorator.unit.ts" %} ```ts import {test, getTestMetadata} from '../../..'; @@ -194,7 +194,7 @@ export class RandomNumberProvider implements Provider { } ``` -{% include code-caption.html content="test/unit/providers/random-number.provider.unit.ts" %} +{% include code-caption.html content="src/__tests__/unit/providers/random-number.provider.unit.ts" %} ```ts import {RandomNumberProvider} from '../../..'; @@ -255,7 +255,7 @@ export function TimeMixin>(superClass: T) { } ``` -{% include code-caption.html content="test/integration/mixins/time.mixin.integration.ts" %} +{% include code-caption.html content="src/__tests__/integration/mixins/time.mixin.integration.ts" %} ```ts import {expect} from '@loopback/testlab'; @@ -302,4 +302,4 @@ Have a look at [loopback4-example-log-extension](https://github.com/strongloop/loopback-next/tree/master/examples/log-extension) to understand the extension artifacts and their usage. An Acceptance test can be seen here: -[test/acceptance/log.extension.acceptance.ts](https://github.com/strongloop/loopback-next/blob/master/examples/log-extension/test/acceptance/log.extension.acceptance.ts). +[src/**tests**/acceptance/log.extension.acceptance.ts](https://github.com/strongloop/loopback-next/blob/master/examples/log-extension/src/__tests__/acceptance/log.extension.acceptance.ts). diff --git a/docs/site/Testing-your-application.md b/docs/site/Testing-your-application.md index d6bae0f58f8f..7027a1236bbc 100644 --- a/docs/site/Testing-your-application.md +++ b/docs/site/Testing-your-application.md @@ -103,7 +103,7 @@ database is not something we want to clean before each test it's handy to use an independent in-memory datasource which is filled appropriately using [test data builders](#use-test-data-builders) before each test run. -{% include code-caption.html content="test/fixtures/datasources/testdb.datasource.ts" %} +{% include code-caption.html content="src/__tests__/fixtures/datasources/testdb.datasource.ts" %} ```ts import {juggler} from '@loopback/repository'; @@ -126,7 +126,7 @@ database in the state that caused the test to fail. To clean the database before each test, set up a `beforeEach` hook to call a helper method; for example: -{% include code-caption.html content="test/helpers/database.helpers.ts" %} +{% include code-caption.html content="src/__tests__/helpers/database.helpers.ts" %} ```ts import {ProductRepository, CategoryRepository} from '../../src/repositories'; @@ -141,7 +141,7 @@ 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" %} +{% include code-caption.html content="src/__tests__/helpers/database.helpers.ts" %} ```ts import {Getter} from '@loopback/context'; @@ -160,7 +160,7 @@ export async function givenEmptyDatabase() { } ``` -{% include code-caption.html content="test/integration/controllers/product.controller.integration.ts" %} +{% include code-caption.html content="src/__tests__/integration/controllers/product.controller.integration.ts" %} ```ts // in your test file @@ -198,7 +198,7 @@ documents. In practice, a simple function that adds missing required properties is sufficient. -{% include code-caption.html content="test/helpers/database.helpers.ts" %} +{% include code-caption.html content="src/__tests__/helpers/database.helpers.ts" %} ```ts // ... @@ -432,7 +432,7 @@ implementation of its repository dependency using the `testlab` [Create a stub repository](#create-a-stub-repository) for a detailed explanation. -{% include code-caption.html content="test/unit/controllers/product.controller.unit.ts" %} +{% include code-caption.html content="src/__tests__/unit/controllers/product.controller.unit.ts" %} ```ts import { @@ -482,7 +482,7 @@ unit tests to verify the implementation of this additional method. Remember to use [Test data builders](#use-test-data-builders) whenever you need valid data to create a new model instance. -{% include code-caption.html content="test/unit/models/person.model.unit.ts" %} +{% include code-caption.html content="src/__tests__/unit/models/person.model.unit.ts" %} ```ts import {Person} from '../../../src/models'; @@ -569,7 +569,7 @@ Integration tests are one of the places to put the best practices in Here is an example showing how to write an integration test for a custom repository method `findByName`: -{% include code-caption.html content="test/integration/repositories/category.repository.integration.ts" %} +{% include code-caption.html content="src/__tests__/integration/repositories/category.repository.integration.ts" %} ```ts import { @@ -604,7 +604,7 @@ commands and queries produce expected results when executed on a real database. These tests are similar to repository tests with controllers added as another ingredient. -{% include code-caption.html content="test/integration/controllers/product.controller.integration.ts" %} +{% include code-caption.html content="src/__tests__/integration/controllers/product.controller.integration.ts" %} ```ts import {expect} from '@loopback/testlab'; @@ -742,10 +742,9 @@ provides a helper method `validateApiSpec` that builds on top of the popular Example usage: -{% include code-caption.html content= "test/acceptance/api-spec.acceptance.ts" %} +{% include code-caption.html content= "src/__tests__/acceptance/api-spec.acceptance.ts" %} ```ts -// test/acceptance/api-spec.test.ts import {HelloWorldApplication} from '../..'; import {RestServer} from '@loopback/rest'; import {validateApiSpec} from '@loopback/testlab'; @@ -785,7 +784,7 @@ developers consuming your API will find them useful too. Here is an example showing how to run Dredd to test your API against the spec: -{% include code-caption.html content= "test/acceptance/api-spec.acceptance.ts" %} +{% include code-caption.html content= "src/__tests__/acceptance/api-spec.acceptance.ts" %} ```ts import {expect} from '@loopback/testlab'; @@ -857,7 +856,7 @@ two tests (one test for each user role). Here is an example of an acceptance test: -{% include code-caption.html content= "test/acceptance/product.acceptance.ts" %} +{% include code-caption.html content= "src/__tests__/acceptance/product.acceptance.ts" %} ```ts import {HelloWorldApplication} from '../..'; diff --git a/docs/site/VSCODE.md b/docs/site/VSCODE.md index 79d680c23604..8b3d3d6026e1 100644 --- a/docs/site/VSCODE.md +++ b/docs/site/VSCODE.md @@ -20,7 +20,7 @@ Our monorepo comes with few preconfigured ### Compilation errors -1. Open any existing TypeScript file, e.g. `packages/src/index.ts` +1. Open any existing TypeScript file, e.g. `packages/core/src/index.ts` 2. Add a small bit of code to break TypeScript's type checks, for example: @@ -51,9 +51,7 @@ Our monorepo comes with few preconfigured VSCode. 8. Verify that compilation errors are correctly associated with the problematic - source code line. _(This is does not work now, `tsc` is reporting paths - relative to individual package directories. See - )_ + source code line. ### Navigation in VS Code diff --git a/docs/site/todo-tutorial-scaffolding.md b/docs/site/todo-tutorial-scaffolding.md index 3f8a904d0396..13c053537c8d 100644 --- a/docs/site/todo-tutorial-scaffolding.md +++ b/docs/site/todo-tutorial-scaffolding.md @@ -44,6 +44,12 @@ the following: ```text src/ + __tests__/ + README.md + mocha.opts + acceptance/ + home-page.controller.acceptance.ts + ping.controller.acceptance.ts controllers/ home-page.controller.ts README.md @@ -57,12 +63,6 @@ src/ application.ts index.ts sequence.ts -test/ - README.md - mocha.opts - acceptance/ - home-page.controller.acceptance.ts - ping.controller.acceptance.ts node_modules/ *** LICENSE @@ -75,27 +75,27 @@ tslint.build.json tslint.json ``` -| File | Purpose | -| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| index.ts | Allows importing contents of the `src` folder (for use elsewhere) | -| index.js | Top-level file connecting components of the application. | -| package.json | Your application's package manifest. See [package.json](https://docs.npmjs.com/files/package.json) for details. | -| tsconfig.json | The TypeScript project configuration. See [tsconfig.json](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) for details. | -| tslint.json | [TSLint configuration](https://palantir.github.io/tslint/usage/tslint-json/) | -| tslint.build.json | [TSLint configuration (build only)](https://palantir.github.io/tslint/usage/tslint-json/) | -| README.md | The Markdown-based README generated for your application. | -| LICENSE | A copy of the MIT license. If you do not wish to use this license, please delete this file. | -| src/application.ts | The application class, which extends [`RestApplication`](http://apidocs.strongloop.com/@loopback%2fdocs/rest.html#RestApplication) by default. This is the root of your application, and is where your application will be configured. It also extends [`RepositoryMixin`](https://apidocs.strongloop.com/@loopback%2fdocs/repository.html#RepositoryMixin) which defines the datasource. | -| src/index.ts | The starting point of your microservice. This file creates an instance of your application, runs the booter, then attempts to start the [`RestServer`](http://apidocs.strongloop.com/@loopback%2fdocs/rest.html#RestServer) instance bound to the application. | -| src/sequence.ts | An extension of the [Sequence](Sequence.md) class used to define the set of actions to take during a REST request/response. | -| src/controllers/README.md | Provides information about the controller directory, how to generate new controllers, and where to find more information. | -| src/controllers/ping.controller.ts | A basic controller that responds to GET requests at `/ping`. | -| src/datasources/README.md | Provides information about the datasources directory, how to generate new datasources, and where to find more information. | -| src/models/README.md | Provides information about the models directory, how to generate new models, and where to find more information. | -| src/repositories/README.md | Provides information about the repositories directory, how to generate new repositories, and where to find more information. | -| test/README.md | Please place your tests in this folder. | -| test/mocha.opts | [Mocha](https://mochajs.org/) configuration for running your application's tests. | -| test/acceptance/ping.controller.acceptance.ts | An example test to go with the ping controller in `src/controllers`. | +| File | Purpose | +| ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `index.ts` | Allows importing contents of the `src` folder (for use elsewhere) | +| `index.js` | Top-level file connecting components of the application. | +| `package.json` | Your application's package manifest. See [package.json](https://docs.npmjs.com/files/package.json) for details. | +| `tsconfig.json` | The TypeScript project configuration. See [tsconfig.json](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) for details. | +| `tslint.json` | [TSLint configuration](https://palantir.github.io/tslint/usage/tslint-json/) | +| `tslint.build.json` | [TSLint configuration (build only)](https://palantir.github.io/tslint/usage/tslint-json/) | +| `README.md` | The Markdown-based README generated for your application. | +| `LICENSE` | A copy of the MIT license. If you do not wish to use this license, please delete this file. | +| `src/application.ts` | The application class, which extends [`RestApplication`](http://apidocs.strongloop.com/@loopback%2fdocs/rest.html#RestApplication) by default. This is the root of your application, and is where your application will be configured. It also extends [`RepositoryMixin`](https://apidocs.strongloop.com/@loopback%2fdocs/repository.html#RepositoryMixin) which defines the datasource. | +| `src/index.ts` | The starting point of your microservice. This file creates an instance of your application, runs the booter, then attempts to start the [`RestServer`](http://apidocs.strongloop.com/@loopback%2fdocs/rest.html#RestServer) instance bound to the application. | +| `src/sequence.ts | An extension of the [Sequence](Sequence.md) class used to define the set of actions to take during a REST request/response. | +| `src/controllers/README.md` | Provides information about the controller directory, how to generate new controllers, and where to find more information. | +| `src/controllers/ping.controller.ts` | A basic controller that responds to GET requests at `/ping`. | +| `src/datasources/README.md` | Provides information about the datasources directory, how to generate new datasources, and where to find more information. | +| `src/models/README.md` | Provides information about the models directory, how to generate new models, and where to find more information. | +| `src/repositories/README.md` | Provides information about the repositories directory, how to generate new repositories, and where to find more information. | +| `src/__tests__/README.md` | Please place your tests in this folder. | +| `src/test/mocha.opts` | [Mocha](https://mochajs.org/) configuration for running your application's tests. | +| `src/__tests__/acceptance/ping.controller.acceptance.ts` | An example test to go with the ping controller in `src/controllers`. | ### Navigation diff --git a/examples/hello-world/CHANGELOG.md b/examples/hello-world/CHANGELOG.md index 5c405af776fa..fe6f93ecb86b 100644 --- a/examples/hello-world/CHANGELOG.md +++ b/examples/hello-world/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/example-hello-world@1.1.2...@loopback/example-hello-world@1.1.3) (2019-02-08) + +**Note:** Version bump only for package @loopback/example-hello-world + + + + + ## [1.1.2](https://github.com/strongloop/loopback-next/compare/@loopback/example-hello-world@1.1.1...@loopback/example-hello-world@1.1.2) (2019-01-28) **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 3597aadb035c..48bd7de63757 100644 --- a/examples/hello-world/package.json +++ b/examples/hello-world/package.json @@ -1,13 +1,13 @@ { "name": "@loopback/example-hello-world", - "version": "1.1.2", + "version": "1.1.3", "description": "A simple hello-world Application using LoopBack 4", "main": "index.js", "engines": { "node": ">=8.9" }, "scripts": { - "acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"", + "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", "build:watch": "lb-tsc es2017 --outDir dist --watch", @@ -21,9 +21,9 @@ "tslint": "lb-tslint", "tslint:fix": "npm run tslint -- --fix", "pretest": "npm run clean && npm run build", - "test": "lb-mocha --allow-console-logs \"dist/test\"", + "test": "lb-mocha --allow-console-logs \"dist/__tests__/**/*.js\"", "posttest": "npm run lint", - "test:dev": "lb-mocha --allow-console-logs dist/test/**/*.js && npm run posttest", + "test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest", "prestart": "npm run build", "start": "node ." }, @@ -36,16 +36,16 @@ }, "license": "MIT", "dependencies": { - "@loopback/core": "^1.1.5", - "@loopback/rest": "^1.5.4" + "@loopback/core": "^1.1.6", + "@loopback/rest": "^1.5.5" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2", "tslint": "^5.12.0", - "typescript": "^3.2.2" + "typescript": "^3.3.1" }, "keywords": [ "loopback", diff --git a/examples/hello-world/test/acceptance/application.acceptance.ts b/examples/hello-world/src/__tests__/acceptance/application.acceptance.ts similarity index 93% rename from examples/hello-world/test/acceptance/application.acceptance.ts rename to examples/hello-world/src/__tests__/acceptance/application.acceptance.ts index 70c171431e2f..4022d45bc3c4 100644 --- a/examples/hello-world/test/acceptance/application.acceptance.ts +++ b/examples/hello-world/src/__tests__/acceptance/application.acceptance.ts @@ -9,7 +9,7 @@ import { expect, givenHttpServerConfig, } from '@loopback/testlab'; -import {HelloWorldApplication} from '../../src/application'; +import {HelloWorldApplication} from '../../application'; describe('Application', () => { let app: HelloWorldApplication; diff --git a/examples/hello-world/tsconfig.build.json b/examples/hello-world/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/examples/hello-world/tsconfig.build.json +++ b/examples/hello-world/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/examples/log-extension/CHANGELOG.md b/examples/log-extension/CHANGELOG.md index f70d8276f3f4..1a90e6bc2e60 100644 --- a/examples/log-extension/CHANGELOG.md +++ b/examples/log-extension/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/example-log-extension@1.1.2...@loopback/example-log-extension@1.1.3) (2019-02-08) + +**Note:** Version bump only for package @loopback/example-log-extension + + + + + ## [1.1.2](https://github.com/strongloop/loopback-next/compare/@loopback/example-log-extension@1.1.1...@loopback/example-log-extension@1.1.2) (2019-01-28) **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 16c2ad2ce32a..e28d49562a71 100644 --- a/examples/log-extension/package.json +++ b/examples/log-extension/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-log-extension", - "version": "1.1.2", + "version": "1.1.3", "description": "An example extension project for LoopBack 4", "main": "index.js", "engines": { @@ -19,9 +19,9 @@ "tslint": "lb-tslint", "tslint:fix": "npm run tslint -- --fix", "pretest": "npm run clean && npm run build", - "test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/acceptance/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/**/*.js\"", "posttest": "npm run lint", - "test:dev": "lb-mocha --allow-console-logs dist/test/**/*.js && npm run posttest", + "test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest", "verify": "npm pack && tar xf *example-log-extension*.tgz && tree package && npm run clean" }, "repository": { @@ -41,19 +41,19 @@ }, "homepage": "https://github.com/strongloop/loopback-next/tree/master/examples/log-extension", "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", - "@types/debug": "0.0.30", + "@types/debug": "^4.1.0", "@types/node": "^10.11.2", "tslint": "^5.12.0", - "typescript": "^3.2.2" + "typescript": "^3.3.1" }, "dependencies": { - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", - "@loopback/openapi-v3": "^1.2.0", - "@loopback/rest": "^1.5.4", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", + "@loopback/openapi-v3": "^1.2.1", + "@loopback/rest": "^1.5.5", "chalk": "^2.3.2", "debug": "^4.0.1" } diff --git a/examples/log-extension/test/acceptance/log.extension.acceptance.ts b/examples/log-extension/src/__tests__/acceptance/log.extension.acceptance.ts similarity index 100% rename from examples/log-extension/test/acceptance/log.extension.acceptance.ts rename to examples/log-extension/src/__tests__/acceptance/log.extension.acceptance.ts diff --git a/examples/log-extension/test/in-memory-logger.ts b/examples/log-extension/src/__tests__/in-memory-logger.ts similarity index 100% rename from examples/log-extension/test/in-memory-logger.ts rename to examples/log-extension/src/__tests__/in-memory-logger.ts diff --git a/examples/log-extension/test/log-spy.ts b/examples/log-extension/src/__tests__/log-spy.ts similarity index 100% rename from examples/log-extension/test/log-spy.ts rename to examples/log-extension/src/__tests__/log-spy.ts diff --git a/examples/log-extension/test/unit/decorators/log.decorator.unit.ts b/examples/log-extension/src/__tests__/unit/decorators/log.decorator.unit.ts similarity index 100% rename from examples/log-extension/test/unit/decorators/log.decorator.unit.ts rename to examples/log-extension/src/__tests__/unit/decorators/log.decorator.unit.ts diff --git a/examples/log-extension/test/unit/mixins/log.mixin.unit.ts b/examples/log-extension/src/__tests__/unit/mixins/log.mixin.unit.ts similarity index 100% rename from examples/log-extension/test/unit/mixins/log.mixin.unit.ts rename to examples/log-extension/src/__tests__/unit/mixins/log.mixin.unit.ts diff --git a/examples/log-extension/test/unit/providers/log-action.provider.unit.ts b/examples/log-extension/src/__tests__/unit/providers/log-action.provider.unit.ts similarity index 100% rename from examples/log-extension/test/unit/providers/log-action.provider.unit.ts rename to examples/log-extension/src/__tests__/unit/providers/log-action.provider.unit.ts diff --git a/examples/log-extension/test/unit/providers/timer.provider.unit.ts b/examples/log-extension/src/__tests__/unit/providers/timer.provider.unit.ts similarity index 100% rename from examples/log-extension/test/unit/providers/timer.provider.unit.ts rename to examples/log-extension/src/__tests__/unit/providers/timer.provider.unit.ts diff --git a/examples/log-extension/tsconfig.build.json b/examples/log-extension/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/examples/log-extension/tsconfig.build.json +++ b/examples/log-extension/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/examples/rpc-server/CHANGELOG.md b/examples/rpc-server/CHANGELOG.md index 1fc58bf84008..ea100887dac4 100644 --- a/examples/rpc-server/CHANGELOG.md +++ b/examples/rpc-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.2](https://github.com/strongloop/loopback-next/compare/@loopback/example-rpc-server@1.1.1...@loopback/example-rpc-server@1.1.2) (2019-02-08) + +**Note:** Version bump only for package @loopback/example-rpc-server + + + + + ## [1.1.1](https://github.com/strongloop/loopback-next/compare/@loopback/example-rpc-server@1.1.0...@loopback/example-rpc-server@1.1.1) (2019-01-28) **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 5199aa735f4e..81b669552557 100644 --- a/examples/rpc-server/package.json +++ b/examples/rpc-server/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-rpc-server", - "version": "1.1.1", + "version": "1.1.2", "description": "A basic RPC server using a made-up protocol.", "keywords": [ "loopback-application", @@ -22,9 +22,9 @@ "tslint": "lb-tslint", "tslint:fix": "npm run tslint -- --fix", "pretest": "npm run clean && npm run build", - "test": "lb-mocha dist/test", + "test": "lb-mocha dist/__tests__/**/*.js", "posttest": "npm run lint", - "test:dev": "lb-mocha --allow-console-logs dist/test/**/*.js && npm run posttest", + "test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest", "prestart": "npm run build", "start": "node ." }, @@ -38,19 +38,19 @@ "author": "", "license": "MIT", "dependencies": { - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", "express": "^4.16.3", "p-event": "^2.1.0" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/express": "^4.11.1", "@types/node": "^10.11.2", "@types/p-event": "^1.3.0", "tslint": "^5.12.0", - "typescript": "^3.2.2" + "typescript": "^3.3.1" } } diff --git a/examples/rpc-server/test/README.md b/examples/rpc-server/src/__tests__/README.md similarity index 100% rename from examples/rpc-server/test/README.md rename to examples/rpc-server/src/__tests__/README.md diff --git a/examples/rpc-server/test/unit/controllers/greet.controller.unit.ts b/examples/rpc-server/src/__tests__/unit/controllers/greet.controller.unit.ts similarity index 95% rename from examples/rpc-server/test/unit/controllers/greet.controller.unit.ts rename to examples/rpc-server/src/__tests__/unit/controllers/greet.controller.unit.ts index ce0f5735938d..4d39e6edb57a 100644 --- a/examples/rpc-server/test/unit/controllers/greet.controller.unit.ts +++ b/examples/rpc-server/src/__tests__/unit/controllers/greet.controller.unit.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {GreetController} from '../../../src/controllers'; +import {GreetController} from '../../../controllers'; import {expect} from '@loopback/testlab'; describe('greet.controller', () => { diff --git a/examples/rpc-server/test/unit/rpc.router.unit.ts b/examples/rpc-server/src/__tests__/unit/rpc.router.unit.ts similarity index 96% rename from examples/rpc-server/test/unit/rpc.router.unit.ts rename to examples/rpc-server/src/__tests__/unit/rpc.router.unit.ts index 4be3981cd36a..b93f95ee369c 100644 --- a/examples/rpc-server/test/unit/rpc.router.unit.ts +++ b/examples/rpc-server/src/__tests__/unit/rpc.router.unit.ts @@ -4,8 +4,8 @@ // License text available at https://opensource.org/licenses/MIT import * as express from 'express'; -import {RPCServer} from '../../src/rpc.server'; -import {routeHandler} from '../../src/rpc.router'; +import {RPCServer} from '../../rpc.server'; +import {routeHandler} from '../../rpc.router'; import {expect, sinon} from '@loopback/testlab'; describe('rpcRouter', () => { diff --git a/examples/soap-calculator/CHANGELOG.md b/examples/soap-calculator/CHANGELOG.md index a395560affff..e6c263559c79 100644 --- a/examples/soap-calculator/CHANGELOG.md +++ b/examples/soap-calculator/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.3.3](https://github.com/strongloop/loopback-next/compare/@loopback/example-soap-calculator@1.3.2...@loopback/example-soap-calculator@1.3.3) (2019-02-08) + +**Note:** Version bump only for package @loopback/example-soap-calculator + + + + + ## [1.3.2](https://github.com/strongloop/loopback-next/compare/@loopback/example-soap-calculator@1.3.1...@loopback/example-soap-calculator@1.3.2) (2019-01-28) **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 d6d8b21465ec..0d23bd278f1c 100644 --- a/examples/soap-calculator/package.json +++ b/examples/soap-calculator/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-soap-calculator", - "version": "1.3.2", + "version": "1.3.3", "description": "Integrate a SOAP webservice with LoopBack 4", "keywords": [ "loopback", @@ -26,9 +26,9 @@ "tslint": "lb-tslint", "tslint:fix": "npm run tslint -- --fix", "pretest": "npm run clean && npm run build", - "test": "lb-mocha \"dist/test\"", + "test": "lb-mocha \"dist/__tests__/**/*.js\"", "posttest": "npm run lint", - "test:dev": "lb-mocha --allow-console-logs dist/test/**/*.js && npm run posttest", + "test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest", "prestart": "npm run build", "start": "node ." }, @@ -40,25 +40,25 @@ }, "license": "MIT", "dependencies": { - "@loopback/boot": "^1.0.11", - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", - "@loopback/openapi-v3": "^1.2.0", - "@loopback/repository": "^1.1.4", - "@loopback/rest": "^1.5.4", - "@loopback/rest-explorer": "^1.1.7", - "@loopback/service-proxy": "^1.0.7", + "@loopback/boot": "^1.0.12", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", + "@loopback/openapi-v3": "^1.2.1", + "@loopback/repository": "^1.1.5", + "@loopback/rest": "^1.5.5", + "@loopback/rest-explorer": "^1.1.8", + "@loopback/service-proxy": "^1.0.8", "loopback-connector-soap": "^5.0.0" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@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", "tslint": "^5.12.0", - "typescript": "^3.2.2" + "typescript": "^3.3.1" } } diff --git a/examples/soap-calculator/test/acceptance/application.acceptance.ts b/examples/soap-calculator/src/__tests__/acceptance/application.acceptance.ts similarity index 97% rename from examples/soap-calculator/test/acceptance/application.acceptance.ts rename to examples/soap-calculator/src/__tests__/acceptance/application.acceptance.ts index 9cfb325ba0f6..e143fdf92aa3 100644 --- a/examples/soap-calculator/test/acceptance/application.acceptance.ts +++ b/examples/soap-calculator/src/__tests__/acceptance/application.acceptance.ts @@ -1,5 +1,5 @@ import {Client, createRestAppClient, expect} from '@loopback/testlab'; -import {SoapCalculatorApplication} from '../../src/application'; +import {SoapCalculatorApplication} from '../../application'; describe('Application', function() { let app: SoapCalculatorApplication; diff --git a/examples/soap-calculator/test/acceptance/home-page.acceptance.ts b/examples/soap-calculator/src/__tests__/acceptance/home-page.acceptance.ts similarity index 100% rename from examples/soap-calculator/test/acceptance/home-page.acceptance.ts rename to examples/soap-calculator/src/__tests__/acceptance/home-page.acceptance.ts diff --git a/examples/soap-calculator/test/acceptance/test-helper.ts b/examples/soap-calculator/src/__tests__/acceptance/test-helper.ts similarity index 100% rename from examples/soap-calculator/test/acceptance/test-helper.ts rename to examples/soap-calculator/src/__tests__/acceptance/test-helper.ts diff --git a/examples/soap-calculator/test/helpers.ts b/examples/soap-calculator/src/__tests__/helpers.ts similarity index 73% rename from examples/soap-calculator/test/helpers.ts rename to examples/soap-calculator/src/__tests__/helpers.ts index 52e06d404955..0890db788baf 100644 --- a/examples/soap-calculator/test/helpers.ts +++ b/examples/soap-calculator/src/__tests__/helpers.ts @@ -1,4 +1,4 @@ -import {CalculatorDataSource} from '../src/datasources/calculator.datasource'; +import {CalculatorDataSource} from '../datasources/calculator.datasource'; export async function givenAConnectedDataSource(): Promise< CalculatorDataSource diff --git a/examples/soap-calculator/test/integration/services/calculator.service.integration.ts b/examples/soap-calculator/src/__tests__/integration/services/calculator.service.integration.ts similarity index 91% rename from examples/soap-calculator/test/integration/services/calculator.service.integration.ts rename to examples/soap-calculator/src/__tests__/integration/services/calculator.service.integration.ts index 52800b1826a3..25b8ad352ecd 100644 --- a/examples/soap-calculator/test/integration/services/calculator.service.integration.ts +++ b/examples/soap-calculator/src/__tests__/integration/services/calculator.service.integration.ts @@ -1,8 +1,8 @@ import { CalculatorService, CalculatorParameters, -} from '../../../src/services/calculator.service'; -import {CalculatorServiceProvider} from '../../../src/services/calculator.service'; +} from '../../../services/calculator.service'; +import {CalculatorServiceProvider} from '../../../services/calculator.service'; import {givenAConnectedDataSource} from '../../helpers'; import {expect} from '@loopback/testlab'; diff --git a/examples/soap-calculator/src/application.ts b/examples/soap-calculator/src/application.ts index 3837da303019..e74bd58dcf7a 100644 --- a/examples/soap-calculator/src/application.ts +++ b/examples/soap-calculator/src/application.ts @@ -17,7 +17,7 @@ export class SoapCalculatorApplication extends BootMixin( this.sequence(MySequence); // Set up default home page - this.static('/', path.join(__dirname, '../../public')); + this.static('/', path.join(__dirname, '../public')); this.component(RestExplorerComponent); diff --git a/examples/soap-calculator/tsconfig.build.json b/examples/soap-calculator/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/examples/soap-calculator/tsconfig.build.json +++ b/examples/soap-calculator/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/examples/todo-list/CHANGELOG.md b/examples/todo-list/CHANGELOG.md index 04a16f0dc5a3..e940301be00c 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.3](https://github.com/strongloop/loopback-next/compare/@loopback/example-todo-list@1.4.2...@loopback/example-todo-list@1.4.3) (2019-02-08) + + +### Bug Fixes + +* **example-todo-list:** "npm run migration" script path ([bf26cc3](https://github.com/strongloop/loopback-next/commit/bf26cc3)) + + + + + ## [1.4.2](https://github.com/strongloop/loopback-next/compare/@loopback/example-todo-list@1.4.1...@loopback/example-todo-list@1.4.2) (2019-01-28) **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 aaca718b37f7..3aa5108278eb 100644 --- a/examples/todo-list/package.json +++ b/examples/todo-list/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-todo-list", - "version": "1.4.2", + "version": "1.4.3", "description": "Continuation of the todo example using relations in LoopBack 4.", "main": "index.js", "engines": { @@ -19,10 +19,10 @@ "tslint": "lb-tslint", "tslint:fix": "npm run tslint -- --fix", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/*/**/*.js\"", - "test:dev": "lb-mocha --allow-console-logs dist/test/**/*.js && npm run posttest", + "test": "lb-mocha \"dist/__tests__/**/*.js\"", + "test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest", "verify": "npm pack && tar xf loopback-todo-list*.tgz && tree package && npm run clean", - "migrate": "node ./dist/src/migrate", + "migrate": "node ./dist/migrate", "prestart": "npm run build", "start": "node ." }, @@ -35,27 +35,27 @@ }, "license": "MIT", "dependencies": { - "@loopback/boot": "^1.0.11", - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", - "@loopback/openapi-v3": "^1.2.0", - "@loopback/openapi-v3-types": "^1.0.5", - "@loopback/repository": "^1.1.4", - "@loopback/rest": "^1.5.4", - "@loopback/rest-explorer": "^1.1.7", - "@loopback/service-proxy": "^1.0.7", + "@loopback/boot": "^1.0.12", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", + "@loopback/openapi-v3": "^1.2.1", + "@loopback/openapi-v3-types": "^1.0.6", + "@loopback/repository": "^1.1.5", + "@loopback/rest": "^1.5.5", + "@loopback/rest-explorer": "^1.1.8", + "@loopback/service-proxy": "^1.0.8", "loopback-connector-rest": "^3.1.1" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/http-caching-proxy": "^1.0.5", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/http-caching-proxy": "^1.0.6", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/lodash": "^4.14.109", "@types/node": "^10.11.2", "lodash": "^4.17.10", "tslint": "^5.12.0", - "typescript": "^3.2.2" + "typescript": "^3.3.1" }, "keywords": [ "loopback", diff --git a/examples/todo-list/test/acceptance/home-page.acceptance.ts b/examples/todo-list/src/__tests__/acceptance/home-page.acceptance.ts similarity index 100% rename from examples/todo-list/test/acceptance/home-page.acceptance.ts rename to examples/todo-list/src/__tests__/acceptance/home-page.acceptance.ts diff --git a/examples/todo-list/test/acceptance/test-helper.ts b/examples/todo-list/src/__tests__/acceptance/test-helper.ts similarity index 100% rename from examples/todo-list/test/acceptance/test-helper.ts rename to examples/todo-list/src/__tests__/acceptance/test-helper.ts diff --git a/examples/todo-list/test/acceptance/todo-list-image.acceptance.ts b/examples/todo-list/src/__tests__/acceptance/todo-list-image.acceptance.ts similarity index 94% rename from examples/todo-list/test/acceptance/todo-list-image.acceptance.ts rename to examples/todo-list/src/__tests__/acceptance/todo-list-image.acceptance.ts index 7ae3a05cdb96..cf31e1911498 100644 --- a/examples/todo-list/test/acceptance/todo-list-image.acceptance.ts +++ b/examples/todo-list/src/__tests__/acceptance/todo-list-image.acceptance.ts @@ -10,12 +10,9 @@ import { givenHttpServerConfig, toJSON, } from '@loopback/testlab'; -import {TodoListApplication} from '../../src/application'; -import {TodoList, TodoListImage} from '../../src/models/'; -import { - TodoListRepository, - TodoListImageRepository, -} from '../../src/repositories/'; +import {TodoListApplication} from '../../application'; +import {TodoList, TodoListImage} from '../../models/'; +import {TodoListRepository, TodoListImageRepository} from '../../repositories/'; import {givenTodoListImage, givenTodoList} from '../helpers'; describe('TodoListApplication', () => { diff --git a/examples/todo-list/test/acceptance/todo-list-todo.acceptance.ts b/examples/todo-list/src/__tests__/acceptance/todo-list-todo.acceptance.ts similarity index 97% rename from examples/todo-list/test/acceptance/todo-list-todo.acceptance.ts rename to examples/todo-list/src/__tests__/acceptance/todo-list-todo.acceptance.ts index ad3368626074..df5d7d9e3ff3 100644 --- a/examples/todo-list/test/acceptance/todo-list-todo.acceptance.ts +++ b/examples/todo-list/src/__tests__/acceptance/todo-list-todo.acceptance.ts @@ -10,9 +10,9 @@ import { givenHttpServerConfig, toJSON, } from '@loopback/testlab'; -import {TodoListApplication} from '../../src/application'; -import {Todo, TodoList} from '../../src/models/'; -import {TodoListRepository, TodoRepository} from '../../src/repositories/'; +import {TodoListApplication} from '../../application'; +import {Todo, TodoList} from '../../models/'; +import {TodoListRepository, TodoRepository} from '../../repositories/'; import {givenTodo, givenTodoList} from '../helpers'; describe('TodoListApplication', () => { diff --git a/examples/todo-list/test/acceptance/todo-list.acceptance.ts b/examples/todo-list/src/__tests__/acceptance/todo-list.acceptance.ts similarity index 97% rename from examples/todo-list/test/acceptance/todo-list.acceptance.ts rename to examples/todo-list/src/__tests__/acceptance/todo-list.acceptance.ts index 03d6d39ca21b..8c3ad47df6a4 100644 --- a/examples/todo-list/test/acceptance/todo-list.acceptance.ts +++ b/examples/todo-list/src/__tests__/acceptance/todo-list.acceptance.ts @@ -11,9 +11,9 @@ import { givenHttpServerConfig, toJSON, } from '@loopback/testlab'; -import {TodoListApplication} from '../../src/application'; -import {TodoList} from '../../src/models/'; -import {TodoListRepository} from '../../src/repositories/'; +import {TodoListApplication} from '../../application'; +import {TodoList} from '../../models/'; +import {TodoListRepository} from '../../repositories/'; import {givenTodoList} from '../helpers'; describe('TodoListApplication', () => { diff --git a/examples/todo-list/test/acceptance/todo.acceptance.ts b/examples/todo-list/src/__tests__/acceptance/todo.acceptance.ts similarity index 96% rename from examples/todo-list/test/acceptance/todo.acceptance.ts rename to examples/todo-list/src/__tests__/acceptance/todo.acceptance.ts index f95a3f056859..359a5307bb1e 100644 --- a/examples/todo-list/test/acceptance/todo.acceptance.ts +++ b/examples/todo-list/src/__tests__/acceptance/todo.acceptance.ts @@ -11,9 +11,9 @@ import { givenHttpServerConfig, toJSON, } from '@loopback/testlab'; -import {TodoListApplication} from '../../src/application'; -import {Todo, TodoList} from '../../src/models/'; -import {TodoRepository, TodoListRepository} from '../../src/repositories/'; +import {TodoListApplication} from '../../application'; +import {Todo, TodoList} from '../../models/'; +import {TodoRepository, TodoListRepository} from '../../repositories/'; import {givenTodo, givenTodoList} from '../helpers'; describe('TodoListApplication', () => { diff --git a/examples/todo-list/test/helpers.ts b/examples/todo-list/src/__tests__/helpers.ts similarity index 97% rename from examples/todo-list/test/helpers.ts rename to examples/todo-list/src/__tests__/helpers.ts index 691166745df9..37deec1abfa6 100644 --- a/examples/todo-list/test/helpers.ts +++ b/examples/todo-list/src/__tests__/helpers.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {Todo, TodoList, TodoListImage} from '../src/models'; +import {Todo, TodoList, TodoListImage} from '../models'; /* ============================================================================== diff --git a/examples/todo-list/test/unit/controllers/todo-list-todo.controller.unit.ts b/examples/todo-list/src/__tests__/unit/controllers/todo-list-todo.controller.unit.ts similarity index 96% rename from examples/todo-list/test/unit/controllers/todo-list-todo.controller.unit.ts rename to examples/todo-list/src/__tests__/unit/controllers/todo-list-todo.controller.unit.ts index 4ee036826651..1c607e0cb3aa 100644 --- a/examples/todo-list/test/unit/controllers/todo-list-todo.controller.unit.ts +++ b/examples/todo-list/src/__tests__/unit/controllers/todo-list-todo.controller.unit.ts @@ -13,9 +13,9 @@ import { sinon, StubbedInstanceWithSinonAccessor, } from '@loopback/testlab'; -import {TodoListTodoController} from '../../../src/controllers'; -import {Todo, TodoList} from '../../../src/models'; -import {TodoListRepository} from '../../../src/repositories'; +import {TodoListTodoController} from '../../../controllers'; +import {Todo, TodoList} from '../../../models'; +import {TodoListRepository} from '../../../repositories'; import {givenTodo, givenTodoList} from '../../helpers'; describe('TodoController', () => { diff --git a/examples/todo-list/test/unit/controllers/todo-list.controller.unit.ts b/examples/todo-list/src/__tests__/unit/controllers/todo-list.controller.unit.ts similarity index 96% rename from examples/todo-list/test/unit/controllers/todo-list.controller.unit.ts rename to examples/todo-list/src/__tests__/unit/controllers/todo-list.controller.unit.ts index cd415a8a03e6..e66569025618 100644 --- a/examples/todo-list/test/unit/controllers/todo-list.controller.unit.ts +++ b/examples/todo-list/src/__tests__/unit/controllers/todo-list.controller.unit.ts @@ -9,9 +9,9 @@ import { sinon, StubbedInstanceWithSinonAccessor, } from '@loopback/testlab'; -import {TodoListController} from '../../../src/controllers'; -import {TodoList} from '../../../src/models'; -import {TodoListRepository} from '../../../src/repositories'; +import {TodoListController} from '../../../controllers'; +import {TodoList} from '../../../models'; +import {TodoListRepository} from '../../../repositories'; import {givenTodoList} from '../../helpers'; describe('TodoController', () => { diff --git a/examples/todo-list/test/unit/controllers/todo.controller.unit.ts b/examples/todo-list/src/__tests__/unit/controllers/todo.controller.unit.ts similarity index 96% rename from examples/todo-list/test/unit/controllers/todo.controller.unit.ts rename to examples/todo-list/src/__tests__/unit/controllers/todo.controller.unit.ts index c331caeceab5..bdf52ca0410d 100644 --- a/examples/todo-list/test/unit/controllers/todo.controller.unit.ts +++ b/examples/todo-list/src/__tests__/unit/controllers/todo.controller.unit.ts @@ -9,9 +9,9 @@ import { sinon, StubbedInstanceWithSinonAccessor, } from '@loopback/testlab'; -import {TodoController} from '../../../src/controllers'; -import {Todo} from '../../../src/models'; -import {TodoRepository} from '../../../src/repositories'; +import {TodoController} from '../../../controllers'; +import {Todo} from '../../../models'; +import {TodoRepository} from '../../../repositories'; import {givenTodo} from '../../helpers'; describe('TodoController', () => { diff --git a/examples/todo-list/src/application.ts b/examples/todo-list/src/application.ts index 9df34019d3ca..beff3668e950 100644 --- a/examples/todo-list/src/application.ts +++ b/examples/todo-list/src/application.ts @@ -21,7 +21,7 @@ export class TodoListApplication extends BootMixin( this.sequence(MySequence); // Set up default home page - this.static('/', path.join(__dirname, '../../public')); + this.static('/', path.join(__dirname, '../public')); this.component(RestExplorerComponent); diff --git a/examples/todo-list/tsconfig.build.json b/examples/todo-list/tsconfig.build.json index f8bd0f50ef8f..d0cbe282ad53 100644 --- a/examples/todo-list/tsconfig.build.json +++ b/examples/todo-list/tsconfig.build.json @@ -4,5 +4,5 @@ "compilerOptions": { "rootDir": "." }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/examples/todo/CHANGELOG.md b/examples/todo/CHANGELOG.md index 1ec9e5c6d057..a9998a142bf0 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.3](https://github.com/strongloop/loopback-next/compare/@loopback/example-todo@1.4.2...@loopback/example-todo@1.4.3) (2019-02-08) + + +### Bug Fixes + +* **example-todo:** "npm run migration" script path ([a54fbf1](https://github.com/strongloop/loopback-next/commit/a54fbf1)) + + + + + ## [1.4.2](https://github.com/strongloop/loopback-next/compare/@loopback/example-todo@1.4.1...@loopback/example-todo@1.4.2) (2019-01-28) **Note:** Version bump only for package @loopback/example-todo diff --git a/examples/todo/package.json b/examples/todo/package.json index e3ca1bdc45d0..3bf22559de86 100644 --- a/examples/todo/package.json +++ b/examples/todo/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/example-todo", - "version": "1.4.2", + "version": "1.4.3", "description": "Tutorial example on how to build an application with LoopBack 4.", "main": "index.js", "engines": { @@ -19,10 +19,10 @@ "tslint": "lb-tslint", "tslint:fix": "npm run tslint -- --fix", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/*/**/*.js\"", - "test:dev": "lb-mocha --allow-console-logs dist/test/**/*.js && npm run posttest", + "test": "lb-mocha \"dist/__tests__/**/*.js\"", + "test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest", "verify": "npm pack && tar xf loopback-todo*.tgz && tree package && npm run clean", - "migrate": "node ./dist/src/migrate", + "migrate": "node ./dist/migrate", "prestart": "npm run build", "start": "node ." }, @@ -35,27 +35,27 @@ }, "license": "MIT", "dependencies": { - "@loopback/boot": "^1.0.11", - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", - "@loopback/openapi-v3": "^1.2.0", - "@loopback/openapi-v3-types": "^1.0.5", - "@loopback/repository": "^1.1.4", - "@loopback/rest": "^1.5.4", - "@loopback/rest-explorer": "^1.1.7", - "@loopback/service-proxy": "^1.0.7", + "@loopback/boot": "^1.0.12", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", + "@loopback/openapi-v3": "^1.2.1", + "@loopback/openapi-v3-types": "^1.0.6", + "@loopback/repository": "^1.1.5", + "@loopback/rest": "^1.5.5", + "@loopback/rest-explorer": "^1.1.8", + "@loopback/service-proxy": "^1.0.8", "loopback-connector-rest": "^3.1.1" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/http-caching-proxy": "^1.0.5", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/http-caching-proxy": "^1.0.6", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/lodash": "^4.14.109", "@types/node": "^10.11.2", "lodash": "^4.17.10", "tslint": "^5.12.0", - "typescript": "^3.2.2" + "typescript": "^3.3.1" }, "keywords": [ "loopback", diff --git a/examples/todo/test/acceptance/home-page.acceptance.ts b/examples/todo/src/__tests__/acceptance/home-page.acceptance.ts similarity index 100% rename from examples/todo/test/acceptance/home-page.acceptance.ts rename to examples/todo/src/__tests__/acceptance/home-page.acceptance.ts diff --git a/examples/todo/test/acceptance/test-helper.ts b/examples/todo/src/__tests__/acceptance/test-helper.ts similarity index 100% rename from examples/todo/test/acceptance/test-helper.ts rename to examples/todo/src/__tests__/acceptance/test-helper.ts diff --git a/examples/todo/test/acceptance/todo.acceptance.ts b/examples/todo/src/__tests__/acceptance/todo.acceptance.ts similarity index 97% rename from examples/todo/test/acceptance/todo.acceptance.ts rename to examples/todo/src/__tests__/acceptance/todo.acceptance.ts index ab2b34097fcc..2dd81a399bf0 100644 --- a/examples/todo/test/acceptance/todo.acceptance.ts +++ b/examples/todo/src/__tests__/acceptance/todo.acceptance.ts @@ -11,9 +11,9 @@ import { givenHttpServerConfig, toJSON, } from '@loopback/testlab'; -import {TodoListApplication} from '../../src/application'; -import {Todo} from '../../src/models/'; -import {TodoRepository} from '../../src/repositories/'; +import {TodoListApplication} from '../../application'; +import {Todo} from '../../models/'; +import {TodoRepository} from '../../repositories/'; import { aLocation, getProxiedGeoCoderConfig, diff --git a/examples/todo/test/helpers.ts b/examples/todo/src/__tests__/helpers.ts similarity index 92% rename from examples/todo/test/helpers.ts rename to examples/todo/src/__tests__/helpers.ts index 754d597d993c..245e0700bd65 100644 --- a/examples/todo/test/helpers.ts +++ b/examples/todo/src/__tests__/helpers.ts @@ -6,9 +6,9 @@ import {HttpCachingProxy} from '@loopback/http-caching-proxy'; import {merge} from 'lodash'; import * as path from 'path'; -import {Todo} from '../src/models/index'; -import {GeoPoint} from '../src/services/geocoder.service'; -import * as GEO_CODER_CONFIG from '../src/datasources/geocoder.datasource.json'; +import {Todo} from '../models/index'; +import {GeoPoint} from '../services/geocoder.service'; +import * as GEO_CODER_CONFIG from '../datasources/geocoder.datasource.json'; /* ============================================================================== diff --git a/examples/todo/test/integration/services/geocoder.service.integration.ts b/examples/todo/src/__tests__/integration/services/geocoder.service.integration.ts similarity index 92% rename from examples/todo/test/integration/services/geocoder.service.integration.ts rename to examples/todo/src/__tests__/integration/services/geocoder.service.integration.ts index 5e6be6a7ed37..314235c83bff 100644 --- a/examples/todo/test/integration/services/geocoder.service.integration.ts +++ b/examples/todo/src/__tests__/integration/services/geocoder.service.integration.ts @@ -4,13 +4,13 @@ // License text available at https://opensource.org/licenses/MIT import {expect} from '@loopback/testlab'; -import {GeocoderService, GeocoderServiceProvider} from '../../../src/services'; +import {GeocoderService, GeocoderServiceProvider} from '../../../services'; import { HttpCachingProxy, givenCachingProxy, getProxiedGeoCoderConfig, } from '../../helpers'; -import {GeocoderDataSource} from '../../../src/datasources/geocoder.datasource'; +import {GeocoderDataSource} from '../../../datasources/geocoder.datasource'; describe('GeoLookupService', function() { // tslint:disable-next-line:no-invalid-this diff --git a/examples/todo/test/unit/controllers/todo.controller.unit.ts b/examples/todo/src/__tests__/unit/controllers/todo.controller.unit.ts similarity index 95% rename from examples/todo/test/unit/controllers/todo.controller.unit.ts rename to examples/todo/src/__tests__/unit/controllers/todo.controller.unit.ts index 06141cb8a9f9..9b442b0fca62 100644 --- a/examples/todo/test/unit/controllers/todo.controller.unit.ts +++ b/examples/todo/src/__tests__/unit/controllers/todo.controller.unit.ts @@ -10,10 +10,10 @@ import { sinon, StubbedInstanceWithSinonAccessor, } from '@loopback/testlab'; -import {TodoController} from '../../../src/controllers'; -import {Todo} from '../../../src/models/index'; -import {TodoRepository} from '../../../src/repositories'; -import {GeocoderService} from '../../../src/services'; +import {TodoController} from '../../../controllers'; +import {Todo} from '../../../models/index'; +import {TodoRepository} from '../../../repositories'; +import {GeocoderService} from '../../../services'; import {aLocation, givenTodo} from '../../helpers'; describe('TodoController', () => { diff --git a/examples/todo/src/application.ts b/examples/todo/src/application.ts index 8f2af45bd508..879521b6a13f 100644 --- a/examples/todo/src/application.ts +++ b/examples/todo/src/application.ts @@ -22,7 +22,7 @@ export class TodoListApplication extends BootMixin( this.sequence(MySequence); // Set up default home page - this.static('/', path.join(__dirname, '../../public')); + this.static('/', path.join(__dirname, '../public')); this.component(RestExplorerComponent); diff --git a/examples/todo/tsconfig.build.json b/examples/todo/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/examples/todo/tsconfig.build.json +++ b/examples/todo/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/greenkeeper.json b/greenkeeper.json new file mode 100644 index 000000000000..3847c5254d6b --- /dev/null +++ b/greenkeeper.json @@ -0,0 +1,37 @@ +{ + "groups": { + "default": { + "packages": [ + "package.json", + "benchmark/package.json", + "docs/package.json", + "examples/hello-world/package.json", + "examples/log-extension/package.json", + "examples/rpc-server/package.json", + "examples/soap-calculator/package.json", + "examples/todo-list/package.json", + "examples/todo/package.json", + "packages/authentication/package.json", + "packages/boot/package.json", + "packages/build/package.json", + "packages/cli/package.json", + "packages/context/package.json", + "packages/core/package.json", + "packages/http-caching-proxy/package.json", + "packages/http-server/package.json", + "packages/metadata/package.json", + "packages/openapi-spec-builder/package.json", + "packages/openapi-v3-types/package.json", + "packages/openapi-v3/package.json", + "packages/repository-json-schema/package.json", + "packages/repository/package.json", + "packages/rest-explorer/package.json", + "packages/rest/package.json", + "packages/service-proxy/package.json", + "packages/testlab/package.json", + "packages/tslint-config/package.json", + "sandbox/example/package.json" + ] + } + } +} diff --git a/package.json b/package.json index fe89b0e1020d..fb9eca54cca2 100644 --- a/package.json +++ b/package.json @@ -10,22 +10,23 @@ }, "license": "MIT", "devDependencies": { - "@commitlint/cli": "^7.0.0", - "@commitlint/config-conventional": "^7.0.0", - "@commitlint/travis-cli": "^7.0.0", + "@commitlint/cli": "^7.5.0", + "@commitlint/config-conventional": "^7.5.0", + "@commitlint/travis-cli": "^7.5.0", "@types/mocha": "^5.0.0", "coveralls": "^3.0.0", "cz-conventional-changelog": "^2.1.0", - "husky": "^1.2.0", - "lerna": "^3.5.1", + "husky": "^1.3.1", + "lerna": "^3.10.7", "tslint": "^5.12.0", - "typescript": "^3.2.2" + "typescript": "^3.3.1" }, "scripts": { - "postinstall": "lerna bootstrap", + "postinstall": "lerna bootstrap && npm run -s update-greenkeeper-json", "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", + "update-greenkeeper-json": "node bin/update-greenkeeper-json -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\"", @@ -50,7 +51,7 @@ "test:ci": "node packages/build/bin/run-nyc npm run mocha --scripts-prepend-node-path", "verify:docs": "npm run build:site -- --verify", "build:site": "./bin/build-docs-site.sh", - "mocha": "node packages/build/bin/run-mocha \"packages/*/dist/test/**/*.js\" \"examples/*/dist/test/**/*.js\" \"packages/cli/test/**/*.js\" \"packages/build/test/*/*.js\"", + "mocha": "node packages/build/bin/run-mocha \"packages/*/dist/__tests__/**/*.js\" \"examples/*/dist/__tests__/**/*.js\" \"packages/cli/test/**/*.js\" \"packages/build/test/*/*.js\"", "posttest": "npm run lint" }, "config": { @@ -63,5 +64,24 @@ "hooks": { "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } + }, + "greenkeeper": { + "commitMessages": { + "initialBadge": "docs: add Greenkeeper badge", + "initialDependencies": "chore: update dependencies", + "initialBranches": "chore: whitelist greenkeeper branches", + "dependencyUpdate": "chore: update ${dependency} to version ${version}", + "devDependencyUpdate": "chore: update ${dependency} to version ${version}", + "dependencyPin": "chore: pin ${dependency} to ${oldVersion}", + "devDependencyPin": "chore: pin ${dependency} to ${oldVersion}" + }, + "prTitles": { + "initialPR": "[greenkeeper] update dependencies to enable Greenkeeper", + "initialPrBadge": "[greenkeeper] add badge to enable Greenkeeper", + "initialPrBadgeOnly": "[greenkeeper] add Greenkeeper badge", + "initialSubgroupPR": "[greenkeeper] update dependencies for ${group}", + "basicPR": "[greenkeeper] update ${dependency} to the latest", + "groupPR": "[greenkeeper] update ${dependency} in group ${group} to the latest" + } } } diff --git a/packages/authentication/CHANGELOG.md b/packages/authentication/CHANGELOG.md index f92cb6e60b9d..64d659400eb5 100644 --- a/packages/authentication/CHANGELOG.md +++ b/packages/authentication/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.12](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@1.0.11...@loopback/authentication@1.0.12) (2019-02-08) + +**Note:** Version bump only for package @loopback/authentication + + + + + ## [1.0.11](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@1.0.10...@loopback/authentication@1.0.11) (2019-01-28) **Note:** Version bump only for package @loopback/authentication diff --git a/packages/authentication/package.json b/packages/authentication/package.json index ed2af0d76b5b..9a57a464940a 100644 --- a/packages/authentication/package.json +++ b/packages/authentication/package.json @@ -1,40 +1,40 @@ { "name": "@loopback/authentication", - "version": "1.0.11", + "version": "1.0.12", "description": "A LoopBack component for authentication support.", "engines": { "node": ">=8.9" }, "scripts": { - "acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"", + "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-authentication*.tgz dist package api-docs", - "integration": "lb-mocha \"dist/test/integration/**/*.js\"", + "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/integration/**/*.js\" \"dist/test/acceptance/**/*.js\"", - "unit": "lb-mocha \"dist/test/unit/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/integration/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"", + "unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"", "verify": "npm pack && tar xf loopback-authentication*.tgz && tree package && npm run clean" }, "author": "IBM", "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", - "@loopback/metadata": "^1.0.5", - "@loopback/openapi-v3": "^1.2.0", - "@loopback/rest": "^1.5.4", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", + "@loopback/metadata": "^1.0.6", + "@loopback/openapi-v3": "^1.2.1", + "@loopback/rest": "^1.5.5", "passport": "^0.4.0", "passport-strategy": "^1.0.0" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/openapi-spec-builder": "^1.0.5", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/openapi-spec-builder": "^1.0.6", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2", - "@types/passport": "^0.4.4", + "@types/passport": "^1.0.0", "@types/passport-http": "^0.3.6", "passport-http": "^0.3.0" }, @@ -46,9 +46,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "repository": { "type": "git", diff --git a/packages/authentication/test/acceptance/basic-auth.acceptance.ts b/packages/authentication/src/__tests__/acceptance/basic-auth.acceptance.ts similarity index 100% rename from packages/authentication/test/acceptance/basic-auth.acceptance.ts rename to packages/authentication/src/__tests__/acceptance/basic-auth.acceptance.ts diff --git a/packages/authentication/test/acceptance/feature.md b/packages/authentication/src/__tests__/acceptance/feature.md similarity index 100% rename from packages/authentication/test/acceptance/feature.md rename to packages/authentication/src/__tests__/acceptance/feature.md diff --git a/packages/authentication/test/integration/smoke.integration.ts b/packages/authentication/src/__tests__/integration/smoke.integration.ts similarity index 100% rename from packages/authentication/test/integration/smoke.integration.ts rename to packages/authentication/src/__tests__/integration/smoke.integration.ts diff --git a/packages/authentication/test/unit/decorators/authenticate.decorator.unit.ts b/packages/authentication/src/__tests__/unit/decorators/authenticate.decorator.unit.ts similarity index 100% rename from packages/authentication/test/unit/decorators/authenticate.decorator.unit.ts rename to packages/authentication/src/__tests__/unit/decorators/authenticate.decorator.unit.ts diff --git a/packages/authentication/test/unit/fixtures/mock-strategy.ts b/packages/authentication/src/__tests__/unit/fixtures/mock-strategy.ts similarity index 100% rename from packages/authentication/test/unit/fixtures/mock-strategy.ts rename to packages/authentication/src/__tests__/unit/fixtures/mock-strategy.ts diff --git a/packages/authentication/test/unit/providers/auth-metadata.provider.unit.ts b/packages/authentication/src/__tests__/unit/providers/auth-metadata.provider.unit.ts similarity index 97% rename from packages/authentication/test/unit/providers/auth-metadata.provider.unit.ts rename to packages/authentication/src/__tests__/unit/providers/auth-metadata.provider.unit.ts index bfe74652cc36..03602701bac3 100644 --- a/packages/authentication/test/unit/providers/auth-metadata.provider.unit.ts +++ b/packages/authentication/src/__tests__/unit/providers/auth-metadata.provider.unit.ts @@ -7,7 +7,7 @@ import {expect} from '@loopback/testlab'; import {CoreBindings} from '@loopback/core'; import {Context, Provider} from '@loopback/context'; import {AuthenticationMetadata, authenticate} from '../../..'; -import {AuthMetadataProvider} from '../../../src/providers'; +import {AuthMetadataProvider} from '../../../providers'; describe('AuthMetadataProvider', () => { let provider: Provider; diff --git a/packages/authentication/test/unit/providers/authentication.provider.unit.ts b/packages/authentication/src/__tests__/unit/providers/authentication.provider.unit.ts similarity index 98% rename from packages/authentication/test/unit/providers/authentication.provider.unit.ts rename to packages/authentication/src/__tests__/unit/providers/authentication.provider.unit.ts index 0c727be83e7b..709ebcab74ff 100644 --- a/packages/authentication/test/unit/providers/authentication.provider.unit.ts +++ b/packages/authentication/src/__tests__/unit/providers/authentication.provider.unit.ts @@ -9,7 +9,7 @@ import {Request} from '@loopback/rest'; import {AuthenticateFn, UserProfile, AuthenticationBindings} from '../../..'; import {MockStrategy} from '../fixtures/mock-strategy'; import {Strategy} from 'passport'; -import {AuthenticateActionProvider} from '../../../src/providers'; +import {AuthenticateActionProvider} from '../../../providers'; describe('AuthenticateActionProvider', () => { describe('constructor()', () => { diff --git a/packages/authentication/test/unit/strategy-adapter.unit.ts b/packages/authentication/src/__tests__/unit/strategy-adapter.unit.ts similarity index 100% rename from packages/authentication/test/unit/strategy-adapter.unit.ts rename to packages/authentication/src/__tests__/unit/strategy-adapter.unit.ts diff --git a/packages/authentication/tsconfig.build.json b/packages/authentication/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/authentication/tsconfig.build.json +++ b/packages/authentication/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/boot/CHANGELOG.md b/packages/boot/CHANGELOG.md index 9e208edf9f7e..166cebd1ab82 100644 --- a/packages/boot/CHANGELOG.md +++ b/packages/boot/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.12](https://github.com/strongloop/loopback-next/compare/@loopback/boot@1.0.11...@loopback/boot@1.0.12) (2019-02-08) + +**Note:** Version bump only for package @loopback/boot + + + + + ## [1.0.11](https://github.com/strongloop/loopback-next/compare/@loopback/boot@1.0.10...@loopback/boot@1.0.11) (2019-01-28) **Note:** Version bump only for package @loopback/boot diff --git a/packages/boot/package.json b/packages/boot/package.json index 705f5866b7f2..07a53a43dcf4 100644 --- a/packages/boot/package.json +++ b/packages/boot/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/boot", - "version": "1.0.11", + "version": "1.0.12", "description": "A collection of Booters for LoopBack 4 Applications", "engines": { "node": ">=8.9" @@ -9,45 +9,44 @@ "access": "public" }, "scripts": { - "acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"", + "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-boot*.tgz dist package api-docs", "pretest": "npm run build", - "integration": "lb-mocha \"dist/test/integration/**/*.js\"", - "test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/integration/**/*.js\" \"dist/test/acceptance/**/*.js\"", - "unit": "lb-mocha \"dist/test/unit/**/*.js\"", + "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/integration/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"", + "unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"", "verify": "npm pack && tar xf loopback-boot*.tgz && tree package && npm run clean" }, "author": "IBM", "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", - "@loopback/repository": "^1.1.4", - "@loopback/service-proxy": "^1.0.7", - "@types/debug": "0.0.30", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", + "@loopback/repository": "^1.1.5", + "@loopback/service-proxy": "^1.0.8", + "@types/debug": "^4.1.0", "@types/glob": "^7.1.1", "debug": "^4.0.1", "glob": "^7.1.2" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/openapi-v3": "^1.2.0", - "@loopback/rest": "^1.5.4", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/openapi-v3": "^1.2.1", + "@loopback/rest": "^1.5.5", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, "files": [ "README.md", "index.js", - "index.js.map", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "repository": { "type": "git", diff --git a/packages/boot/test/acceptance/application-metadata.booter.acceptance.ts b/packages/boot/src/__tests__/acceptance/application-metadata.booter.acceptance.ts similarity index 100% rename from packages/boot/test/acceptance/application-metadata.booter.acceptance.ts rename to packages/boot/src/__tests__/acceptance/application-metadata.booter.acceptance.ts diff --git a/packages/boot/test/acceptance/controller.booter.acceptance.ts b/packages/boot/src/__tests__/acceptance/controller.booter.acceptance.ts similarity index 100% rename from packages/boot/test/acceptance/controller.booter.acceptance.ts rename to packages/boot/src/__tests__/acceptance/controller.booter.acceptance.ts diff --git a/packages/boot/test/fixtures/application.ts b/packages/boot/src/__tests__/fixtures/application.ts similarity index 100% rename from packages/boot/test/fixtures/application.ts rename to packages/boot/src/__tests__/fixtures/application.ts diff --git a/packages/boot/test/fixtures/datasource.artifact.ts b/packages/boot/src/__tests__/fixtures/datasource.artifact.ts similarity index 100% rename from packages/boot/test/fixtures/datasource.artifact.ts rename to packages/boot/src/__tests__/fixtures/datasource.artifact.ts diff --git a/packages/boot/test/fixtures/empty.artifact.ts b/packages/boot/src/__tests__/fixtures/empty.artifact.ts similarity index 100% rename from packages/boot/test/fixtures/empty.artifact.ts rename to packages/boot/src/__tests__/fixtures/empty.artifact.ts diff --git a/packages/boot/test/fixtures/multiple.artifact.ts b/packages/boot/src/__tests__/fixtures/multiple.artifact.ts similarity index 100% rename from packages/boot/test/fixtures/multiple.artifact.ts rename to packages/boot/src/__tests__/fixtures/multiple.artifact.ts diff --git a/packages/boot/test/fixtures/package.json b/packages/boot/src/__tests__/fixtures/package.json similarity index 100% rename from packages/boot/test/fixtures/package.json rename to packages/boot/src/__tests__/fixtures/package.json diff --git a/packages/boot/test/fixtures/service-class.artifact.ts b/packages/boot/src/__tests__/fixtures/service-class.artifact.ts similarity index 100% rename from packages/boot/test/fixtures/service-class.artifact.ts rename to packages/boot/src/__tests__/fixtures/service-class.artifact.ts diff --git a/packages/boot/test/fixtures/service-provider.artifact.ts b/packages/boot/src/__tests__/fixtures/service-provider.artifact.ts similarity index 100% rename from packages/boot/test/fixtures/service-provider.artifact.ts rename to packages/boot/src/__tests__/fixtures/service-provider.artifact.ts diff --git a/packages/boot/test/integration/controller.booter.integration.ts b/packages/boot/src/__tests__/integration/controller.booter.integration.ts similarity index 100% rename from packages/boot/test/integration/controller.booter.integration.ts rename to packages/boot/src/__tests__/integration/controller.booter.integration.ts diff --git a/packages/boot/test/integration/datasource.booter.integration.ts b/packages/boot/src/__tests__/integration/datasource.booter.integration.ts similarity index 100% rename from packages/boot/test/integration/datasource.booter.integration.ts rename to packages/boot/src/__tests__/integration/datasource.booter.integration.ts diff --git a/packages/boot/test/integration/repository.booter.integration.ts b/packages/boot/src/__tests__/integration/repository.booter.integration.ts similarity index 100% rename from packages/boot/test/integration/repository.booter.integration.ts rename to packages/boot/src/__tests__/integration/repository.booter.integration.ts diff --git a/packages/boot/test/integration/service.booter.integration.ts b/packages/boot/src/__tests__/integration/service.booter.integration.ts similarity index 100% rename from packages/boot/test/integration/service.booter.integration.ts rename to packages/boot/src/__tests__/integration/service.booter.integration.ts diff --git a/packages/boot/test/unit/boot.component.unit.ts b/packages/boot/src/__tests__/unit/boot.component.unit.ts similarity index 100% rename from packages/boot/test/unit/boot.component.unit.ts rename to packages/boot/src/__tests__/unit/boot.component.unit.ts diff --git a/packages/boot/test/unit/booters/base-artifact.booter.unit.ts b/packages/boot/src/__tests__/unit/booters/base-artifact.booter.unit.ts similarity index 100% rename from packages/boot/test/unit/booters/base-artifact.booter.unit.ts rename to packages/boot/src/__tests__/unit/booters/base-artifact.booter.unit.ts diff --git a/packages/boot/test/unit/booters/booter-utils.unit.ts b/packages/boot/src/__tests__/unit/booters/booter-utils.unit.ts similarity index 100% rename from packages/boot/test/unit/booters/booter-utils.unit.ts rename to packages/boot/src/__tests__/unit/booters/booter-utils.unit.ts diff --git a/packages/boot/test/unit/booters/controller.booter.unit.ts b/packages/boot/src/__tests__/unit/booters/controller.booter.unit.ts similarity index 100% rename from packages/boot/test/unit/booters/controller.booter.unit.ts rename to packages/boot/src/__tests__/unit/booters/controller.booter.unit.ts diff --git a/packages/boot/test/unit/booters/datasource.booter.unit.ts b/packages/boot/src/__tests__/unit/booters/datasource.booter.unit.ts similarity index 100% rename from packages/boot/test/unit/booters/datasource.booter.unit.ts rename to packages/boot/src/__tests__/unit/booters/datasource.booter.unit.ts diff --git a/packages/boot/test/unit/booters/repository.booter.unit.ts b/packages/boot/src/__tests__/unit/booters/repository.booter.unit.ts similarity index 100% rename from packages/boot/test/unit/booters/repository.booter.unit.ts rename to packages/boot/src/__tests__/unit/booters/repository.booter.unit.ts diff --git a/packages/boot/test/unit/booters/service.booter.unit.ts b/packages/boot/src/__tests__/unit/booters/service.booter.unit.ts similarity index 100% rename from packages/boot/test/unit/booters/service.booter.unit.ts rename to packages/boot/src/__tests__/unit/booters/service.booter.unit.ts diff --git a/packages/boot/test/unit/bootstrapper.unit.ts b/packages/boot/src/__tests__/unit/bootstrapper.unit.ts similarity index 100% rename from packages/boot/test/unit/bootstrapper.unit.ts rename to packages/boot/src/__tests__/unit/bootstrapper.unit.ts diff --git a/packages/boot/test/unit/mixins/boot.mixin.unit.ts b/packages/boot/src/__tests__/unit/mixins/boot.mixin.unit.ts similarity index 100% rename from packages/boot/test/unit/mixins/boot.mixin.unit.ts rename to packages/boot/src/__tests__/unit/mixins/boot.mixin.unit.ts diff --git a/packages/boot/tsconfig.build.json b/packages/boot/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/boot/tsconfig.build.json +++ b/packages/boot/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/build/CHANGELOG.md b/packages/build/CHANGELOG.md index ba31957aaa24..aaed8761a8a4 100644 --- a/packages/build/CHANGELOG.md +++ b/packages/build/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/build@1.2.1...@loopback/build@1.3.0) (2019-02-08) + + +### Features + +* **build:** use `dist/__tests__` in code examples and tests ([a3da024](https://github.com/strongloop/loopback-next/commit/a3da024)) + + + + + ## [1.2.1](https://github.com/strongloop/loopback-next/compare/@loopback/build@1.2.0...@loopback/build@1.2.1) (2019-01-28) **Note:** Version bump only for package @loopback/build diff --git a/packages/build/README.md b/packages/build/README.md index 830423e75f87..5b9b97ec0ab9 100644 --- a/packages/build/README.md +++ b/packages/build/README.md @@ -40,7 +40,7 @@ To use `@loopback/build` for your package: "tslint": "lb-tslint", "tslint:fix": "npm run tslint -- --fix", "pretest": "npm run clean && npm run build", - "test": "lb-mocha \"dist/test\"", + "test": "lb-mocha \"dist/__tests__\"", "posttest": "npm run lint", "start": "npm run build && node .", "prepublishOnly": "npm run test" diff --git a/packages/build/bin/select-dist.js b/packages/build/bin/select-dist.js index 84dccbb4282a..13514b0274eb 100755 --- a/packages/build/bin/select-dist.js +++ b/packages/build/bin/select-dist.js @@ -18,7 +18,7 @@ Then the provided command is executed with the modified arguments. Example usage: - node ./bin/select-dist mocha dist/test + node ./bin/select-dist mocha dist/__tests__ ======== */ diff --git a/packages/build/package.json b/packages/build/package.json index 9d08bf0489ee..b60425ad91e2 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.2.1", + "version": "1.3.0", "engines": { "node": ">=8.9" }, @@ -27,7 +27,7 @@ "source-map-support": "^0.5.5", "strong-docs": "^4.0.0", "tslint": "^5.12.0", - "typescript": "^3.2.2" + "typescript": "^3.3.1" }, "bin": { "lb-tsc": "./bin/compile-package.js", @@ -44,6 +44,6 @@ "mocha": "node bin/run-mocha --timeout 30000 \"test/integration/*.js\"" }, "devDependencies": { - "@loopback/tslint-config": "^1.0.0-1" + "@loopback/tslint-config": "^2.0.0" } } diff --git a/packages/build/test/integration/scripts.integration.js b/packages/build/test/integration/scripts.integration.js index c50721aeda73..273eb66f8601 100644 --- a/packages/build/test/integration/scripts.integration.js +++ b/packages/build/test/integration/scripts.integration.js @@ -380,7 +380,7 @@ describe('mocha', function() { it('loads built-in mocha.opts file', () => { var run = require('../../bin/run-mocha'); - var command = run(['node', 'bin/run-mocha', '"dist/test"'], true); + var command = run(['node', 'bin/run-mocha', '"dist/__tests__"'], true); const builtInMochaOptsFile = path.join( __dirname, '../../config/mocha.opts', @@ -394,7 +394,7 @@ describe('mocha', function() { it('honors --opts option', () => { var run = require('../../bin/run-mocha'); var command = run( - ['node', 'bin/run-mocha', '--opts custom/mocha.opts', '"dist/test"'], + ['node', 'bin/run-mocha', '--opts custom/mocha.opts', '"dist/__tests__"'], true, ); assert( @@ -410,7 +410,7 @@ describe('mocha', function() { fs.copyFileSync(buitInMochaOptsPath, destPath); - var command = run(['node', 'bin/run-mocha', '"dist/test"'], true); + var command = run(['node', 'bin/run-mocha', '"dist/__tests__"'], true); assert( command.indexOf('--opts') === -1, 'should skip built-in mocha.opts file when specific project file exist', diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 98e32373a540..29deb31605f1 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.6.0](https://github.com/strongloop/loopback-next/compare/@loopback/cli@1.5.2...@loopback/cli@1.6.0) (2019-02-08) + + +### Bug Fixes + +* remove unused juggler import ([0121c10](https://github.com/strongloop/loopback-next/commit/0121c10)) +* update to the most recent lodash version ([65ee865](https://github.com/strongloop/loopback-next/commit/65ee865)) + + +### Features + +* **cli:** scaffold test files to `src/__tests__` ([d3a3bea](https://github.com/strongloop/loopback-next/commit/d3a3bea)) +* **cli:** use a custom repository base class ([edbbe88](https://github.com/strongloop/loopback-next/commit/edbbe88)) + + + + + ## [1.5.2](https://github.com/strongloop/loopback-next/compare/@loopback/cli@1.5.1...@loopback/cli@1.5.2) (2019-01-28) diff --git a/packages/cli/generators/app/templates/test/README.md b/packages/cli/generators/app/templates/src/__tests__/README.md similarity index 100% rename from packages/cli/generators/app/templates/test/README.md rename to packages/cli/generators/app/templates/src/__tests__/README.md diff --git a/packages/cli/generators/app/templates/test/acceptance/home-page.acceptance.ts.ejs b/packages/cli/generators/app/templates/src/__tests__/acceptance/home-page.acceptance.ts.ejs similarity index 100% rename from packages/cli/generators/app/templates/test/acceptance/home-page.acceptance.ts.ejs rename to packages/cli/generators/app/templates/src/__tests__/acceptance/home-page.acceptance.ts.ejs diff --git a/packages/cli/generators/app/templates/test/acceptance/ping.controller.acceptance.ts.ejs b/packages/cli/generators/app/templates/src/__tests__/acceptance/ping.controller.acceptance.ts.ejs similarity index 100% rename from packages/cli/generators/app/templates/test/acceptance/ping.controller.acceptance.ts.ejs rename to packages/cli/generators/app/templates/src/__tests__/acceptance/ping.controller.acceptance.ts.ejs diff --git a/packages/cli/generators/app/templates/test/acceptance/test-helper.ts.ejs b/packages/cli/generators/app/templates/src/__tests__/acceptance/test-helper.ts.ejs similarity index 100% rename from packages/cli/generators/app/templates/test/acceptance/test-helper.ts.ejs rename to packages/cli/generators/app/templates/src/__tests__/acceptance/test-helper.ts.ejs diff --git a/packages/cli/generators/app/templates/src/application.ts.ejs b/packages/cli/generators/app/templates/src/application.ts.ejs index d5f4d6c4dc85..875bc2450b33 100644 --- a/packages/cli/generators/app/templates/src/application.ts.ejs +++ b/packages/cli/generators/app/templates/src/application.ts.ejs @@ -30,7 +30,7 @@ export class <%= project.applicationName %> extends BootMixin(RestApplication) { this.sequence(MySequence); // Set up default home page - this.static('/', path.join(__dirname, '../../public')); + this.static('/', path.join(__dirname, '../public')); // Customize @loopback/rest-explorer configuration here this.bind(RestExplorerBindings.CONFIG).to({ diff --git a/packages/cli/generators/extension/templates/test/acceptance/README.md b/packages/cli/generators/extension/templates/src/__tests__/acceptance/README.md similarity index 100% rename from packages/cli/generators/extension/templates/test/acceptance/README.md rename to packages/cli/generators/extension/templates/src/__tests__/acceptance/README.md diff --git a/packages/cli/generators/extension/templates/test/integration/README.md b/packages/cli/generators/extension/templates/src/__tests__/integration/README.md similarity index 100% rename from packages/cli/generators/extension/templates/test/integration/README.md rename to packages/cli/generators/extension/templates/src/__tests__/integration/README.md diff --git a/packages/cli/generators/extension/templates/test/unit/README.md b/packages/cli/generators/extension/templates/src/__tests__/unit/README.md similarity index 100% rename from packages/cli/generators/extension/templates/test/unit/README.md rename to packages/cli/generators/extension/templates/src/__tests__/unit/README.md diff --git a/packages/cli/generators/project/templates/package.json.ejs b/packages/cli/generators/project/templates/package.json.ejs index c30c45f0320a..6246cdfa227b 100644 --- a/packages/cli/generators/project/templates/package.json.ejs +++ b/packages/cli/generators/project/templates/package.json.ejs @@ -36,18 +36,18 @@ <% } -%> "pretest": "npm run clean && npm run build", <% if (project.mocha) { -%> - "test": "lb-mocha --allow-console-logs \"dist/test\"", + "test": "lb-mocha --allow-console-logs \"dist/__tests__\"", <% } -%> <% if (project.prettier || project.tslint) { -%> "posttest": "npm run lint", <% } -%> <% if (project.mocha && (project.prettier || project.tslint)) { -%> - "test:dev": "lb-mocha --allow-console-logs dist/test/**/*.js && npm run posttest", + "test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js && npm run posttest", <% } else if (project.mocha) { -%> - "test:dev": "lb-mocha --allow-console-logs dist/test/**/*.js", + "test:dev": "lb-mocha --allow-console-logs dist/__tests__/**/*.js", <% } -%> <% if (project.projectType === 'application') { -%> - "migrate": "node ./dist/src/migrate", + "migrate": "node ./dist/migrate", "prestart": "npm run build", "start": "node .", <% } -%> @@ -65,9 +65,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "dependencies": { "@loopback/boot": "<%= project.dependencies['@loopback/boot'] -%>", diff --git a/packages/cli/generators/project/templates/package.plain.json.ejs b/packages/cli/generators/project/templates/package.plain.json.ejs index 36c39c05c9c3..ac1298e2c774 100644 --- a/packages/cli/generators/project/templates/package.plain.json.ejs +++ b/packages/cli/generators/project/templates/package.plain.json.ejs @@ -35,18 +35,18 @@ <% } -%> "pretest": "npm run clean && npm run build", <% if (project.mocha) { -%> - "test": "mocha dist/test", + "test": "mocha dist/__tests__", <% } -%> <% if (project.prettier || project.tslint) { -%> "posttest": "npm run lint", <% } -%> <% if (project.mocha && (project.prettier || project.tslint)) { -%> - "test:dev": "mocha dist/test/**/*.js && npm run posttest", + "test:dev": "mocha dist/__tests__/**/*.js && npm run posttest", <% } else if (project.mocha) { -%> - "test:dev": "mocha dist/test/**/*.js", + "test:dev": "mocha dist/__tests__/**/*.js", <% } -%> <% if (project.projectType === 'application') { -%> - "migrate": "node ./dist/src/migrate", + "migrate": "node ./dist/migrate", "start": "npm run build && node .", <% } -%> "prepare": "npm run build" @@ -64,7 +64,8 @@ "index.js", "index.d.ts", "dist", - "src" + "src", + "!*/__tests__" ], "dependencies": { "@loopback/boot": "<%= project.dependencies['@loopback/boot'] -%>", diff --git a/packages/cli/generators/project/templates/tsconfig.json.ejs b/packages/cli/generators/project/templates/tsconfig.json.ejs index 3558f3da80cf..e89fc7f68e4f 100644 --- a/packages/cli/generators/project/templates/tsconfig.json.ejs +++ b/packages/cli/generators/project/templates/tsconfig.json.ejs @@ -2,8 +2,14 @@ "$schema": "http://json.schemastore.org/tsconfig", <% if (project.loopbackBuild) { -%> "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src" + }, + "include": ["src"] <% } else { -%> "compilerOptions": { + "rootDir": "src", + "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": true, @@ -17,15 +23,11 @@ "sourceMap": true, "declaration": true }, -<% } -%> - "include": [ - "src", - "test", - "index.ts" - ], + "include": ["src"], "exclude": [ "node_modules/**", "packages/*/node_modules/**", "**/*.d.ts" ] +<% } -%> } diff --git a/packages/cli/generators/repository/index.js b/packages/cli/generators/repository/index.js index 429cf9c67643..f73e87f66c8f 100644 --- a/packages/cli/generators/repository/index.js +++ b/packages/cli/generators/repository/index.js @@ -14,12 +14,34 @@ const chalk = require('chalk'); const utils = require('../../lib/utils'); const connectors = require('../datasource/connectors.json'); const tsquery = require('../../lib/ast-helper'); +const pascalCase = require('change-case').pascalCase; const VALID_CONNECTORS_FOR_REPOSITORY = ['KeyValueModel', 'PersistedModel']; const KEY_VALUE_CONNECTOR = ['KeyValueModel']; const DEFAULT_CRUD_REPOSITORY = 'DefaultCrudRepository'; const KEY_VALUE_REPOSITORY = 'DefaultKeyValueRepository'; +const BASE_REPOSITORIES = [DEFAULT_CRUD_REPOSITORY, KEY_VALUE_REPOSITORY]; +const CLI_BASE_CRUD_REPOSITORIES = [ + { + name: `${DEFAULT_CRUD_REPOSITORY} ${chalk.gray('(Legacy juggler bridge)')}`, + value: DEFAULT_CRUD_REPOSITORY, + }, +]; +const CLI_BASE_KEY_VALUE_REPOSITORIES = [ + { + name: `${KEY_VALUE_REPOSITORY} ${chalk.gray( + '(For access to a key-value store)', + )}`, + value: KEY_VALUE_REPOSITORY, + }, +]; +const CLI_BASE_SEPARATOR = [ + { + type: 'separator', + line: '----- Custom Repositories -----', + }, +]; const REPOSITORY_KV_TEMPLATE = 'repository-kv-template.ts.ejs'; const REPOSITORY_CRUD_TEMPLATE = 'repository-crud-default-template.ts.ejs'; @@ -27,6 +49,7 @@ const REPOSITORY_CRUD_TEMPLATE = 'repository-crud-default-template.ts.ejs'; const PROMPT_MESSAGE_MODEL = 'Select the model(s) you want to generate a repository'; const PROMPT_MESSAGE_DATA_SOURCE = 'Please select the datasource'; +const PROMPT_BASE_REPOSITORY_CLASS = 'Please select the repository base class'; const ERROR_READING_FILE = 'Error reading file'; const ERROR_NO_DATA_SOURCES_FOUND = 'No datasources found at'; const ERROR_NO_MODELS_FOUND = 'No models found at'; @@ -38,6 +61,35 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator { super(args, opts); } + /** + * Find all the base artifacts in the given path whose type matches the + * provided artifactType. + * For example, a artifactType of "repository" will search the target path for + * matches to "*.repository.base.ts" + * @param {string} dir The target directory from which to load artifacts. + * @param {string} artifactType The artifact type (ex. "model", "repository") + */ + async _findBaseClasses(dir, artifactType) { + const paths = await utils.findArtifactPaths(dir, artifactType + '.base'); + debug(`repository artifact paths: ${paths}`); + + // get base class and path + const baseRepositoryList = []; + for (const p of paths) { + //get name removing anything from .artifactType.base + const artifactFile = path.parse(_.last(_.split(p, path.sep))).name; + const firstWord = _.first(_.split(artifactFile, '.')); + const artifactName = + utils.toClassName(firstWord) + utils.toClassName(artifactType); + + const baseRepository = {name: artifactName, file: artifactFile}; + baseRepositoryList.push(baseRepository); + } + + debug(`repository base classes: ${inspect(baseRepositoryList)}`); + return baseRepositoryList; + } + /** * get the property name for the id field * @param {string} modelName @@ -131,6 +183,13 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator { description: 'A valid datasource name', }); + this.option('repositoryBaseClass', { + type: String, + required: false, + description: 'A valid repository base class', + default: 'DefaultCrudRepository', + }); + return super._setupGenerator(); } @@ -313,6 +372,65 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator { }); } + async promptBaseClass() { + debug('Prompting for repository base'); + if (this.shouldExit()) return; + + const availableRepositoryList = []; + + debug(`repositoryTypeClass ${this.artifactInfo.repositoryTypeClass}`); + // Add base repositories based on datasource type + if (this.artifactInfo.repositoryTypeClass === KEY_VALUE_REPOSITORY) + availableRepositoryList.push(...CLI_BASE_KEY_VALUE_REPOSITORIES); + else availableRepositoryList.push(...CLI_BASE_CRUD_REPOSITORIES); + availableRepositoryList.push(...CLI_BASE_SEPARATOR); + + try { + this.artifactInfo.baseRepositoryList = await this._findBaseClasses( + this.artifactInfo.outDir, + 'repository', + ); + if ( + this.artifactInfo.baseRepositoryList && + this.artifactInfo.baseRepositoryList.length > 0 + ) { + availableRepositoryList.push(...this.artifactInfo.baseRepositoryList); + debug(`availableRepositoryList ${availableRepositoryList}`); + } + } catch (err) { + return this.exit(err); + } + + if (this.options.repositoryBaseClass) { + debug( + `Base repository received from command line: ${ + this.options.repositoryBaseClass + }`, + ); + this.artifactInfo.repositoryBaseClass = this.options.repositoryBaseClass; + } + + return this.prompt([ + { + type: 'list', + name: 'repositoryBaseClass', + message: PROMPT_BASE_REPOSITORY_CLASS, + when: this.artifactInfo.repositoryBaseClass === undefined, + choices: availableRepositoryList, + default: availableRepositoryList[0], + }, + ]) + .then(props => { + debug(`props after custom repository prompt: ${inspect(props)}`); + Object.assign(this.artifactInfo, props); + return props; + }) + .catch(err => { + debug(`Error during repository base class prompt: ${err.stack}`); + return this.exit(err); + }); + } + async promptModelId() { if (this.shouldExit()) return false; let idProperty; @@ -362,6 +480,22 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator { async _scaffold() { if (this.shouldExit()) return false; + this.artifactInfo.isRepositoryBaseBuiltin = BASE_REPOSITORIES.includes( + this.artifactInfo.repositoryBaseClass, + ); + debug( + `isRepositoryBaseBuiltin : ${this.artifactInfo.isRepositoryBaseBuiltin}`, + ); + if (!this.artifactInfo.isRepositoryBaseBuiltin) { + const baseIndex = _.findIndex(this.artifactInfo.baseRepositoryList, [ + 'name', + this.artifactInfo.repositoryBaseClass, + ]); + this.artifactInfo.repositoryBaseFile = this.artifactInfo.baseRepositoryList[ + baseIndex + ].file; + } + if (this.options.name) { this.artifactInfo.className = utils.toClassName(this.options.name); this.artifactInfo.outFile = utils.getRepositoryFileName( @@ -401,6 +535,7 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator { debug(`artifactInfo: ${inspect(this.artifactInfo)}`); debug(`Copying artifact to: ${dest}`); } + this.copyTemplatedFiles(source, dest, this.artifactInfo); return; } @@ -412,6 +547,13 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator { ? 'Repositories' : 'Repository'; + this.artifactInfo.modelNameList = _.map( + this.artifactInfo.modelNameList, + repositoryName => { + return repositoryName + 'Repository'; + }, + ); + this.artifactInfo.name = this.artifactInfo.modelNameList ? this.artifactInfo.modelNameList.join() : this.artifactInfo.modelName; diff --git a/packages/cli/generators/repository/templates/src/repositories/repository-crud-default-template.ts.ejs b/packages/cli/generators/repository/templates/src/repositories/repository-crud-default-template.ts.ejs index ff412603a65e..10c17ca0151c 100644 --- a/packages/cli/generators/repository/templates/src/repositories/repository-crud-default-template.ts.ejs +++ b/packages/cli/generators/repository/templates/src/repositories/repository-crud-default-template.ts.ejs @@ -1,9 +1,14 @@ -import {<%= repositoryTypeClass %>, juggler} from '@loopback/repository'; +<%if (isRepositoryBaseBuiltin) { -%> +import {<%= repositoryTypeClass %>} from '@loopback/repository'; +<% } -%> import {<%= modelName %>} from '../models'; import {<%= dataSourceClassName %>} from '../datasources'; import {inject} from '@loopback/core'; +<%if ( !isRepositoryBaseBuiltin ) { -%> +import {<%=repositoryBaseClass %>} from './<%=repositoryBaseFile %>'; +<% } -%> -export class <%= className %>Repository extends <%= repositoryTypeClass %>< +export class <%= className %>Repository extends <%= repositoryBaseClass %>< <%= modelName %>, typeof <%= modelName %>.prototype.<%= idProperty %> > { diff --git a/packages/cli/generators/repository/templates/src/repositories/repository-kv-template.ts.ejs b/packages/cli/generators/repository/templates/src/repositories/repository-kv-template.ts.ejs index d84bc66f309b..2f70bfdda13c 100644 --- a/packages/cli/generators/repository/templates/src/repositories/repository-kv-template.ts.ejs +++ b/packages/cli/generators/repository/templates/src/repositories/repository-kv-template.ts.ejs @@ -1,11 +1,16 @@ -import {<%= repositoryTypeClass %>} from '@loopback/repository'; +<%if (isRepositoryBaseBuiltin) { -%> +import {<%= repositoryTypeClass %>, juggler} from '@loopback/repository'; +<% } -%> import {<%= modelName %>} from '../models'; import {<%= dataSourceClassName %>} from '../datasources'; import {inject} from '@loopback/core'; +<%if ( !isRepositoryBaseBuiltin ) { -%> +import {<%=repositoryBaseClass %>} from './<%=repositoryBaseFile %>'; +<% } -%> -export class <%= className %>Repository extends <%= repositoryTypeClass %>< +export class <%= className %>Repository extends <%= repositoryBaseClass %>< <%= modelName %> - > { +> { constructor( @inject('datasources.<%= dataSourceName %>') dataSource: <%= dataSourceClassName %>, ) { diff --git a/packages/cli/package.json b/packages/cli/package.json index a6b7e82c5922..225e2266a4e0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/cli", - "version": "1.5.2", + "version": "1.6.0", "description": "Yeoman generator for LoopBack 4", "homepage": "https://github.com/strongloop/loopback-next/tree/master/packages/cli", "author": { @@ -24,8 +24,8 @@ "yeoman-generator" ], "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/ejs": "^2.6.0", "@types/node": "^10.11.2", @@ -36,27 +36,27 @@ "request": "^2.87.0", "request-promise-native": "^1.0.5", "rimraf": "^2.6.2", - "sinon": "^6.3.4", + "sinon": "^7.2.3", "yeoman-assert": "^3.1.1", "yeoman-environment": "^2.0.6", "yeoman-test": "^1.7.0" }, "dependencies": { - "@phenomnomnominal/tsquery": "^2.1.1", - "camelcase-keys": "^4.2.0", + "@phenomnomnominal/tsquery": "^3.0.0", + "camelcase-keys": "^5.0.0", "chalk": "^2.3.2", "change-case": "^3.0.2", "debug": "^4.0.1", "fs-extra": "^7.0.1", "json5": "^2.0.1", - "lodash": "^4.17.10", + "lodash": "^4.17.11", "minimist": "^1.2.0", "pacote": "^9.1.0", "pluralize": "^7.0.0", "regenerate": "^1.3.3", "semver": "^5.5.0", - "swagger-parser": "^5.0.0", - "swagger2openapi": "^3.2.10", + "swagger-parser": "^6.0.5", + "swagger2openapi": "^5.1.0", "typescript": "^3.1.1", "unicode-10.0.0": "^0.7.4", "update-notifier": "^2.5.0", @@ -87,34 +87,34 @@ "source-map-support": "^0.5.5", "strong-docs": "^4.0.0", "tslint": "^5.12.0", - "typescript": "^3.2.2", - "@loopback/authentication": "^1.0.11", - "@loopback/boot": "^1.0.11", - "@loopback/build": "^1.2.1", - "@loopback/cli": "^1.5.2", - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", - "@loopback/metadata": "^1.0.5", - "@loopback/openapi-spec-builder": "^1.0.5", - "@loopback/openapi-v3-types": "^1.0.5", - "@loopback/openapi-v3": "^1.2.0", - "@loopback/repository-json-schema": "^1.3.0", - "@loopback/repository": "^1.1.4", - "@loopback/rest": "^1.5.4", - "@loopback/testlab": "^1.0.5", - "@loopback/docs": "^1.7.2", + "typescript": "^3.3.1", + "@loopback/authentication": "^1.0.12", + "@loopback/boot": "^1.0.12", + "@loopback/build": "^1.3.0", + "@loopback/cli": "^1.6.0", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", + "@loopback/metadata": "^1.0.6", + "@loopback/openapi-spec-builder": "^1.0.6", + "@loopback/openapi-v3-types": "^1.0.6", + "@loopback/openapi-v3": "^1.2.1", + "@loopback/repository-json-schema": "^1.3.1", + "@loopback/repository": "^1.1.5", + "@loopback/rest": "^1.5.5", + "@loopback/testlab": "^1.0.6", + "@loopback/docs": "^1.7.3", "glob": "^7.1.2", - "@loopback/example-hello-world": "^1.1.2", - "@loopback/example-log-extension": "^1.1.2", - "@loopback/example-rpc-server": "^1.1.1", - "@loopback/example-todo": "^1.4.2", - "@loopback/example-soap-calculator": "^1.3.2", - "@loopback/service-proxy": "^1.0.7", - "@loopback/http-caching-proxy": "^1.0.5", - "@loopback/http-server": "^1.1.4", - "@loopback/example-todo-list": "^1.4.2", + "@loopback/example-hello-world": "^1.1.3", + "@loopback/example-log-extension": "^1.1.3", + "@loopback/example-rpc-server": "^1.1.2", + "@loopback/example-todo": "^1.4.3", + "@loopback/example-soap-calculator": "^1.3.3", + "@loopback/service-proxy": "^1.0.8", + "@loopback/http-caching-proxy": "^1.0.6", + "@loopback/http-server": "^1.1.5", + "@loopback/example-todo-list": "^1.4.3", "@loopback/dist-util": "^0.4.0", - "@loopback/rest-explorer": "^1.1.7", + "@loopback/rest-explorer": "^1.1.8", "@loopback/tslint-config": "^2.0.0" } }, diff --git a/packages/cli/test/fixtures/repository/index.js b/packages/cli/test/fixtures/repository/index.js index 7e0a993a78bd..6e224c0e6db5 100644 --- a/packages/cli/test/fixtures/repository/index.js +++ b/packages/cli/test/fixtures/repository/index.js @@ -1,5 +1,6 @@ const DATASOURCE_APP_PATH = 'src/datasources'; const MODEL_APP_PATH = 'src/models'; +const REPOSITORY_APP_PATH = 'src/repositories'; const CONFIG_PATH = '.'; const DUMMY_CONTENT = '--DUMMY VALUE--'; const fs = require('fs'); @@ -107,4 +108,14 @@ exports.SANDBOX_FILES = [ encoding: 'utf-8', }), }, + { + path: REPOSITORY_APP_PATH, + file: 'defaultmodel.repository.base.ts', + content: fs.readFileSync( + require.resolve('./repositories/defaultmodel.repository.base.ts'), + { + encoding: 'utf-8', + }, + ), + }, ]; diff --git a/packages/cli/test/fixtures/repository/repositories/defaultmodel.repository.base.ts b/packages/cli/test/fixtures/repository/repositories/defaultmodel.repository.base.ts new file mode 100644 index 000000000000..ddf7f1ca71f7 --- /dev/null +++ b/packages/cli/test/fixtures/repository/repositories/defaultmodel.repository.base.ts @@ -0,0 +1,13 @@ +import {DefaultCrudRepository} from '@loopback/repository'; +import {Defaultmodel} from '../models'; +import {DbmemDataSource} from '../datasources'; +import {inject} from '@loopback/core'; + +export class DefaultmodelRepository extends DefaultCrudRepository< + Defaultmodel, + typeof Defaultmodel.prototype.id +> { + constructor(@inject('datasources.dbmem') dataSource: DbmemDataSource) { + super(Defaultmodel, dataSource); + } +} diff --git a/packages/cli/test/integration/generators/app.integration.js b/packages/cli/test/integration/generators/app.integration.js index ba47c1165f26..6454afbb9423 100644 --- a/packages/cli/test/integration/generators/app.integration.js +++ b/packages/cli/test/integration/generators/app.integration.js @@ -69,15 +69,15 @@ describe('app-generator specific files', () => { /\'\@loopback\/rest\'/, ); assert.fileContent( - 'test/acceptance/ping.controller.acceptance.ts', + 'src/__tests__/acceptance/ping.controller.acceptance.ts', /describe\('PingController'/, ); assert.fileContent( - 'test/acceptance/home-page.acceptance.ts', + 'src/__tests__/acceptance/home-page.acceptance.ts', /describe\('HomePage'/, ); assert.fileContent( - 'test/acceptance/test-helper.ts', + 'src/__tests__/acceptance/test-helper.ts', /export async function setupApplication/, ); }); @@ -98,7 +98,7 @@ describe('app-generator specific files', () => { it('creates npm script "migrate-db"', async () => { const pkg = JSON.parse(await readFile('package.json')); - expect(pkg.scripts).to.have.property('migrate', 'node ./dist/src/migrate'); + expect(pkg.scripts).to.have.property('migrate', 'node ./dist/migrate'); }); }); diff --git a/packages/cli/test/integration/generators/repository.integration.js b/packages/cli/test/integration/generators/repository.integration.js index ed393f68d0e5..82fa0ac8b771 100644 --- a/packages/cli/test/integration/generators/repository.integration.js +++ b/packages/cli/test/integration/generators/repository.integration.js @@ -384,6 +384,41 @@ describe('lb4 repository', function() { /export \* from '.\/decoratordefined.repository';/, ); }); + it('generates a crud repository from custom base class', async () => { + await testUtils + .executeGenerator(generator) + .inDir(SANDBOX_PATH, () => + testUtils.givenLBProject(SANDBOX_PATH, { + additionalFiles: SANDBOX_FILES, + }), + ) + .withArguments( + '--datasource dbmem --model decoratordefined --repositoryBaseClass DefaultmodelRepository', + ); + const expectedFile = path.join( + SANDBOX_PATH, + REPOSITORY_APP_PATH, + 'decoratordefined.repository.ts', + ); + assert.file(expectedFile); + assert.fileContent( + expectedFile, + /import {DefaultmodelRepository} from '.\/defaultmodel.repository.base';/, + ); + assert.fileContent( + expectedFile, + /export class DecoratordefinedRepository extends DefaultmodelRepository\ { @@ -395,7 +430,9 @@ describe('lb4 repository', function() { additionalFiles: SANDBOX_FILES, }), ) - .withArguments('--datasource dbkv --model Defaultmodel'); + .withArguments( + '--datasource dbkv --model Defaultmodel --repositoryBaseClass DefaultKeyValueRepository', + ); const expectedFile = path.join( SANDBOX_PATH, REPOSITORY_APP_PATH, @@ -425,7 +462,9 @@ describe('lb4 repository', function() { }), ) .withPrompts(basicPrompt) - .withArguments('--model decoratordefined'); + .withArguments( + '--model decoratordefined --repositoryBaseClass DefaultKeyValueRepository', + ); const expectedFile = path.join( SANDBOX_PATH, REPOSITORY_APP_PATH, diff --git a/packages/cli/test/integration/lib/project-generator.js b/packages/cli/test/integration/lib/project-generator.js index ca399e61de53..8f344845ac1e 100644 --- a/packages/cli/test/integration/lib/project-generator.js +++ b/packages/cli/test/integration/lib/project-generator.js @@ -254,10 +254,7 @@ module.exports = function(projGenerator, props, projectType) { ['tslint.json', '@loopback/tslint-config'], ['tsconfig.json', '@loopback/build'], ]); - assert.noFileContent([ - ['tslint.json', '"rules"'], - ['tsconfig.json', '"compilerOptions"'], - ]); + assert.noFileContent([['tslint.json', '"rules"']]); if (projectType === 'application') { assert.fileContent( diff --git a/packages/context/CHANGELOG.md b/packages/context/CHANGELOG.md index 9919830d3074..4a488167c6e4 100644 --- a/packages/context/CHANGELOG.md +++ b/packages/context/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.5.1](https://github.com/strongloop/loopback-next/compare/@loopback/context@1.5.0...@loopback/context@1.5.1) (2019-02-08) + +**Note:** Version bump only for package @loopback/context + + + + + # [1.5.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@1.4.1...@loopback/context@1.5.0) (2019-01-28) diff --git a/packages/context/package.json b/packages/context/package.json index 5df62eefa0fb..96a2d286d989 100644 --- a/packages/context/package.json +++ b/packages/context/package.json @@ -1,34 +1,34 @@ { "name": "@loopback/context", - "version": "1.5.0", + "version": "1.5.1", "description": "LoopBack's container for Inversion of Control", "engines": { "node": ">=8.9" }, "scripts": { - "acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"", + "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-context*.tgz dist package api-docs", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/acceptance/**/*.js\"", - "unit": "lb-mocha \"dist/test/unit/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"", + "unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"", "verify": "npm pack && tar xf loopback-context*.tgz && tree package && npm run clean" }, "author": "IBM", "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/metadata": "^1.0.5", + "@loopback/metadata": "^1.0.6", "debug": "^4.0.1", "uuid": "^3.2.1" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/bluebird": "^3.5.20", - "@types/debug": "^0.0.30", + "@types/debug": "^4.1.0", "@types/node": "^10.11.2", "@types/uuid": "^3.4.3", "bluebird": "^3.5.1" @@ -46,9 +46,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "repository": { "type": "git", diff --git a/packages/context/test/acceptance/1-feature.md b/packages/context/src/__tests__/acceptance/1-feature.md similarity index 100% rename from packages/context/test/acceptance/1-feature.md rename to packages/context/src/__tests__/acceptance/1-feature.md diff --git a/packages/context/test/acceptance/bind-decorator.acceptance.ts b/packages/context/src/__tests__/acceptance/bind-decorator.acceptance.ts similarity index 94% rename from packages/context/test/acceptance/bind-decorator.acceptance.ts rename to packages/context/src/__tests__/acceptance/bind-decorator.acceptance.ts index a67ff0bf9070..696e024102eb 100644 --- a/packages/context/test/acceptance/bind-decorator.acceptance.ts +++ b/packages/context/src/__tests__/acceptance/bind-decorator.acceptance.ts @@ -4,8 +4,13 @@ // License text available at https://opensource.org/licenses/MIT import {expect} from '@loopback/testlab'; -import {Context, bind, BindingScope, Provider} from '../..'; -import {createBindingFromClass} from '../../src'; +import { + bind, + BindingScope, + Context, + createBindingFromClass, + Provider, +} from '../..'; describe('@bind - customize classes with binding attributes', () => { @bind({ diff --git a/packages/context/test/acceptance/binding-decorator.feature.md b/packages/context/src/__tests__/acceptance/binding-decorator.feature.md similarity index 100% rename from packages/context/test/acceptance/binding-decorator.feature.md rename to packages/context/src/__tests__/acceptance/binding-decorator.feature.md diff --git a/packages/context/test/acceptance/child-context.acceptance.ts b/packages/context/src/__tests__/acceptance/child-context.acceptance.ts similarity index 100% rename from packages/context/test/acceptance/child-context.acceptance.ts rename to packages/context/src/__tests__/acceptance/child-context.acceptance.ts diff --git a/packages/context/test/acceptance/class-level-bindings.acceptance.ts b/packages/context/src/__tests__/acceptance/class-level-bindings.acceptance.ts similarity index 100% rename from packages/context/test/acceptance/class-level-bindings.acceptance.ts rename to packages/context/src/__tests__/acceptance/class-level-bindings.acceptance.ts diff --git a/packages/context/test/acceptance/class-level-bindings.feature.md b/packages/context/src/__tests__/acceptance/class-level-bindings.feature.md similarity index 100% rename from packages/context/test/acceptance/class-level-bindings.feature.md rename to packages/context/src/__tests__/acceptance/class-level-bindings.feature.md diff --git a/packages/context/test/acceptance/creating-and-resolving-bindings.acceptance.ts b/packages/context/src/__tests__/acceptance/creating-and-resolving-bindings.acceptance.ts similarity index 100% rename from packages/context/test/acceptance/creating-and-resolving-bindings.acceptance.ts rename to packages/context/src/__tests__/acceptance/creating-and-resolving-bindings.acceptance.ts diff --git a/packages/context/test/acceptance/creating-and-resolving-bindings.feature.md b/packages/context/src/__tests__/acceptance/creating-and-resolving-bindings.feature.md similarity index 100% rename from packages/context/test/acceptance/creating-and-resolving-bindings.feature.md rename to packages/context/src/__tests__/acceptance/creating-and-resolving-bindings.feature.md diff --git a/packages/context/test/acceptance/finding-bindings.acceptance.ts b/packages/context/src/__tests__/acceptance/finding-bindings.acceptance.ts similarity index 100% rename from packages/context/test/acceptance/finding-bindings.acceptance.ts rename to packages/context/src/__tests__/acceptance/finding-bindings.acceptance.ts diff --git a/packages/context/test/acceptance/finding-bindings.feature.md b/packages/context/src/__tests__/acceptance/finding-bindings.feature.md similarity index 100% rename from packages/context/test/acceptance/finding-bindings.feature.md rename to packages/context/src/__tests__/acceptance/finding-bindings.feature.md diff --git a/packages/context/test/acceptance/locking-bindings.acceptance.ts b/packages/context/src/__tests__/acceptance/locking-bindings.acceptance.ts similarity index 100% rename from packages/context/test/acceptance/locking-bindings.acceptance.ts rename to packages/context/src/__tests__/acceptance/locking-bindings.acceptance.ts diff --git a/packages/context/test/acceptance/locking-bindings.feature.md b/packages/context/src/__tests__/acceptance/locking-bindings.feature.md similarity index 100% rename from packages/context/test/acceptance/locking-bindings.feature.md rename to packages/context/src/__tests__/acceptance/locking-bindings.feature.md diff --git a/packages/context/test/acceptance/method-level-bindings.acceptance.ts b/packages/context/src/__tests__/acceptance/method-level-bindings.acceptance.ts similarity index 100% rename from packages/context/test/acceptance/method-level-bindings.acceptance.ts rename to packages/context/src/__tests__/acceptance/method-level-bindings.acceptance.ts diff --git a/packages/context/test/acceptance/method-level-bindings.feature.md b/packages/context/src/__tests__/acceptance/method-level-bindings.feature.md similarity index 100% rename from packages/context/test/acceptance/method-level-bindings.feature.md rename to packages/context/src/__tests__/acceptance/method-level-bindings.feature.md diff --git a/packages/context/test/acceptance/tagged-bindings.acceptance.ts b/packages/context/src/__tests__/acceptance/tagged-bindings.acceptance.ts similarity index 100% rename from packages/context/test/acceptance/tagged-bindings.acceptance.ts rename to packages/context/src/__tests__/acceptance/tagged-bindings.acceptance.ts diff --git a/packages/context/test/acceptance/tagged-bindings.feature.md b/packages/context/src/__tests__/acceptance/tagged-bindings.feature.md similarity index 100% rename from packages/context/test/acceptance/tagged-bindings.feature.md rename to packages/context/src/__tests__/acceptance/tagged-bindings.feature.md diff --git a/packages/context/test/acceptance/unlocking-bindings.acceptance.ts b/packages/context/src/__tests__/acceptance/unlocking-bindings.acceptance.ts similarity index 100% rename from packages/context/test/acceptance/unlocking-bindings.acceptance.ts rename to packages/context/src/__tests__/acceptance/unlocking-bindings.acceptance.ts diff --git a/packages/context/test/acceptance/unlocking-bindings.feature.md b/packages/context/src/__tests__/acceptance/unlocking-bindings.feature.md similarity index 100% rename from packages/context/test/acceptance/unlocking-bindings.feature.md rename to packages/context/src/__tests__/acceptance/unlocking-bindings.feature.md diff --git a/packages/context/test/unit/binding-decorator.unit.ts b/packages/context/src/__tests__/unit/binding-decorator.unit.ts similarity index 100% rename from packages/context/test/unit/binding-decorator.unit.ts rename to packages/context/src/__tests__/unit/binding-decorator.unit.ts diff --git a/packages/context/src/__tests__/unit/binding-filter.unit.ts b/packages/context/src/__tests__/unit/binding-filter.unit.ts new file mode 100644 index 000000000000..af414352ec3c --- /dev/null +++ b/packages/context/src/__tests__/unit/binding-filter.unit.ts @@ -0,0 +1,110 @@ +// Copyright IBM Corp. 2017,2018. All Rights Reserved. +// Node module: @loopback/context +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + +import {expect} from '@loopback/testlab'; +import {Binding, filterByKey, filterByTag} from '../..'; + +const key = 'foo'; + +describe('BindingFilter', () => { + let binding: Binding; + beforeEach(givenBinding); + + describe('filterByTag', () => { + it('accepts bindings MATCHING the provided tag name', () => { + const filter = filterByTag('controller'); + binding.tag('controller'); + expect(filter(binding)).to.be.true(); + }); + + it('rejects bindings NOT MATCHING the provided tag name', () => { + const filter = filterByTag('controller'); + binding.tag('dataSource'); + expect(filter(binding)).to.be.false(); + }); + + it('accepts bindings MATCHING the provided tag regexp', () => { + const filter = filterByTag(/^c/); + binding.tag('controller'); + expect(filter(binding)).to.be.true(); + }); + + it('rejects bindings NOT MATCHING the provided tag regexp', () => { + const filter = filterByTag(/^c/); + binding.tag('dataSource'); + expect(filter(binding)).to.be.false(); + }); + + it('accepts bindings MATCHING the provided tag map', () => { + const filter = filterByTag({controller: 'my-controller'}); + binding.tag({controller: 'my-controller'}); + binding.tag({name: 'my-controller'}); + expect(filter(binding)).to.be.true(); + }); + + it('accepts bindings MATCHING the provided tag map with multiple tags', () => { + const filter = filterByTag({ + controller: 'my-controller', + name: 'my-name', + }); + binding.tag({controller: 'my-controller'}); + binding.tag({name: 'my-name'}); + expect(filter(binding)).to.be.true(); + }); + + it('rejects bindings NOT MATCHING the provided tag map', () => { + const filter = filterByTag({controller: 'your-controller'}); + binding.tag({controller: 'my-controller'}); + binding.tag({name: 'my-controller'}); + expect(filter(binding)).to.be.false(); + }); + + it('rejects bindings NOT MATCHING the provided tag map with multiple tags', () => { + const filter = filterByTag({ + controller: 'my-controller', + name: 'my-name', + }); + binding.tag({controller: 'my-controller'}); + binding.tag({name: 'my-controller'}); + expect(filter(binding)).to.be.false(); + }); + }); + + describe('filterByKey', () => { + it('accepts bindings MATCHING the provided key', () => { + const filter = filterByKey(key); + expect(filter(binding)).to.be.true(); + }); + + it('rejects bindings NOT MATCHING the provided key', () => { + const filter = filterByKey(`another-${key}`); + expect(filter(binding)).to.be.false(); + }); + + it('accepts bindings MATCHING the provided key regexp', () => { + const filter = filterByKey(/f.*/); + expect(filter(binding)).to.be.true(); + }); + + it('rejects bindings NOT MATCHING the provided key regexp', () => { + const filter = filterByKey(/^ba/); + expect(filter(binding)).to.be.false(); + }); + + it('accepts bindings MATCHING the provided filter', () => { + const filter = filterByKey(b => b.key === key); + expect(filter(binding)).to.be.true(); + }); + + it('rejects bindings NOT MATCHING the provided filter', () => { + const filter = filterByKey(b => b.key !== key); + expect(filter(binding)).to.be.false(); + }); + }); + + function givenBinding() { + binding = new Binding(key); + } +}); diff --git a/packages/context/test/unit/binding-inspector.unit.ts b/packages/context/src/__tests__/unit/binding-inspector.unit.ts similarity index 99% rename from packages/context/test/unit/binding-inspector.unit.ts rename to packages/context/src/__tests__/unit/binding-inspector.unit.ts index 39e470b7053f..b9d6976a5bd6 100644 --- a/packages/context/test/unit/binding-inspector.unit.ts +++ b/packages/context/src/__tests__/unit/binding-inspector.unit.ts @@ -6,6 +6,7 @@ import {expect} from '@loopback/testlab'; import { bind, + BindingFromClassOptions, BindingScope, BindingScopeAndTags, Constructor, @@ -13,7 +14,6 @@ import { createBindingFromClass, Provider, } from '../..'; -import {BindingFromClassOptions} from '../../src'; describe('createBindingFromClass()', () => { it('inspects classes', () => { diff --git a/packages/context/test/unit/binding-key.unit.ts b/packages/context/src/__tests__/unit/binding-key.unit.ts similarity index 100% rename from packages/context/test/unit/binding-key.unit.ts rename to packages/context/src/__tests__/unit/binding-key.unit.ts diff --git a/packages/context/test/unit/binding.unit.ts b/packages/context/src/__tests__/unit/binding.unit.ts similarity index 100% rename from packages/context/test/unit/binding.unit.ts rename to packages/context/src/__tests__/unit/binding.unit.ts diff --git a/packages/context/test/unit/context.unit.ts b/packages/context/src/__tests__/unit/context.unit.ts similarity index 100% rename from packages/context/test/unit/context.unit.ts rename to packages/context/src/__tests__/unit/context.unit.ts diff --git a/packages/context/test/unit/inject.unit.ts b/packages/context/src/__tests__/unit/inject.unit.ts similarity index 100% rename from packages/context/test/unit/inject.unit.ts rename to packages/context/src/__tests__/unit/inject.unit.ts diff --git a/packages/context/test/unit/is-promise.unit.ts b/packages/context/src/__tests__/unit/is-promise.unit.ts similarity index 100% rename from packages/context/test/unit/is-promise.unit.ts rename to packages/context/src/__tests__/unit/is-promise.unit.ts diff --git a/packages/context/test/unit/provider.unit.ts b/packages/context/src/__tests__/unit/provider.unit.ts similarity index 100% rename from packages/context/test/unit/provider.unit.ts rename to packages/context/src/__tests__/unit/provider.unit.ts diff --git a/packages/context/test/unit/resolution-session.unit.ts b/packages/context/src/__tests__/unit/resolution-session.unit.ts similarity index 100% rename from packages/context/test/unit/resolution-session.unit.ts rename to packages/context/src/__tests__/unit/resolution-session.unit.ts diff --git a/packages/context/test/unit/resolver.unit.ts b/packages/context/src/__tests__/unit/resolver.unit.ts similarity index 100% rename from packages/context/test/unit/resolver.unit.ts rename to packages/context/src/__tests__/unit/resolver.unit.ts diff --git a/packages/context/test/unit/value-promise.unit.ts b/packages/context/src/__tests__/unit/value-promise.unit.ts similarity index 100% rename from packages/context/test/unit/value-promise.unit.ts rename to packages/context/src/__tests__/unit/value-promise.unit.ts diff --git a/packages/context/test/unit/binding-filter.unit.ts b/packages/context/test/unit/binding-filter.unit.ts deleted file mode 100644 index 7d7ae14ac645..000000000000 --- a/packages/context/test/unit/binding-filter.unit.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/context -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -import {expect} from '@loopback/testlab'; -import {Binding, filterByKey, filterByTag} from '../..'; - -const key = 'foo'; - -describe('BindingFilter', () => { - let binding: Binding; - beforeEach(givenBinding); - - describe('filterByTag', () => { - it('accepts bindings MATCHING the provided tag name', () => { - const filter = filterByTag('controller'); - binding.tag('controller'); - expect(filter(binding)).to.be.true(); - }); - - it('rejects bindings NOT MATCHING the provided tag name', () => { - const filter = filterByTag('controller'); - binding.tag('dataSource'); - expect(filter(binding)).to.be.false(); - }); - - // TODO: filter by tag map, filter by regexp - }); - - describe('filterByKey', () => { - it('accepts bindings MATCHING the provided key', () => { - const filter = filterByKey(key); - expect(filter(binding)).to.be.true(); - }); - - it('rejects bindings NOT MATCHING the provided key', () => { - const filter = filterByKey(`another-${key}`); - expect(filter(binding)).to.be.false(); - }); - - // TODO: filter by regexp, filter by BindingFunction - }); - - function givenBinding() { - binding = new Binding(key); - } -}); diff --git a/packages/context/tsconfig.build.json b/packages/context/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/context/tsconfig.build.json +++ b/packages/context/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index e6d891c4abcf..a52a00a0286f 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.6](https://github.com/strongloop/loopback-next/compare/@loopback/core@1.1.5...@loopback/core@1.1.6) (2019-02-08) + +**Note:** Version bump only for package @loopback/core + + + + + ## [1.1.5](https://github.com/strongloop/loopback-next/compare/@loopback/core@1.1.4...@loopback/core@1.1.5) (2019-01-28) **Note:** Version bump only for package @loopback/core diff --git a/packages/core/package.json b/packages/core/package.json index cd58ed730939..ff32eef77aba 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,30 +1,30 @@ { "name": "@loopback/core", - "version": "1.1.5", + "version": "1.1.6", "description": "", "engines": { "node": ">=8.9" }, "scripts": { - "acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"", + "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-core*.tgz dist package api-docs", "pretest": "npm run build", - "integration": "lb-mocha \"dist/test/integration/**/*.js\"", - "test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/integration/**/*.js\" \"dist/test/acceptance/**/*.js\"", - "unit": "lb-mocha \"dist/test/unit/**/*.js\"", + "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/integration/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"", + "unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"", "verify": "npm pack && tar xf loopback-core*.tgz && tree package && npm run clean" }, "author": "IBM", "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/context": "^1.5.0" + "@loopback/context": "^1.5.1" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, @@ -32,9 +32,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "repository": { "type": "git", diff --git a/packages/core/test/acceptance/application.acceptance.ts b/packages/core/src/__tests__/acceptance/application.acceptance.ts similarity index 100% rename from packages/core/test/acceptance/application.acceptance.ts rename to packages/core/src/__tests__/acceptance/application.acceptance.ts diff --git a/packages/core/test/acceptance/application.feature.md b/packages/core/src/__tests__/acceptance/application.feature.md similarity index 100% rename from packages/core/test/acceptance/application.feature.md rename to packages/core/src/__tests__/acceptance/application.feature.md diff --git a/packages/core/test/unit/application.unit.ts b/packages/core/src/__tests__/unit/application.unit.ts similarity index 100% rename from packages/core/test/unit/application.unit.ts rename to packages/core/src/__tests__/unit/application.unit.ts diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/core/tsconfig.build.json +++ b/packages/core/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/http-caching-proxy/CHANGELOG.md b/packages/http-caching-proxy/CHANGELOG.md index e340735585d3..59548b9b1a59 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.6](https://github.com/strongloop/loopback-next/compare/@loopback/http-caching-proxy@1.0.5...@loopback/http-caching-proxy@1.0.6) (2019-02-08) + +**Note:** Version bump only for package @loopback/http-caching-proxy + + + + + ## [1.0.5](https://github.com/strongloop/loopback-next/compare/@loopback/http-caching-proxy@1.0.4...@loopback/http-caching-proxy@1.0.5) (2019-01-28) **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 9ed8b52794f7..5ed00431ea18 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.5", + "version": "1.0.6", "description": "A caching HTTP proxy for integration tests. NOT SUITABLE FOR PRODUCTION USE!", "engines": { "node": ">=8.9" @@ -10,7 +10,7 @@ "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-caching-proxy*.tgz dist package api-docs", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/integration/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/integration/**/*.js\"", "verify": "npm pack && tar xf loopback-caching-proxy*.tgz && tree package && npm run clean" }, "author": "IBM", @@ -25,10 +25,10 @@ "rimraf": "^2.6.2" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", - "@types/debug": "^0.0.30", + "@types/debug": "^4.1.0", "@types/node": "^10.11.2", "@types/p-event": "^1.3.0", "@types/request-promise-native": "^1.0.14", @@ -46,9 +46,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "publishConfig": { "access": "public" diff --git a/packages/http-caching-proxy/test/integration/http-caching-proxy.integration.ts b/packages/http-caching-proxy/src/__tests__/integration/http-caching-proxy.integration.ts similarity index 98% rename from packages/http-caching-proxy/test/integration/http-caching-proxy.integration.ts rename to packages/http-caching-proxy/src/__tests__/integration/http-caching-proxy.integration.ts index 4302748fbe43..7375fd827e9b 100644 --- a/packages/http-caching-proxy/test/integration/http-caching-proxy.integration.ts +++ b/packages/http-caching-proxy/src/__tests__/integration/http-caching-proxy.integration.ts @@ -12,7 +12,7 @@ import * as path from 'path'; import * as makeRequest from 'request-promise-native'; import * as rimrafCb from 'rimraf'; import * as util from 'util'; -import {HttpCachingProxy, ProxyOptions} from '../../src/http-caching-proxy'; +import {HttpCachingProxy, ProxyOptions} from '../../http-caching-proxy'; const CACHE_DIR = path.join(__dirname, '.cache'); diff --git a/packages/http-caching-proxy/test/unit/http-caching-proxy.test.ts b/packages/http-caching-proxy/src/__tests__/unit/http-caching-proxy.test.ts similarity index 90% rename from packages/http-caching-proxy/test/unit/http-caching-proxy.test.ts rename to packages/http-caching-proxy/src/__tests__/unit/http-caching-proxy.test.ts index df04524038fc..a6982b9f62ea 100644 --- a/packages/http-caching-proxy/test/unit/http-caching-proxy.test.ts +++ b/packages/http-caching-proxy/src/__tests__/unit/http-caching-proxy.test.ts @@ -4,7 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {expect} from '@loopback/testlab'; -import {HttpCachingProxy} from '../../src/http-caching-proxy'; +import {HttpCachingProxy} from '../../http-caching-proxy'; describe('HttpCachingProxy', () => { describe('constructor', () => { diff --git a/packages/http-caching-proxy/tsconfig.build.json b/packages/http-caching-proxy/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/http-caching-proxy/tsconfig.build.json +++ b/packages/http-caching-proxy/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/http-server/CHANGELOG.md b/packages/http-server/CHANGELOG.md index 4e7e4433e109..c0385bf34354 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.5](https://github.com/strongloop/loopback-next/compare/@loopback/http-server@1.1.4...@loopback/http-server@1.1.5) (2019-02-08) + +**Note:** Version bump only for package @loopback/http-server + + + + + ## [1.1.4](https://github.com/strongloop/loopback-next/compare/@loopback/http-server@1.1.3...@loopback/http-server@1.1.4) (2019-01-28) **Note:** Version bump only for package @loopback/http-server diff --git a/packages/http-server/package.json b/packages/http-server/package.json index 412b0a5a3fe6..175cd6bea211 100644 --- a/packages/http-server/package.json +++ b/packages/http-server/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/http-server", - "version": "1.1.4", + "version": "1.1.5", "description": "A wrapper for creating HTTP/HTTPS servers", "engines": { "node": ">=8.9" @@ -10,7 +10,7 @@ "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-http-server*.tgz dist package api-docs", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/**/*.js\"", "verify": "npm pack && tar xf loopback-http-server*.tgz && tree package && npm run clean" }, "author": "IBM", @@ -20,9 +20,9 @@ "p-event": "^2.0.0" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/core": "^1.1.5", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/core": "^1.1.6", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2", "@types/p-event": "^1.3.0", @@ -33,9 +33,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "publishConfig": { "access": "public" diff --git a/packages/http-server/test/integration/http-server.integration.ts b/packages/http-server/src/__tests__/integration/http-server.integration.ts similarity index 100% rename from packages/http-server/test/integration/http-server.integration.ts rename to packages/http-server/src/__tests__/integration/http-server.integration.ts diff --git a/packages/http-server/tsconfig.build.json b/packages/http-server/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/http-server/tsconfig.build.json +++ b/packages/http-server/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/metadata/CHANGELOG.md b/packages/metadata/CHANGELOG.md index 209a173bc816..cb05a7c1d416 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.6](https://github.com/strongloop/loopback-next/compare/@loopback/metadata@1.0.5...@loopback/metadata@1.0.6) (2019-02-08) + + +### Bug Fixes + +* update to the most recent lodash version ([65ee865](https://github.com/strongloop/loopback-next/commit/65ee865)) + + + + + ## [1.0.5](https://github.com/strongloop/loopback-next/compare/@loopback/metadata@1.0.4...@loopback/metadata@1.0.5) (2019-01-28) **Note:** Version bump only for package @loopback/metadata diff --git a/packages/metadata/package.json b/packages/metadata/package.json index 3f4d18ed6787..7fea10d4617b 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -1,18 +1,18 @@ { "name": "@loopback/metadata", - "version": "1.0.5", + "version": "1.0.6", "description": "LoopBack's metadata utilities for reflection and decoration", "engines": { "node": ">=8.9" }, "scripts": { - "acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"", + "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-metadata*.tgz dist package api-docs", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/acceptance/**/*.js\"", - "unit": "lb-mocha \"dist/test/unit/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"", + "unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"", "verify": "npm pack && tar xf loopback-metadata*.tgz && tree package && npm run clean" }, "author": "IBM", @@ -20,14 +20,14 @@ "license": "MIT", "dependencies": { "debug": "^4.0.1", - "lodash": "^4.17.5", + "lodash": "^4.17.11", "reflect-metadata": "^0.1.10" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", - "@types/debug": "^0.0.30", + "@types/debug": "^4.1.0", "@types/lodash": "^4.14.106", "@types/node": "^10.11.2" }, @@ -40,9 +40,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "publishConfig": { "access": "public" diff --git a/packages/metadata/test/unit/decorator-factory.unit.ts b/packages/metadata/src/__tests__/unit/decorator-factory.unit.ts similarity index 100% rename from packages/metadata/test/unit/decorator-factory.unit.ts rename to packages/metadata/src/__tests__/unit/decorator-factory.unit.ts diff --git a/packages/metadata/test/unit/inspector.unit.ts b/packages/metadata/src/__tests__/unit/inspector.unit.ts similarity index 100% rename from packages/metadata/test/unit/inspector.unit.ts rename to packages/metadata/src/__tests__/unit/inspector.unit.ts diff --git a/packages/metadata/test/unit/metadata-accessor.test.ts b/packages/metadata/src/__tests__/unit/metadata-accessor.test.ts similarity index 100% rename from packages/metadata/test/unit/metadata-accessor.test.ts rename to packages/metadata/src/__tests__/unit/metadata-accessor.test.ts diff --git a/packages/metadata/test/unit/reflect.unit.ts b/packages/metadata/src/__tests__/unit/reflect.unit.ts similarity index 99% rename from packages/metadata/test/unit/reflect.unit.ts rename to packages/metadata/src/__tests__/unit/reflect.unit.ts index 82480460ab2a..fa9e99ceed18 100644 --- a/packages/metadata/test/unit/reflect.unit.ts +++ b/packages/metadata/src/__tests__/unit/reflect.unit.ts @@ -4,7 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {expect} from '@loopback/testlab'; -import {NamespacedReflect, Reflector} from '../../src/reflect'; +import {NamespacedReflect, Reflector} from '../../reflect'; import 'reflect-metadata'; function givenReflectContextWithNameSpace(): NamespacedReflect { diff --git a/packages/metadata/tsconfig.build.json b/packages/metadata/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/metadata/tsconfig.build.json +++ b/packages/metadata/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/openapi-spec-builder/CHANGELOG.md b/packages/openapi-spec-builder/CHANGELOG.md index d2999c26ec5a..fb8550378e61 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.6](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-spec-builder@1.0.5...@loopback/openapi-spec-builder@1.0.6) (2019-02-08) + +**Note:** Version bump only for package @loopback/openapi-spec-builder + + + + + ## [1.0.5](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-spec-builder@1.0.4...@loopback/openapi-spec-builder@1.0.5) (2019-01-28) **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 6a978ac79757..3b6f712c9bc6 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.5", + "version": "1.0.6", "description": "Make it easy to create OpenAPI (Swagger) specification documents in your tests using the builder pattern.", "engines": { "node": ">=8.9" @@ -22,10 +22,10 @@ "Testing" ], "dependencies": { - "@loopback/openapi-v3-types": "^1.0.5" + "@loopback/openapi-v3-types": "^1.0.6" }, "devDependencies": { - "@loopback/build": "^1.2.1", + "@loopback/build": "^1.3.0", "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, @@ -33,9 +33,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "repository": { "type": "git", diff --git a/packages/openapi-spec-builder/tsconfig.build.json b/packages/openapi-spec-builder/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/openapi-spec-builder/tsconfig.build.json +++ b/packages/openapi-spec-builder/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/openapi-v3-types/CHANGELOG.md b/packages/openapi-v3-types/CHANGELOG.md index cc378d3dcc4c..aa1a9760f641 100644 --- a/packages/openapi-v3-types/CHANGELOG.md +++ b/packages/openapi-v3-types/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/openapi-v3-types@1.0.5...@loopback/openapi-v3-types@1.0.6) (2019-02-08) + +**Note:** Version bump only for package @loopback/openapi-v3-types + + + + + ## [1.0.5](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3-types@1.0.4...@loopback/openapi-v3-types@1.0.5) (2019-01-28) **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 c39f1fa6673f..f94e05e246e5 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.5", + "version": "1.0.6", "description": "TypeScript type definitions for OpenAPI Specifications.", "engines": { "node": ">=8.9" @@ -9,8 +9,8 @@ "openapi3-ts": "^1.0.0" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, @@ -20,8 +20,8 @@ "clean": "lb-clean loopback-openapi-v3-types*.tgz dist package api-docs", "verify": "npm pack && tar xf loopback-openapi-v3-types*.tgz && tree package && npm run clean", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/**/*.js\"", - "unit": "npm run build && lb-mocha \"dist/test/unit/**/*.js\"" + "test": "lb-mocha \"dist/__tests__/**/*.js\"", + "unit": "npm run build && lb-mocha \"dist/__tests__/unit/**/*.js\"" }, "author": "IBM", "copyright.owner": "IBM Corp.", @@ -35,9 +35,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "publishConfig": { "access": "public" diff --git a/packages/openapi-v3-types/test/unit/openapi-v3-spec-types.unit.ts b/packages/openapi-v3-types/src/__tests__/unit/openapi-v3-spec-types.unit.ts similarity index 100% rename from packages/openapi-v3-types/test/unit/openapi-v3-spec-types.unit.ts rename to packages/openapi-v3-types/src/__tests__/unit/openapi-v3-spec-types.unit.ts diff --git a/packages/openapi-v3-types/test/unit/type-guards.unit.ts b/packages/openapi-v3-types/src/__tests__/unit/type-guards.unit.ts similarity index 100% rename from packages/openapi-v3-types/test/unit/type-guards.unit.ts rename to packages/openapi-v3-types/src/__tests__/unit/type-guards.unit.ts diff --git a/packages/openapi-v3-types/tsconfig.build.json b/packages/openapi-v3-types/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/openapi-v3-types/tsconfig.build.json +++ b/packages/openapi-v3-types/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/openapi-v3/CHANGELOG.md b/packages/openapi-v3/CHANGELOG.md index 0e0240cb2dd9..0c77a5c2bcc4 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.2.1](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.2.0...@loopback/openapi-v3@1.2.1) (2019-02-08) + + +### Bug Fixes + +* update to the most recent lodash version ([65ee865](https://github.com/strongloop/loopback-next/commit/65ee865)) + + + + + # [1.2.0](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.1.7...@loopback/openapi-v3@1.2.0) (2019-01-28) diff --git a/packages/openapi-v3/package.json b/packages/openapi-v3/package.json index 2e04dbf8915b..48a356283aba 100644 --- a/packages/openapi-v3/package.json +++ b/packages/openapi-v3/package.json @@ -1,17 +1,17 @@ { "name": "@loopback/openapi-v3", - "version": "1.2.0", + "version": "1.2.1", "description": "Processes openapi v3 related metadata", "engines": { "node": ">=8.9" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/openapi-spec-builder": "^1.0.5", - "@loopback/repository": "^1.1.4", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/openapi-spec-builder": "^1.0.6", + "@loopback/repository": "^1.1.5", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", - "@types/debug": "0.0.30", + "@types/debug": "^4.1.0", "@types/lodash": "^4.14.106", "@types/node": "^10.11.2" }, @@ -19,10 +19,10 @@ "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-openapi-v3*.tgz dist package", - "integration": "lb-mocha \"dist/test/integration/**/*.js\"", + "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/integration/**/*.js\"", - "unit": "lb-mocha \"dist/test/unit/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/integration/**/*.js\"", + "unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"", "verify": "npm pack && tar xf loopback-openapi-v3*.tgz && tree package && npm run clean" }, "author": "IBM", @@ -37,9 +37,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "publishConfig": { "access": "public" @@ -49,10 +49,10 @@ "url": "https://github.com/strongloop/loopback-next.git" }, "dependencies": { - "@loopback/context": "^1.5.0", - "@loopback/openapi-v3-types": "^1.0.5", - "@loopback/repository-json-schema": "^1.3.0", + "@loopback/context": "^1.5.1", + "@loopback/openapi-v3-types": "^1.0.6", + "@loopback/repository-json-schema": "^1.3.1", "debug": "^4.0.1", - "lodash": "^4.17.5" + "lodash": "^4.17.11" } } diff --git a/packages/openapi-v3/test/integration/controller-spec.integration.ts b/packages/openapi-v3/src/__tests__/integration/controller-spec.integration.ts similarity index 98% rename from packages/openapi-v3/test/integration/controller-spec.integration.ts rename to packages/openapi-v3/src/__tests__/integration/controller-spec.integration.ts index 54156cb42777..488aaccd0d7e 100644 --- a/packages/openapi-v3/test/integration/controller-spec.integration.ts +++ b/packages/openapi-v3/src/__tests__/integration/controller-spec.integration.ts @@ -3,11 +3,17 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {expect} from '@loopback/testlab'; -import {model, property} from '@loopback/repository'; import {ParameterObject, SchemaObject} from '@loopback/openapi-v3-types'; -import {param, requestBody, getControllerSpec, post, get} from '../../'; -import {ControllerSpec} from '../../src'; +import {model, property} from '@loopback/repository'; +import {expect} from '@loopback/testlab'; +import { + ControllerSpec, + get, + getControllerSpec, + param, + post, + requestBody, +} from '../..'; describe('controller spec', () => { it('adds property schemas in components.schemas', () => { diff --git a/packages/openapi-v3/test/integration/operation-spec.integration.ts b/packages/openapi-v3/src/__tests__/integration/operation-spec.integration.ts similarity index 100% rename from packages/openapi-v3/test/integration/operation-spec.integration.ts rename to packages/openapi-v3/src/__tests__/integration/operation-spec.integration.ts diff --git a/packages/openapi-v3/test/unit/decorators/operation.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/operation.decorator.unit.ts similarity index 100% rename from packages/openapi-v3/test/unit/decorators/operation.decorator.unit.ts rename to packages/openapi-v3/src/__tests__/unit/decorators/operation.decorator.unit.ts diff --git a/packages/openapi-v3/test/unit/decorators/param/param-header.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/param/param-header.decorator.unit.ts similarity index 100% rename from packages/openapi-v3/test/unit/decorators/param/param-header.decorator.unit.ts rename to packages/openapi-v3/src/__tests__/unit/decorators/param/param-header.decorator.unit.ts diff --git a/packages/openapi-v3/test/unit/decorators/param/param-path.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/param/param-path.decorator.unit.ts similarity index 100% rename from packages/openapi-v3/test/unit/decorators/param/param-path.decorator.unit.ts rename to packages/openapi-v3/src/__tests__/unit/decorators/param/param-path.decorator.unit.ts diff --git a/packages/openapi-v3/test/unit/decorators/param/param-query.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/param/param-query.decorator.unit.ts similarity index 100% rename from packages/openapi-v3/test/unit/decorators/param/param-query.decorator.unit.ts rename to packages/openapi-v3/src/__tests__/unit/decorators/param/param-query.decorator.unit.ts diff --git a/packages/openapi-v3/test/unit/decorators/param/param.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/param/param.decorator.unit.ts similarity index 100% rename from packages/openapi-v3/test/unit/decorators/param/param.decorator.unit.ts rename to packages/openapi-v3/src/__tests__/unit/decorators/param/param.decorator.unit.ts diff --git a/packages/openapi-v3/test/unit/decorators/request-body/request-body-primitives.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/request-body/request-body-primitives.decorator.unit.ts similarity index 100% rename from packages/openapi-v3/test/unit/decorators/request-body/request-body-primitives.decorator.unit.ts rename to packages/openapi-v3/src/__tests__/unit/decorators/request-body/request-body-primitives.decorator.unit.ts diff --git a/packages/openapi-v3/test/unit/decorators/request-body/request-body-shortcut.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/request-body/request-body-shortcut.decorator.unit.ts similarity index 100% rename from packages/openapi-v3/test/unit/decorators/request-body/request-body-shortcut.decorator.unit.ts rename to packages/openapi-v3/src/__tests__/unit/decorators/request-body/request-body-shortcut.decorator.unit.ts diff --git a/packages/openapi-v3/test/unit/decorators/request-body/request-body.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/request-body/request-body.decorator.unit.ts similarity index 100% rename from packages/openapi-v3/test/unit/decorators/request-body/request-body.decorator.unit.ts rename to packages/openapi-v3/src/__tests__/unit/decorators/request-body/request-body.decorator.unit.ts diff --git a/packages/openapi-v3/test/unit/filter-schema.unit.ts b/packages/openapi-v3/src/__tests__/unit/filter-schema.unit.ts similarity index 100% rename from packages/openapi-v3/test/unit/filter-schema.unit.ts rename to packages/openapi-v3/src/__tests__/unit/filter-schema.unit.ts diff --git a/packages/openapi-v3/test/unit/generate-schema.unit.ts b/packages/openapi-v3/src/__tests__/unit/generate-schema.unit.ts similarity index 96% rename from packages/openapi-v3/test/unit/generate-schema.unit.ts rename to packages/openapi-v3/src/__tests__/unit/generate-schema.unit.ts index 4fad7b555edc..f601d0403d02 100644 --- a/packages/openapi-v3/test/unit/generate-schema.unit.ts +++ b/packages/openapi-v3/src/__tests__/unit/generate-schema.unit.ts @@ -4,7 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {expect} from '@loopback/testlab'; -import {resolveSchema} from '../../src/generate-schema'; +import {resolveSchema} from '../../generate-schema'; describe('generate-schema unit tests', () => { it('returns an empty object given no arguments', () => { diff --git a/packages/openapi-v3/test/unit/json-to-schema.unit.ts b/packages/openapi-v3/src/__tests__/unit/json-to-schema.unit.ts similarity index 100% rename from packages/openapi-v3/test/unit/json-to-schema.unit.ts rename to packages/openapi-v3/src/__tests__/unit/json-to-schema.unit.ts diff --git a/packages/openapi-v3/tsconfig.build.json b/packages/openapi-v3/tsconfig.build.json index b337b93a9838..6e15e4be4f6f 100644 --- a/packages/openapi-v3/tsconfig.build.json +++ b/packages/openapi-v3/tsconfig.build.json @@ -1,8 +1,8 @@ { - "$schema": "http://json.schemastore.org/tsconfig", - "extends": "@loopback/build/config/tsconfig.common.json", - "compilerOptions": { - "rootDir": "." - }, - "include": ["index.ts", "src", "test"] + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "@loopback/build/config/tsconfig.common.json", + "compilerOptions": { + "rootDir": "src" + }, + "include": ["src"] } diff --git a/packages/repository-json-schema/CHANGELOG.md b/packages/repository-json-schema/CHANGELOG.md index bd5b6a10e868..7c90a6f4193a 100644 --- a/packages/repository-json-schema/CHANGELOG.md +++ b/packages/repository-json-schema/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.3.1](https://github.com/strongloop/loopback-next/compare/@loopback/repository-json-schema@1.3.0...@loopback/repository-json-schema@1.3.1) (2019-02-08) + +**Note:** Version bump only for package @loopback/repository-json-schema + + + + + # [1.3.0](https://github.com/strongloop/loopback-next/compare/@loopback/repository-json-schema@1.2.7...@loopback/repository-json-schema@1.3.0) (2019-01-28) diff --git a/packages/repository-json-schema/package.json b/packages/repository-json-schema/package.json index 0b5715758064..3f98b98151fb 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.3.0", + "version": "1.3.1", "description": "Converts TS classes into JSON Schemas using TypeScript's reflection API", "engines": { "node": ">=8.9" @@ -10,7 +10,7 @@ "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-json-schema*.tgz dist package api-docs", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/integration/**/*.js\" \"dist/test/acceptance/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/integration/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"", "verify": "npm pack && tar xf loopback-json-schema*.tgz && tree package && npm run clean" }, "author": "IBM", @@ -24,14 +24,14 @@ "access": "public" }, "dependencies": { - "@loopback/context": "^1.5.0", - "@loopback/metadata": "^1.0.5", - "@loopback/repository": "^1.1.4", + "@loopback/context": "^1.5.1", + "@loopback/metadata": "^1.0.6", + "@loopback/repository": "^1.1.5", "@types/json-schema": "^7.0.1" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2", "ajv": "^6.5.0" @@ -40,9 +40,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "repository": { "type": "git", diff --git a/packages/repository-json-schema/test/integration/build-schema.integration.ts b/packages/repository-json-schema/src/__tests__/integration/build-schema.integration.ts similarity index 100% rename from packages/repository-json-schema/test/integration/build-schema.integration.ts rename to packages/repository-json-schema/src/__tests__/integration/build-schema.integration.ts diff --git a/packages/repository-json-schema/test/unit/build-schema.unit.ts b/packages/repository-json-schema/src/__tests__/unit/build-schema.unit.ts similarity index 100% rename from packages/repository-json-schema/test/unit/build-schema.unit.ts rename to packages/repository-json-schema/src/__tests__/unit/build-schema.unit.ts diff --git a/packages/repository-json-schema/test/unit/filter-json-schema.unit.ts b/packages/repository-json-schema/src/__tests__/unit/filter-json-schema.unit.ts similarity index 99% rename from packages/repository-json-schema/test/unit/filter-json-schema.unit.ts rename to packages/repository-json-schema/src/__tests__/unit/filter-json-schema.unit.ts index a3093b7a6213..81045b64a221 100644 --- a/packages/repository-json-schema/test/unit/filter-json-schema.unit.ts +++ b/packages/repository-json-schema/src/__tests__/unit/filter-json-schema.unit.ts @@ -10,7 +10,7 @@ import {JsonSchema} from '../..'; import { getFilterJsonSchemaFor, getWhereJsonSchemaFor, -} from '../../src/filter-json-schema'; +} from '../../filter-json-schema'; describe('getFilterJsonSchemaFor', () => { let ajv: Ajv.Ajv; diff --git a/packages/repository-json-schema/test/unit/json-schema.unit.ts b/packages/repository-json-schema/src/__tests__/unit/json-schema.unit.ts similarity index 100% rename from packages/repository-json-schema/test/unit/json-schema.unit.ts rename to packages/repository-json-schema/src/__tests__/unit/json-schema.unit.ts diff --git a/packages/repository-json-schema/tsconfig.build.json b/packages/repository-json-schema/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/repository-json-schema/tsconfig.build.json +++ b/packages/repository-json-schema/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/repository/CHANGELOG.md b/packages/repository/CHANGELOG.md index c1d61de87c0f..653a515766ba 100644 --- a/packages/repository/CHANGELOG.md +++ b/packages/repository/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.5](https://github.com/strongloop/loopback-next/compare/@loopback/repository@1.1.4...@loopback/repository@1.1.5) (2019-02-08) + + +### Bug Fixes + +* update to the most recent lodash version ([65ee865](https://github.com/strongloop/loopback-next/commit/65ee865)) + + + + + ## [1.1.4](https://github.com/strongloop/loopback-next/compare/@loopback/repository@1.1.3...@loopback/repository@1.1.4) (2019-01-28) **Note:** Version bump only for package @loopback/repository diff --git a/packages/repository/package.json b/packages/repository/package.json index 2e0060c1cf4b..6dc787d9fdfa 100644 --- a/packages/repository/package.json +++ b/packages/repository/package.json @@ -1,45 +1,45 @@ { "name": "@loopback/repository", - "version": "1.1.4", + "version": "1.1.5", "description": "Repository based persistence for LoopBack 4", "engines": { "node": ">=8.9" }, "main": "index", "scripts": { - "acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"", + "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-repository*.tgz dist package api-docs", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/**/*.js\"", "verify": "npm pack && tar xf loopback-repository*.tgz && tree package && npm run clean" }, "author": "IBM", "copyright.owner": "IBM Corp.", "license": "MIT", "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/lodash": "^4.14.108", "@types/node": "^10.11.2" }, "dependencies": { - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", - "@types/debug": "0.0.30", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", + "@types/debug": "^4.1.0", "debug": "^4.0.1", - "lodash": "^4.17.10", + "lodash": "^4.17.11", "loopback-datasource-juggler": "^4.0.0" }, "files": [ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "repository": { "type": "git", diff --git a/packages/repository/test/acceptance/belongs-to.relation.acceptance.ts b/packages/repository/src/__tests__/acceptance/belongs-to.relation.acceptance.ts similarity index 100% rename from packages/repository/test/acceptance/belongs-to.relation.acceptance.ts rename to packages/repository/src/__tests__/acceptance/belongs-to.relation.acceptance.ts diff --git a/packages/repository/test/acceptance/has-many-without-di.relation.acceptance.ts b/packages/repository/src/__tests__/acceptance/has-many-without-di.relation.acceptance.ts similarity index 100% rename from packages/repository/test/acceptance/has-many-without-di.relation.acceptance.ts rename to packages/repository/src/__tests__/acceptance/has-many-without-di.relation.acceptance.ts diff --git a/packages/repository/test/acceptance/has-many.relation.acceptance.ts b/packages/repository/src/__tests__/acceptance/has-many.relation.acceptance.ts similarity index 100% rename from packages/repository/test/acceptance/has-many.relation.acceptance.ts rename to packages/repository/src/__tests__/acceptance/has-many.relation.acceptance.ts diff --git a/packages/repository/test/acceptance/has-one.relation.acceptance.ts b/packages/repository/src/__tests__/acceptance/has-one.relation.acceptance.ts similarity index 100% rename from packages/repository/test/acceptance/has-one.relation.acceptance.ts rename to packages/repository/src/__tests__/acceptance/has-one.relation.acceptance.ts diff --git a/packages/repository/test/acceptance/repository.acceptance.ts b/packages/repository/src/__tests__/acceptance/repository.acceptance.ts similarity index 100% rename from packages/repository/test/acceptance/repository.acceptance.ts rename to packages/repository/src/__tests__/acceptance/repository.acceptance.ts diff --git a/packages/repository/test/fixtures/models/address.model.ts b/packages/repository/src/__tests__/fixtures/models/address.model.ts similarity index 100% rename from packages/repository/test/fixtures/models/address.model.ts rename to packages/repository/src/__tests__/fixtures/models/address.model.ts diff --git a/packages/repository/test/fixtures/models/customer.model.ts b/packages/repository/src/__tests__/fixtures/models/customer.model.ts similarity index 100% rename from packages/repository/test/fixtures/models/customer.model.ts rename to packages/repository/src/__tests__/fixtures/models/customer.model.ts diff --git a/packages/repository/test/fixtures/models/index.ts b/packages/repository/src/__tests__/fixtures/models/index.ts similarity index 100% rename from packages/repository/test/fixtures/models/index.ts rename to packages/repository/src/__tests__/fixtures/models/index.ts diff --git a/packages/repository/test/fixtures/models/order.model.ts b/packages/repository/src/__tests__/fixtures/models/order.model.ts similarity index 100% rename from packages/repository/test/fixtures/models/order.model.ts rename to packages/repository/src/__tests__/fixtures/models/order.model.ts diff --git a/packages/repository/test/fixtures/models/product.model.ts b/packages/repository/src/__tests__/fixtures/models/product.model.ts similarity index 100% rename from packages/repository/test/fixtures/models/product.model.ts rename to packages/repository/src/__tests__/fixtures/models/product.model.ts diff --git a/packages/repository/test/fixtures/repositories/address.repository.ts b/packages/repository/src/__tests__/fixtures/repositories/address.repository.ts similarity index 100% rename from packages/repository/test/fixtures/repositories/address.repository.ts rename to packages/repository/src/__tests__/fixtures/repositories/address.repository.ts diff --git a/packages/repository/test/fixtures/repositories/customer.repository.ts b/packages/repository/src/__tests__/fixtures/repositories/customer.repository.ts similarity index 100% rename from packages/repository/test/fixtures/repositories/customer.repository.ts rename to packages/repository/src/__tests__/fixtures/repositories/customer.repository.ts diff --git a/packages/repository/test/fixtures/repositories/index.ts b/packages/repository/src/__tests__/fixtures/repositories/index.ts similarity index 100% rename from packages/repository/test/fixtures/repositories/index.ts rename to packages/repository/src/__tests__/fixtures/repositories/index.ts diff --git a/packages/repository/test/fixtures/repositories/order.repository.ts b/packages/repository/src/__tests__/fixtures/repositories/order.repository.ts similarity index 100% rename from packages/repository/test/fixtures/repositories/order.repository.ts rename to packages/repository/src/__tests__/fixtures/repositories/order.repository.ts diff --git a/packages/repository/test/fixtures/repositories/product.repository.ts b/packages/repository/src/__tests__/fixtures/repositories/product.repository.ts similarity index 100% rename from packages/repository/test/fixtures/repositories/product.repository.ts rename to packages/repository/src/__tests__/fixtures/repositories/product.repository.ts diff --git a/packages/repository/test/integration/repositories/relation.factory.integration.ts b/packages/repository/src/__tests__/integration/repositories/relation.factory.integration.ts similarity index 100% rename from packages/repository/test/integration/repositories/relation.factory.integration.ts rename to packages/repository/src/__tests__/integration/repositories/relation.factory.integration.ts diff --git a/packages/repository/test/unit/decorator/metadata.unit.ts b/packages/repository/src/__tests__/unit/decorator/metadata.unit.ts similarity index 100% rename from packages/repository/test/unit/decorator/metadata.unit.ts rename to packages/repository/src/__tests__/unit/decorator/metadata.unit.ts diff --git a/packages/repository/test/unit/decorator/model-and-relation.decorator.unit.ts b/packages/repository/src/__tests__/unit/decorator/model-and-relation.decorator.unit.ts similarity index 100% rename from packages/repository/test/unit/decorator/model-and-relation.decorator.unit.ts rename to packages/repository/src/__tests__/unit/decorator/model-and-relation.decorator.unit.ts diff --git a/packages/repository/test/unit/decorator/relation.decorator.unit.ts b/packages/repository/src/__tests__/unit/decorator/relation.decorator.unit.ts similarity index 100% rename from packages/repository/test/unit/decorator/relation.decorator.unit.ts rename to packages/repository/src/__tests__/unit/decorator/relation.decorator.unit.ts diff --git a/packages/repository/test/unit/decorator/repository-with-di.decorator.unit.ts b/packages/repository/src/__tests__/unit/decorator/repository-with-di.decorator.unit.ts similarity index 100% rename from packages/repository/test/unit/decorator/repository-with-di.decorator.unit.ts rename to packages/repository/src/__tests__/unit/decorator/repository-with-di.decorator.unit.ts diff --git a/packages/repository/test/unit/decorator/repository-with-value-provider.decorator.unit.ts b/packages/repository/src/__tests__/unit/decorator/repository-with-value-provider.decorator.unit.ts similarity index 100% rename from packages/repository/test/unit/decorator/repository-with-value-provider.decorator.unit.ts rename to packages/repository/src/__tests__/unit/decorator/repository-with-value-provider.decorator.unit.ts diff --git a/packages/repository/test/unit/decorator/repository.decorator.unit.ts b/packages/repository/src/__tests__/unit/decorator/repository.decorator.unit.ts similarity index 100% rename from packages/repository/test/unit/decorator/repository.decorator.unit.ts rename to packages/repository/src/__tests__/unit/decorator/repository.decorator.unit.ts diff --git a/packages/repository/test/unit/errors/entity-not-found-error.test.ts b/packages/repository/src/__tests__/unit/errors/entity-not-found-error.test.ts similarity index 100% rename from packages/repository/test/unit/errors/entity-not-found-error.test.ts rename to packages/repository/src/__tests__/unit/errors/entity-not-found-error.test.ts diff --git a/packages/repository/test/unit/errors/invalid-relation-error.test.ts b/packages/repository/src/__tests__/unit/errors/invalid-relation-error.test.ts similarity index 100% rename from packages/repository/test/unit/errors/invalid-relation-error.test.ts rename to packages/repository/src/__tests__/unit/errors/invalid-relation-error.test.ts diff --git a/packages/repository/test/unit/mixins/repository.mixin.unit.ts b/packages/repository/src/__tests__/unit/mixins/repository.mixin.unit.ts similarity index 100% rename from packages/repository/test/unit/mixins/repository.mixin.unit.ts rename to packages/repository/src/__tests__/unit/mixins/repository.mixin.unit.ts diff --git a/packages/repository/test/unit/model/model.unit.ts b/packages/repository/src/__tests__/unit/model/model.unit.ts similarity index 100% rename from packages/repository/test/unit/model/model.unit.ts rename to packages/repository/src/__tests__/unit/model/model.unit.ts diff --git a/packages/repository/test/unit/query/query-builder.unit.ts b/packages/repository/src/__tests__/unit/query/query-builder.unit.ts similarity index 100% rename from packages/repository/test/unit/query/query-builder.unit.ts rename to packages/repository/src/__tests__/unit/query/query-builder.unit.ts diff --git a/packages/repository/test/unit/repositories/belongs-to-repository-factory.unit.ts b/packages/repository/src/__tests__/unit/repositories/belongs-to-repository-factory.unit.ts similarity index 100% rename from packages/repository/test/unit/repositories/belongs-to-repository-factory.unit.ts rename to packages/repository/src/__tests__/unit/repositories/belongs-to-repository-factory.unit.ts diff --git a/packages/repository/test/unit/repositories/constraint-utils.unit.ts b/packages/repository/src/__tests__/unit/repositories/constraint-utils.unit.ts similarity index 100% rename from packages/repository/test/unit/repositories/constraint-utils.unit.ts rename to packages/repository/src/__tests__/unit/repositories/constraint-utils.unit.ts diff --git a/packages/repository/test/unit/repositories/crud.repository.unit.ts b/packages/repository/src/__tests__/unit/repositories/crud.repository.unit.ts similarity index 100% rename from packages/repository/test/unit/repositories/crud.repository.unit.ts rename to packages/repository/src/__tests__/unit/repositories/crud.repository.unit.ts diff --git a/packages/repository/test/unit/repositories/has-many-repository-factory.unit.ts b/packages/repository/src/__tests__/unit/repositories/has-many-repository-factory.unit.ts similarity index 100% rename from packages/repository/test/unit/repositories/has-many-repository-factory.unit.ts rename to packages/repository/src/__tests__/unit/repositories/has-many-repository-factory.unit.ts diff --git a/packages/repository/test/unit/repositories/has-one-repository-factory.unit.ts b/packages/repository/src/__tests__/unit/repositories/has-one-repository-factory.unit.ts similarity index 100% rename from packages/repository/test/unit/repositories/has-one-repository-factory.unit.ts rename to packages/repository/src/__tests__/unit/repositories/has-one-repository-factory.unit.ts diff --git a/packages/repository/test/unit/repositories/kv.repository.bridge.unit.ts b/packages/repository/src/__tests__/unit/repositories/kv.repository.bridge.unit.ts similarity index 100% rename from packages/repository/test/unit/repositories/kv.repository.bridge.unit.ts rename to packages/repository/src/__tests__/unit/repositories/kv.repository.bridge.unit.ts diff --git a/packages/repository/test/unit/repositories/legacy-juggler-bridge.unit.ts b/packages/repository/src/__tests__/unit/repositories/legacy-juggler-bridge.unit.ts similarity index 100% rename from packages/repository/test/unit/repositories/legacy-juggler-bridge.unit.ts rename to packages/repository/src/__tests__/unit/repositories/legacy-juggler-bridge.unit.ts diff --git a/packages/repository/test/unit/repositories/relation.repository.unit.ts b/packages/repository/src/__tests__/unit/repositories/relation.repository.unit.ts similarity index 99% rename from packages/repository/test/unit/repositories/relation.repository.unit.ts rename to packages/repository/src/__tests__/unit/repositories/relation.repository.unit.ts index ea242f63c22d..467e99dfe6ae 100644 --- a/packages/repository/test/unit/repositories/relation.repository.unit.ts +++ b/packages/repository/src/__tests__/unit/repositories/relation.repository.unit.ts @@ -88,7 +88,7 @@ describe('relation repository', () => { }); }); - context('patch', async () => { + context('patch', () => { it('can patch related model instance', async () => { const constraint: Partial = {name: 'Jane'}; const hasManyCrudInstance = givenDefaultHasManyInstance(constraint); diff --git a/packages/repository/test/unit/type-resolver.unit.ts b/packages/repository/src/__tests__/unit/type-resolver.unit.ts similarity index 97% rename from packages/repository/test/unit/type-resolver.unit.ts rename to packages/repository/src/__tests__/unit/type-resolver.unit.ts index c395c2b8d30a..f3d8afc6dca6 100644 --- a/packages/repository/test/unit/type-resolver.unit.ts +++ b/packages/repository/src/__tests__/unit/type-resolver.unit.ts @@ -4,11 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {expect} from '@loopback/testlab'; -import { - isBuiltinType, - isTypeResolver, - resolveType, -} from '../../src/type-resolver'; +import {isBuiltinType, isTypeResolver, resolveType} from '../../type-resolver'; class SomeModel { constructor(public name: string) {} diff --git a/packages/repository/test/unit/type/type.unit.ts b/packages/repository/src/__tests__/unit/type/type.unit.ts similarity index 100% rename from packages/repository/test/unit/type/type.unit.ts rename to packages/repository/src/__tests__/unit/type/type.unit.ts diff --git a/packages/repository/tsconfig.build.json b/packages/repository/tsconfig.build.json index 2364eca7dfb4..6e15e4be4f6f 100644 --- a/packages/repository/tsconfig.build.json +++ b/packages/repository/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test", "examples"] + "include": ["src"] } diff --git a/packages/rest-explorer/CHANGELOG.md b/packages/rest-explorer/CHANGELOG.md index 85ef4b27086e..1efeb6ab46ec 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.8](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@1.1.7...@loopback/rest-explorer@1.1.8) (2019-02-08) + +**Note:** Version bump only for package @loopback/rest-explorer + + + + + ## [1.1.7](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@1.1.6...@loopback/rest-explorer@1.1.7) (2019-01-28) **Note:** Version bump only for package @loopback/rest-explorer diff --git a/packages/rest-explorer/package.json b/packages/rest-explorer/package.json index f85c034f2ad4..406e7358788b 100644 --- a/packages/rest-explorer/package.json +++ b/packages/rest-explorer/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/rest-explorer", - "version": "1.1.7", + "version": "1.1.8", "description": "LoopBack's API Explorer", "engines": { "node": ">=8.9" @@ -10,22 +10,22 @@ "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-explorer*.tgz dist package api-docs", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/**/*.js\"", "verify": "npm pack && tar xf loopback-explorer*.tgz && tree package && npm run clean" }, "author": "IBM", "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", - "@loopback/rest": "^1.5.4", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", + "@loopback/rest": "^1.5.5", "ejs": "^2.6.1", "swagger-ui-dist": "^3.20.0" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/ejs": "^2.6.0", "@types/node": "^10.1.1" @@ -39,9 +39,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", + "dist", "src", + "!*/__tests__", "templates" ], "publishConfig": { diff --git a/packages/rest-explorer/test/acceptance/rest-explorer.acceptance.ts b/packages/rest-explorer/src/__tests__/acceptance/rest-explorer.acceptance.ts similarity index 98% rename from packages/rest-explorer/test/acceptance/rest-explorer.acceptance.ts rename to packages/rest-explorer/src/__tests__/acceptance/rest-explorer.acceptance.ts index b8159fa2d15f..61edfa291295 100644 --- a/packages/rest-explorer/test/acceptance/rest-explorer.acceptance.ts +++ b/packages/rest-explorer/src/__tests__/acceptance/rest-explorer.acceptance.ts @@ -55,7 +55,7 @@ describe('API Explorer (acceptance)', () => { }); }); - context('with custom RestServerConfig', async () => { + context('with custom RestServerConfig', () => { it('honours custom OpenAPI path', async () => { await givenAppWithCustomRestConfig({ openApiSpec: { diff --git a/packages/rest-explorer/src/rest-explorer.controller.ts b/packages/rest-explorer/src/rest-explorer.controller.ts index 19d52dbf5f99..85dac4796852 100644 --- a/packages/rest-explorer/src/rest-explorer.controller.ts +++ b/packages/rest-explorer/src/rest-explorer.controller.ts @@ -16,7 +16,7 @@ import * as fs from 'fs'; import * as path from 'path'; // TODO(bajtos) Allow users to customize the template -const indexHtml = path.resolve(__dirname, '../../templates/index.html.ejs'); +const indexHtml = path.resolve(__dirname, '../templates/index.html.ejs'); const template = fs.readFileSync(indexHtml, 'utf-8'); const templateFn = ejs.compile(template); diff --git a/packages/rest-explorer/tsconfig.build.json b/packages/rest-explorer/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/rest-explorer/tsconfig.build.json +++ b/packages/rest-explorer/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/rest/CHANGELOG.md b/packages/rest/CHANGELOG.md index f047f5d77f4e..b516a35ed9bc 100644 --- a/packages/rest/CHANGELOG.md +++ b/packages/rest/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.5.5](https://github.com/strongloop/loopback-next/compare/@loopback/rest@1.5.4...@loopback/rest@1.5.5) (2019-02-08) + + +### Bug Fixes + +* **rest:** sanitize json for JSON.parse() ([5042698](https://github.com/strongloop/loopback-next/commit/5042698)) +* update to the most recent lodash version ([65ee865](https://github.com/strongloop/loopback-next/commit/65ee865)) + + + + + ## [1.5.4](https://github.com/strongloop/loopback-next/compare/@loopback/rest@1.5.3...@loopback/rest@1.5.4) (2019-01-28) **Note:** Version bump only for package @loopback/rest diff --git a/packages/rest/package.json b/packages/rest/package.json index 9bf239146c70..169cd3cda55c 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -1,30 +1,30 @@ { "name": "@loopback/rest", - "version": "1.5.4", + "version": "1.5.5", "description": "", "engines": { "node": ">=8.9" }, "scripts": { - "acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"", + "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-rest*.tgz dist package api-docs", "pretest": "npm run build", - "integration": "lb-mocha \"dist/test/integration/**/*.js\"", - "test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/integration/**/*.js\" \"dist/test/acceptance/**/*.js\"", - "unit": "lb-mocha \"dist/test/unit/**/*.js\"", + "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/integration/**/*.js\" \"dist/__tests__/acceptance/**/*.js\"", + "unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"", "verify": "npm pack && tar xf loopback-rest*.tgz && tree package && npm run clean" }, "author": "IBM", "copyright.owner": "IBM Corp.", "license": "MIT", "dependencies": { - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", - "@loopback/http-server": "^1.1.4", - "@loopback/openapi-v3": "^1.2.0", - "@loopback/openapi-v3-types": "^1.0.5", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", + "@loopback/http-server": "^1.1.5", + "@loopback/openapi-v3": "^1.2.1", + "@loopback/openapi-v3-types": "^1.0.6", "@types/body-parser": "^1.17.0", "@types/cors": "^2.8.3", "@types/express": "^4.11.1", @@ -39,22 +39,22 @@ "express": "^4.16.3", "http-errors": "^1.6.3", "js-yaml": "^3.11.0", - "lodash": "^4.17.5", + "lodash": "^4.17.11", "openapi-schema-to-json-schema": "^2.1.0", "openapi3-ts": "^1.0.0", - "path-to-regexp": "^2.2.0", + "path-to-regexp": "^3.0.0", "qs": "^6.5.2", "strong-error-handler": "^3.2.0", "type-is": "^1.6.16", "validator": "^10.4.0" }, "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/openapi-spec-builder": "^1.0.5", - "@loopback/repository": "^1.1.4", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/openapi-spec-builder": "^1.0.6", + "@loopback/repository": "^1.1.5", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", - "@types/debug": "0.0.30", + "@types/debug": "^4.1.0", "@types/js-yaml": "^3.11.1", "@types/lodash": "^4.14.106", "@types/multer": "^1.3.7", @@ -66,9 +66,9 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "repository": { "type": "git", diff --git a/packages/rest/test/acceptance/bootstrapping/rest.acceptance.ts b/packages/rest/src/__tests__/acceptance/bootstrapping/rest.acceptance.ts similarity index 100% rename from packages/rest/test/acceptance/bootstrapping/rest.acceptance.ts rename to packages/rest/src/__tests__/acceptance/bootstrapping/rest.acceptance.ts diff --git a/packages/rest/test/acceptance/coercion/coercion.acceptance.ts b/packages/rest/src/__tests__/acceptance/coercion/coercion.acceptance.ts similarity index 100% rename from packages/rest/test/acceptance/coercion/coercion.acceptance.ts rename to packages/rest/src/__tests__/acceptance/coercion/coercion.acceptance.ts diff --git a/packages/rest/test/acceptance/file-upload/file-upload-with-parser.acceptance.ts b/packages/rest/src/__tests__/acceptance/file-upload/file-upload-with-parser.acceptance.ts similarity index 100% rename from packages/rest/test/acceptance/file-upload/file-upload-with-parser.acceptance.ts rename to packages/rest/src/__tests__/acceptance/file-upload/file-upload-with-parser.acceptance.ts diff --git a/packages/rest/test/acceptance/file-upload/file-upload.acceptance.ts b/packages/rest/src/__tests__/acceptance/file-upload/file-upload.acceptance.ts similarity index 100% rename from packages/rest/test/acceptance/file-upload/file-upload.acceptance.ts rename to packages/rest/src/__tests__/acceptance/file-upload/file-upload.acceptance.ts diff --git a/packages/rest/test/acceptance/module-exporting/feature.md b/packages/rest/src/__tests__/acceptance/module-exporting/feature.md similarity index 100% rename from packages/rest/test/acceptance/module-exporting/feature.md rename to packages/rest/src/__tests__/acceptance/module-exporting/feature.md diff --git a/packages/rest/test/acceptance/request-parsing/request-parsing.acceptance.ts b/packages/rest/src/__tests__/acceptance/request-parsing/request-parsing.acceptance.ts similarity index 100% rename from packages/rest/test/acceptance/request-parsing/request-parsing.acceptance.ts rename to packages/rest/src/__tests__/acceptance/request-parsing/request-parsing.acceptance.ts diff --git a/packages/rest/test/acceptance/routing/feature.md b/packages/rest/src/__tests__/acceptance/routing/feature.md similarity index 100% rename from packages/rest/test/acceptance/routing/feature.md rename to packages/rest/src/__tests__/acceptance/routing/feature.md diff --git a/packages/rest/test/acceptance/routing/routing.acceptance.ts b/packages/rest/src/__tests__/acceptance/routing/routing.acceptance.ts similarity index 100% rename from packages/rest/test/acceptance/routing/routing.acceptance.ts rename to packages/rest/src/__tests__/acceptance/routing/routing.acceptance.ts diff --git a/packages/rest/test/acceptance/sequence/sequence.acceptance.ts b/packages/rest/src/__tests__/acceptance/sequence/sequence.acceptance.ts similarity index 100% rename from packages/rest/test/acceptance/sequence/sequence.acceptance.ts rename to packages/rest/src/__tests__/acceptance/sequence/sequence.acceptance.ts diff --git a/packages/rest/test/acceptance/validation/validation.acceptance.ts b/packages/rest/src/__tests__/acceptance/validation/validation.acceptance.ts similarity index 100% rename from packages/rest/test/acceptance/validation/validation.acceptance.ts rename to packages/rest/src/__tests__/acceptance/validation/validation.acceptance.ts diff --git a/packages/rest/test/helpers.ts b/packages/rest/src/__tests__/helpers.ts similarity index 100% rename from packages/rest/test/helpers.ts rename to packages/rest/src/__tests__/helpers.ts diff --git a/packages/rest/test/integration/http-handler.integration.ts b/packages/rest/src/__tests__/integration/http-handler.integration.ts similarity index 100% rename from packages/rest/test/integration/http-handler.integration.ts rename to packages/rest/src/__tests__/integration/http-handler.integration.ts diff --git a/packages/rest/test/integration/rest.application.integration.ts b/packages/rest/src/__tests__/integration/rest.application.integration.ts similarity index 100% rename from packages/rest/test/integration/rest.application.integration.ts rename to packages/rest/src/__tests__/integration/rest.application.integration.ts diff --git a/packages/rest/test/integration/rest.server.integration.ts b/packages/rest/src/__tests__/integration/rest.server.integration.ts similarity index 100% rename from packages/rest/test/integration/rest.server.integration.ts rename to packages/rest/src/__tests__/integration/rest.server.integration.ts diff --git a/packages/rest/test/unit/body-parser.unit.ts b/packages/rest/src/__tests__/unit/body-parser.unit.ts similarity index 94% rename from packages/rest/test/unit/body-parser.unit.ts rename to packages/rest/src/__tests__/unit/body-parser.unit.ts index 8d760c1610dc..9acfd631909c 100644 --- a/packages/rest/test/unit/body-parser.unit.ts +++ b/packages/rest/src/__tests__/unit/body-parser.unit.ts @@ -21,7 +21,7 @@ import { TextBodyParser, UrlEncodedBodyParser, } from '../..'; -import {builtinParsers} from '../../src/body-parsers/body-parser.helpers'; +import {builtinParsers} from '../../body-parsers/body-parser.helpers'; describe('body parser', () => { const defaultSchema = { @@ -186,6 +186,24 @@ describe('body parser', () => { }); }); + it('reports error for json payload with "__proto__" key', () => { + const req = givenRequest({ + url: '/', + payload: '{"x": 1, "__proto__": {"y": "2"}}', + headers: { + 'Content-Type': 'application/json', + }, + }); + + const spec = givenOperationWithRequestBody({ + description: 'data', + content: {}, + }); + return expect( + requestBodyParser.loadRequestBodyIfNeeded(spec, req), + ).to.be.rejectedWith('JSON string cannot contain "__proto__" key.'); + }); + it('sorts body parsers', () => { const options: RequestBodyParserOptions = {}; const bodyParser = new RequestBodyParser([ diff --git a/packages/rest/test/unit/coercion/invalid-spec.unit.test.ts b/packages/rest/src/__tests__/unit/coercion/invalid-spec.unit.test.ts similarity index 100% rename from packages/rest/test/unit/coercion/invalid-spec.unit.test.ts rename to packages/rest/src/__tests__/unit/coercion/invalid-spec.unit.test.ts diff --git a/packages/rest/test/unit/coercion/paramObject.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramObject.unit.ts similarity index 98% rename from packages/rest/test/unit/coercion/paramObject.unit.ts rename to packages/rest/src/__tests__/unit/coercion/paramObject.unit.ts index c948e296a18b..74bd3669cfe8 100644 --- a/packages/rest/test/unit/coercion/paramObject.unit.ts +++ b/packages/rest/src/__tests__/unit/coercion/paramObject.unit.ts @@ -87,7 +87,7 @@ describe('coerce object param - optional', function() { test(OPTIONAL_ANY_OBJECT, {key: 'value'}, {key: 'value'}); test(OPTIONAL_ANY_OBJECT, undefined, undefined); test(OPTIONAL_ANY_OBJECT, '', undefined); - test(OPTIONAL_ANY_OBJECT, 'null', null); + test(OPTIONAL_ANY_OBJECT, {key: 'null'}, {key: 'null'}); }); context('nested values are not coerced', () => { diff --git a/packages/rest/test/unit/coercion/paramStringToBoolean.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToBoolean.unit.ts similarity index 100% rename from packages/rest/test/unit/coercion/paramStringToBoolean.unit.ts rename to packages/rest/src/__tests__/unit/coercion/paramStringToBoolean.unit.ts diff --git a/packages/rest/test/unit/coercion/paramStringToBuffer.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToBuffer.unit.ts similarity index 100% rename from packages/rest/test/unit/coercion/paramStringToBuffer.unit.ts rename to packages/rest/src/__tests__/unit/coercion/paramStringToBuffer.unit.ts diff --git a/packages/rest/test/unit/coercion/paramStringToDate.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToDate.unit.ts similarity index 100% rename from packages/rest/test/unit/coercion/paramStringToDate.unit.ts rename to packages/rest/src/__tests__/unit/coercion/paramStringToDate.unit.ts diff --git a/packages/rest/test/unit/coercion/paramStringToInteger.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToInteger.unit.ts similarity index 100% rename from packages/rest/test/unit/coercion/paramStringToInteger.unit.ts rename to packages/rest/src/__tests__/unit/coercion/paramStringToInteger.unit.ts diff --git a/packages/rest/test/unit/coercion/paramStringToNumber.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToNumber.unit.ts similarity index 98% rename from packages/rest/test/unit/coercion/paramStringToNumber.unit.ts rename to packages/rest/src/__tests__/unit/coercion/paramStringToNumber.unit.ts index f778c64e35cb..30c9325e9a94 100644 --- a/packages/rest/test/unit/coercion/paramStringToNumber.unit.ts +++ b/packages/rest/src/__tests__/unit/coercion/paramStringToNumber.unit.ts @@ -56,7 +56,7 @@ describe('coerce param from string to number - required', () => { }); describe('coerce param from string to number - optional', () => { - context('valid values', async () => { + context('valid values', () => { test(NUMBER_PARAM, '0', 0); test(NUMBER_PARAM, '1', 1); test(NUMBER_PARAM, '-1', -1); diff --git a/packages/rest/test/unit/coercion/paramStringToString.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToString.unit.ts similarity index 100% rename from packages/rest/test/unit/coercion/paramStringToString.unit.ts rename to packages/rest/src/__tests__/unit/coercion/paramStringToString.unit.ts diff --git a/packages/rest/test/unit/coercion/parseStringToDatetime.unit.ts b/packages/rest/src/__tests__/unit/coercion/parseStringToDatetime.unit.ts similarity index 100% rename from packages/rest/test/unit/coercion/parseStringToDatetime.unit.ts rename to packages/rest/src/__tests__/unit/coercion/parseStringToDatetime.unit.ts diff --git a/packages/rest/test/unit/coercion/utils.ts b/packages/rest/src/__tests__/unit/coercion/utils.ts similarity index 100% rename from packages/rest/test/unit/coercion/utils.ts rename to packages/rest/src/__tests__/unit/coercion/utils.ts diff --git a/packages/rest/src/__tests__/unit/parse-json.unit.ts b/packages/rest/src/__tests__/unit/parse-json.unit.ts new file mode 100644 index 000000000000..ac70d7129ad2 --- /dev/null +++ b/packages/rest/src/__tests__/unit/parse-json.unit.ts @@ -0,0 +1,37 @@ +// Copyright IBM Corp. 2018. All Rights Reserved. +// Node module: @loopback/rest +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + +import {expect} from '@loopback/testlab'; +import {parseJson} from '../../parse-json'; + +describe('parseJson', () => { + it('throws for JSON text with __proto__ key', () => { + const text = '{"x": "1", "__proto__": {"y": 2}}'; + expect(() => parseJson(text)).to.throw( + 'JSON string cannot contain "__proto__" key.', + ); + }); + + it('throws for JSON text with deep __proto__ key', () => { + const text = '{"x": "1", "y": {"__proto__": {"z": 2}}}'; + expect(() => parseJson(text)).to.throw( + 'JSON string cannot contain "__proto__" key.', + ); + }); + + it('works for JSON text with deep __proto__ value', () => { + const text = '{"x": "1", "y": "__proto__"}'; + expect(parseJson(text)).to.eql(JSON.parse(text)); + }); + + it('supports reviver function', () => { + const text = '{"x": 1, "y": "2"}'; + const obj = parseJson(text, (key, value) => { + if (key === 'y') return parseInt(value); + return value; + }); + expect(obj).to.eql({x: 1, y: 2}); + }); +}); diff --git a/packages/rest/test/unit/parser.unit.ts b/packages/rest/src/__tests__/unit/parser.unit.ts similarity index 100% rename from packages/rest/test/unit/parser.unit.ts rename to packages/rest/src/__tests__/unit/parser.unit.ts diff --git a/packages/rest/test/unit/re-export.unit.ts b/packages/rest/src/__tests__/unit/re-export.unit.ts similarity index 100% rename from packages/rest/test/unit/re-export.unit.ts rename to packages/rest/src/__tests__/unit/re-export.unit.ts diff --git a/packages/rest/test/unit/request-body.validator.test.ts b/packages/rest/src/__tests__/unit/request-body.validator.test.ts similarity index 99% rename from packages/rest/test/unit/request-body.validator.test.ts rename to packages/rest/src/__tests__/unit/request-body.validator.test.ts index 73817c3489ab..7058e09abb2b 100644 --- a/packages/rest/test/unit/request-body.validator.test.ts +++ b/packages/rest/src/__tests__/unit/request-body.validator.test.ts @@ -4,7 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {expect} from '@loopback/testlab'; -import {validateRequestBody} from '../../src/validation/request-body.validator'; +import {validateRequestBody} from '../../validation/request-body.validator'; import {RestHttpErrors} from '../../'; import {aBodySpec} from '../helpers'; import { diff --git a/packages/rest/src/__tests__/unit/request-query.validator.test.ts b/packages/rest/src/__tests__/unit/request-query.validator.test.ts new file mode 100644 index 000000000000..8e86057a1b3e --- /dev/null +++ b/packages/rest/src/__tests__/unit/request-query.validator.test.ts @@ -0,0 +1,194 @@ +import {expect} from '@loopback/testlab'; +import {validateRequestQuery} from '../../src/validation/request-query.validator'; +import {RestHttpErrors} from '../../'; +import {aBodySpec} from '../helpers'; +import { + ReferenceObject, + SchemaObject, + SchemasObject, +} from '@loopback/openapi-v3-types'; + +const INVALID_MSG = RestHttpErrors.INVALID_REQUEST_QUERY_MESSAGE; + +const PING_SCHEMA = { + //title: 'Ping', + properties: { + pageSize: {type: 'integer', minimum: 0, maximum: 100, multipleOf: 5}, + pageNumber: {type: 'number', minimum: 10, maximum: 200, multipleOf: 3}, + pageBool: {type: 'boolean'}, + pageName: {type: 'string', maxLength: 5, minLength: 1, pattern: '[abc]+'}, + }, + required: ['pageSize'], +}; + +describe('validateRequestQuery', () => { + it('accepts valid data omitting optional properties', () => { + validateRequestQuery( + {value: {pageSize: 5}, schema: PING_SCHEMA}, + aBodySpec(PING_SCHEMA), + ); + }); + + it('rejects data missing a required property', () => { + const details: RestHttpErrors.ValidationErrorDetails[] = [ + { + path: '', + code: 'required', + message: "should have required property 'pageSize'", + info: {missingProperty: 'pageSize'}, + }, + ]; + verifyValidationRejectsInputWithError( + INVALID_MSG, + 'VALIDATION_FAILED', + details, + { + description: 'missing required "pageSize"', + }, + PING_SCHEMA, + ); + }); + + it('rejects data containing values of a wrong type', () => { + const details: RestHttpErrors.ValidationErrorDetails[] = [ + { + path: '.pageBool', + code: 'type', + message: 'should be boolean', + info: {type: 'boolean'}, + }, + ]; + verifyValidationRejectsInputWithError( + INVALID_MSG, + 'VALIDATION_FAILED', + details, + { + pageSize: 5, + pageBool: 1111, + }, + PING_SCHEMA, + ); + }); + + it('rejects invalid values for number properties', () => { + const details: RestHttpErrors.ValidationErrorDetails[] = [ + { + path: '.pageNumber', + code: 'type', + message: 'should be number', + info: {type: 'number'}, + }, + ]; + const schema: SchemaObject = { + properties: { + pageNumber: {type: 'number'}, + }, + }; + verifyValidationRejectsInputWithError( + INVALID_MSG, + 'VALIDATION_FAILED', + details, + {pageNumber: 'string value'}, + schema, + ); + }); + + it('rejects invalid values for number properties', () => { + const details: RestHttpErrors.ValidationErrorDetails[] = [ + { + path: '.pageNumber', + code: 'type', + message: 'should be number', + info: {type: 'number'}, + }, + ]; + const schema: SchemaObject = { + properties: { + pageNumber: {type: 'number'}, + }, + }; + verifyValidationRejectsInputWithError( + INVALID_MSG, + 'VALIDATION_FAILED', + details, + {pageNumber: 'string value'}, + schema, + ); + }); + + it('rejects invalid values for number properties', () => { + const details: RestHttpErrors.ValidationErrorDetails[] = [ + { + path: '.pageSize', + code: 'type', + message: 'should be number', + info: {type: 'number'}, + }, + { + path: '.pageNumber', + code: 'type', + message: 'should be number', + info: {type: 'number'}, + }, + { + path: '.pageBool', + code: 'type', + message: 'should be boolean', + info: {type: 'boolean'}, + }, + { + path: '.pageName', + code: 'type', + message: 'should be string', + info: {type: 'string'}, + }, + ]; + const schema: SchemaObject = { + properties: { + pageSize: {type: 'number'}, + pageNumber: {type: 'number'}, + pageBool: {type: 'boolean'}, + pageName: {type: 'string'}, + }, + }; + verifyValidationRejectsInputWithError( + INVALID_MSG, + 'VALIDATION_FAILED', + details, + { + pageSize: 'string value', + pageNumber: 'string value', + pageBool: 1111, + pageName: 123, + }, + schema, + ); + }); +}); + +// ----- HELPERS ----- / + +function verifyValidationRejectsInputWithError( + expectedMessage: string, + expectedCode: string, + expectedDetails: RestHttpErrors.ValidationErrorDetails[] | undefined, + query: object | null, + schema: SchemaObject | ReferenceObject, + schemas?: SchemasObject, + required?: boolean, +) { + try { + validateRequestQuery( + {value: query, schema}, + aBodySpec(schema, {required}), + schemas, + ); + throw new Error( + "expected Function { name: 'validateRequestQuery' } to throw exception", + ); + } catch (err) { + expect(err.message).to.equal(expectedMessage); + expect(err.code).to.equal(expectedCode); + expect(err.details).to.deepEqual(expectedDetails); + } +} diff --git a/packages/rest/test/unit/rest.application/rest.application.unit.ts b/packages/rest/src/__tests__/unit/rest.application/rest.application.unit.ts similarity index 100% rename from packages/rest/test/unit/rest.application/rest.application.unit.ts rename to packages/rest/src/__tests__/unit/rest.application/rest.application.unit.ts diff --git a/packages/rest/test/unit/rest.component.unit.ts b/packages/rest/src/__tests__/unit/rest.component.unit.ts similarity index 74% rename from packages/rest/test/unit/rest.component.unit.ts rename to packages/rest/src/__tests__/unit/rest.component.unit.ts index b4872068a65e..050c70091fd4 100644 --- a/packages/rest/test/unit/rest.component.unit.ts +++ b/packages/rest/src/__tests__/unit/rest.component.unit.ts @@ -24,22 +24,30 @@ import { const SequenceActions = RestBindings.SequenceActions; describe('RestComponent', () => { describe('Providers', () => { - describe('Default implementations are bound', async () => { - const app = new Application(); - app.component(RestComponent); + describe('Default implementations are bound', () => { + let app: Application; + let comp: Component; - // Stub constructor requirements for some providers. - app.bind(RestBindings.Http.CONTEXT).to(new Context()); - app.bind(RestBindings.HANDLER).to(new HttpHandler(app)); + before(async () => { + app = new Application(); + app.component(RestComponent); + + // Stub constructor requirements for some providers. + app.bind(RestBindings.Http.CONTEXT).to(new Context()); + app.bind(RestBindings.HANDLER).to(new HttpHandler(app)); + + comp = await app.get('components.RestComponent'); + }); - const comp = await app.get('components.RestComponent'); - for (const key in comp.providers || {}) { - it(key, async () => { - const result = await app.get(key); - const expected: Provider = new comp.providers![key](); - expect(result).to.deepEqual(expected.value()); - }); - } + it('', async () => { + for (const key in comp.providers || {}) { + it(key, async () => { + const result = await app.get(key); + const expected: Provider = new comp.providers![key](); + expect(result).to.deepEqual(expected.value()); + }); + } + }); }); describe('LOG_ERROR', () => { it('matches expected argument signature', async () => { diff --git a/packages/rest/test/unit/rest.server/rest.server.controller.unit.ts b/packages/rest/src/__tests__/unit/rest.server/rest.server.controller.unit.ts similarity index 100% rename from packages/rest/test/unit/rest.server/rest.server.controller.unit.ts rename to packages/rest/src/__tests__/unit/rest.server/rest.server.controller.unit.ts diff --git a/packages/rest/test/unit/rest.server/rest.server.open-api-spec.unit.ts b/packages/rest/src/__tests__/unit/rest.server/rest.server.open-api-spec.unit.ts similarity index 100% rename from packages/rest/test/unit/rest.server/rest.server.open-api-spec.unit.ts rename to packages/rest/src/__tests__/unit/rest.server/rest.server.open-api-spec.unit.ts diff --git a/packages/rest/test/unit/rest.server/rest.server.unit.ts b/packages/rest/src/__tests__/unit/rest.server/rest.server.unit.ts similarity index 100% rename from packages/rest/test/unit/rest.server/rest.server.unit.ts rename to packages/rest/src/__tests__/unit/rest.server/rest.server.unit.ts diff --git a/packages/rest/test/unit/router/controller-factory.unit.ts b/packages/rest/src/__tests__/unit/router/controller-factory.unit.ts similarity index 100% rename from packages/rest/test/unit/router/controller-factory.unit.ts rename to packages/rest/src/__tests__/unit/router/controller-factory.unit.ts diff --git a/packages/rest/test/unit/router/controller-route.unit.ts b/packages/rest/src/__tests__/unit/router/controller-route.unit.ts similarity index 100% rename from packages/rest/test/unit/router/controller-route.unit.ts rename to packages/rest/src/__tests__/unit/router/controller-route.unit.ts diff --git a/packages/rest/test/unit/router/openapi-path.unit.ts b/packages/rest/src/__tests__/unit/router/openapi-path.unit.ts similarity index 94% rename from packages/rest/test/unit/router/openapi-path.unit.ts rename to packages/rest/src/__tests__/unit/router/openapi-path.unit.ts index 80f3f0054927..6654dfc78b7e 100644 --- a/packages/rest/test/unit/router/openapi-path.unit.ts +++ b/packages/rest/src/__tests__/unit/router/openapi-path.unit.ts @@ -32,6 +32,11 @@ describe('validateApiPath', () => { expect(path).to.eql('/{foo}@{bar}'); }); + it('allows /{foo}#{bar}', () => { + const path = validateApiPath('/{foo}#{bar}'); + expect(path).to.eql('/{foo}#{bar}'); + }); + it('allows /{_foo}/{bar}', () => { const path = validateApiPath('/{_foo}/{bar}'); expect(path).to.eql('/{_foo}/{bar}'); diff --git a/packages/rest/test/unit/router/reject.provider.unit.ts b/packages/rest/src/__tests__/unit/router/reject.provider.unit.ts similarity index 100% rename from packages/rest/test/unit/router/reject.provider.unit.ts rename to packages/rest/src/__tests__/unit/router/reject.provider.unit.ts diff --git a/packages/rest/test/unit/router/route-sort.unit.ts b/packages/rest/src/__tests__/unit/router/route-sort.unit.ts similarity index 100% rename from packages/rest/test/unit/router/route-sort.unit.ts rename to packages/rest/src/__tests__/unit/router/route-sort.unit.ts diff --git a/packages/rest/test/unit/router/routing-table.unit.ts b/packages/rest/src/__tests__/unit/router/routing-table.unit.ts similarity index 100% rename from packages/rest/test/unit/router/routing-table.unit.ts rename to packages/rest/src/__tests__/unit/router/routing-table.unit.ts diff --git a/packages/rest/test/unit/router/trie-router.unit.ts b/packages/rest/src/__tests__/unit/router/trie-router.unit.ts similarity index 98% rename from packages/rest/test/unit/router/trie-router.unit.ts rename to packages/rest/src/__tests__/unit/router/trie-router.unit.ts index e592ca46cdae..ae02e14cdda0 100644 --- a/packages/rest/test/unit/router/trie-router.unit.ts +++ b/packages/rest/src/__tests__/unit/router/trie-router.unit.ts @@ -3,14 +3,13 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT +import {anOperationSpec} from '@loopback/openapi-spec-builder'; import { expect, ShotRequestOptions, stubExpressContext, } from '@loopback/testlab'; -import {TrieRouter, RouteEntry, Request} from '../../..'; -import {anOperationSpec} from '@loopback/openapi-spec-builder'; -import {ResolvedRoute} from '../../../src'; +import {Request, ResolvedRoute, RouteEntry, TrieRouter} from '../../..'; class TestTrieRouter extends TrieRouter { get staticRoutes() { diff --git a/packages/rest/test/unit/router/trie.unit.ts b/packages/rest/src/__tests__/unit/router/trie.unit.ts similarity index 100% rename from packages/rest/test/unit/router/trie.unit.ts rename to packages/rest/src/__tests__/unit/router/trie.unit.ts diff --git a/packages/rest/test/unit/writer.unit.ts b/packages/rest/src/__tests__/unit/writer.unit.ts similarity index 100% rename from packages/rest/test/unit/writer.unit.ts rename to packages/rest/src/__tests__/unit/writer.unit.ts diff --git a/packages/rest/src/body-parsers/body-parser.json.ts b/packages/rest/src/body-parsers/body-parser.json.ts index 937ac9e8ef61..c75489890c93 100644 --- a/packages/rest/src/body-parsers/body-parser.json.ts +++ b/packages/rest/src/body-parsers/body-parser.json.ts @@ -15,6 +15,7 @@ import { builtinParsers, } from './body-parser.helpers'; import {BodyParser, RequestBody} from './types'; +import {sanitizeJsonParse} from '../parse-json'; export class JsonBodyParser implements BodyParser { name = builtinParsers.json; @@ -25,6 +26,7 @@ export class JsonBodyParser implements BodyParser { options: RequestBodyParserOptions = {}, ) { const jsonOptions = getParserOptions('json', options); + jsonOptions.reviver = sanitizeJsonParse(jsonOptions.reviver); this.jsonParser = json(jsonOptions); } diff --git a/packages/rest/src/coercion/coerce-parameter.ts b/packages/rest/src/coercion/coerce-parameter.ts index 731755411632..7fcc2e6883d9 100644 --- a/packages/rest/src/coercion/coerce-parameter.ts +++ b/packages/rest/src/coercion/coerce-parameter.ts @@ -3,20 +3,21 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ParameterObject, isReferenceObject} from '@loopback/openapi-v3-types'; -import {Validator} from './validator'; +import {isReferenceObject, ParameterObject} from '@loopback/openapi-v3-types'; import * as debugModule from 'debug'; import {RestHttpErrors} from '../'; +import {parseJson} from '../parse-json'; import { + DateCoercionOptions, getOAIPrimitiveType, + IntegerCoercionOptions, isEmpty, isFalse, isTrue, isValidDateTime, matchDateFormat, - DateCoercionOptions, - IntegerCoercionOptions, } from './utils'; +import {Validator} from './validator'; const isRFC3339 = require('validator/lib/isRFC3339'); const debug = debugModule('loopback:rest:coercion'); @@ -185,7 +186,7 @@ function parseJsonIfNeeded( } try { - const result = JSON.parse(data); + const result = parseJson(data); debug('Parsed parameter %s as %j', spec.name, result); return result; } catch (err) { diff --git a/packages/rest/src/index.ts b/packages/rest/src/index.ts index 059b664dd14b..e81fe8835a93 100644 --- a/packages/rest/src/index.ts +++ b/packages/rest/src/index.ts @@ -19,6 +19,7 @@ export * from './rest.component'; export * from './rest.server'; export * from './sequence'; export * from './rest-http-error'; +export * from './parse-json'; // export all errors from external http-errors package import * as HttpErrors from 'http-errors'; diff --git a/packages/rest/src/parse-json.ts b/packages/rest/src/parse-json.ts new file mode 100644 index 000000000000..7c10df9b778f --- /dev/null +++ b/packages/rest/src/parse-json.ts @@ -0,0 +1,42 @@ +// Copyright IBM Corp. 2018. All Rights Reserved. +// Node module: @loopback/rest +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + +//tslint:disable:no-any + +// These utilities are introduced to mitigate the prototype pollution issue +// with `JSON.parse`. +// See https://hueniverse.com/a-tale-of-prototype-poisoning-2610fa170061 +// +// The [bourne](https://github.com/hapijs/bourne) module provides a drop-in +// replacement for `JSON.parse` but we need to instruct `body-parser` to honor +// a `reviver` function. + +/** + * Factory to create a reviver function for `JSON.parse` to sanitize keys + * @param reviver Reviver function + */ +export function sanitizeJsonParse(reviver?: (key: any, value: any) => any) { + return (key: string, value: any) => { + if (key === '__proto__') + throw new Error('JSON string cannot contain "__proto__" key.'); + if (reviver) { + return reviver(key, value); + } else { + return value; + } + }; +} + +/** + * + * @param text JSON string + * @param reviver Optional reviver function for `JSON.parse` + */ +export function parseJson( + text: string, + reviver?: (key: any, value: any) => any, +) { + return JSON.parse(text, sanitizeJsonParse(reviver)); +} diff --git a/packages/rest/src/parser.ts b/packages/rest/src/parser.ts index 87d7452a73ca..a6d6d7312cd9 100644 --- a/packages/rest/src/parser.ts +++ b/packages/rest/src/parser.ts @@ -17,6 +17,7 @@ import {RestHttpErrors} from './rest-http-error'; import {ResolvedRoute} from './router'; import {OperationArgs, PathParameterValues, Request} from './types'; import {validateRequestBody} from './validation/request-body.validator'; +import {validateRequestQuery} from './validation/request-query.validator'; const debug = debugFactory('loopback:rest:parser'); /** @@ -38,11 +39,18 @@ export async function parseOperationArgs( operationSpec, request, ); + + const query = await requestBodyParser.loadRequestBodyIfNeeded( + operationSpec, + request, + ); + return buildOperationArguments( operationSpec, request, pathParams, body, + query, route.schemas, ); } @@ -52,6 +60,7 @@ function buildOperationArguments( request: Request, pathParams: PathParameterValues, body: RequestBody, + query: RequestBody, globalSchemas: SchemasObject, ): OperationArgs { let requestBodyIndex: number = -1; @@ -67,6 +76,12 @@ function buildOperationArguments( const paramArgs: OperationArgs = []; + let isQuery = false; + let paramName = ''; + let paramSchema = {}; + let queryValue = {}; + let schemasValue = {}; + for (const paramSpec of operationSpec.parameters || []) { if (isReferenceObject(paramSpec)) { // TODO(bajtos) implement $ref parameters @@ -77,11 +92,30 @@ function buildOperationArguments( const rawValue = getParamFromRequest(spec, request, pathParams); const coercedValue = coerceParameter(rawValue, spec); paramArgs.push(coercedValue); - } - debug('Validating request body - value %j', body); - validateRequestBody(body, operationSpec.requestBody, globalSchemas); + if (spec.in === 'query' && paramSpec.schema != null) { + isQuery = true; + paramName = paramSpec.name; + paramSchema = paramSpec.schema || []; + // tslint:disable-next-line:no-any + (queryValue)[paramName] = coercedValue; + // tslint:disable-next-line:no-any + (schemasValue)[paramName] = paramSchema; + } + } + //if query parameters from URL - send to query validation + if (isQuery) { + query.value = queryValue; + globalSchemas = {properties: schemasValue}; + query.schema = globalSchemas; + validateRequestQuery(query, operationSpec.requestBody, globalSchemas); + } + //if body parameters - send to body validation + else { + debug('Validating request body - value %j', body); + validateRequestBody(body, operationSpec.requestBody, globalSchemas); + } if (requestBodyIndex > -1) paramArgs.splice(requestBodyIndex, 0, body.value); return paramArgs; } diff --git a/packages/rest/src/rest-http-error.ts b/packages/rest/src/rest-http-error.ts index 125806bcfb54..f6f4ede950a2 100644 --- a/packages/rest/src/rest-http-error.ts +++ b/packages/rest/src/rest-http-error.ts @@ -60,6 +60,17 @@ export namespace RestHttpErrors { }, ); } + export const INVALID_REQUEST_QUERY_MESSAGE = + 'The request query is invalid. See error object details property for more info.'; + + export function invalidRequestQuery(): HttpErrors.HttpError { + return Object.assign( + new HttpErrors.UnprocessableEntity(INVALID_REQUEST_QUERY_MESSAGE), + { + code: 'VALIDATION_FAILED', + }, + ); + } /** * An invalid request body error contains a `details` property as the machine-readable error. diff --git a/packages/rest/src/router/openapi-path.ts b/packages/rest/src/router/openapi-path.ts index d86d0d7c232b..6afd05bb2a57 100644 --- a/packages/rest/src/router/openapi-path.ts +++ b/packages/rest/src/router/openapi-path.ts @@ -42,7 +42,11 @@ export function validateApiPath(path: string = '/') { // Such as /(.*) throw new Error(`Unnamed parameter is not allowed in path '${path}'`); } - if (token.optional || token.repeat || token.pattern !== '[^\\/]+?') { + if ( + (token.optional || token.repeat || token.pattern !== '[^\\/]+?') && + // Required by path-to-regexp@3.x + token.prefix === '/' + ) { // Such as /:foo*, /:foo+, /:foo?, or /:foo(\\d+) throw new Error(`Parameter modifier is not allowed in path '${path}'`); } diff --git a/packages/rest/src/validation/request-query.validator.ts b/packages/rest/src/validation/request-query.validator.ts new file mode 100644 index 000000000000..798c57d63aa2 --- /dev/null +++ b/packages/rest/src/validation/request-query.validator.ts @@ -0,0 +1,150 @@ +import { + RequestBodyObject, + SchemaObject, + ReferenceObject, + SchemasObject, +} from '@loopback/openapi-v3-types'; +import * as AJV from 'ajv'; +import * as debugModule from 'debug'; +import * as util from 'util'; +import {HttpErrors, RestHttpErrors, RequestBody} from '..'; +import * as _ from 'lodash'; + +const toJsonSchema = require('openapi-schema-to-json-schema'); +const debug = debugModule('loopback:rest:validation'); + +export type RequestQueryValidationOptions = AJV.Options; + +/** + * Check whether the request query is valid according to the provided OpenAPI schema. + * The JSON schema is generated from the OpenAPI schema which is typically defined + * by `@requestQuery()`. + * The validation leverages AJS schema validator. + * @param query The request query parsed from an HTTP request. + * @param requestQuerySpec The OpenAPI requestQuery specification defined in `@requestQuery()`. + * @param globalSchemas The referenced schemas generated from `OpenAPISpec.components.schemas`. + */ +export function validateRequestQuery( + query: RequestBody, + requestQuerySpec?: RequestBodyObject, + globalSchemas: SchemasObject = {}, + options: RequestQueryValidationOptions = {}, +) { + const required = requestQuerySpec && requestQuerySpec.required; + + if (required && query.value == undefined) { + const err = Object.assign( + new HttpErrors.BadRequest('Request query is required'), + { + code: 'MISSING_REQUIRED_PARAMETER', + parameterName: 'request query', + }, + ); + throw err; + } + + const schema = query.schema; + /* istanbul ignore if */ + if (debug.enabled) { + debug('Request query schema: %j', util.inspect(schema, {depth: null})); + } + if (!schema) return; + + options = Object.assign({coerceTypes: query.coercionRequired}, options); + validateValueAgainstSchema(query.value, schema, globalSchemas, options); +} + +/** + * Convert an OpenAPI schema to the corresponding JSON schema. + * @param openapiSchema The OpenAPI schema to convert. + */ +function convertToJsonSchema(openapiSchema: SchemaObject) { + const jsonSchema = toJsonSchema(openapiSchema); + delete jsonSchema['$schema']; + /* istanbul ignore if */ + if (debug.enabled) { + debug( + 'Converted OpenAPI schema to JSON schema: %s', + util.inspect(jsonSchema, {depth: null}), + ); + } + return jsonSchema; +} + +/** + * Validate the request query data against JSON schema. + * @param query The request query data. + * @param schema The JSON schema used to perform the validation. + * @param globalSchemas Schema references. + */ + +const compiledSchemaCache = new WeakMap(); + +function validateValueAgainstSchema( + // tslint:disable-next-line:no-any + query: any, + schema: SchemaObject | ReferenceObject, + globalSchemas?: SchemasObject, + options?: RequestQueryValidationOptions, +) { + let validate; + + if (compiledSchemaCache.has(schema)) { + validate = compiledSchemaCache.get(schema); + } else { + validate = createValidator(schema, globalSchemas, options); + compiledSchemaCache.set(schema, validate); + } + + if (validate(query)) { + debug('Request query passed AJV validation.'); + return; + } + + const validationErrors = validate.errors; + + /* istanbul ignore if */ + if (debug.enabled) { + debug( + 'Invalid request query: %s. Errors: %s', + util.inspect(query, {depth: null}), + util.inspect(validationErrors), + ); + } + + const error = RestHttpErrors.invalidRequestQuery(); + error.details = _.map(validationErrors, e => { + return { + path: e.dataPath, + code: e.keyword, + message: e.message, + info: e.params, + }; + }); + throw error; +} + +function createValidator( + schema: SchemaObject, + globalSchemas?: SchemasObject, + options?: RequestQueryValidationOptions, +): Function { + const jsonSchema = convertToJsonSchema(schema); + + const schemaWithRef = Object.assign({components: {}}, jsonSchema); + schemaWithRef.components = { + schemas: globalSchemas, + }; + + const ajv = new AJV( + Object.assign( + {}, + { + allErrors: true, + }, + options, + ), + ); + + return ajv.compile(schemaWithRef); +} diff --git a/packages/rest/tsconfig.build.json b/packages/rest/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/rest/tsconfig.build.json +++ b/packages/rest/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/service-proxy/CHANGELOG.md b/packages/service-proxy/CHANGELOG.md index 2fc4b560dcec..e79d0d5688d8 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.8](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@1.0.7...@loopback/service-proxy@1.0.8) (2019-02-08) + +**Note:** Version bump only for package @loopback/service-proxy + + + + + ## [1.0.7](https://github.com/strongloop/loopback-next/compare/@loopback/service-proxy@1.0.6...@loopback/service-proxy@1.0.7) (2019-01-28) **Note:** Version bump only for package @loopback/service-proxy diff --git a/packages/service-proxy/package.json b/packages/service-proxy/package.json index 5fe3914a2303..6844de83ad19 100644 --- a/packages/service-proxy/package.json +++ b/packages/service-proxy/package.json @@ -1,20 +1,20 @@ { "name": "@loopback/service-proxy", - "version": "1.0.7", + "version": "1.0.8", "description": "Service integration for LoopBack 4", "engines": { "node": ">=8.9" }, "main": "index", "scripts": { - "acceptance": "lb-mocha \"dist/test/acceptance/**/*.js\"", + "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"", "build:apidocs": "lb-apidocs", "build": "lb-tsc es2017 --outDir dist", "clean": "lb-clean loopback-service-proxy*.tgz dist package api-docs", - "integration": "lb-mocha \"dist/test/integration/**/*.js\"", + "integration": "lb-mocha \"dist/__tests__/integration/**/*.js\"", "pretest": "npm run build", - "test": "lb-mocha \"dist/test/unit/**/*.js\" \"dist/test/acceptance/**/*.js\" \"dist/test/integration/**/*.js\"", - "unit": "lb-mocha \"dist/test/unit/**/*.js\"", + "test": "lb-mocha \"dist/__tests__/unit/**/*.js\" \"dist/__tests__/acceptance/**/*.js\" \"dist/__tests__/integration/**/*.js\"", + "unit": "lb-mocha \"dist/__tests__/unit/**/*.js\"", "verify": "npm pack && tar xf loopback-service-proxy*.tgz && tree package && npm run clean" }, "publishConfig": { @@ -24,23 +24,23 @@ "copyright.owner": "IBM Corp.", "license": "MIT", "devDependencies": { - "@loopback/build": "^1.2.1", - "@loopback/testlab": "^1.0.5", + "@loopback/build": "^1.3.0", + "@loopback/testlab": "^1.0.6", "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, "dependencies": { - "@loopback/context": "^1.5.0", - "@loopback/core": "^1.1.5", + "@loopback/context": "^1.5.1", + "@loopback/core": "^1.1.6", "loopback-datasource-juggler": "^4.0.0" }, "files": [ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", - "src" + "dist", + "src", + "!*/__tests__" ], "repository": { "type": "git", diff --git a/packages/service-proxy/test/integration/service-proxy.integration.ts b/packages/service-proxy/src/__tests__/integration/service-proxy.integration.ts similarity index 100% rename from packages/service-proxy/test/integration/service-proxy.integration.ts rename to packages/service-proxy/src/__tests__/integration/service-proxy.integration.ts diff --git a/packages/service-proxy/test/mock-service.connector.ts b/packages/service-proxy/src/__tests__/mock-service.connector.ts similarity index 100% rename from packages/service-proxy/test/mock-service.connector.ts rename to packages/service-proxy/src/__tests__/mock-service.connector.ts diff --git a/packages/service-proxy/test/unit/decorators/service-proxy.decorator.unit.ts b/packages/service-proxy/src/__tests__/unit/decorators/service-proxy.decorator.unit.ts similarity index 100% rename from packages/service-proxy/test/unit/decorators/service-proxy.decorator.unit.ts rename to packages/service-proxy/src/__tests__/unit/decorators/service-proxy.decorator.unit.ts diff --git a/packages/service-proxy/test/unit/mixin/service.mixin.unit.ts b/packages/service-proxy/src/__tests__/unit/mixin/service.mixin.unit.ts similarity index 100% rename from packages/service-proxy/test/unit/mixin/service.mixin.unit.ts rename to packages/service-proxy/src/__tests__/unit/mixin/service.mixin.unit.ts diff --git a/packages/service-proxy/tsconfig.build.json b/packages/service-proxy/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/service-proxy/tsconfig.build.json +++ b/packages/service-proxy/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] } diff --git a/packages/testlab/CHANGELOG.md b/packages/testlab/CHANGELOG.md index c26bad971a59..56354cf59a6c 100644 --- a/packages/testlab/CHANGELOG.md +++ b/packages/testlab/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/testlab@1.0.5...@loopback/testlab@1.0.6) (2019-02-08) + +**Note:** Version bump only for package @loopback/testlab + + + + + ## [1.0.5](https://github.com/strongloop/loopback-next/compare/@loopback/testlab@1.0.4...@loopback/testlab@1.0.5) (2019-01-28) **Note:** Version bump only for package @loopback/testlab diff --git a/packages/testlab/fixtures/README.md b/packages/testlab/fixtures/README.md new file mode 100644 index 000000000000..b1296db403b3 --- /dev/null +++ b/packages/testlab/fixtures/README.md @@ -0,0 +1,9 @@ +# Static fixtures + +This directory contains test fixture files that we want to use in verbatim and +also files that TypeScript compiler would not copy from `src` to `dist`. + +For example: + +- text files +- JSON files not imported by any `.ts` file diff --git a/packages/testlab/package.json b/packages/testlab/package.json index 6356b811499c..7846e5b0ec84 100644 --- a/packages/testlab/package.json +++ b/packages/testlab/package.json @@ -1,6 +1,6 @@ { "name": "@loopback/testlab", - "version": "1.0.5", + "version": "1.0.6", "description": "A collection of test utilities we use to write LoopBack tests.", "engines": { "node": ">=8.9" @@ -10,7 +10,7 @@ "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-testlab*.tgz dist package api-docs", "pretest": "npm run build", - "test": "lb-mocha \"dist/test\"", + "test": "lb-mocha \"dist/__tests__\"", "verify": "npm pack && tar xf loopback-testlab*.tgz && tree package && npm run clean" }, "author": "IBM", @@ -24,14 +24,14 @@ "@types/supertest": "^2.0.7", "express": "^4.16.4", "fs-extra": "^7.0.1", - "oas-validator": "^2.0.0", + "oas-validator": "^3.1.0", "shot": "^4.0.7", "should": "^13.2.3", "sinon": "^7.2.2", "supertest": "^3.3.0" }, "devDependencies": { - "@loopback/build": "^1.2.1", + "@loopback/build": "^1.3.0", "@loopback/tslint-config": "^2.0.0", "@types/node": "^10.11.2" }, @@ -39,10 +39,10 @@ "README.md", "index.js", "index.d.ts", - "dist/src", - "dist/index*", + "dist", "should-as-function.d.ts", - "src" + "src", + "!*/__tests__" ], "repository": { "type": "git", diff --git a/packages/testlab/src/__tests__/fixtures/README.md b/packages/testlab/src/__tests__/fixtures/README.md new file mode 100644 index 000000000000..d3871836255d --- /dev/null +++ b/packages/testlab/src/__tests__/fixtures/README.md @@ -0,0 +1,4 @@ +# Compiled fixtures + +This directory contains test fixture files that we want to compile by TypeScript +before using in tests. diff --git a/packages/testlab/test/fixtures/test.ts b/packages/testlab/src/__tests__/fixtures/test.ts similarity index 100% rename from packages/testlab/test/fixtures/test.ts rename to packages/testlab/src/__tests__/fixtures/test.ts diff --git a/packages/testlab/test/integration/test-sandbox.integration.ts b/packages/testlab/src/__tests__/integration/test-sandbox.integration.ts similarity index 100% rename from packages/testlab/test/integration/test-sandbox.integration.ts rename to packages/testlab/src/__tests__/integration/test-sandbox.integration.ts diff --git a/packages/testlab/test/integration/testlab.smoke.integration.ts b/packages/testlab/src/__tests__/integration/testlab.smoke.integration.ts similarity index 100% rename from packages/testlab/test/integration/testlab.smoke.integration.ts rename to packages/testlab/src/__tests__/integration/testlab.smoke.integration.ts diff --git a/packages/testlab/test/unit/to-json.test.ts b/packages/testlab/src/__tests__/unit/to-json.test.ts similarity index 97% rename from packages/testlab/test/unit/to-json.test.ts rename to packages/testlab/src/__tests__/unit/to-json.test.ts index 726dd0ef6574..6ac0bc8fb028 100644 --- a/packages/testlab/test/unit/to-json.test.ts +++ b/packages/testlab/src/__tests__/unit/to-json.test.ts @@ -3,8 +3,8 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {expect} from '../../src/expect'; -import {toJSON} from '../../src/to-json'; +import {expect} from '../../expect'; +import {toJSON} from '../../to-json'; describe('toJSON', () => { it('removes properties set to undefined', () => { diff --git a/packages/testlab/tsconfig.build.json b/packages/testlab/tsconfig.build.json index f8bd0f50ef8f..6e15e4be4f6f 100644 --- a/packages/testlab/tsconfig.build.json +++ b/packages/testlab/tsconfig.build.json @@ -2,7 +2,7 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "@loopback/build/config/tsconfig.common.json", "compilerOptions": { - "rootDir": "." + "rootDir": "src" }, - "include": ["index.ts", "src", "test"] + "include": ["src"] }