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

automutate

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

automutate - npm Package Compare versions

Comparing version 0.8.1 to 0.9.0

2

lib/index.d.ts
export * from "./fileProviderFactories/cachingFileProviderFactory";
export * from "./fileProviders/localFileProvider";
export * from "./fileProviders/stubFileProvider";
export * from "./loggers/consoleLogger";
export * from "./loggers/noopLogger";
export * from "./mutationsAppliers/fileMutationsApplier";

@@ -7,0 +5,0 @@ export * from "./mutationsProvider";

@@ -16,4 +16,2 @@ "use strict";

__exportStar(require("./fileProviders/stubFileProvider"), exports);
__exportStar(require("./loggers/consoleLogger"), exports);
__exportStar(require("./loggers/noopLogger"), exports);
__exportStar(require("./mutationsAppliers/fileMutationsApplier"), exports);

@@ -20,0 +18,0 @@ __exportStar(require("./mutationsProvider"), exports);

3

lib/mutationsAppliers/fileMutationsApplier.d.ts

@@ -6,2 +6,3 @@ import { MutatorFactory } from "../mutatorFactory";

import { FileMutations } from "../mutationsProvider";
import { Mutation } from "../types/mutation";
/**

@@ -60,3 +61,3 @@ * Settings to initialize a new FileMutationsApplier.

*/
private applyFileMutations;
applyFileMutations(fileName: string, mutations: ReadonlyArray<Mutation>): Promise<string>;
}

@@ -59,3 +59,2 @@ "use strict";

}));
this.logger.onComplete();
}

@@ -75,3 +74,3 @@ /**

fileContents = this.mutatorFactory.generateAndApply(fileContents, mutation);
this.logger.onMutation(fileName, mutation);
this.logger.onMutation?.(fileName, mutation);
}

@@ -78,0 +77,0 @@ await fileProvider.write(fileContents);

@@ -49,3 +49,3 @@ "use strict";

if (!mutator) {
this.logger.onUnknownMutationType(mutation);
this.logger.onUnknownMutationType?.(mutation);
return fileContents;

@@ -52,0 +52,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.runMutations = void 0;
const consoleLogger_1 = require("./loggers/consoleLogger");
const fileMutationsApplier_1 = require("./mutationsAppliers/fileMutationsApplier");

@@ -12,8 +11,11 @@ /**

exports.runMutations = async (settings) => {
const logger = settings.logger ?? new consoleLogger_1.ConsoleLogger();
const logger = settings.logger ?? {};
const mutatedFileNames = new Set();
const mutationsApplier = settings.mutationsApplier ?? new fileMutationsApplier_1.FileMutationsApplier({ logger });
const { maximum = Infinity, minimum = 0 } = settings.waves ?? {};
logger.onRunMutationsBegin?.();
for (let i = 0; i < maximum; i += 1) {
logger.onProvideBegin?.();
const mutationsWave = await settings.mutationsProvider.provide();
logger.onProvideEnd?.(mutationsWave);
if (mutationsWave.fileMutations === undefined) {

@@ -25,5 +27,5 @@ if (i < minimum) {

}
logger.onWaveBegin(mutationsWave);
logger.onMutationsApplyBegin?.(mutationsWave.fileMutations);
await mutationsApplier.apply(mutationsWave.fileMutations);
logger.onWaveEnd(mutationsWave);
logger.onMutationsApplyEnd?.(mutationsWave.fileMutations);
for (const fileName of Object.keys(mutationsWave.fileMutations)) {

@@ -33,2 +35,3 @@ mutatedFileNames.add(fileName);

}
logger.onRunMutationsEnd?.();
return {

@@ -35,0 +38,0 @@ mutatedFileNames: Array.from(mutatedFileNames),

@@ -0,3 +1,3 @@

import { FileMutations, MutationsWave } from "../mutationsProvider";
import { Mutation } from "./mutation";
import { MutationsWave } from "../mutationsProvider";
/**

@@ -8,6 +8,2 @@ * Generates output messages for significant operations.

/**
* Logs that mutations have completed.
*/
onComplete(): void;
/**
* Logs that a mutation was applied.

@@ -18,21 +14,49 @@ *

*/
onMutation(fileName: string, mutation: Mutation): void;
onMutation?(fileName: string, mutation: Mutation): void;
/**
* Logs that an unknown mutator was requested.
* Logs that a mutations is about to be applied.
*
* @param mutation The requesting mutation of unknown type.
* @param mutation File mutation to be applied.
*/
onUnknownMutationType(mutation: Mutation): void;
onMutationApplyBegin?(mutation: Mutation): void;
/**
* Logs that a mutations wave is about to start.
* Logs that mutations were applied.
*
* @param mutationsWave A wave of file mutations.
* @param mutation File mutation to be applied.
*/
onWaveBegin(mutationsWave: MutationsWave): void;
onMutationApplyEnd?(mutation: Mutation): void;
/**
* Logs that a mutations wave finished.
* Logs that mutations are about to be applied.
*
* @param mutationsWave A wave of file mutations.
* @param fileMutations File mutations to be applied.
*/
onWaveEnd(mutationsWave: MutationsWave): void;
onMutationsApplyBegin?(fileMutations: FileMutations): void;
/**
* Logs that mutations were applied.
*
* @param fileMutations File mutations to be applied
*/
onMutationsApplyEnd?(fileMutations: FileMutations): void;
/**
* Logs that a wave mutations is going to be provided.
*/
onProvideBegin?(): void;
/**
* Logs that a wave mutations is was provided.
*/
onProvideEnd?(mutationsWave: MutationsWave): void;
/**
* Logs that mutations are going to begin.
*/
onRunMutationsBegin?(): void;
/**
* Logs that mutations have completed.
*/
onRunMutationsEnd?(): void;
/**
* Logs that an unknown mutator was requested.
*
* @param mutation The requesting mutation of unknown type.
*/
onUnknownMutationType?(mutation: Mutation): void;
}
{
"name": "automutate",
"version": "0.8.1",
"version": "0.9.0",
"description": "Applies waves of mutations provided by other tools, such as linters.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

export * from "./fileProviderFactories/cachingFileProviderFactory";
export * from "./fileProviders/localFileProvider";
export * from "./fileProviders/stubFileProvider";
export * from "./loggers/consoleLogger";
export * from "./loggers/noopLogger";
export * from "./mutationsAppliers/fileMutationsApplier";

@@ -7,0 +5,0 @@ export * from "./mutationsProvider";

@@ -88,4 +88,2 @@ import * as path from "path";

);
this.logger.onComplete();
}

@@ -100,10 +98,9 @@

*/
private async applyFileMutations(
public async applyFileMutations(
fileName: string,
mutations: ReadonlyArray<Mutation>
) {
const mutationsOrdered: Mutation[] =
): Promise<string> {
const mutationsOrdered =
orderMutationsLastToFirstWithoutOverlaps(mutations);
const fileProvider: FileProvider =
this.fileProviderFactory.generate(fileName);
const fileProvider = this.fileProviderFactory.generate(fileName);
let fileContents = await fileProvider.read();

@@ -116,3 +113,3 @@

);
this.logger.onMutation(fileName, mutation);
this.logger.onMutation?.(fileName, mutation);
}

@@ -119,0 +116,0 @@

@@ -76,3 +76,3 @@ import { Logger } from "./types/logger";

if (!mutator) {
this.logger.onUnknownMutationType(mutation);
this.logger.onUnknownMutationType?.(mutation);

@@ -79,0 +79,0 @@ return fileContents;

import { Logger } from "./types/logger";
import { ConsoleLogger } from "./loggers/consoleLogger";
import { MutationsApplier } from "./types/mutationsApplier";

@@ -62,3 +61,3 @@ import { FileMutationsApplier } from "./mutationsAppliers/fileMutationsApplier";

): Promise<MutationRunResults> => {
const logger = settings.logger ?? new ConsoleLogger();
const logger = settings.logger ?? {};
const mutatedFileNames = new Set<string>();

@@ -69,4 +68,8 @@ const mutationsApplier =

logger.onRunMutationsBegin?.();
for (let i = 0; i < maximum; i += 1) {
logger.onProvideBegin?.();
const mutationsWave = await settings.mutationsProvider.provide();
logger.onProvideEnd?.(mutationsWave);
if (mutationsWave.fileMutations === undefined) {

@@ -80,5 +83,5 @@ if (i < minimum) {

logger.onWaveBegin(mutationsWave);
logger.onMutationsApplyBegin?.(mutationsWave.fileMutations);
await mutationsApplier.apply(mutationsWave.fileMutations);
logger.onWaveEnd(mutationsWave);
logger.onMutationsApplyEnd?.(mutationsWave.fileMutations);

@@ -90,2 +93,4 @@ for (const fileName of Object.keys(mutationsWave.fileMutations)) {

logger.onRunMutationsEnd?.();
return {

@@ -92,0 +97,0 @@ mutatedFileNames: Array.from(mutatedFileNames),

@@ -0,3 +1,3 @@

import { FileMutations, MutationsWave } from "../mutationsProvider";
import { Mutation } from "./mutation";
import { MutationsWave } from "../mutationsProvider";

@@ -9,7 +9,2 @@ /**

/**
* Logs that mutations have completed.
*/
onComplete(): void;
/**
* Logs that a mutation was applied.

@@ -20,24 +15,58 @@ *

*/
onMutation(fileName: string, mutation: Mutation): void;
onMutation?(fileName: string, mutation: Mutation): void;
/**
* Logs that an unknown mutator was requested.
* Logs that a mutations is about to be applied.
*
* @param mutation The requesting mutation of unknown type.
* @param mutation File mutation to be applied.
*/
onUnknownMutationType(mutation: Mutation): void;
onMutationApplyBegin?(mutation: Mutation): void;
/**
* Logs that a mutations wave is about to start.
* Logs that mutations were applied.
*
* @param mutationsWave A wave of file mutations.
* @param mutation File mutation to be applied.
*/
onWaveBegin(mutationsWave: MutationsWave): void;
onMutationApplyEnd?(mutation: Mutation): void;
/**
* Logs that a mutations wave finished.
* Logs that mutations are about to be applied.
*
* @param mutationsWave A wave of file mutations.
* @param fileMutations File mutations to be applied.
*/
onWaveEnd(mutationsWave: MutationsWave): void;
onMutationsApplyBegin?(fileMutations: FileMutations): void;
/**
* Logs that mutations were applied.
*
* @param fileMutations File mutations to be applied
*/
onMutationsApplyEnd?(fileMutations: FileMutations): void;
/**
* Logs that a wave mutations is going to be provided.
*/
onProvideBegin?(): void;
/**
* Logs that a wave mutations is was provided.
*/
onProvideEnd?(mutationsWave: MutationsWave): void;
/**
* Logs that mutations are going to begin.
*/
onRunMutationsBegin?(): void;
/**
* Logs that mutations have completed.
*/
onRunMutationsEnd?(): void;
/**
* Logs that an unknown mutator was requested.
*
* @param mutation The requesting mutation of unknown type.
*/
onUnknownMutationType?(mutation: Mutation): void;
}
import { StubFileProvider } from "../../src/fileProviders/stubFileProvider";
import { NoopLogger } from "../../src/loggers/noopLogger";
import { FileMutationsApplier } from "../../src/mutationsAppliers/fileMutationsApplier";

@@ -25,3 +24,3 @@ import { MutatorFactory } from "../../src/mutatorFactory";

const stubLogger = new NoopLogger();
const stubLogger = {};

@@ -28,0 +27,0 @@ const mutatorClasses = new Map<string, MutatorClass>([

import { jest } from "@jest/globals";
import { FileMutations, Mutation, MutationsWave } from "../../src";
import { FileMutations, MutationsWave } from "../../src";
import { NoopLogger } from "../../src/loggers/noopLogger";
import { runMutations } from "../../src/runMutations";

@@ -9,3 +8,3 @@

const provide = jest.fn<Promise<MutationsWave>, []>();
const stubLogger = new NoopLogger();
const stubLogger = {};

@@ -12,0 +11,0 @@ describe("runMutations", () => {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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