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

@cloud-cli/cli

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloud-cli/cli - npm Package Compare versions

Comparing version
1.9.3
to
1.9.4
+1
data/plugin.json
{}
+1
-0

@@ -5,3 +5,4 @@ import { Configuration } from './configuration.js';

export { getStorage } from './storage.js';
export { readJson, writeJson } from './utils.js';
export type { ServerParams } from './http-server.js';
export declare function run(command: string, args?: Record<string, any>, config?: Configuration): Promise<unknown>;

@@ -6,2 +6,3 @@ import { CliCommand } from './cli-command.js';

export { getStorage } from './storage.js';
export { readJson, writeJson } from './utils.js';
export async function run(command, args, config) {

@@ -8,0 +9,0 @@ if (!config) {

+7
-6

@@ -1,8 +0,9 @@

export declare function getStorage<T>(prefix: any): {
export declare function getStorage<T>(prefix: string, computeKey?: (key: string) => string): {
get: (key: string) => T | null;
set: (key: string, value: any) => Promise<boolean>;
update: (key: string, values: any) => Promise<boolean>;
getKeys: () => Promise<string[]>;
getAll: () => Promise<T[]>;
remove: (key: string) => Promise<boolean>;
set: (key: string, value: any) => boolean;
reset: () => boolean;
has: (key: string) => boolean;
update: (key: string, values: Partial<T>) => boolean;
getAll: () => T[];
remove: (key: string) => boolean;
};

@@ -1,44 +0,48 @@

import { existsSync, mkdirSync } from 'node:fs';
import { readdir, rm, writeFile } from 'node:fs/promises';
import { mkdirSync } from 'node:fs';
import { join } from 'node:path';
import { readJson } from './utils.js';
import { readJson, writeJson } from './utils.js';
import { createHash } from 'node:crypto';
const extension = '.json';
export function getStorage(prefix) {
const storagePath = join(process.cwd(), 'data', prefix);
mkdirSync(storagePath, { recursive: true });
const sha256 = (string) => createHash('sha256').update(string).digest('hex');
export function getStorage(prefix, computeKey = sha256) {
const dataPath = join(process.cwd(), 'data');
const storagePath = join(dataPath, prefix + extension);
mkdirSync(dataPath, { recursive: true });
let store;
const save = () => writeJson(storagePath, store);
const load = () => (store = readJson(storagePath) || {});
load();
const get = (key) => {
const path = join(storagePath, key + extension);
return readJson(path);
load();
return store[computeKey(key)] || null;
};
const set = async (key, value) => {
await writeFile(join(storagePath, key + extension), JSON.stringify(value), 'utf-8');
const has = (key) => {
return computeKey(key) in store;
};
const set = (key, value) => {
store[computeKey(key)] = value;
save();
return true;
};
const update = async (key, values) => {
const previous = await get(key);
const next = Object.assign({}, previous || {}, values);
await writeFile(join(storagePath, key + extension), JSON.stringify(next), 'utf-8');
const reset = () => {
store = {};
save();
return true;
};
const getKeys = async () => {
const all = await readdir(storagePath, { withFileTypes: true });
return all.filter((f) => f.isFile() && f.name.endsWith(extension)).map((f) => f.name.replace(extension, ''));
const update = (key, values) => {
const previous = get(key);
const next = Object.assign({}, previous, values);
store[computeKey(key)] = next;
save();
return true;
};
const getAll = async () => {
const keys = await getKeys();
const all = [];
for (const next of keys) {
all.push(await get(next));
}
return all;
const getAll = () => {
return Object.values(store);
};
const remove = async (key) => {
const path = join(storagePath, key + extension);
if (existsSync(path)) {
await rm(join(storagePath, key + extension));
return true;
}
return false;
const remove = (key) => {
delete store[computeKey(key)];
save();
return true;
};
return { get, set, update, getKeys, getAll, remove };
return { get, set, reset, has, update, getAll, remove };
}
export declare function readJson<T>(path: string): T | null;
export declare function writeJson(path: string, value: any): void;

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

import { existsSync, readFileSync } from 'fs';
import { existsSync, readFileSync, writeFileSync } from 'fs';
export function readJson(path) {

@@ -11,1 +11,4 @@ if (existsSync(path)) {

}
export function writeJson(path, value) {
return writeFileSync(path, JSON.stringify(value));
}
{
"name": "@cloud-cli/cli",
"version": "1.9.3",
"version": "1.9.4",
"description": "CLI for the Cloud CLI project",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",