@tech_query/node-toolkit
Advanced tools
+1
-5
@@ -20,6 +20,2 @@ export declare function packageNameOf(path: string): string; | ||
| export declare function configOf(name: string): Record<string, any>; | ||
| export declare function getNPMConfig(key: string): string | Record<string, any> | undefined; | ||
| /** | ||
| * @see {@link https://github.blog/changelog/2022-10-24-npm-v9-0-0-released/#:~:text=npm%20config%20set%20will%20no%20longer%20accept%20deprecated%20or%20invalid%20config%20options} | ||
| */ | ||
| export declare function setNPMConfig(key: string, value: any): void; | ||
| export declare const stringifyEnv: (data: Record<string, unknown>) => string; |
+5
-21
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.stringifyEnv = void 0; | ||
| exports.packageNameOf = packageNameOf; | ||
@@ -8,8 +9,5 @@ exports.patternOf = patternOf; | ||
| exports.configOf = configOf; | ||
| exports.getNPMConfig = getNPMConfig; | ||
| exports.setNPMConfig = setNPMConfig; | ||
| const path_1 = require("path"); | ||
| const fs_extra_1 = require("fs-extra"); | ||
| const yaml_1 = require("yaml"); | ||
| const child_process_1 = require("child_process"); | ||
| const language_1 = require("./language"); | ||
@@ -75,19 +73,5 @@ const file_1 = require("./file"); | ||
| } | ||
| function getNPMConfig(key) { | ||
| const value = ((0, child_process_1.execSync)(`npm get ${key}`) + '').trim(); | ||
| if (value !== 'undefined') | ||
| try { | ||
| return JSON.parse(value); | ||
| } | ||
| catch (_a) { | ||
| return value; | ||
| } | ||
| } | ||
| /** | ||
| * @see {@link https://github.blog/changelog/2022-10-24-npm-v9-0-0-released/#:~:text=npm%20config%20set%20will%20no%20longer%20accept%20deprecated%20or%20invalid%20config%20options} | ||
| */ | ||
| function setNPMConfig(key, value) { | ||
| const data = JSON.stringify(value); | ||
| (0, child_process_1.execSync)(value != null ? `npm set ${key} ${data}` : `npm config delete ${key}`); | ||
| console.info(`${key} = ${data}`); | ||
| } | ||
| const stringifyEnv = (data) => Object.entries(data) | ||
| .map(([key, value]) => `${key}=${JSON.stringify(value)}`) | ||
| .join('\n'); | ||
| exports.stringifyEnv = stringifyEnv; |
+19
-16
| { | ||
| "name": "@tech_query/node-toolkit", | ||
| "version": "2.0.0-beta.0", | ||
| "version": "2.0.0-beta.1", | ||
| "license": "LGPL-3.0", | ||
| "author": "shiy2008@gmail.com", | ||
| "description": "Toolkit for Node.JS packages", | ||
@@ -14,4 +16,2 @@ "keywords": [ | ||
| ], | ||
| "author": "shiy2008@gmail.com", | ||
| "license": "LGPL-3.0", | ||
| "homepage": "https://tech-query.me/node-toolkit/", | ||
@@ -25,18 +25,8 @@ "repository": { | ||
| }, | ||
| "engines": { | ||
| "node": ">=20" | ||
| }, | ||
| "main": "dist/index.js", | ||
| "source": "source/index.ts", | ||
| "types": "dist/index.d.ts", | ||
| "lint-staged": { | ||
| "*.{json,yml,ts}": "biome check --write" | ||
| }, | ||
| "jest": { | ||
| "preset": "ts-jest" | ||
| }, | ||
| "scripts": { | ||
| "prepare": "husky", | ||
| "test": "lint-staged && jest", | ||
| "build": "rm -rf dist/ docs/ && tsc && typedoc source/", | ||
| "prepublishOnly": "npm test && npm run build", | ||
| "start": "typedoc && open-cli docs/index.html" | ||
| }, | ||
| "dependencies": { | ||
@@ -63,2 +53,15 @@ "file-type": "^16.5.4", | ||
| }, | ||
| "lint-staged": { | ||
| "*.{json,yml,ts}": "biome check --write" | ||
| }, | ||
| "jest": { | ||
| "preset": "ts-jest" | ||
| }, | ||
| "scripts": { | ||
| "prepare": "husky", | ||
| "test": "lint-staged && jest", | ||
| "build": "rm -rf dist/ docs/ && tsc && typedoc source/", | ||
| "prepublishOnly": "npm test && npm run build", | ||
| "start": "typedoc && open-cli docs/index.html" | ||
| }, | ||
| "test": { | ||
@@ -65,0 +68,0 @@ "env": { |
+4
-4
@@ -12,6 +12,6 @@ # Node.JS toolkit | ||
| | SemVer | status | Node.js | | ||
| | :----: | :----------: | :-----: | | ||
| | `>=2` | ✅developing | `>=16` | | ||
| | `<2` | ❌deprecated | `>=6` | | ||
| | SemVer | status | Node.js | | ||
| | :----: | :----------: | :-------: | | ||
| | `>=2` | ✅developing | `>=20.12` | | ||
| | `<2` | ❌deprecated | `>=6` | | ||
@@ -18,0 +18,0 @@ ## Basic usage |
+4
-25
| import { resolve, basename, dirname } from 'path'; | ||
| import { readJSONSync, existsSync, readFileSync } from 'fs-extra'; | ||
| import { parse } from 'yaml'; | ||
| import { execSync } from 'child_process'; | ||
@@ -79,25 +78,5 @@ import { toRegExp } from './language'; | ||
| export function getNPMConfig( | ||
| key: string | ||
| ): string | Record<string, any> | undefined { | ||
| const value = (execSync(`npm get ${key}`) + '').trim(); | ||
| if (value !== 'undefined') | ||
| try { | ||
| return JSON.parse(value); | ||
| } catch { | ||
| return value; | ||
| } | ||
| } | ||
| /** | ||
| * @see {@link https://github.blog/changelog/2022-10-24-npm-v9-0-0-released/#:~:text=npm%20config%20set%20will%20no%20longer%20accept%20deprecated%20or%20invalid%20config%20options} | ||
| */ | ||
| export function setNPMConfig(key: string, value: any) { | ||
| const data = JSON.stringify(value); | ||
| execSync( | ||
| value != null ? `npm set ${key} ${data}` : `npm config delete ${key}` | ||
| ); | ||
| console.info(`${key} = ${data}`); | ||
| } | ||
| export const stringifyEnv = (data: Record<string, unknown>) => | ||
| Object.entries(data) | ||
| .map(([key, value]) => `${key}=${JSON.stringify(value)}`) | ||
| .join('\n'); |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
0
-100%28569
-4.68%492
-7.17%