Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/compiler

Package Overview
Dependencies
Maintainers
1
Versions
300
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/compiler - npm Package Compare versions

Comparing version 4.0.0-rc.4 to 4.0.0-rc.5

8

package.json
{
"name": "@travetto/compiler",
"version": "4.0.0-rc.4",
"version": "4.0.0-rc.5",
"description": "The compiler infrastructure for the Travetto framework",

@@ -34,8 +34,8 @@ "keywords": [

"@parcel/watcher": "^2.4.0",
"@travetto/manifest": "^4.0.0-rc.4",
"@travetto/transformer": "^4.0.0-rc.4",
"@travetto/manifest": "^4.0.0-rc.5",
"@travetto/transformer": "^4.0.0-rc.5",
"@types/node": "^20.11.16"
},
"peerDependencies": {
"@travetto/cli": "^4.0.0-rc.5"
"@travetto/cli": "^4.0.0-rc.6"
},

@@ -42,0 +42,0 @@ "peerDependenciesMeta": {

@@ -73,3 +73,3 @@ import ts from 'typescript';

case 'reset': {
Log.info('Triggering reset due to change in core files');
Log.info('Triggering reset due to change in core files', err?.cause);
EventUtil.sendEvent('state', { state: 'reset' });

@@ -76,0 +76,0 @@ process.exitCode = 0;

@@ -131,3 +131,3 @@ import { ManifestContext, ManifestModuleUtil, ManifestUtil, PackageUtil, RuntimeIndex, path } from '@travetto/manifest';

) {
throw new Error('RESET');
throw new Error('RESET', { cause: `${action}:${sourceFile}` });
}

@@ -134,0 +134,0 @@

@@ -50,2 +50,3 @@ // @trv-no-transform

async stop(): Promise<void> {
LogUtil.initLogs(ctx);
if (await client.stop()) {

@@ -66,2 +67,3 @@ console.log(`Stopped server ${ctx.workspace.path}: ${client}`);

async clean(): Promise<void> {
LogUtil.initLogs(ctx);
if (await client.clean()) {

@@ -95,3 +97,3 @@ return console.log(`Clean triggered ${ctx.workspace.path}:`, buildFolders);

if (!(await client.isWatching())) {
await compile('build', 'error');
await compile('build', LogUtil.isInteractiveShell ? 'info' : 'error');
}

@@ -98,0 +100,0 @@ return CommonUtil.moduleLoader(ctx);

@@ -34,6 +34,11 @@ import type { ManifestContext } from '@travetto/manifest';

/** Are we in a shell that is interactive */
static get isInteractiveShell(): boolean {
return !!process.env.PS1 && process.stdout.isTTY;
}
/**
* Set level for operation
*/
static initLogs(ctx: ManifestContext, defaultLevel: CompilerLogLevel): void {
static initLogs(ctx: ManifestContext, defaultLevel?: CompilerLogLevel): void {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions

@@ -46,3 +51,3 @@ const build = process.env.TRV_BUILD as CompilerLogLevel | 'none';

// If we are in info or a terminal and also in a tty
this.logProgress = ((this.isLevelActive('info') || process.env.PS1) && process.stdout.isTTY) ? this.#logProgressEvent : undefined;
this.logProgress = (this.isLevelActive('info') && process.stdout.isTTY) ? this.#logProgressEvent : undefined;
if (this.logProgress) {

@@ -49,0 +54,0 @@ process.stdout.write(`${ESC}?25l`); // Hide cursor

@@ -46,3 +46,3 @@ import rl from 'node:readline/promises';

ctrl.abort('TIMEOUT');
}, 100).unref();
}, opts?.timeout ?? 100).unref();
try {

@@ -57,3 +57,3 @@ return await fetch(`${this.#url}${rel}`, { ...opts, signal: ctrl.signal });

info(): Promise<CompilerServerInfo | undefined> {
return this.#fetch('/info', {}, false).then(v => v.json(), () => undefined)
return this.#fetch('/info', { timeout: 200 }, false).then(v => v.json(), () => undefined)
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions

@@ -60,0 +60,0 @@ .then(v => v as CompilerServerInfo);

@@ -6,2 +6,3 @@ import fs from 'node:fs/promises';

import type { ManifestContext } from '@travetto/manifest';
import { CompilerLogger, LogUtil } from '../log';

@@ -11,5 +12,7 @@ export class ProcessHandle {

#file: string;
#log: CompilerLogger;
constructor(ctx: ManifestContext, name: string) {
this.#file = path.resolve(ctx.workspace.path, ctx.build.toolFolder, `${name}.pid`);
this.#log = LogUtil.logger(`process-handle.${name}`);
}

@@ -31,5 +34,8 @@

process.kill(pid, 0); // See if process is still running
return false;
} catch { }
return true; // Still running
this.#log('debug', 'Is running', pid);
return true;
} catch {
this.#log('debug', 'Is not running', pid);
}
return false; // Not running
}

@@ -41,2 +47,3 @@

try {
this.#log('debug', 'Killing', pid);
return process.kill(pid);

@@ -51,2 +58,3 @@ } catch { }

const pid = await this.getPid();
this.#log('debug', 'Ensuring Killed', pid);
while (pid && (Date.now() - start) < gracePeriod) { // Ensure its done

@@ -59,6 +67,8 @@ if (!await this.isRunning()) {

try {
this.#log('debug', 'Force Killing', pid);
pid && process.kill(pid); // Force kill
} catch { }
this.#log('debug', 'Did Kill', this.#file, !!pid);
return pid !== undefined;
}
}

@@ -10,4 +10,4 @@ import http from 'node:http';

import { LogUtil } from '../log';
import { CommonUtil } from '../util';
import { CompilerClient } from './client';
import { CommonUtil } from '../util';
import { ProcessHandle } from './process-handle';

@@ -127,4 +127,5 @@

for (const el of Object.values(this.#listeners)) {
el.res.end();
try { el.res.end(); } catch { }
}
this.#listeners = {}; // Ensure its empty
}

@@ -149,11 +150,7 @@

let out: unknown;
let close = false;
switch (action) {
case 'event': return await this.#addListener(subAction, res);
case 'clean': out = await this.#clean(); break;
case 'stop': {
// Must send immediately
res.end(JSON.stringify({ closing: true }));
await this.close();
break;
}
case 'stop': out = JSON.stringify({ closing: true }); close = true; break;
case 'info':

@@ -163,2 +160,5 @@ default: out = this.info ?? {}; break;

res.end(JSON.stringify(out));
if (close) {
await this.close();
}
}

@@ -224,7 +224,3 @@

this.#server.closeAllConnections();
if (this.info.compilerPid) { // Ensure its killed
try {
process.kill(this.info.compilerPid);
} catch { }
}
await this.#handle.compiler.kill();
}

@@ -231,0 +227,0 @@

@@ -219,3 +219,3 @@ import path from 'node:path';

for (const mod of mods) {
const modCtx = ManifestUtil.getModuleContext(ctx, mod.sourceFolder);
const modCtx = ManifestUtil.getModuleContext(ctx, mod.sourceFolder, true);
const modManifest = await ManifestUtil.buildManifest(modCtx);

@@ -222,0 +222,0 @@ await ManifestUtil.writeManifest(modManifest);

@@ -66,3 +66,4 @@ import fs from 'node:fs/promises';

// Chain
parent.addEventListener('abort', () => controller.abort());
const kill = (): void => controller.abort();
parent.addEventListener('abort', kill);

@@ -79,2 +80,3 @@ const comp = src(controller.signal);

controller.abort(); // Ensure terminated of process
parent.removeEventListener('abort', kill);
continue outer;

@@ -81,0 +83,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc