From 71026ed9d9a19aeab8921625b046b47dbc597df2 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Thu, 29 Mar 2018 19:01:17 -0700 Subject: [PATCH 1/3] chore: update package.json to remove api-docs Now the apidocs will be generated for the whole monorepo --- docs/package.json | 7 ++++++- examples/hello-world/package.json | 1 - examples/log-extension/package.json | 1 - examples/rpc-server/package.json | 3 +-- examples/todo/package.json | 1 - package.json | 3 ++- packages/authentication/package.json | 2 -- packages/boot/package.json | 2 -- packages/context/package.json | 2 -- packages/core/package.json | 2 -- packages/metadata/package.json | 2 -- packages/openapi-spec-builder/package.json | 2 -- packages/openapi-v3-types/package.json | 1 - packages/openapi-v3/package.json | 2 -- packages/repository-json-schema/package.json | 2 -- packages/repository/package.json | 2 -- packages/rest/package.json | 2 -- packages/testlab/package.json | 1 - 18 files changed, 9 insertions(+), 29 deletions(-) diff --git a/docs/package.json b/docs/package.json index 66e0cb47bc52..f4df64e03e81 100644 --- a/docs/package.json +++ b/docs/package.json @@ -16,7 +16,12 @@ "LoopBack", "docs" ], - "scripts": {}, + "scripts": { + "clean": "lb-clean loopback-docs*.tgz package api-docs" + }, + "devDependencies": { + "@loopback/build": "^0.3.3" + }, "publishConfig": { "access": "public" }, diff --git a/examples/hello-world/package.json b/examples/hello-world/package.json index 106d762a1a06..9c11b5fe429e 100644 --- a/examples/hello-world/package.json +++ b/examples/hello-world/package.json @@ -12,7 +12,6 @@ "build": "lb-tsc es2017", "build:apidocs": "lb-apidocs", "clean": "lb-clean *example-hello-world*.tgz dist package api-docs", - "prepublishOnly": "npm run build && npm run build:apidocs", "verify": "npm pack && tar xf *example-hello-world*.tgz && tree package && npm run clean", "start": "npm run build && node ." }, diff --git a/examples/log-extension/package.json b/examples/log-extension/package.json index 49af887c0574..75e188440216 100644 --- a/examples/log-extension/package.json +++ b/examples/log-extension/package.json @@ -19,7 +19,6 @@ "prettier:fix": "npm run prettier:cli -- --write", "tslint": "lb-tslint", "tslint:fix": "npm run tslint -- --fix", - "prepublishOnly": "npm run build", "pretest": "npm run clean && npm run build", "test": "lb-mocha \"DIST/test/unit/**/*.js\" \"DIST/test/acceptance/**/*.js\"", "posttest": "npm run lint", diff --git a/examples/rpc-server/package.json b/examples/rpc-server/package.json index f951658ff9ed..6bac347f2b31 100644 --- a/examples/rpc-server/package.json +++ b/examples/rpc-server/package.json @@ -24,8 +24,7 @@ "pretest": "npm run clean && npm run build", "test": "lb-mocha DIST/test", "posttest": "npm run lint", - "start": "npm run build && node .", - "prepublishOnly": "npm run build" + "start": "npm run build && node ." }, "repository": { "type": "git", diff --git a/examples/todo/package.json b/examples/todo/package.json index e88e21f2f4e0..c4ae1381be87 100644 --- a/examples/todo/package.json +++ b/examples/todo/package.json @@ -12,7 +12,6 @@ "build": "lb-tsc es2017", "build:apidocs": "lb-apidocs", "clean": "lb-clean *example-todo*.tgz dist package api-docs", - "prepublishOnly": "npm run build && npm run build:apidocs", "pretest": "npm run build", "test": "lb-mocha \"DIST/test/unit/**/*.js\" \"DIST/test/acceptance/**/*.js\"", "unit": "lb-mocha \"DIST/test/unit/**/*.js\"", diff --git a/package.json b/package.json index 69c6bc2c473e..263fbef90c87 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "bootstrap": "npm i && lerna bootstrap", "release": "npm run build:full && lerna publish", "update-template-deps": "node bin/update-template-deps -f", - "version": "npm run update-template-deps", + "version": "npm run update-template-deps && npm run apidocs", + "apidocs": "npm run clean && node bin/run-lerna run build:apidocs --parallel --loglevel=silent", "coverage:ci": "node packages/build/bin/run-nyc report --reporter=text-lcov | coveralls", "precoverage": "npm test", "coverage": "open coverage/index.html", diff --git a/packages/authentication/package.json b/packages/authentication/package.json index a41c68053993..61015f41cd59 100644 --- a/packages/authentication/package.json +++ b/packages/authentication/package.json @@ -11,7 +11,6 @@ "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-authentication*.tgz dist package api-docs", "integration": "lb-mocha \"DIST/test/integration/**/*.js\"", - "prepublishOnly": "npm run build && npm run build:apidocs", "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\"", @@ -46,7 +45,6 @@ "index.js", "index.d.ts", "dist/src", - "api-docs", "src" ], "repository": { diff --git a/packages/boot/package.json b/packages/boot/package.json index 3e449b90b598..33fdc074d90e 100644 --- a/packages/boot/package.json +++ b/packages/boot/package.json @@ -15,7 +15,6 @@ "build:dist": "lb-tsc es2017", "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-boot*.tgz dist package api-docs", - "prepublishOnly": "npm run build && npm run build:apidocs", "pretest": "npm run build:current", "integration": "lb-mocha \"DIST/test/integration/**/*.js\"", "test": "lb-mocha \"DIST/test/unit/**/*.js\" \"DIST/test/integration/**/*.js\" \"DIST/test/acceptance/**/*.js\"", @@ -50,7 +49,6 @@ "dist/index.js", "dist/index.js.map", "dist/index.d.ts", - "api-docs", "src" ], "repository": { diff --git a/packages/context/package.json b/packages/context/package.json index c5386afa7730..45672bcfa07b 100644 --- a/packages/context/package.json +++ b/packages/context/package.json @@ -10,7 +10,6 @@ "build": "lb-tsc es2017", "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-context*.tgz dist package api-docs", - "prepublishOnly": "npm run build && npm run build:apidocs", "pretest": "npm run build", "test": "lb-mocha \"DIST/test/unit/**/*.js\" \"DIST/test/acceptance/**/*.js\"", "unit": "lb-mocha \"DIST/test/unit/**/*.js\"", @@ -47,7 +46,6 @@ "index.js", "index.d.ts", "dist/src", - "api-docs", "src" ], "repository": { diff --git a/packages/core/package.json b/packages/core/package.json index a2b581a6e1aa..9f5b6522b10c 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -10,7 +10,6 @@ "build": "lb-tsc es2017", "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-core*.tgz dist package api-docs", - "prepublishOnly": "npm run build && npm run build:apidocs", "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\"", @@ -36,7 +35,6 @@ "dist/src", "dist/index.d.ts", "dist/index.js.map", - "api-docs", "src" ], "repository": { diff --git a/packages/metadata/package.json b/packages/metadata/package.json index 833aadb3df68..56db725dd096 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -10,7 +10,6 @@ "build": "lb-tsc es2017", "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-metadata*.tgz dist package api-docs", - "prepublishOnly": "npm run build && npm run build:apidocs", "pretest": "npm run build", "test": "lb-mocha \"DIST/test/unit/**/*.js\" \"DIST/test/acceptance/**/*.js\"", "unit": "lb-mocha \"DIST/test/unit/**/*.js\"", @@ -41,7 +40,6 @@ "index.js", "index.d.ts", "dist/src", - "api-docs", "src" ], "publishConfig": { diff --git a/packages/openapi-spec-builder/package.json b/packages/openapi-spec-builder/package.json index 2720348d12cd..79e93b34d90f 100644 --- a/packages/openapi-spec-builder/package.json +++ b/packages/openapi-spec-builder/package.json @@ -9,7 +9,6 @@ "build": "lb-tsc es2017", "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-openapi-spec-builder*.tgz dist package api-docs", - "prepublishOnly": "npm run build && npm run build:apidocs", "verify": "npm pack && tar xf loopback-openapi-spec-builder*.tgz && tree package && npm run clean" }, "author": "IBM", @@ -34,7 +33,6 @@ "index.js", "index.d.ts", "dist/src", - "api-docs", "src" ], "repository": { diff --git a/packages/openapi-v3-types/package.json b/packages/openapi-v3-types/package.json index b33db0da9723..8f03b791b15f 100644 --- a/packages/openapi-v3-types/package.json +++ b/packages/openapi-v3-types/package.json @@ -36,7 +36,6 @@ "index.js", "index.d.ts", "dist/src", - "api-docs", "src" ], "publishConfig": { diff --git a/packages/openapi-v3/package.json b/packages/openapi-v3/package.json index 2ea2dc5cb219..f8d021d1842e 100644 --- a/packages/openapi-v3/package.json +++ b/packages/openapi-v3/package.json @@ -19,7 +19,6 @@ "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-openapi-v3*.tgz dist* package", "integration": "lb-mocha \"DIST/test/integration/**/*.js\"", - "prepublishOnly": "npm run build && npm run build:apidocs", "pretest": "npm run build", "test": "lb-mocha \"DIST/test/unit/**/*.js\" \"DIST/test/integration/**/*.js\"", "unit": "lb-mocha \"DIST/test/unit/**/*.js\"", @@ -38,7 +37,6 @@ "index.js", "index.d.ts", "dist/src", - "api-docs", "src" ], "publishConfig": { diff --git a/packages/repository-json-schema/package.json b/packages/repository-json-schema/package.json index d3ba2f074952..6b11c5c37973 100644 --- a/packages/repository-json-schema/package.json +++ b/packages/repository-json-schema/package.json @@ -9,7 +9,6 @@ "build": "lb-tsc es2017", "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-json-schema*.tgz dist package api-docs", - "prepublishOnly": "npm run build && npm run build:apidocs", "pretest": "npm run build", "test": "lb-mocha \"DIST/test/unit/**/*.js\" \"DIST/test/integration/**/*.js\" \"DIST/test/acceptance/**/*.js\"", "verify": "npm pack && tar xf loopback-json-schema*.tgz && tree package && npm run clean" @@ -41,7 +40,6 @@ "index.js", "index.d.ts", "dist/src", - "api-docs", "src" ], "repository": { diff --git a/packages/repository/package.json b/packages/repository/package.json index 5d68d3f89d76..bfb3bf648d4d 100644 --- a/packages/repository/package.json +++ b/packages/repository/package.json @@ -11,7 +11,6 @@ "build": "lb-tsc es2017", "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-repository*.tgz dist package api-docs", - "prepublishOnly": "npm run build && npm run build:apidocs", "pretest": "npm run build", "test": "lb-mocha \"DIST/test/unit/**/*.js\" \"DIST/test/acceptance/**/*.js\"", "unit": "lb-mocha \"DIST/test/unit/**/*.js\"", @@ -35,7 +34,6 @@ "index.js", "index.d.ts", "dist/src", - "api-docs", "src" ], "repository": { diff --git a/packages/rest/package.json b/packages/rest/package.json index 9b7dc877a4c7..0a1688543579 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -10,7 +10,6 @@ "build": "lb-tsc es2017", "build:apidocs": "lb-apidocs", "clean": "lb-clean loopback-rest*.tgz dist package api-docs", - "prepublishOnly": "npm run build && npm run build:apidocs", "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\"", @@ -50,7 +49,6 @@ "index.js", "index.d.ts", "dist/src", - "api-docs", "src" ], "repository": { diff --git a/packages/testlab/package.json b/packages/testlab/package.json index 1fc9342f23c8..03d97b1193a8 100644 --- a/packages/testlab/package.json +++ b/packages/testlab/package.json @@ -8,7 +8,6 @@ "scripts": { "build": "lb-tsc es2017", "clean": "lb-clean loopback-testlab*.tgz dist package api-docs", - "prepublishOnly": "npm run build", "pretest": "npm run build", "test": "lb-mocha \"DIST/test\"", "verify": "npm pack && tar xf loopback-testlab*.tgz && tree package && npm run clean" From 06bc5cecf56eec6c04949c86c39d681dccae7495 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Wed, 28 Mar 2018 19:15:53 -0700 Subject: [PATCH 2/3] chore: update docs/apidocs.html --- docs/README.md | 17 +++++++++++++++++ docs/apidocs.html | 20 +++++++++++--------- docs/docs.json | 6 ++++++ docs/package.json | 1 + 4 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 docs/README.md create mode 100644 docs/docs.json diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 000000000000..596e2f5f8eaf --- /dev/null +++ b/docs/README.md @@ -0,0 +1,17 @@ +# LoopBack 4 documentation + +This package contains documentation for LoopBack 4. It's published to npm +as [@loopback/docs](https://www.npmjs.com/package/@loopback/docs). + +## Documentation site + +The `site` directory contains pages for http://loopback.io/doc/en/lb4/index.html. + +To contribute, please check out https://loopback.io/doc/en/contrib/doc-contrib.html. + +## API references + +The API references are generated by running `npm run apidocs` at the root +directory of [loopback-next](https://github.com/strongloop/loopback-next). + +[API references](./apidocs.html) diff --git a/docs/apidocs.html b/docs/apidocs.html index cea569132a7c..36e003a4c151 100644 --- a/docs/apidocs.html +++ b/docs/apidocs.html @@ -13,18 +13,20 @@

LoopBack4 packages (local)

Run the following command to (re)build API doc files: -

$ npx lerna run build:apidocs
+

$ npm run apidocs

List of packages

diff --git a/docs/docs.json b/docs/docs.json new file mode 100644 index 000000000000..45813c37ae53 --- /dev/null +++ b/docs/docs.json @@ -0,0 +1,6 @@ +{ + "content": ["README.md"], + "assets": { + "/apidocs.html": "apidocs.html" + } +} diff --git a/docs/package.json b/docs/package.json index f4df64e03e81..10d4bce94a5e 100644 --- a/docs/package.json +++ b/docs/package.json @@ -17,6 +17,7 @@ "docs" ], "scripts": { + "build:apidocs": "lb-apidocs --html-file=index.html", "clean": "lb-clean loopback-docs*.tgz package api-docs" }, "devDependencies": { From 1ae68fa04ac9b50d3e4dcedd0b11219ae23e4288 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Wed, 28 Mar 2018 16:21:28 -0700 Subject: [PATCH 3/3] fix(build): update build scripts --- bin/update-template-deps.js | 2 +- package.json | 2 +- packages/build/bin/compile-package.js | 5 +- packages/build/bin/generate-apidocs.js | 27 ++++++- packages/build/bin/utils.js | 5 +- .../{ => integration}/fixtures/.gitignore | 0 .../test/{ => integration}/fixtures/docs.json | 0 .../{ => integration}/fixtures/package.json | 2 +- .../{ => integration}/fixtures/src/index.ts | 0 .../test/integration/scripts.integration.js | 77 +++++++++++++++++-- 10 files changed, 105 insertions(+), 15 deletions(-) rename packages/build/test/{ => integration}/fixtures/.gitignore (100%) rename packages/build/test/{ => integration}/fixtures/docs.json (100%) rename packages/build/test/{ => integration}/fixtures/package.json (82%) rename packages/build/test/{ => integration}/fixtures/src/index.ts (100%) diff --git a/bin/update-template-deps.js b/bin/update-template-deps.js index d3e2859f650e..913272f5e88f 100644 --- a/bin/update-template-deps.js +++ b/bin/update-template-deps.js @@ -1,6 +1,6 @@ #!/usr/bin/env node // Copyright IBM Corp. 2017,2018. All Rights Reserved. -// Node module: @loopback/cli +// Node module: loopback-next // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT diff --git a/package.json b/package.json index 263fbef90c87..cfcce5a06af3 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "build:full": "npm run clean:lerna && npm run bootstrap && npm test", "pretest": "npm run clean && npm run build", "test": "node packages/build/bin/run-nyc npm run mocha --scripts-prepend-node-path", - "mocha": "node packages/build/bin/run-mocha \"packages/*/DIST/test/**/*.js\" \"examples/*/DIST/test/**/*.js\" \"packages/cli/test/**/*.js\"", + "mocha": "node packages/build/bin/run-mocha \"packages/*/DIST/test/**/*.js\" \"examples/*/DIST/test/**/*.js\" \"packages/cli/test/*.js\" \"packages/build/test/*/*.js\"", "posttest": "npm run lint" }, "config": { diff --git a/packages/build/bin/compile-package.js b/packages/build/bin/compile-package.js index 9b768cab3152..7f2250328861 100755 --- a/packages/build/bin/compile-package.js +++ b/packages/build/bin/compile-package.js @@ -72,10 +72,11 @@ function run(argv, options) { // No local tsconfig.build.json or tsconfig.json found var baseConfigFile = path.join(rootDir, 'config/tsconfig.common.json'); baseConfigFile = path.relative(packageDir, baseConfigFile); - if (baseConfigFile.indexOf('../') !== 0) { + if (baseConfigFile.indexOf('..' + path.sep) !== 0) { // tsconfig only supports relative or rooted path - baseConfigFile = './' + baseConfigFile; + baseConfigFile = '.' + path.sep + baseConfigFile; } + baseConfigFile = baseConfigFile.replace(/\\/g, '/'); // Create tsconfig.json under the package as it's required to parse // include/exclude correctly tsConfigFile = path.join(packageDir, 'tsconfig.json'); diff --git a/packages/build/bin/generate-apidocs.js b/packages/build/bin/generate-apidocs.js index 726ee3f1d8a0..b384e703f686 100755 --- a/packages/build/bin/generate-apidocs.js +++ b/packages/build/bin/generate-apidocs.js @@ -42,7 +42,32 @@ function run(argv, options) { args.push('--tsconfig', config); } if (!utils.isOptionSet(apidocsOpts, '--out', '-o')) { - args.push('-o', 'api-docs'); + let out = 'api-docs'; + if (process.env.LERNA_ROOT_PATH) { + out = path.join(process.env.LERNA_ROOT_PATH, `docs/${out}`); + } + args.push('-o', out); + } + if (process.env.LERNA_ROOT_PATH) { + const pkg = require(path.join(utils.getPackageDir(), 'package.json')); + // Skip private packages for repo level apidocs + if (pkg.private) return; + if (!utils.isOptionSet(apidocsOpts, '--html-file')) { + // Generate api docs into loopback-next/docs/api-docs/ + let name = pkg.name; + + const index = pkg.name.lastIndexOf('/'); + if (index !== -1) { + name = pkg.name.substring(index + 1); + } + args.push('--html-file', `${name}.html`); + } + + if (!utils.isOptionSet(apidocsOpts, '--skip-public-assets')) { + if (pkg.name !== '@loopback/docs') { + args.push('--skip-public-assets'); + } + } } args.push(...apidocsOpts); return utils.runCLI('strong-docs/bin/cli', args, options); diff --git a/packages/build/bin/utils.js b/packages/build/bin/utils.js index c210da06efb8..c91e0c23239d 100644 --- a/packages/build/bin/utils.js +++ b/packages/build/bin/utils.js @@ -181,7 +181,10 @@ function runShell(command, args, options) { * @param {string[]} optionNames */ function isOptionSet(opts, ...optionNames) { - return opts.some(o => optionNames.indexOf(o) !== -1); + return opts.some(opt => + // It can be --my-opt or --my-opt=my-value + optionNames.some(name => name === opt || opt.startsWith(`${name}=`)) + ); } exports.getCompilationTarget = getCompilationTarget; diff --git a/packages/build/test/fixtures/.gitignore b/packages/build/test/integration/fixtures/.gitignore similarity index 100% rename from packages/build/test/fixtures/.gitignore rename to packages/build/test/integration/fixtures/.gitignore diff --git a/packages/build/test/fixtures/docs.json b/packages/build/test/integration/fixtures/docs.json similarity index 100% rename from packages/build/test/fixtures/docs.json rename to packages/build/test/integration/fixtures/docs.json diff --git a/packages/build/test/fixtures/package.json b/packages/build/test/integration/fixtures/package.json similarity index 82% rename from packages/build/test/fixtures/package.json rename to packages/build/test/integration/fixtures/package.json index 624fb77ab295..97736ba0ef91 100644 --- a/packages/build/test/fixtures/package.json +++ b/packages/build/test/integration/fixtures/package.json @@ -1,5 +1,5 @@ { - "name": "ts-test-proj", + "name": "@loopback/ts-test-proj", "version": "1.0.0", "description": "Test", "scripts": { diff --git a/packages/build/test/fixtures/src/index.ts b/packages/build/test/integration/fixtures/src/index.ts similarity index 100% rename from packages/build/test/fixtures/src/index.ts rename to packages/build/test/integration/fixtures/src/index.ts diff --git a/packages/build/test/integration/scripts.integration.js b/packages/build/test/integration/scripts.integration.js index 174043fafe74..131d02d61c31 100644 --- a/packages/build/test/integration/scripts.integration.js +++ b/packages/build/test/integration/scripts.integration.js @@ -12,7 +12,7 @@ const fs = require('fs-extra'); describe('build', function() { this.timeout(30000); var cwd = process.cwd(); - var projectDir = path.resolve(__dirname, '../fixtures'); + var projectDir = path.resolve(__dirname, './fixtures'); function cleanup() { var run = require('../../bin/run-clean'); @@ -50,41 +50,40 @@ describe('build', function() { 'tsconfig.json should have been created' ); var tsConfig = fs.readJSONSync(path.join(projectDir, 'tsconfig.json')); - assert.equal(tsConfig.extends, '../../config/tsconfig.common.json'); + assert.equal(tsConfig.extends, '../../../config/tsconfig.common.json'); done(); }); }); it('honors tsconfig.build.json over tsconfig.json', () => { fs.writeJSONSync('tsconfig.build.json', { - extends: '../../config/tsconfig.common.json', + extends: '../../../config/tsconfig.common.json', include: ['src', 'test'], exclude: ['node_modules/**', 'packages/*/node_modules/**', '**/*.d.ts'], }); fs.writeJSONSync('tsconfig.json', { - extends: '../../config/tsconfig.common.json', + extends: '../../../config/tsconfig.common.json', include: ['src', 'test'], exclude: ['node_modules/**', 'packages/*/node_modules/**', '**/*.d.ts'], }); var run = require('../../bin/compile-package'); var command = run(['node', 'bin/compile-package'], true); assert( - command.indexOf('-p ' + path.join(projectDir, 'tsconfig.build.json')) !== - -1, + command.indexOf('-p tsconfig.build.json') !== -1, 'project level tsconfig.build.json should be honored' ); }); it('honors tsconfig.json if tsconfig.build.json is not present', () => { fs.writeJSONSync('tsconfig.json', { - extends: '../../config/tsconfig.common.json', + extends: '../../../config/tsconfig.common.json', include: ['src', 'test'], exclude: ['node_modules/**', 'packages/*/node_modules/**', '**/*.d.ts'], }); var run = require('../../bin/compile-package'); var command = run(['node', 'bin/compile-package'], true); assert( - command.indexOf('-p ' + path.join(projectDir, 'tsconfig.json')) !== -1, + command.indexOf('-p tsconfig.json') !== -1, 'project level tsconfig.json should be honored' ); }); @@ -212,6 +211,30 @@ describe('build', function() { ); }); + it('honors --skip-public-assets for apidocs', () => { + var run = require('../../bin/generate-apidocs'); + var command = run( + ['node', 'bin/generate-apidocs', '--skip-public-assets'], + true + ); + assert( + command.indexOf('--skip-public-assets') !== -1, + '--skip-public-assets should be honored' + ); + }); + + it('honors --html-file for apidocs', () => { + var run = require('../../bin/generate-apidocs'); + var command = run( + ['node', 'bin/generate-apidocs', '--html-file=my.html'], + true + ); + assert( + command.indexOf('--html-file=my.html') !== -1, + '--html-file should be honored' + ); + }); + it('runs tslint against ts files', done => { var run = require('../../bin/run-tslint'); var childProcess = run(['node', 'bin/run-tslint']); @@ -294,4 +317,42 @@ describe('build', function() { ); assert(command.indexOf('rm -rf ./dist') !== -1); }); + + describe('with LERNA_ROOT_PATH', () => { + const repoRoot = path.join(__dirname, '../../../..'); + before(() => (process.env.LERNA_ROOT_PATH = repoRoot)); + + it('sets --skip-public-assets for apidocs', () => { + var run = require('../../bin/generate-apidocs'); + var command = run(['node', 'bin/generate-apidocs'], true); + assert( + command.indexOf('--skip-public-assets') !== -1, + '--skip-public-assets should be set by default' + ); + }); + + it('sets --html-file for apidocs', () => { + var run = require('../../bin/generate-apidocs'); + var command = run(['node', 'bin/generate-apidocs'], true); + assert( + command.indexOf('--html-file ts-test-proj.html') !== -1, + '--html-file should be set to the package name by default' + ); + }); + + it('sets --project option for tsc', () => { + var run = require('../../bin/compile-package'); + var command = run(['node', 'bin/compile-package'], true); + const tsConfig = path.relative( + repoRoot, + path.join(__dirname, './fixtures/tsconfig.json') + ); + assert( + command.indexOf(`-p ${tsConfig}`) !== -1, + '-p should be set relative to the monorepo root' + ); + }); + + after(() => delete process.env.LERNA_ROOT_PATH); + }); });