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

@sewing-kit/ui

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sewing-kit/ui - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

9

build/ts/runner.d.ts
import { Step } from '@sewing-kit/types';
import { Ui } from './ui';
export declare function run(steps: Step[], { ui, pre, post, title, }: {
interface RunOptions {
ui: Ui;
pre?: Step[];
post?: Step[];
skip?: string[];
skipPre?: string[];
skipPost?: string[];
title?: string;
}): Promise<void>;
}
export declare function run(steps: Step[], { ui, pre, post, skip, skipPre, skipPost, title, }: RunOptions): Promise<void>;
export {};
//# sourceMappingURL=runner.d.ts.map

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

StepState[StepState["Pending"] = 3] = "Pending";
StepState[StepState["Skipped"] = 4] = "Skipped";
})(StepState || (StepState = {}));

@@ -23,4 +24,12 @@ const symbols = '⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆';

this.stepRunners = [];
for (const subStep of step.steps || []) {
const stepRunner = new StepRunner(subStep, this.update);
this.stepRunners.push(stepRunner);
}
}
async run(ui) {
async run(ui, skip) {
if (this.step.skip(skip)) {
this.setState(StepState.Skipped);
return;
}
this.setState(StepState.InProgress);

@@ -33,13 +42,9 @@ try {

},
run: async (steps) => {
for (const step of steps) {
const stepRunner = new StepRunner(step, this.update);
this.stepRunners.push(stepRunner);
}
for (const stepRunner of this.stepRunners) {
await stepRunner.run(ui);
}
},
};
await this.step.run(runner);
if (this.step.run) {
await this.step.run(runner);
}
for (const stepRunner of this.stepRunners) {
await stepRunner.run(ui, skip);
}
this.setState(StepState.Success);

@@ -66,3 +71,3 @@ }

case StepState.Failure:
prefix = fmt `{error o}`;
prefix = fmt `{error ✕}`;
break;

@@ -72,2 +77,5 @@ case StepState.Pending:

break;
case StepState.Skipped:
prefix = fmt `{subdued ⇥}`;
break;
}

@@ -90,4 +98,4 @@ const ownLine = fmt `${prefix} ${fmt `${this.step.label || ''}`}`;

class StepGroupRunner {
constructor(steps, update) {
this.steps = steps;
constructor(group, update) {
this.group = group;
this.update = update;

@@ -97,7 +105,7 @@ this.stepRunners = [];

async run(ui) {
for (const step of this.steps) {
for (const step of this.group.steps) {
this.stepRunners.push(new StepRunner(step, this.update));
}
for (const step of this.stepRunners) {
await step.run(ui);
await step.run(ui, this.group.skip);
}

@@ -155,4 +163,11 @@ }

}
async function run(steps, { ui, pre = [], post = [], title, }) {
const runnerUi = new RunnerUi([pre, steps, post], ui);
async function run(steps, { ui, pre = [], post = [], skip = [], skipPre = [], skipPost = [], title, }) {
if (pre.length + steps.length + post.length === 0) {
return;
}
const runnerUi = new RunnerUi([
{ steps: pre, skip: skipPre },
{ steps, skip },
{ steps: post, skip: skipPost },
], ui);
try {

@@ -185,7 +200,15 @@ if (title) {

// ui.log(error.message);
if (error.all == null) {
if (error.all != null) {
ui.error(error.all);
ui.error(error.stack);
}
else if (error.stderr != null) {
ui.error(error.stderr);
ui.error(error.stack);
}
else if (error.stdout == null) {
ui.error(error.stack);
}
else {
ui.error(error.all);
ui.error(error.stdout);
ui.error(error.stack);

@@ -192,0 +215,0 @@ }

import { Step } from '@sewing-kit/types';
declare type Skipper = ((skipped: string[]) => boolean) | RegExp;
export declare function createStep(run: Step['run']): Step;
export declare function createStep(options: Omit<Step, 'run'>, run: Step['run']): Step;
export declare function createStep(options: Omit<Step, 'run' | 'skip'> & {
skip?: Skipper;
}, run?: Step['run']): Step;
export {};
//# sourceMappingURL=steps.d.ts.map
"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
const defaultSkip = () => false;
function createStep(runOrStep, run) {
return typeof runOrStep === 'function'
? { run: runOrStep }
: Object.assign({ run }, runOrStep);
? { run: runOrStep, skip: defaultSkip }
: Object.assign({ run }, normalizeOptions(runOrStep));
}
exports.createStep = createStep;
function normalizeOptions(_a) {
var { skip } = _a, rest = __rest(_a, ["skip"]);
return Object.assign(Object.assign({}, rest), { skip: skip ? normalizeSkip(skip) : defaultSkip });
}
function normalizeSkip(skipper) {
return typeof skipper === 'function'
? skipper
: (skipped) => skipped.some((skip) => skipper.test(skip));
}

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

module.exports = require("./build/cjs");
module.exports = require("./src/index");
{
"name": "@sewing-kit/ui",
"version": "0.0.5",
"version": "0.0.6",
"sideEffects": false,

@@ -10,9 +10,10 @@ "publishConfig": {

"dependencies": {
"@shopify/useful-types": "^2.0.0",
"ansi-escapes": "^4.2.1",
"chalk": "^2.4.2",
"execa": "^2.0.4",
"@sewing-kit/types": "^0.0.2",
"@shopify/useful-types": "^2.1.2",
"ansi-escapes": "^4.3.0",
"chalk": "^3.0.0",
"execa": "^3.4.0",
"supports-hyperlinks": "^2.0.0"
},
"gitHead": "b92b7a4350e29b5c1500b895558743767617d725"
"gitHead": "1fc44608f952bd67cfe6f98006e1e510ec2ce82b"
}
import {FirstArgument} from '@shopify/useful-types';
import {Ui} from './ui';

@@ -3,0 +4,0 @@

import exec from 'execa';
import {Step, StepRunner as NestedStepRunner} from '@sewing-kit/types';
import {Step, StepRunner as NestedStepRunner} from '@sewing-kit/types';
import {Ui, Loggable} from './ui';

@@ -12,2 +12,3 @@ import {DiagnosticError} from './errors';

Pending,
Skipped,
}

@@ -23,5 +24,15 @@

constructor(private readonly step: Step, private readonly update: Update) {}
constructor(private readonly step: Step, private readonly update: Update) {
for (const subStep of step.steps || []) {
const stepRunner = new StepRunner(subStep, this.update);
this.stepRunners.push(stepRunner);
}
}
async run(ui: Ui) {
async run(ui: Ui, skip: string[]) {
if (this.step.skip(skip)) {
this.setState(StepState.Skipped);
return;
}
this.setState(StepState.InProgress);

@@ -35,15 +46,12 @@

},
run: async (steps) => {
for (const step of steps) {
const stepRunner = new StepRunner(step, this.update);
this.stepRunners.push(stepRunner);
}
for (const stepRunner of this.stepRunners) {
await stepRunner.run(ui);
}
},
};
await this.step.run(runner);
if (this.step.run) {
await this.step.run(runner);
}
for (const stepRunner of this.stepRunners) {
await stepRunner.run(ui, skip);
}
this.setState(StepState.Success);

@@ -72,3 +80,3 @@ } catch (error) {

case StepState.Failure:
prefix = fmt`{error o}`;
prefix = fmt`{error ✕}`;
break;

@@ -78,2 +86,5 @@ case StepState.Pending:

break;
case StepState.Skipped:
prefix = fmt`{subdued ⇥}`;
break;
}

@@ -102,2 +113,7 @@

interface StepGroup {
steps: Step[];
skip: string[];
}
class StepGroupRunner {

@@ -107,3 +123,3 @@ readonly stepRunners: StepRunner[] = [];

constructor(
private readonly steps: Step[],
private readonly group: StepGroup,
private readonly update: Update,

@@ -113,3 +129,3 @@ ) {}

async run(ui: Ui) {
for (const step of this.steps) {
for (const step of this.group.steps) {
this.stepRunners.push(new StepRunner(step, this.update));

@@ -119,3 +135,3 @@ }

for (const step of this.stepRunners) {
await step.run(ui);
await step.run(ui, this.group.skip);
}

@@ -138,3 +154,3 @@ }

constructor(private readonly groups: Step[][], private readonly ui: Ui) {}
constructor(private readonly groups: StepGroup[], private readonly ui: Ui) {}

@@ -185,2 +201,12 @@ async run() {

interface RunOptions {
ui: Ui;
pre?: Step[];
post?: Step[];
skip?: string[];
skipPre?: string[];
skipPost?: string[];
title?: string;
}
export async function run(

@@ -192,7 +218,21 @@ steps: Step[],

post = [],
skip = [],
skipPre = [],
skipPost = [],
title,
}: {ui: Ui; pre?: Step[]; post?: Step[]; title?: string},
}: RunOptions,
) {
const runnerUi = new RunnerUi([pre, steps, post], ui);
if (pre.length + steps.length + post.length === 0) {
return;
}
const runnerUi = new RunnerUi(
[
{steps: pre, skip: skipPre},
{steps, skip},
{steps: post, skip: skipPost},
],
ui,
);
try {

@@ -234,6 +274,12 @@ if (title) {

if (error.all == null) {
if (error.all != null) {
ui.error(error.all);
ui.error(error.stack);
} else if (error.stderr != null) {
ui.error(error.stderr);
ui.error(error.stack);
} else if (error.stdout == null) {
ui.error(error.stack);
} else {
ui.error(error.all);
ui.error(error.stdout);
ui.error(error.stack);

@@ -240,0 +286,0 @@ }

import {Step} from '@sewing-kit/types';
type Skipper = ((skipped: string[]) => boolean) | RegExp;
const defaultSkip = () => false;
export function createStep(run: Step['run']): Step;
export function createStep(options: Omit<Step, 'run'>, run: Step['run']): Step;
export function createStep(
runOrStep: Step['run'] | Omit<Step, 'run'>,
options: Omit<Step, 'run' | 'skip'> & {skip?: Skipper},
run?: Step['run'],
) {
): Step;
export function createStep(
runOrStep: Step['run'] | (Omit<Step, 'run' | 'skip'> & {skip?: Skipper}),
run?: Step['run'],
): Step {
return typeof runOrStep === 'function'
? {run: runOrStep}
: {run, ...runOrStep};
? {run: runOrStep, skip: defaultSkip}
: {run, ...normalizeOptions(runOrStep!)};
}
function normalizeOptions({
skip,
...rest
}: Omit<Step, 'run' | 'skip'> & {skip?: Skipper}): Step {
return {...rest, skip: skip ? normalizeSkip(skip) : defaultSkip};
}
function normalizeSkip(skipper: Skipper) {
return typeof skipper === 'function'
? skipper
: (skipped: string[]) => skipped.some((skip) => skipper.test(skip));
}
import {clearScreenDown, clearLine, moveCursor, cursorTo} from 'readline';
import {link} from 'ansi-escapes';

@@ -3,0 +4,0 @@ import chalk from 'chalk';

@@ -8,5 +8,5 @@ {

"typeRoots": [
"./config/typescript/typings",
"./node_modules/@types",
"../../node_modules/@types"
"../../node_modules/@types",
"./config/typescript/typings"
],

@@ -13,0 +13,0 @@ "types": ["supports-hyperlinks"]

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