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

amplify-prompts

Package Overview
Dependencies
Maintainers
1
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amplify-prompts - npm Package Compare versions

Comparing version 2.5.1-fix-bytecode-issue-with-arm64-revised.0 to 2.6.0-binary-file-size.0

7

CHANGELOG.md

@@ -6,10 +6,13 @@ # Change Log

## [2.5.1-fix-bytecode-issue-with-arm64-revised.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-prompts@2.5.0...amplify-prompts@2.5.1-fix-bytecode-issue-with-arm64-revised.0) (2022-10-12)
# [2.6.0-binary-file-size.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-prompts@2.5.0...amplify-prompts@2.6.0-binary-file-size.0) (2022-10-12)
**Note:** Version bump only for package amplify-prompts
### Features
* pretty-print for iterative deployment ([#11051](https://github.com/aws-amplify/amplify-cli/issues/11051)) ([4184164](https://github.com/aws-amplify/amplify-cli/commit/418416420756273f286d81384f4e63924deda4a9))
# [2.5.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-prompts@2.3.0...amplify-prompts@2.5.0) (2022-09-21)

@@ -16,0 +19,0 @@

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

import { StringObj } from './terminal';
import { TerminalLine } from './terminal';
import { ProgressBar as Bar, BarOptions, ItemPayload, ProgressPayload } from './progressbar';

@@ -19,3 +19,3 @@ export declare class MultiProgressBar {

isTTY(): boolean;
writeLines(prefixText: StringObj): void;
writeLines(terminalLine: TerminalLine): void;
render(): void;

@@ -32,2 +32,3 @@ getBar(name: string): {

finishBar(name: string): void;
finishAllBars(): void;
create(bars: {

@@ -39,2 +40,3 @@ name: string;

}[]): void;
updatePrefixText(newPrefixText: string): void;
getBarCount(): number;

@@ -41,0 +43,0 @@ stop(): void;

@@ -27,7 +27,7 @@ "use strict";

}
writeLines(prefixText) {
writeLines(terminalLine) {
let barStrings = [];
let stringsToRender = [];
if (Object.keys(prefixText).length !== 0) {
stringsToRender.push(prefixText);
if (Object.keys(terminalLine).length !== 0) {
stringsToRender.push(terminalLine);
}

@@ -45,3 +45,6 @@ if (this.updated) {

render() {
let initLine = {};
const initLine = {
renderString: '',
color: '',
};
if (this.timer) {

@@ -51,6 +54,3 @@ clearTimeout(this.timer);

if (this.prefixText.length) {
initLine = {
renderString: `${this.prefixText} ${this.frames[this.frameCount]}`,
color: '',
};
initLine.renderString = `${this.prefixText} ${this.frames[this.frameCount]}`;
}

@@ -115,2 +115,5 @@ this.writeLines(initLine);

}
finishAllBars() {
this.bars.forEach(bar => this.finishBar(bar.name));
}
create(bars) {

@@ -136,2 +139,5 @@ if (!this.bars.length) {

}
updatePrefixText(newPrefixText) {
this.prefixText = newPrefixText;
}
getBarCount() {

@@ -138,0 +144,0 @@ return this.count;

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

import { StringObj } from './terminal';
import { TerminalLine } from './terminal';
export declare type BarOptions = {

@@ -50,3 +50,3 @@ progressBarFormatter: (payload: ProgressPayload, value: number, total: number) => string;

createBarString(): string;
getRenderStrings(): StringObj[];
getRenderStrings(): TerminalLine[];
getValue(): number;

@@ -53,0 +53,0 @@ render(): void;

@@ -8,3 +8,5 @@ "use strict";

constructor(options) {
this.terminal = new terminal_1.AmplifyTerminal();
if (options.loneWolf) {
this.terminal = new terminal_1.AmplifyTerminal();
}
this.value = 0;

@@ -44,4 +46,6 @@ this.total = 1;

render() {
const stringsToRender = this.getRenderStrings();
this.terminal.writeLines(stringsToRender);
if (this.terminal) {
const stringsToRender = this.getRenderStrings();
this.terminal.writeLines(stringsToRender);
}
}

@@ -60,3 +64,3 @@ isFinished() {

this.isActive = true;
if (this.options.loneWolf) {
if (this.terminal) {
if (this.options.hideCursor === true) {

@@ -70,3 +74,3 @@ this.terminal.cursor(false);

this.isActive = false;
if (this.options.loneWolf) {
if (this.terminal) {
if (this.options.hideCursor) {

@@ -91,5 +95,3 @@ this.terminal.cursor(true);

});
if (this.options.loneWolf) {
this.render();
}
this.render();
}

@@ -110,5 +112,3 @@ updateItem(name, newPayload) {

this.items = newItemsSet;
if (this.options.loneWolf) {
this.render();
}
this.render();
}

@@ -115,0 +115,0 @@ increment(value = 1) {

@@ -8,7 +8,8 @@ export declare class AmplifySpinner {

private refreshRate;
constructor(text: string);
render(): void;
start(): void;
stop(text: string | null, success?: boolean): void;
constructor();
private render;
start(text: string | null): void;
resetMessage(text: string | null): void;
stop(text?: string | null, success?: boolean): void;
}
//# sourceMappingURL=spinner.d.ts.map

@@ -6,10 +6,13 @@ "use strict";

class AmplifySpinner {
constructor(text) {
constructor() {
this.frameCount = 0;
this.frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
this.prefixText = text;
this.terminal = new terminal_1.AmplifyTerminal();
this.prefixText = '';
this.refreshRate = 50;
this.terminal = null;
}
render() {
if (!this.terminal) {
return;
}
if (this.timer) {

@@ -26,16 +29,29 @@ clearTimeout(this.timer);

}
start() {
this.prefixText = this.prefixText.replace('\n', '');
start(text) {
if (!this.terminal) {
this.terminal = new terminal_1.AmplifyTerminal();
}
this.prefixText = text ? text.replace('\n', '') : this.prefixText;
this.terminal.cursor(false);
this.render();
}
resetMessage(text) {
if (!this.terminal) {
this.start(text);
return;
}
this.prefixText = text ? text.replace('\n', '') : this.prefixText;
}
stop(text, success = true) {
if (text) {
const lines = [{
renderString: text,
color: success ? 'green' : 'red',
}];
clearTimeout(this.timer);
this.terminal.writeLines(lines);
if (!this.terminal) {
return;
}
const lines = [{
renderString: text || '',
color: success ? 'green' : 'red',
}];
clearTimeout(this.timer);
this.terminal.writeLines(lines);
this.terminal.cursor(true);
this.terminal = null;
}

@@ -42,0 +58,0 @@ }

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

export declare type StringObj = {
export declare type TerminalLine = {
renderString: string;

@@ -14,3 +14,3 @@ color: string;

private get height();
writeLines(lines: StringObj[]): void;
writeLines(lines: TerminalLine[]): void;
cursor(enabled: boolean): void;

@@ -17,0 +17,0 @@ newLine(): void;

@@ -46,5 +46,7 @@ "use strict";

const { renderString, color } = line;
const truncatedLine = renderString.substring(0, Math.min(renderString.length, this.width - BUFFER_LENGTH));
const writtenLine = getColoredLine(truncatedLine, color);
this.stream.write(`${clearLine()}${writtenLine}${os_1.default.EOL}`);
let truncatedLine = renderString.substring(0, Math.min(renderString.length, this.width - BUFFER_LENGTH));
if (truncatedLine.length) {
truncatedLine = getColoredLine(truncatedLine, color);
}
this.stream.write(`${clearLine()}${truncatedLine}${os_1.default.EOL}`);
});

@@ -51,0 +53,0 @@ this.trailingEmptyLines = Math.max(0, this.lastHeight - lines.length);

{
"name": "amplify-prompts",
"version": "2.5.1-fix-bytecode-issue-with-arm64-revised.0",
"version": "2.6.0-binary-file-size.0",
"description": "Utility functions for Amplify CLI terminal I/O",

@@ -52,3 +52,3 @@ "main": "lib/index.js",

},
"gitHead": "df3263518bb847ca5e6e5c594589d6888166da11"
"gitHead": "cb79047d53e5484b98a8afff7ca57eed52e7a74c"
}

@@ -5,3 +5,3 @@ /**

*/
import { AmplifyTerminal as Terminal, StringObj } from './terminal';
import { AmplifyTerminal as Terminal, TerminalLine } from './terminal';
import {

@@ -18,17 +18,17 @@ ProgressBar as Bar,

export class MultiProgressBar {
private count : number;
private terminal : Terminal;
private options : BarOptions;
private bars : {name: string, bar: Bar}[];
private count: number;
private terminal: Terminal;
private options: BarOptions;
private bars: { name: string, bar: Bar }[];
private lastDrawnTime: number;
isActive: boolean;
private refreshRate: number;
private frameCount : number;
private frames : string[];
private frameCount: number;
private frames: string[];
private timer!: ReturnType<typeof setTimeout>;
private prefixText : string;
private prefixText: string; // Header text goes in front of an animated spinner
private updated: boolean;
private lastDrawnStrings : StringObj[];
private lastDrawnStrings: TerminalLine[];
constructor(options : BarOptions) {
constructor(options: BarOptions) {
this.terminal = new Terminal();

@@ -61,3 +61,3 @@ this.options = options;

*/
isTTY() : boolean {
isTTY(): boolean {
return this.terminal.isTTY();

@@ -69,7 +69,7 @@ }

*/
writeLines(prefixText: StringObj) : void {
let barStrings : StringObj[] = [];
let stringsToRender : StringObj[] = [];
if (Object.keys(prefixText).length !== 0) {
stringsToRender.push(prefixText);
writeLines(terminalLine: TerminalLine): void {
let barStrings: TerminalLine[] = [];
let stringsToRender: TerminalLine[] = [];
if (Object.keys(terminalLine).length !== 0) {
stringsToRender.push(terminalLine);
}

@@ -91,4 +91,7 @@ // Only call on the render strings for the individual bar if an update happened.

*/
render() : void {
let initLine = {} as StringObj;
render(): void {
const initLine: TerminalLine = {
renderString: '',
color: '',
};
if (this.timer) {

@@ -99,6 +102,3 @@ clearTimeout(this.timer);

if (this.prefixText.length) {
initLine = {
renderString: `${this.prefixText} ${this.frames[this.frameCount]}`,
color: '',
};
initLine.renderString = `${this.prefixText} ${this.frames[this.frameCount]}`;
}

@@ -123,3 +123,3 @@ this.writeLines(initLine);

*/
getBar(name: string) : { name: string, bar: Bar } | undefined {
getBar(name: string): { name: string, bar: Bar } | undefined {
return this.bars.find(obj => obj.name === name);

@@ -131,3 +131,3 @@ }

*/
updateBar(name: string, updateObj: { name: string, payload: ItemPayload }) : void {
updateBar(name: string, updateObj: { name: string, payload: ItemPayload }): void {
const barDetails = this.getBar(name);

@@ -166,3 +166,3 @@ if (!barDetails) {

*/
incrementBar(name: string, value: number) : void {
incrementBar(name: string, value: number): void {
const barDetails = this.getBar(name);

@@ -180,3 +180,3 @@ if (!barDetails) {

*/
finishBar(name: string) : void {
finishBar(name: string): void {
const barDetails = this.getBar(name);

@@ -194,2 +194,9 @@ if (!barDetails) {

/**
* Finish all bars
*/
finishAllBars(): void {
this.bars.forEach(bar => this.finishBar(bar.name));
}
/**
* Creates a set of progress bars under the multi bar

@@ -202,3 +209,3 @@ */

payload: ProgressPayload
}[]) : void {
}[]): void {
if (!this.bars.length) {

@@ -225,5 +232,12 @@ this.terminal.newLine();

/**
* Update the header text that has a trailing spinner
*/
updatePrefixText(newPrefixText: string): void {
this.prefixText = newPrefixText;
}
/**
* Returns count of progress bars under the multi bar
*/
getBarCount() : number {
getBarCount(): number {
return this.count;

@@ -235,3 +249,3 @@ }

*/
stop() : void {
stop(): void {
this.isActive = false;

@@ -241,3 +255,3 @@ clearTimeout(this.timer);

// Change prefix text according to success/failure
let initLine : StringObj = {
let initLine: TerminalLine = {
renderString: this.options.successText || '',

@@ -244,0 +258,0 @@ color: 'green',

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

import { AmplifyTerminal as Terminal, StringObj } from './terminal';
import { AmplifyTerminal as Terminal, TerminalLine } from './terminal';

@@ -60,3 +60,3 @@ /**

private total: number;
private terminal: Terminal;
private terminal: Terminal | undefined;
private payload!: ProgressPayload;

@@ -73,3 +73,5 @@ private isActive: boolean;

constructor(options: BarOptions) {
this.terminal = new Terminal();
if (options.loneWolf) {
this.terminal = new Terminal();
}
this.value = 0;

@@ -90,3 +92,3 @@ this.total = 1;

*/
createBarString() : string {
createBarString(): string {
const completeSize = Math.round((this.value / this.total) * this.barSize);

@@ -105,4 +107,4 @@ const incompleteSize = this.barSize - completeSize;

*/
getRenderStrings() : StringObj[] {
let finalStrings : StringObj[] = [];
getRenderStrings(): TerminalLine[] {
let finalStrings: TerminalLine[] = [];
const progressBar = this.options.progressBarFormatter.call(this, this.payload, this.value, this.total) + this.createBarString();

@@ -123,3 +125,3 @@ finalStrings.push({

*/
getValue() : number {
getValue(): number {
return this.value;

@@ -131,5 +133,7 @@ }

*/
render() : void {
const stringsToRender = this.getRenderStrings();
this.terminal.writeLines(stringsToRender);
render(): void {
if (this.terminal) {
const stringsToRender = this.getRenderStrings();
this.terminal.writeLines(stringsToRender);
}
}

@@ -140,3 +144,3 @@

*/
isFinished() : boolean {
isFinished(): boolean {
return this.value === this.total;

@@ -148,3 +152,3 @@ }

*/
isFailed() : boolean {
isFailed(): boolean {
return this.items.some(item => this.options.itemFailedStatus.includes(item.status));

@@ -156,3 +160,3 @@ }

*/
start(total: number, startValue: number, payload: ProgressPayload) : void {
start(total: number, startValue: number, payload: ProgressPayload): void {
this.value = startValue || 0;

@@ -166,3 +170,3 @@ this.total = total >= 0 ? total : this.total;

if (this.options.loneWolf) {
if (this.terminal) {
if (this.options.hideCursor === true) {

@@ -178,5 +182,5 @@ this.terminal.cursor(false);

*/
stop() : void {
stop(): void {
this.isActive = false;
if (this.options.loneWolf) {
if (this.terminal) {
if (this.options.hideCursor) {

@@ -191,3 +195,3 @@ this.terminal.cursor(true);

*/
hasItem(name: string) : boolean {
hasItem(name: string): boolean {
return !!this.getItem(name);

@@ -199,3 +203,3 @@ }

*/
getItem(name: string) : Item | undefined {
getItem(name: string): Item | undefined {
return this.items.find(item => item.name === name);

@@ -207,3 +211,3 @@ }

*/
addItem(name: string, itemPayload: ItemPayload) : void {
addItem(name: string, itemPayload: ItemPayload): void {
const status = itemPayload.ResourceStatus;

@@ -216,5 +220,3 @@ this.items.push({

});
if (this.options.loneWolf) {
this.render();
}
this.render();
}

@@ -225,3 +227,3 @@

*/
updateItem(name: string, newPayload: ItemPayload) : void {
updateItem(name: string, newPayload: ItemPayload): void {
const newItemsSet = this.items.map(item => {

@@ -241,5 +243,3 @@ let obj = null;

this.items = newItemsSet;
if (this.options.loneWolf) {
this.render();
}
this.render();
}

@@ -250,3 +250,3 @@

*/
increment(value = 1) : void {
increment(value = 1): void {
this.value += value;

@@ -261,3 +261,3 @@ if (this.options.loneWolf) {

*/
finish() : void {
finish(): void {
const diff = this.total - this.value;

@@ -264,0 +264,0 @@ this.increment(diff);

@@ -6,3 +6,3 @@ /**

import { AmplifyTerminal as Terminal, StringObj } from './terminal';
import { AmplifyTerminal, TerminalLine } from './terminal';

@@ -13,56 +13,76 @@ /**

export class AmplifySpinner {
private frameCount : number;
private frames : string[];
private timer!: ReturnType<typeof setTimeout>;
private prefixText : string;
private terminal: Terminal;
private refreshRate: number;
private frameCount: number;
private frames: string[];
private timer!: ReturnType<typeof setTimeout>;
private prefixText: string;
private terminal: AmplifyTerminal | null;
private refreshRate: number;
constructor(text : string) {
this.frameCount = 0;
this.frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
this.prefixText = text;
this.terminal = new Terminal();
this.refreshRate = 50;
constructor() {
this.frameCount = 0;
this.frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
this.prefixText = '';
this.refreshRate = 50;
this.terminal = null;
}
/**
* Render function
*/
private render(): void {
if (!this.terminal) {
return;
}
if (this.timer) {
clearTimeout(this.timer);
}
const lines = [{
renderString: `${this.frames[this.frameCount]} ${this.prefixText}`,
color: '',
}];
this.frameCount = ++this.frameCount % this.frames.length;
this.terminal.writeLines(lines);
this.timer = setTimeout(() => this.render(), this.refreshRate);
}
/**
* Render function
*/
render() : void {
if (this.timer) {
clearTimeout(this.timer);
}
const lines = [{
renderString: `${this.frames[this.frameCount]} ${this.prefixText}`,
color: '',
}];
this.frameCount = ++this.frameCount % this.frames.length;
this.terminal.writeLines(lines);
this.timer = setTimeout(() => this.render(), this.refreshRate);
/**
* Starts a spinner and calls render function.
*/
start(text: string | null): void {
if (!this.terminal) {
this.terminal = new AmplifyTerminal();
}
this.prefixText = text ? text.replace('\n', '') : this.prefixText;
this.terminal.cursor(false);
this.render();
}
/**
* Starts a spinner and calls render function.
*/
start() : void {
this.prefixText = this.prefixText.replace('\n', '');
this.terminal.cursor(false);
this.render();
/**
* Reset spinner message
*/
resetMessage(text: string | null): void {
if (!this.terminal) {
this.start(text);
return;
}
this.prefixText = text ? text.replace('\n', '') : this.prefixText;
}
/**
* Stops the spinner
*/
stop(text : string | null, success = true) : void {
if (text) {
const lines : StringObj[] = [{
renderString: text,
color: success ? 'green' : 'red',
}];
/**
* Stops the spinner
*/
stop(text?: string | null, success = true): void {
if (!this.terminal) {
return;
}
const lines: TerminalLine[] = [{
renderString: text || '',
color: success ? 'green' : 'red',
}];
clearTimeout(this.timer);
this.terminal.writeLines(lines);
}
}
clearTimeout(this.timer);
this.terminal.writeLines(lines);
this.terminal.cursor(true);
this.terminal = null;
}
}

@@ -5,5 +5,5 @@ import os from 'os';

/**
* String obj passed to terminal
* string and color to be passed to terminal
*/
export type StringObj = {
export type TerminalLine = {
renderString: string,

@@ -77,3 +77,3 @@ color: string

*/
public writeLines(lines : StringObj[]) : void {
public writeLines(lines: TerminalLine[]): void {
// Go back to beginning of last written block

@@ -85,5 +85,7 @@ this.stream.write(cursorUp(this.lastHeight));

const { renderString, color } = line;
const truncatedLine = renderString.substring(0, Math.min(renderString.length, this.width - BUFFER_LENGTH));
const writtenLine = getColoredLine(truncatedLine, color);
this.stream.write(`${clearLine()}${writtenLine}${os.EOL}`);
let truncatedLine = renderString.substring(0, Math.min(renderString.length, this.width - BUFFER_LENGTH));
if (truncatedLine.length) {
truncatedLine = getColoredLine(truncatedLine, color);
}
this.stream.write(`${clearLine()}${truncatedLine}${os.EOL}`);
});

@@ -90,0 +92,0 @@

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

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