|
8 | 8 | const path = require('path'); |
9 | 9 | const assert = require('yeoman-assert'); |
10 | 10 | const helpers = require('yeoman-test'); |
11 | | - |
12 | 11 | const lerna = require('lerna'); |
13 | | -function lernaBootstrap() { |
14 | | - const cmd = new lerna.BootstrapCommand('', { |
15 | | - loglevel: 'silent', |
16 | | - }); |
17 | | - return cmd.run(); |
18 | | -} |
19 | | - |
20 | | -const runShell = require('@loopback/build').runShell; |
| 12 | +const build = require('@loopback/build'); |
21 | 13 |
|
22 | 14 | describe('app-generator', function() { |
23 | 15 | const generator = path.join(__dirname, '../generators/app'); |
24 | 16 | const rootDir = path.join(__dirname, '../../..'); |
25 | 17 | const sandbox = path.join(__dirname, '../../_sandbox'); |
26 | 18 | const cwd = process.cwd(); |
| 19 | + const appName = '@loopback/sandbox-app'; |
27 | 20 | const props = { |
28 | | - name: 'myApp', |
29 | | - description: 'My app for LoopBack 4', |
| 21 | + name: appName, |
| 22 | + description: 'My sandbox app for LoopBack 4', |
30 | 23 | outdir: sandbox, |
31 | 24 | }; |
32 | 25 |
|
33 | | - // WARNING: It takes a while to run `lerna bootstrap` |
34 | | - this.timeout(0); |
35 | | - before(() => { |
36 | | - return helpers |
| 26 | + before(async () => { |
| 27 | + await helpers |
37 | 28 | .run(generator) |
38 | 29 | .inDir(sandbox) |
| 30 | + // Mark it private to prevent accidental npm publication |
| 31 | + .withOptions({private: true}) |
39 | 32 | .withPrompts(props); |
40 | 33 | }); |
41 | 34 |
|
42 | | - it('passes `npm test` for the generated project', async () => { |
| 35 | + // Run `lerna bootstrap --scope @loopback/sandbox-app` |
| 36 | + // WARNING: It takes a while to run `lerna bootstrap` |
| 37 | + this.timeout(0); |
| 38 | + before(async () => { |
43 | 39 | process.chdir(rootDir); |
44 | | - await lernaBootstrap(); |
| 40 | + await lernaBootstrap(appName); |
| 41 | + }); |
| 42 | + |
| 43 | + it('passes `npm test` for the generated project', () => { |
45 | 44 | process.chdir(sandbox); |
46 | 45 | return new Promise((resolve, reject) => { |
47 | | - runShell('npm', ['test', '--', '--allow-console-logs']).on( |
48 | | - 'close', |
49 | | - code => { |
50 | | - process.chdir(cwd); |
| 46 | + build |
| 47 | + .runShell('npm', ['test', '--', '--allow-console-logs']) |
| 48 | + .on('close', code => { |
51 | 49 | assert.equal(code, 0); |
52 | 50 | resolve(); |
53 | | - } |
54 | | - ); |
| 51 | + }); |
55 | 52 | }); |
56 | 53 | }); |
| 54 | + |
| 55 | + after(() => { |
| 56 | + process.chdir(rootDir); |
| 57 | + build.clean(['node', 'run-clean', sandbox]); |
| 58 | + process.chdir(cwd); |
| 59 | + }); |
57 | 60 | }); |
| 61 | + |
| 62 | +function lernaBootstrap(scope) { |
| 63 | + const cmd = new lerna.BootstrapCommand('', { |
| 64 | + scope: scope, |
| 65 | + loglevel: 'silent', |
| 66 | + }); |
| 67 | + return cmd.run(); |
| 68 | +} |
0 commit comments