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

@dbpath/environments

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dbpath/environments - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

6

dist/src/environments.d.ts

@@ -7,4 +7,4 @@ import { ColumnDefn, ErrorsAnd, NameAnd, NameAndValidator } from "@dbpath/utils";

}
export declare function currentEnvName(cwd: string, env: string | undefined): ErrorsAnd<string>;
export declare function saveEnvName(cwd: string, env: string): ErrorsAnd<void>;
export declare function currentEnvName(cwd: string, marker: string, env: string | undefined, cleanE: NameAnd<CleanEnvironment>): ErrorsAnd<string>;
export declare function saveEnvName(cwd: string, marker: string, env: string): ErrorsAnd<void>;
export interface EnvAndName {

@@ -14,3 +14,3 @@ env: CleanEnvironment;

}
export declare function currentEnvironment(cwd: string, envs: NameAnd<CleanEnvironment>, env: string | undefined): ErrorsAnd<EnvAndName>;
export declare function currentEnvironment(cwd: string, marker: string, envs: NameAnd<CleanEnvironment>, env: string | undefined): ErrorsAnd<EnvAndName>;
export interface CleanEnvironment extends Required<Environment> {

@@ -17,0 +17,0 @@ name: string;

@@ -41,26 +41,17 @@ "use strict";

const fs = __importStar(require("fs"));
const stateFileName = '.db-auto.state.json';
function currentEnvName(cwd, env) {
const stateFileName = '.dbpath.state.json';
function currentEnvName(cwd, marker, env, cleanE) {
if (env)
return env;
const dir = (0, files_1.findDirectoryHoldingFileOrError)(cwd, 'db-auto.json');
if ((0, utils_1.hasErrors)(dir))
return dir;
const envFile = Path.join(dir, stateFileName);
try {
const contents = fs.readFileSync(envFile).toString('utf-8');
try {
return JSON.parse(contents).currentEnvironment;
}
catch (e) {
return [`Error parsing ${envFile}: ${e.message}`];
}
}
catch (e) {
const contents = (0, files_1.loadFileInDirectory)(cwd, marker, stateFileName);
if ((0, utils_1.hasErrors)(contents))
return 'dev';
}
const foundEnv = contents.currentEnvironment;
if (cleanE[foundEnv])
return foundEnv;
return [`Environment ${foundEnv} not found. Legal values are ${Object.keys(cleanE).sort().join(', ')}`];
}
exports.currentEnvName = currentEnvName;
function saveEnvName(cwd, env) {
const dir = (0, files_1.findDirectoryHoldingFileOrError)(cwd, 'db-auto.json');
function saveEnvName(cwd, marker, env) {
const dir = (0, files_1.findDirectoryHoldingFileOrError)(cwd, marker);
if ((0, utils_1.hasErrors)(dir))

@@ -78,4 +69,4 @@ return dir;

exports.saveEnvName = saveEnvName;
function currentEnvironment(cwd, envs, env) {
return (0, utils_1.mapErrors)(currentEnvName(cwd, env), (envName) => {
function currentEnvironment(cwd, marker, envs, env) {
return (0, utils_1.mapErrors)(currentEnvName(cwd, marker, env, envs), (envName) => {
const env = envs[envName];

@@ -82,0 +73,0 @@ if (env)

{
"name": "@dbpath/environments",
"description": "",
"version": "0.1.1",
"version": "0.2.0",
"main": "dist/index",

@@ -20,6 +20,7 @@ "types": "dist/index",

"dependencies": {
"@dbpath/utils": "0.1.1",
"@dbpath/postgres": "0.1.1",
"@dbpath/mysql": "0.1.1",
"@dbpath/oracle": "0.1.1"
"@dbpath/utils": "0.2.0",
"@dbpath/files": "0.2.0",
"@dbpath/postgres": "0.2.0",
"@dbpath/mysql": "0.2.0",
"@dbpath/oracle": "0.2.0"
},

@@ -26,0 +27,0 @@ "devDependencies": {

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