Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async start(clientConnection: IConnection): Promise {
// Same as https://github.com/eclipse-theia/theia/commit/de45794a90fc1a1a590578026f8ad527127afa0a
const command = process.execPath;
const args: string[] = [
path.resolve(__dirname, './json-starter'),
'--stdio'
];
const serverConnection = await this.createProcessStreamConnectionAsync(command, args, { env: environment.electron.runAsNodeEnv() });
this.forward(clientConnection, serverConnection);
}
private childProcess(executable: DebugAdapterExecutable): RawProcess {
// tslint:disable-next-line:no-any
const isForkOptions = (forkOptions: RawForkOptions | any): forkOptions is RawForkOptions =>
!!forkOptions && !!forkOptions.modulePath;
const processOptions: RawProcessOptions | RawForkOptions = { ...executable };
const options: { stdio: (string | number)[], env?: object, execArgv?: string[] } = { stdio: ['pipe', 'pipe', 2] };
if (isForkOptions(processOptions)) {
options.stdio.push('ipc');
options.env = environment.electron.runAsNodeEnv();
options.execArgv = (executable as DebugAdapterForkExecutable).execArgv;
}
processOptions.options = options;
return this.processFactory(processOptions);
}
async start(clientConnection: IConnection, { parameters }: TypeScriptStartOptions): Promise {
// Re-use the same tool used to launch Theia. e.g. for an Electron Theia packaging,
// this will be "electron" executable that is bundled with the application.
const command = process.execPath;
const args: string[] = [
path.join(__dirname, 'startserver.js'),
'--stdio'
];
const tsServerPath = TypescriptVersionURI.getTsServerPath(parameters && parameters.version);
if (tsServerPath) {
args.push(`--tsserver-path=${tsServerPath}`);
}
const serverConnection = await this.createProcessStreamConnectionAsync(command, args, { env: environment.electron.runAsNodeEnv() });
this.forward(clientConnection, serverConnection);
}
private isElectron(): boolean {
return environment.electron.is();
}
protected isDownloadEnabled(uris: URI[]): boolean {
return !environment.electron.is() && uris.length > 0 && uris.every(u => u.scheme === 'file');
}
async search(param: SearchParam): Promise {
const manager = this.project.createPackageManager();
const query = this.prepareQuery(param.query);
const packages = await npms.search(query, param.from, param.size);
const extensions = [];
for (const raw of packages) {
if (PublishedNodePackage.is(raw)) {
const extensionPackage = await manager.pck.findExtensionPackage(raw.name);
if (extensionPackage) {
const extension = this.toRawExtension(extensionPackage);
extensions.push(extension);
}
}
}
return extensions;
}
protected prepareQuery(query: string): string {
constructor(options: ApplicationPackageOptions) {
this.pck = new ApplicationPackage(options);
this.process = new ApplicationProcess(this.pck, options.projectPath);
this.__process = new ApplicationProcess(this.pck, path.join(__dirname, '..'));
this.webpack = new WebpackGenerator(this.pck);
this.backend = new BackendGenerator(this.pck);
this.frontend = new FrontendGenerator(this.pck);
}
constructor(
@inject(ApplicationProjectOptions) readonly options: ApplicationProjectOptions,
@inject(FileSystemWatcherServer) protected readonly fileSystemWatcher: FileSystemWatcherServer,
@inject(ILogger) protected readonly logger: ILogger,
@inject(NpmClient) protected readonly npmClient: NpmClient,
) {
logger.debug('AppProjectOptions', options);
this.registry = new NpmRegistry({
watchChanges: this.options.watchRegistry
});
this.backup();
this.packageUri = FileUri.create(this.packagePath).toString();
this.toDispose.push(this.fileSystemWatcher);
this.fileSystemWatcher.setClient({
onDidFilesChanged: changes => this.onDidFilesChanged(changes)
});
this.fileSystemWatcher.watchFileChanges(this.packageUri).then(watcher =>
this.toDispose.push(Disposable.create(() =>
this.fileSystemWatcher.unwatchFileChanges(watcher)
))
);
this.toDispose.push(this.onWillInstallEmitter);
this.toDispose.push(this.onDidInstallEmitter);
}