"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1280.1/src/lib/common.ts" (20 Feb 2024, 1888 Bytes) of package /linux/misc/snyk-cli-1.1280.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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 
    7 export async function sleep(ms: number): Promise<void> {
    8   return new Promise((resolve) => setTimeout(resolve, ms));
    9 }
   10 
   11 export const reTryMessage =
   12   'Tip: Re-run in debug mode to see more information: DEBUG=*snyk* <COMMAND>';
   13 export const contactSupportMessage =
   14   'If the issue persists contact support@snyk.io';
   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, for details see: https://docs.snyk.io/snyk-cli/install-the-snyk-cli#snyk-cli-in-a-docker-image\n' +
   37       ' If you experience errors please reach out to support@snyk.io.\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://3e845233db8c4f43b4c4b9245f1d7bd6@o30291.ingest.sentry.io/4504599528079360',
   53         release: version.getVersion(),
   54       });
   55       Sentry.captureException(sentryError);
   56     }
   57   }
   58 }