@@ -10,6 +10,8 @@ import { createNpmRegistry } from './e2e/utils/registry';
10
10
import { launchTestProcess } from './e2e/utils/process' ;
11
11
import { join } from 'path' ;
12
12
import { findFreePort } from './e2e/utils/network' ;
13
+ import { extractFile } from './e2e/utils/tar' ;
14
+ import { realpathSync } from 'fs' ;
13
15
14
16
Error . stackTraceLimit = Infinity ;
15
17
@@ -34,6 +36,8 @@ Error.stackTraceLimit = Infinity;
34
36
* --shard Index of this processes' shard.
35
37
* --tmpdir=path Override temporary directory to use for new projects.
36
38
* --yarn Use yarn as package manager.
39
+ * --package=path An npm package to be published before running tests
40
+ *
37
41
* If unnamed flags are passed in, the list of tests will be filtered to include only those passed.
38
42
*/
39
43
const argv = yargsParser ( process . argv . slice ( 2 ) , {
@@ -49,6 +53,7 @@ const argv = yargsParser(process.argv.slice(2), {
49
53
] ,
50
54
string : [ 'devkit' , 'glob' , 'ignore' , 'reuse' , 'ng-tag' , 'tmpdir' , 'ng-version' ] ,
51
55
number : [ 'nb-shards' , 'shard' ] ,
56
+ array : [ 'package' ] ,
52
57
configuration : {
53
58
'dot-notation' : false ,
54
59
'camel-case-expansion' : false ,
@@ -163,10 +168,11 @@ setGlobalVariable('argv', argv);
163
168
setGlobalVariable ( 'ci' , process . env [ 'CI' ] ?. toLowerCase ( ) === 'true' || process . env [ 'CI' ] === '1' ) ;
164
169
setGlobalVariable ( 'package-manager' , argv . yarn ? 'yarn' : 'npm' ) ;
165
170
166
- Promise . all ( [ findFreePort ( ) , findFreePort ( ) ] )
167
- . then ( async ( [ httpPort , httpsPort ] ) => {
171
+ Promise . all ( [ findFreePort ( ) , findFreePort ( ) , findPackageTars ( ) ] )
172
+ . then ( async ( [ httpPort , httpsPort , packageTars ] ) => {
168
173
setGlobalVariable ( 'package-registry' , 'http://localhost:' + httpPort ) ;
169
174
setGlobalVariable ( 'package-secure-registry' , 'http://localhost:' + httpsPort ) ;
175
+ setGlobalVariable ( 'package-tars' , packageTars ) ;
170
176
171
177
// NPM registries for the lifetime of the test execution
172
178
const registryProcess = await createNpmRegistry ( httpPort , httpPort ) ;
@@ -315,3 +321,23 @@ function printFooter(testName: string, type: 'setup' | 'initializer' | 'test', s
315
321
) ;
316
322
console . log ( '' ) ;
317
323
}
324
+
325
+ // Collect the packages passed as arguments and return as {package-name => pkg-path}
326
+ async function findPackageTars ( ) : Promise < { [ pkg : string ] : string } > {
327
+ const pkgs : string [ ] = ( getGlobalVariable ( 'argv' ) . package as string [ ] ) . flatMap ( ( p ) =>
328
+ glob . sync ( p , { realpath : true } ) ,
329
+ ) ;
330
+
331
+ const pkgJsons = await Promise . all ( pkgs . map ( ( pkg ) => extractFile ( pkg , 'package/package.json' ) ) ) ;
332
+
333
+ return pkgs . reduce ( ( all , pkg , i ) => {
334
+ const json = pkgJsons [ i ] . toString ( 'utf8' ) ;
335
+ const name = JSON . parse ( json ) . name as string ;
336
+ if ( ! name ) {
337
+ throw new Error ( `Package ${ pkg } - package.json name not found` ) ;
338
+ }
339
+
340
+ all [ name ] = realpathSync ( pkg ) ;
341
+ return all ;
342
+ } , { } as { [ pkg : string ] : string } ) ;
343
+ }
0 commit comments