Skip to content

Commit

Permalink
fix: Updated postinstall script
Browse files Browse the repository at this point in the history
  • Loading branch information
stevedylandev committed Sep 3, 2024
1 parent a7e21b1 commit 524499f
Showing 1 changed file with 80 additions and 78 deletions.
158 changes: 80 additions & 78 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,84 @@
const colors = {
reset: "\x1b[0m",
bright: "\x1b[1m",
fg: {
yellow: "\x1b[33m",
cyan: "\x1b[36m",
green: "\x1b[32m",
},
dim: "\x1b[2m",
};
(function () {
const colors = {
reset: "\x1b[0m",
bright: "\x1b[1m",
fg: {
yellow: "\x1b[33m",
cyan: "\x1b[36m",
green: "\x1b[32m",
},
dim: "\x1b[2m",
};

const boxWidth = 70;
const horizontalBorder = "+" + "=".repeat(boxWidth - 2) + "+";
const emptyLine = "|" + " ".repeat(boxWidth - 2) + "|";
const boxWidth = 70;
const horizontalBorder = "+" + "=".repeat(boxWidth - 2) + "+";
const emptyLine = "|" + " ".repeat(boxWidth - 2) + "|";

function stripAnsi(str) {
return str.replace(/\x1b\[[0-9;]*m/g, "");
}
function stripAnsi(str) {
return str.replace(/\x1b\[[0-9;]*m/g, "");
}

function centeredText(text, width) {
const visibleLength = stripAnsi(text).length;
const padding = Math.max(0, width - visibleLength);
const leftPad = Math.floor(padding / 2);
const rightPad = padding - leftPad;
return "|" + " ".repeat(leftPad) + text + " ".repeat(rightPad) + "|";
}
function centeredText(text, width) {
const visibleLength = stripAnsi(text).length;
const padding = Math.max(0, width - visibleLength);
const leftPad = Math.floor(padding / 2);
const rightPad = padding - leftPad;
return "|" + " ".repeat(leftPad) + text + " ".repeat(rightPad) + "|";
}

console.log("\n" + colors.fg.yellow + horizontalBorder + colors.reset);
console.log(colors.fg.yellow + emptyLine + colors.reset);
console.log(
colors.fg.yellow +
centeredText(
colors.bright +
colors.fg.yellow +
"🚨 ATTENTION IPFS USERS! 🚨" +
colors.reset,
boxWidth - 2,
) +
colors.reset,
);
console.log(colors.fg.yellow + emptyLine + colors.reset);
console.log(
colors.fg.yellow +
centeredText(
colors.fg.cyan +
"If you're looking to use IPFS please install pinata-web3 instead." +
colors.reset,
boxWidth - 2,
) +
colors.reset,
);
console.log(colors.fg.yellow + emptyLine + colors.reset);
console.log(
colors.fg.yellow +
centeredText(
colors.fg.green + "npm install pinata-web3" + colors.reset,
boxWidth - 2,
) +
colors.reset,
);
console.log(colors.fg.yellow + emptyLine + colors.reset);
console.log(
colors.fg.yellow +
centeredText(
colors.dim +
"For more information please see our documentation at" +
colors.reset,
boxWidth - 2,
) +
colors.reset,
);
console.log(
colors.fg.yellow +
centeredText(
colors.dim + "https://docs.pinata.cloud/web3/sdk" + colors.reset,
boxWidth - 2,
) +
colors.reset,
);
console.log(colors.fg.yellow + emptyLine + colors.reset);
console.log(colors.fg.yellow + horizontalBorder + colors.reset);
console.log("\n");
console.log("\n" + colors.fg.yellow + horizontalBorder + colors.reset);
console.log(colors.fg.yellow + emptyLine + colors.reset);
console.log(
colors.fg.yellow +
centeredText(
colors.bright +
colors.fg.yellow +
"🚨 ATTENTION IPFS USERS! 🚨" +
colors.reset,
boxWidth - 2,
) +
colors.reset,
);
console.log(colors.fg.yellow + emptyLine + colors.reset);
console.log(
colors.fg.yellow +
centeredText(
colors.fg.cyan +
"If you're looking to use IPFS please install pinata-web3 instead." +
colors.reset,
boxWidth - 2,
) +
colors.reset,
);
console.log(colors.fg.yellow + emptyLine + colors.reset);
console.log(
colors.fg.yellow +
centeredText(
colors.fg.green + "npm install pinata-web3" + colors.reset,
boxWidth - 2,
) +
colors.reset,
);
console.log(colors.fg.yellow + emptyLine + colors.reset);
console.log(
colors.fg.yellow +
centeredText(
colors.dim +
"For more information please see our documentation at" +
colors.reset,
boxWidth - 2,
) +
colors.reset,
);
console.log(
colors.fg.yellow +
centeredText(
colors.dim + "https://docs.pinata.cloud/web3/sdk" + colors.reset,
boxWidth - 2,
) +
colors.reset,
);
console.log(colors.fg.yellow + emptyLine + colors.reset);
console.log(colors.fg.yellow + horizontalBorder + colors.reset);
console.log("\n");
})();

0 comments on commit 524499f

Please sign in to comment.