New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@teambit/bvm.config

Package Overview
Dependencies
Maintainers
0
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teambit/bvm.config - npm Package Compare versions

Comparing version

to
1.0.1

42

config.ts

@@ -6,6 +6,3 @@ import { Provider } from "nconf";

import pickBy from "lodash.pickby";
import fs from "fs-extra";
import { execSync } from "child_process";
import semver from "semver";
import chalk from "chalk";
import fs from "fs";

@@ -79,8 +76,3 @@ export const BVM_ENV_VARS_PREFIX = "BVM_";

const DEFAULT_LINK = "bit";
const DEFAULT_ALTERNATIVE_LINK = "bbit";
const ALTERNATIVE_LINK_WARNING = `A legacy version of Bit is installed on your machine.
Use the 'bbit' command for Bit's latest version and the 'bit' command for Bit's legacy version.
For more information, see the following link: https://harmony-docs.bit.dev/introduction/installation`;
const globalDefaults = {

@@ -178,10 +170,6 @@ BVM_DIR: getBvmDirectory(),

if (!fs.existsSync(configPath)) {
fs.ensureDirSync(path.dirname(configPath));
const legacyBitExist = checkIfBitLegacyExist();
const configDir = path.dirname(configPath);
if (!fs.existsSync(configDir)) fs.mkdirSync(configDir, { recursive: true });
let defaultLink = DEFAULT_LINK;
if (legacyBitExist) {
console.log(chalk.yellowBright(ALTERNATIVE_LINK_WARNING));
defaultLink = DEFAULT_ALTERNATIVE_LINK;
}
fs.writeJSONSync(configPath, { DEFAULT_LINK: defaultLink });
fs.writeFileSync(configPath, JSON.stringify({ DEFAULT_LINK: defaultLink }, undefined, 2));
}

@@ -264,3 +252,3 @@ const config = new Config(name, configPath, globalDefaults, sources);

}
const exists = fs.pathExistsSync(versionDir);
const exists = fs.existsSync(versionDir);
return {

@@ -282,3 +270,3 @@ versionDir,

const versionDir = path.join(versionsDir, version);
const exists = fs.pathExistsSync(versionDir);
const exists = fs.existsSync(versionDir);
return {

@@ -294,5 +282,6 @@ versionDir,

getWantedNodeVersion(innerVersionDir: string): string | undefined {
const bitManifest = fs.readJsonSync(
const bitManifestUnparsed = fs.readFileSync(
path.join(innerVersionDir, "node_modules/@teambit/bit/package.json")
);
const bitManifest = JSON.parse(bitManifestUnparsed.toString());
return bitManifest.bvm && bitManifest.bvm.node;

@@ -407,17 +396,2 @@ }

function checkIfBitLegacyExist(): boolean {
try {
// Ignore errors to prevent printing the error to the console. in case of error we just treat it as it doesn't exists
const output = execSync("bit -v", {
stdio: ["pipe", "pipe", "ignore"],
}).toString();
if (output && semver.valid(output.trim()) && output.startsWith("14")) {
return true;
}
return false;
} catch (e) {
return false;
}
}
/**

@@ -424,0 +398,0 @@ * This function will transform the env variable to only get env variable starts with the BVM_ENV_VARS_PREFIX

44

dist/config.js

@@ -12,6 +12,3 @@ "use strict";

const lodash_pickby_1 = __importDefault(require("lodash.pickby"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const child_process_1 = require("child_process");
const semver_1 = __importDefault(require("semver"));
const chalk_1 = __importDefault(require("chalk"));
const fs_1 = __importDefault(require("fs"));
exports.BVM_ENV_VARS_PREFIX = "BVM_";

@@ -77,6 +74,2 @@ exports.BVM_GLOBALS_DIR_ENV_VARIABLE = "BVM_GLOBALS_DIR";

const DEFAULT_LINK = "bit";
const DEFAULT_ALTERNATIVE_LINK = "bbit";
const ALTERNATIVE_LINK_WARNING = `A legacy version of Bit is installed on your machine.
Use the 'bbit' command for Bit's latest version and the 'bit' command for Bit's legacy version.
For more information, see the following link: https://harmony-docs.bit.dev/introduction/installation`;
const globalDefaults = {

@@ -151,11 +144,8 @@ BVM_DIR: getBvmDirectory(),

const configPath = getConfigPath();
if (!fs_extra_1.default.existsSync(configPath)) {
fs_extra_1.default.ensureDirSync(path_1.default.dirname(configPath));
const legacyBitExist = checkIfBitLegacyExist();
if (!fs_1.default.existsSync(configPath)) {
const configDir = path_1.default.dirname(configPath);
if (!fs_1.default.existsSync(configDir))
fs_1.default.mkdirSync(configDir, { recursive: true });
let defaultLink = DEFAULT_LINK;
if (legacyBitExist) {
console.log(chalk_1.default.yellowBright(ALTERNATIVE_LINK_WARNING));
defaultLink = DEFAULT_ALTERNATIVE_LINK;
}
fs_extra_1.default.writeJSONSync(configPath, { DEFAULT_LINK: defaultLink });
fs_1.default.writeFileSync(configPath, JSON.stringify({ DEFAULT_LINK: defaultLink }, undefined, 2));
}

@@ -220,3 +210,3 @@ const config = new Config(name, configPath, globalDefaults, sources);

}
const exists = fs_extra_1.default.pathExistsSync(versionDir);
const exists = fs_1.default.existsSync(versionDir);
return {

@@ -233,3 +223,3 @@ versionDir,

const versionDir = path_1.default.join(versionsDir, version);
const exists = fs_extra_1.default.pathExistsSync(versionDir);
const exists = fs_1.default.existsSync(versionDir);
return {

@@ -244,3 +234,4 @@ versionDir,

getWantedNodeVersion(innerVersionDir) {
const bitManifest = fs_extra_1.default.readJsonSync(path_1.default.join(innerVersionDir, "node_modules/@teambit/bit/package.json"));
const bitManifestUnparsed = fs_1.default.readFileSync(path_1.default.join(innerVersionDir, "node_modules/@teambit/bit/package.json"));
const bitManifest = JSON.parse(bitManifestUnparsed.toString());
return bitManifest.bvm && bitManifest.bvm.node;

@@ -345,17 +336,2 @@ }

exports.Config = Config;
function checkIfBitLegacyExist() {
try {
// Ignore errors to prevent printing the error to the console. in case of error we just treat it as it doesn't exists
const output = (0, child_process_1.execSync)("bit -v", {
stdio: ["pipe", "pipe", "ignore"],
}).toString();
if (output && semver_1.default.valid(output.trim()) && output.startsWith("14")) {
return true;
}
return false;
}
catch (e) {
return false;
}
}
/**

@@ -362,0 +338,0 @@ * This function will transform the env variable to only get env variable starts with the BVM_ENV_VARS_PREFIX

{
"name": "@teambit/bvm.config",
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://bit.cloud/teambit/bvm/config",

@@ -9,18 +9,12 @@ "main": "dist/index.js",

"name": "config",
"version": "1.0.0"
"version": "1.0.1"
},
"dependencies": {
"chalk": "4.1.0",
"fs-extra": "9.1.0",
"lodash.pickby": "4.6.0",
"nconf": "0.11.4",
"semver": "7.6.3",
"user-home": "2.0.0"
"user-home": "3.0.0"
},
"devDependencies": {
"@types/chalk": "0.4.31",
"@types/fs-extra": "9.0.7",
"@types/lodash.pickby": "4.6.6",
"@types/nconf": "0.10.0",
"@types/semver": "7.5.8",
"@types/jest": "26.0.20",

@@ -27,0 +21,0 @@ "@types/node": "22.10.5"

Sorry, the diff of this file is not supported yet