New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@code-coaching/random

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@code-coaching/random - npm Package Compare versions

Comparing version
1.0.5
to
1.1.0
+13
-7
cli/index.js
#!/usr/bin/env node
import { readFile } from "fs/promises";
import { randomID, randomUUID } from "../index.js";
import { cli } from "./utils/cli.js";
import { randomID, randomString, randomUUID } from "../index.js";
import { cli, FLAGS } from "./utils/cli.js";

@@ -9,5 +9,2 @@ const pkg = JSON.parse(await readFile(new URL("../package.json", import.meta.url)));

switch (cli.input[0]) {
case "version":
console.log(pkg.version);
break;
case "uuid":

@@ -17,8 +14,17 @@ console.log(randomUUID());

case "id":
console.log(randomID(cli.flags.characters));
console.log(randomID(cli.flags[FLAGS.CHARACTERS]));
break;
case "string":
console.log(randomString(cli.flags[FLAGS.CHARACTERS]));
break;
default:
cli.showHelp(0);
}
if (cli.flags.help) {
if (cli.flags[FLAGS.HELP]) {
cli.showHelp(0);
}
if (cli.flags[FLAGS.VERSION]) {
console.log(pkg.version);
}

@@ -31,2 +31,17 @@ import chalk from "chalk";

const helpTextString = `
Description
Generate a random string.
Usage
${green(`npx @code-coaching/random`)} ${cyan(`string`)} ${yellow(`[--option]`)}
Options
${yellow(`-c`)}, ${yellow(`--characters`)} Amount of random characters to print ${dim(`(DEFAULT: 8)`)}
Examples
${green(`npx @code-coaching/random string`)}
${green(`npx @code-coaching/random string -c 4`)}
`;
const helpText = `

@@ -50,4 +65,13 @@ Usage

${helpTextUUID}
${helpTextString}
`;
const FLAGS = {
AD: "ad",
HELP: "help",
VERSION: "version",
CHARACTERS: "characters",
};
const options = {

@@ -58,7 +82,7 @@ inferType: true,

flags: {
ad: {
[FLAGS.AD]: {
type: "boolean",
default: true,
},
help: {
[FLAGS.HELP]: {
type: "boolean",

@@ -68,3 +92,3 @@ default: false,

},
version: {
[FLAGS.VERSION]: {
type: "boolean",

@@ -74,3 +98,3 @@ default: false,

},
characters: {
[FLAGS.CHARACTERS]: {
type: "number",

@@ -85,2 +109,2 @@ default: 8,

export { cli };
export { cli, FLAGS };
{
"name": "@code-coaching/random",
"version": "1.0.5",
"version": "1.1.0",
"description": "This package provides functions to generate random stuff (strings, numbers, uuid). It can be used as a dependency for other packages. It can be used as a CLI tool.",

@@ -5,0 +5,0 @@ "type": "module",