mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-25 09:23:17 +01:00
chore: removed legacy code
This commit is contained in:
parent
faf8581ddf
commit
c6fef2f1be
@ -2,8 +2,8 @@ const _ = require('lodash');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const chokidar = require('chokidar');
|
||||
const { hasBruExtension, writeFile } = require('../utils/filesystem');
|
||||
const { bruToEnvJson, envJsonToBru, bruToJson, jsonToBru } = require('../bru');
|
||||
const { hasBruExtension } = require('../utils/filesystem');
|
||||
const { bruToEnvJson, bruToJson } = require('../bru');
|
||||
const { dotenvToJson } = require('@usebruno/lang');
|
||||
|
||||
const { uuid } = require('../utils/common');
|
||||
@ -15,13 +15,6 @@ const EnvironmentSecretsStore = require('../store/env-secrets');
|
||||
|
||||
const environmentSecretsStore = new EnvironmentSecretsStore();
|
||||
|
||||
const isJsonEnvironmentConfig = (pathname, collectionPath) => {
|
||||
const dirname = path.dirname(pathname);
|
||||
const basename = path.basename(pathname);
|
||||
|
||||
return dirname === collectionPath && basename === 'environments.json';
|
||||
};
|
||||
|
||||
const isDotEnvFile = (pathname, collectionPath) => {
|
||||
const dirname = path.dirname(pathname);
|
||||
const basename = path.basename(pathname);
|
||||
@ -198,32 +191,6 @@ const add = async (win, pathname, collectionUid, collectionPath) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (isJsonEnvironmentConfig(pathname, collectionPath)) {
|
||||
try {
|
||||
const dirname = path.dirname(pathname);
|
||||
const bruContent = fs.readFileSync(pathname, 'utf8');
|
||||
|
||||
const jsonData = JSON.parse(bruContent);
|
||||
|
||||
const envDirectory = path.join(dirname, 'environments');
|
||||
if (!fs.existsSync(envDirectory)) {
|
||||
fs.mkdirSync(envDirectory);
|
||||
}
|
||||
|
||||
for (const env of jsonData) {
|
||||
const bruEnvFilename = path.join(envDirectory, `${env.name}.bru`);
|
||||
const bruContent = envJsonToBru(env);
|
||||
await writeFile(bruEnvFilename, bruContent);
|
||||
}
|
||||
|
||||
await fs.unlinkSync(pathname);
|
||||
} catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBruEnvironmentConfig(pathname, collectionPath)) {
|
||||
return addEnvironmentFile(win, pathname, collectionUid, collectionPath);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
const _ = require('lodash');
|
||||
const { bruToJsonV2, jsonToBruV2, bruToEnvJsonV2, envJsonToBruV2 } = require('@usebruno/lang');
|
||||
const { each } = require('lodash');
|
||||
|
||||
const bruToEnvJson = (bru) => {
|
||||
try {
|
||||
@ -10,7 +9,7 @@ const bruToEnvJson = (bru) => {
|
||||
// this need to be evaluated and safely removed
|
||||
// i don't see it being used in schema validation
|
||||
if (json && json.variables && json.variables.length) {
|
||||
each(json.variables, (v) => (v.type = 'text'));
|
||||
_.each(json.variables, (v) => (v.type = 'text'));
|
||||
}
|
||||
|
||||
return json;
|
||||
|
Loading…
Reference in New Issue
Block a user