@@ -34,7 +34,7 @@ module.exports =
3434/******/ // the startup function
3535/******/ function startup ( ) {
3636/******/ // Load entry module and return exports
37- /******/ return __webpack_require__ ( 74 ) ;
37+ /******/ return __webpack_require__ ( 765 ) ;
3838/******/ } ;
3939/******/
4040/******/ // run startup
@@ -43,93 +43,6 @@ module.exports =
4343/************************************************************************/
4444/******/ ( {
4545
46- /***/ 74 :
47- /***/ ( function ( __unusedmodule , __unusedexports , __webpack_require__ ) {
48-
49- const core = __webpack_require__ ( 587 )
50- const exec = __webpack_require__ ( 423 )
51- const path = __webpack_require__ ( 622 )
52- const fs = __webpack_require__ ( 747 )
53-
54- const SCOPE_DSN = 'SCOPE_DSN'
55-
56- const DEFAULT_ARGUMENTS = [
57- '--testRunner=@undefinedlabs/scope-agent/jest/testRunner' ,
58- '--runner=@undefinedlabs/scope-agent/jest/runner' ,
59- '--setupFilesAfterEnv=@undefinedlabs/scope-agent/jest/setupTests' ,
60- '--runInBand' ,
61- ]
62-
63- const DEFAULT_COMMAND = 'npm test'
64-
65- const NPM_INSTALL_COMMAND = 'npm install --save-dev @undefinedlabs/scope-agent'
66- const YARN_INSTALL_COMMAND = 'yarn add --dev @undefinedlabs/scope-agent'
67-
68- const isYarnRepo = ( cwd = process . cwd ( ) ) => {
69- console . log ( 'current directory' , cwd )
70- console . log ( 'yarn lock position' , __webpack_require__ . ab + "scope-for-javascript-action/" + cwd + '/yarn.lock' )
71- return fs . existsSync ( __webpack_require__ . ab + "scope-for-javascript-action/" + cwd + '/yarn.lock' )
72- }
73-
74- async function run ( ) {
75- try {
76- const command = core . getInput ( 'command' ) || DEFAULT_COMMAND
77- const dsn = core . getInput ( 'dsn' ) || process . env [ SCOPE_DSN ]
78-
79- if ( ! dsn ) {
80- throw Error ( 'Cannot find the Scope DSN' )
81- }
82-
83- let apiEndpoint , apiKey
84- try {
85- const { username, origin } = new URL ( dsn )
86- apiEndpoint = origin
87- apiKey = username
88- } catch ( e ) { }
89-
90- if ( ! apiEndpoint || ! apiKey ) {
91- throw Error ( 'SCOPE_DSN does not have the correct format' )
92- }
93-
94- console . log ( `Command: ${ command } ` )
95- if ( dsn ) {
96- console . log ( `DSN has been set.` )
97- }
98-
99- const isYarn = isYarnRepo ( )
100-
101- console . log ( `Project is using ${ isYarn ? 'yarn' : 'npm' } ` )
102-
103- await exec . exec ( isYarn ? YARN_INSTALL_COMMAND : NPM_INSTALL_COMMAND , null , {
104- ignoreReturnCode : true ,
105- } )
106-
107- return ExecScopeRun ( command , apiEndpoint , apiKey , isYarn )
108- } catch ( error ) {
109- core . setFailed ( error . message )
110- }
111- }
112-
113- function ExecScopeRun ( command = DEFAULT_COMMAND , apiEndpoint , apiKey , isYarn ) {
114- return exec . exec (
115- `CI=true ${ command } ` ,
116- isYarn ? DEFAULT_ARGUMENTS : [ '--' , ...DEFAULT_ARGUMENTS ] ,
117- {
118- env : {
119- ...process . env ,
120- SCOPE_API_ENDPOINT : apiEndpoint ,
121- SCOPE_APIKEY : apiKey ,
122- SCOPE_AUTO_INSTRUMENT : true ,
123- } ,
124- }
125- )
126- }
127-
128- run ( )
129-
130-
131- /***/ } ) ,
132-
13346/***/ 87 :
13447/***/ ( function ( module ) {
13548
@@ -144,51 +57,7 @@ module.exports = require("child_process");
14457
14558/***/ } ) ,
14659
147- /***/ 423 :
148- /***/ ( function ( __unusedmodule , exports , __webpack_require__ ) {
149-
150- "use strict" ;
151-
152- var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
153- function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
154- return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
155- function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
156- function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
157- function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
158- step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
159- } ) ;
160- } ;
161- Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
162- const tr = __webpack_require__ ( 855 ) ;
163- /**
164- * Exec a command.
165- * Output will be streamed to the live console.
166- * Returns promise with return code
167- *
168- * @param commandLine command to execute (can include additional args). Must be correctly escaped.
169- * @param args optional arguments for tool. Escaping is handled by the lib.
170- * @param options optional exec options. See ExecOptions
171- * @returns Promise<number> exit code
172- */
173- function exec ( commandLine , args , options ) {
174- return __awaiter ( this , void 0 , void 0 , function * ( ) {
175- const commandArgs = tr . argStringToArray ( commandLine ) ;
176- if ( commandArgs . length === 0 ) {
177- throw new Error ( `Parameter 'commandLine' cannot be null or empty.` ) ;
178- }
179- // Path to tool to execute should be first arg
180- const toolPath = commandArgs [ 0 ] ;
181- args = commandArgs . slice ( 1 ) . concat ( args || [ ] ) ;
182- const runner = new tr . ToolRunner ( toolPath , args , options ) ;
183- return runner . exec ( ) ;
184- } ) ;
185- }
186- exports . exec = exec ;
187- //# sourceMappingURL=exec.js.map
188-
189- /***/ } ) ,
190-
191- /***/ 438 :
60+ /***/ 337 :
19261/***/ ( function ( __unusedmodule , exports , __webpack_require__ ) {
19362
19463"use strict" ;
@@ -261,7 +130,7 @@ function escape(s) {
261130
262131/***/ } ) ,
263132
264- /***/ 587 :
133+ /***/ 586 :
265134/***/ ( function ( __unusedmodule , exports , __webpack_require__ ) {
266135
267136"use strict" ;
@@ -276,7 +145,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
276145 } ) ;
277146} ;
278147Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
279- const command_1 = __webpack_require__ ( 438 ) ;
148+ const command_1 = __webpack_require__ ( 337 ) ;
280149const os = __webpack_require__ ( 87 ) ;
281150const path = __webpack_require__ ( 622 ) ;
282151/**
@@ -484,7 +353,130 @@ module.exports = require("fs");
484353
485354/***/ } ) ,
486355
487- /***/ 855 :
356+ /***/ 765 :
357+ /***/ ( function ( __unusedmodule , __unusedexports , __webpack_require__ ) {
358+
359+ const core = __webpack_require__ ( 586 )
360+ const exec = __webpack_require__ ( 831 )
361+ const fs = __webpack_require__ ( 747 )
362+
363+ const SCOPE_DSN = 'SCOPE_DSN'
364+
365+ const DEFAULT_ARGUMENTS = [
366+ '--testRunner=@undefinedlabs/scope-agent/jest/testRunner' ,
367+ '--runner=@undefinedlabs/scope-agent/jest/runner' ,
368+ '--setupFilesAfterEnv=@undefinedlabs/scope-agent/jest/setupTests' ,
369+ '--runInBand' ,
370+ ]
371+
372+ const DEFAULT_COMMAND = 'npm test'
373+
374+ const NPM_INSTALL_COMMAND = 'npm install --save-dev @undefinedlabs/scope-agent'
375+ const YARN_INSTALL_COMMAND = 'yarn add --dev @undefinedlabs/scope-agent'
376+
377+ const isYarnRepo = ( ) => fs . existsSync ( 'yarn.lock' )
378+
379+ async function run ( ) {
380+ try {
381+ const command = core . getInput ( 'command' ) || DEFAULT_COMMAND
382+ const dsn = core . getInput ( 'dsn' ) || process . env [ SCOPE_DSN ]
383+
384+ if ( ! dsn ) {
385+ throw Error ( 'Cannot find the Scope DSN' )
386+ }
387+
388+ let apiEndpoint , apiKey
389+ try {
390+ const { username, origin } = new URL ( dsn )
391+ apiEndpoint = origin
392+ apiKey = username
393+ } catch ( e ) { }
394+
395+ if ( ! apiEndpoint || ! apiKey ) {
396+ throw Error ( 'SCOPE_DSN does not have the correct format' )
397+ }
398+
399+ console . log ( `Command: ${ command } ` )
400+ if ( dsn ) {
401+ console . log ( `DSN has been set.` )
402+ }
403+
404+ const isYarn = isYarnRepo ( )
405+
406+ console . log ( `Project is using ${ isYarn ? 'yarn' : 'npm' } ` )
407+
408+ await exec . exec ( isYarn ? YARN_INSTALL_COMMAND : NPM_INSTALL_COMMAND , null , {
409+ ignoreReturnCode : true ,
410+ } )
411+
412+ return ExecScopeRun ( command , apiEndpoint , apiKey , isYarn )
413+ } catch ( error ) {
414+ core . setFailed ( error . message )
415+ }
416+ }
417+
418+ function ExecScopeRun ( command = DEFAULT_COMMAND , apiEndpoint , apiKey , isYarn ) {
419+ return exec . exec ( command , isYarn ? DEFAULT_ARGUMENTS : [ '--' , ...DEFAULT_ARGUMENTS ] , {
420+ env : {
421+ ...process . env ,
422+ SCOPE_API_ENDPOINT : apiEndpoint ,
423+ SCOPE_APIKEY : apiKey ,
424+ SCOPE_AUTO_INSTRUMENT : true ,
425+ CI : true ,
426+ } ,
427+ } )
428+ }
429+
430+ run ( )
431+
432+
433+ /***/ } ) ,
434+
435+ /***/ 831 :
436+ /***/ ( function ( __unusedmodule , exports , __webpack_require__ ) {
437+
438+ "use strict" ;
439+
440+ var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
441+ function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
442+ return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
443+ function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
444+ function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
445+ function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
446+ step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
447+ } ) ;
448+ } ;
449+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
450+ const tr = __webpack_require__ ( 963 ) ;
451+ /**
452+ * Exec a command.
453+ * Output will be streamed to the live console.
454+ * Returns promise with return code
455+ *
456+ * @param commandLine command to execute (can include additional args). Must be correctly escaped.
457+ * @param args optional arguments for tool. Escaping is handled by the lib.
458+ * @param options optional exec options. See ExecOptions
459+ * @returns Promise<number> exit code
460+ */
461+ function exec ( commandLine , args , options ) {
462+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
463+ const commandArgs = tr . argStringToArray ( commandLine ) ;
464+ if ( commandArgs . length === 0 ) {
465+ throw new Error ( `Parameter 'commandLine' cannot be null or empty.` ) ;
466+ }
467+ // Path to tool to execute should be first arg
468+ const toolPath = commandArgs [ 0 ] ;
469+ args = commandArgs . slice ( 1 ) . concat ( args || [ ] ) ;
470+ const runner = new tr . ToolRunner ( toolPath , args , options ) ;
471+ return runner . exec ( ) ;
472+ } ) ;
473+ }
474+ exports . exec = exec ;
475+ //# sourceMappingURL=exec.js.map
476+
477+ /***/ } ) ,
478+
479+ /***/ 963 :
488480/***/ ( function ( __unusedmodule , exports , __webpack_require__ ) {
489481
490482"use strict" ;
0 commit comments