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

hjsx

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hjsx - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

2

package.json
{
"name": "hjsx",
"version": "0.1.9",
"version": "0.1.10",
"module": "hjsx.ts",

@@ -5,0 +5,0 @@ "main": "hjsx.js",

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

import { colors } from "./util";
import { parseArgs } from "node:util";

@@ -19,2 +20,6 @@

const config = { args, options };
const quietSpawnOptions = {
stdout: "pipe",
stderr: "pipe",
} as const;

@@ -25,8 +30,12 @@ await build();

await commitAndPush();
await publish();
const green = (text: string) => `\x1b[32m${text}\x1b[0m`;
console.log(`\n${green("published!")} v${oldVersion} -> v${newVersion}`);
if (oldVersion !== newVersion) {
await publish();
console.log(`\n${colors.green("published!")} v${oldVersion} -> v${newVersion}`);
} else {
console.log(`\n${colors.gray("(not published)")} v${oldVersion} == v${newVersion}`);
}
async function build() {
console.log("building...");
const { exited } = Bun.spawn(["bun", "run", "build"]);

@@ -40,3 +49,4 @@ const exitCode = await exited;

async function publish() {
const { exited } = Bun.spawn(["npm", "publish"]);
console.log("publishing to npm...");
const { exited } = Bun.spawn(["npm", "publish"], quietSpawnOptions);
const exitCode = await exited;

@@ -48,15 +58,19 @@ if (exitCode !== 0) {

async function commitAndPush() {
let exited = Bun.spawn(["git", "add", "-A"]).exited;
let exitCode = await exited;
async function commitAndPush(): Promise<void> {
let process = Bun.spawn(["git", "add", "-A"], quietSpawnOptions);
let exitCode = await process.exited;
if (exitCode !== 0) {
throw new Error("git add failed");
}
exited = Bun.spawn(["git", "commit", "-m", "'update version and test results badge'"]).exited;
exitCode = await exited;
process = Bun.spawn(
["git", "commit", "-m", "'update version and test results badge'"],
quietSpawnOptions,
);
exitCode = await process.exited;
if (exitCode !== 0) {
throw new Error("git commit failed");
const stderr = await Bun.readableStreamToText(process.stderr);
throw new Error(`git commit failed: ${stderr}`);
}
exited = Bun.spawn(["git", "push"]).exited;
exitCode = await exited;
process = Bun.spawn(["git", "push"], quietSpawnOptions);
exitCode = await process.exited;
if (exitCode !== 0) {

@@ -68,2 +82,3 @@ throw new Error("git push failed");

async function updateVersion(): Promise<[SemVer, SemVer]> {
console.log("updating version...");
const parsed = parseArgs(config);

@@ -73,3 +88,3 @@ const file = Bun.file("package.json");

const version = pkg.version;
const newVersion = getNewVersion(version, parsed);
const newVersion = getNewVersion(version, parsed.values);
pkg.version = newVersion;

@@ -82,15 +97,21 @@ const writer = file.writer();

function getNewVersion(version: SemVer, parsedArgs: ParsedArgs): SemVer {
const { values } = parsedArgs;
function getNewVersion(version: SemVer, args: ParsedArgs["values"]): SemVer {
const [major, minor, patch] = version.split(".").map(Number);
if (values.major) return `${major + 1}.0.0`;
if (values.minor) return `${major}.${minor + 1}.0`;
return `${major}.${minor}.${patch + 1}` as SemVer;
if (args.major) return `${major + 1}.0.0`;
if (args.minor) return `${major}.${minor + 1}.0`;
if (args.patch) return `${major}.${minor}.${patch + 1}`;
return version;
}
async function runTests() {
const { exited } = Bun.spawn("bun test".split(" "));
console.log("running tests...");
const { exited } = Bun.spawn("bun test".split(" "), quietSpawnOptions);
const exitCode = await exited;
const text = exitCode === 0 ? "passing" : "failing";
const color = exitCode === 0 ? "green" : "red";
return updateReadmeTestsBadge(text, color);
}
async function updateReadmeTestsBadge(text: string, color: string) {
console.log("updating README.md tests badge...");
const link = `![tests](https://img.shields.io/badge/tests-${text}-${color}?style=for-the-badge)`;

@@ -97,0 +118,0 @@ const file = Bun.file("README.md");

@@ -108,1 +108,16 @@ export { normalizeAttributeName } from "./normalize-attribute-name.ts";

];
export const colors = {
green(text: string) {
return `\x1b[32m${text}\x1b[0m`;
},
red(text: string) {
return `\x1b[31m${text}\x1b[0m`;
},
yellow(text: string) {
return `\x1b[33m${text}\x1b[0m`;
},
gray(text: string) {
return `\x1b[90m${text}\x1b[0m`;
}
} as const;
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