@sentry/wizard
Version:
Sentry wizard helping you to configure your project
191 lines (190 loc) • 6.65 kB
TypeScript
/// <reference types="node" />
import type { Integration } from '../../lib/Constants';
import type { ChildProcess } from 'node:child_process';
export declare const KEYS: {
UP: string;
DOWN: string;
LEFT: string;
RIGHT: string;
ENTER: string;
SPACE: string;
};
export declare const TEST_ARGS: {
AUTH_TOKEN: string;
PROJECT_DSN: string;
ORG_SLUG: string;
PROJECT_SLUG: string;
};
export declare const log: {
success: (message: string) => void;
info: (message: string) => void;
error: (message: unknown) => void;
};
export declare class WizardTestEnv {
taskHandle: ChildProcess;
constructor(cmd: string, args: string[], opts?: {
cwd?: string;
debug?: boolean;
});
sendStdin(input: string): void;
/**
* Sends the input and waits for the output.
* @returns a promise that resolves when the output was found
* @throws an error when the output was not found within the timeout
*/
sendStdinAndWaitForOutput(input: string | string[], output: string, options?: {
timeout?: number;
optional?: boolean;
}): Promise<boolean>;
/**
* Waits for the task to exit with a given `statusCode`.
*
* @returns a promise that resolves to `true` if the run ends with the status
* code, or it rejects when the `timeout` was reached.
*/
waitForStatusCode(statusCode: number | null, options?: {
/** Timeout in ms */
timeout?: number;
}): Promise<boolean>;
/**
* Waits for the provided output with `.includes()` logic.
*
* @returns a promise that resolves to `true` if the output was found, `false` if the output was not found within the
* timeout and `optional: true` is set, or it rejects when the timeout was reached with `optional: false`
*/
waitForOutput(output: string, options?: {
/** Timeout in ms */
timeout?: number;
/** Whether to always resolve after the timeout, no matter whether the input was actually found or not. */
optional?: boolean;
}): Promise<boolean>;
kill(): void;
}
/**
* Initialize a git repository in the given directory
* @param projectDir
*/
export declare function initGit(projectDir: string): void;
/**
* Cleanup the git repository in the given directory
*
* Caution! Make sure `projectDir` is a test project directory,
* if in doubt, please commit your local non-test changes first!
* @param projectDir
*/
export declare function cleanupGit(projectDir: string): void;
/**
* Revert local changes in the given directory
*
* Caution! Make sure `projectDir` is a test project directory,
* if in doubt, please commit your local non-test changes first!
*
* @param projectDir
*/
export declare function revertLocalChanges(projectDir: string): void;
export declare function getWizardCommand(integration: Integration): string;
/**
* Start the wizard instance with the given integration and project directory
* @param integration
* @param projectDir
*
* @returns WizardTestEnv
*/
export declare function startWizardInstance(integration: Integration, projectDir: string, debug?: boolean): WizardTestEnv;
/**
* Create a file with the given content
*
* @param filePath
* @param content
*/
export declare function createFile(filePath: string, content?: string): void;
/**
* Modify the file with the new content
*
* @param filePath
* @param oldContent
* @param newContent
*/
export declare function modifyFile(filePath: string, replaceMap: Record<string, string>): void;
/**
* Read the file contents and check if it does not contain the given content
*
* @param {string} filePath
* @param {(string | string[])} content
*/
export declare function checkFileDoesNotContain(filePath: string, content: string | string[]): void;
/**
* Read the file contents and check if it contains the given content
*
* @param {string} filePath
* @param {(string | string[])} content
*/
export declare function checkFileContents(filePath: string, content: string | string[]): void;
/**
* Check if the file exists
*
* @param filePath
*/
export declare function checkFileExists(filePath: string): void;
/**
* Check if the package.json contains the given integration
*
* @param projectDir
* @param integration
*/
export declare function checkPackageJson(projectDir: string, integration: Integration): void;
/**
* Check if the .sentryclirc contains the auth token
*
* @param projectDir
*/
export declare function checkSentryCliRc(projectDir: string): void;
/**
* Check if the .env.sentry-build-plugin contains the auth token
* @param projectDir
*/
export declare function checkEnvBuildPlugin(projectDir: string): void;
/**
* Check if the sentry.properties contains the auth token
* @param projectDir
*/
export declare function checkSentryProperties(projectDir: string): void;
/**
* Check if the project builds
* Check if the project builds and ends with status code 0.
* @param projectDir
*/
export declare function checkIfBuilds(projectDir: string): Promise<void>;
/**
* Check if the flutter project builds
* @param projectDir
*/
export declare function checkIfFlutterBuilds(projectDir: string, expectedOutput: string, debug?: boolean): Promise<void>;
/**
* Check if the React Native project bundles successfully for the specified platform.
* Returns a boolean indicating if the process exits with status code 0.
* @param projectDir The root directory of the React Native project.
* @param platform The platform to bundle for ('ios' or 'android').
* @param debug runs the command in debug mode if true
*/
export declare function checkIfReactNativeBundles(projectDir: string, platform: 'ios' | 'android', debug?: boolean): Promise<boolean>;
/**
* Check if the Expo project exports successfully for the specified platform.
* Returns a boolean indicating if the process exits with status code 0.
* @param projectDir The root directory of the Expo project.
* @param platform The platform to export for ('ios', 'android', or 'web').
* @param debug runs the command in debug mode if true
*/
export declare function checkIfExpoBundles(projectDir: string, platform: 'ios' | 'android' | 'web', debug?: boolean): Promise<boolean>;
/**
* Check if the project runs on dev mode
* @param projectDir
* @param expectedOutput
*/
export declare function checkIfRunsOnDevMode(projectDir: string, expectedOutput: string): Promise<void>;
/**
* Check if the project runs on prod mode
* @param projectDir
* @param expectedOutput
*/
export declare function checkIfRunsOnProdMode(projectDir: string, expectedOutput: string, startCommand?: string): Promise<void>;