1+ import * as os from 'os' ;
2+ import * as alerts from './alerts' ;
3+ import * as Sentry from '@sentry/node' ;
4+ import * as version from './version' ;
5+ import * as analytics from './analytics/index' ;
6+
17export async function sleep ( ms : number ) : Promise < void > {
28 return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
39}
@@ -6,3 +12,47 @@ export const reTryMessage =
612 'Tip: Re-run in debug mode to see more information: DEBUG=*snyk* <COMMAND>' ;
713export const contactSupportMessage =
814 'If the issue persists contact [email protected] ' ; 15+
16+ export function testPlatformSupport ( ) {
17+ const supportedPlatforms = [
18+ 'darwin amd64' ,
19+ 'darwin x64' ,
20+ 'darwin arm64' ,
21+ 'linux amd64' ,
22+ 'linux x64' ,
23+ 'linux arm64' ,
24+ 'win32 amd64' ,
25+ 'win32 x64' ,
26+ 'win32 arm64' ,
27+ ] ;
28+
29+ const currentPlatform = os . platform ( ) + ' ' + os . arch ( ) ;
30+ if ( ! supportedPlatforms . includes ( currentPlatform ) ) {
31+ const platformWarning =
32+ '------------------------------- Warning -------------------------------\n' +
33+ ' The current platform (' +
34+ currentPlatform +
35+ ') is not supported by Snyk.\n' +
36+ ' You may want to consider using docker to run Snyk.\n' +
37+ ' If you experience errors please reach out to [email protected] .\n' + 38+ '-----------------------------------------------------------------------' ;
39+
40+ alerts . registerAlerts ( [
41+ {
42+ type : 'warning' ,
43+ name : 'testPlatformSupport' ,
44+ msg : platformWarning ,
45+ } ,
46+ ] ) ;
47+
48+ if ( analytics . allowAnalytics ( ) ) {
49+ const sentryError = new Error ( 'Unsupported Platform: ' + currentPlatform ) ;
50+ Sentry . init ( {
51+ dsn :
52+ 'https://[email protected] /4504599528079360' , 53+ release : version . getVersion ( ) ,
54+ } ) ;
55+ Sentry . captureException ( sentryError ) ;
56+ }
57+ }
58+ }
0 commit comments