netlify-plugin-dm
Advanced tools
Comparing version 1.0.0 to 1.0.1
29
index.js
@@ -1,16 +0,33 @@ | ||
const { getRoutes } = require('./routes'); | ||
const { getRoutes, updateRoute } = require('./routes'); | ||
const fs = require('fs') | ||
const yaml = require('js-yaml'); | ||
const { VGS_CLIENT_ID, VGS_CLIENT_SECRET, VGS_VAULT_ID} = process.env; | ||
async function run() { | ||
console.log('run'); | ||
const routes = await getRoutes('tntdx8oynfd'); | ||
console.log('routes', routes); | ||
// const routes = await getRoutes('tntdx8oynfd'); | ||
// console.log('routes', routes); | ||
} | ||
function getRouteConfig(path = './vgs/routes.yaml') { | ||
if (fs.existsSync(path)) { | ||
return yaml.load(fs.readFileSync(path, 'utf8')); | ||
} else { | ||
return null; | ||
} | ||
} | ||
module.exports = { | ||
onPreBuild: async ({ constants }) => { | ||
onPreBuild: async (params) => { | ||
console.log("Hello world from onPreBuild event!") | ||
console.log('constants', constants); | ||
console.log('params', params); | ||
await run(); | ||
// await run(); | ||
const routeConfig = getRouteConfig(); | ||
if(routeConfig) { | ||
await updateRoute(VGS_VAULT_ID, routeConfig); | ||
} | ||
}, | ||
} |
{ | ||
"name": "netlify-plugin-dm", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -8,2 +8,3 @@ "main": "index.js", | ||
"axios": "^0.25.0", | ||
"js-yaml": "^4.1.0", | ||
"simple-oauth2": "^4.3.0" | ||
@@ -10,0 +11,0 @@ }, |
@@ -25,3 +25,3 @@ const { | ||
async function createInboundRoute(vaultApiUrl, tenantId, route, refreshToken) { | ||
async function createRoute(vaultApiUrl, tenantId, route, refreshToken) { | ||
const accessToken = await getAccessToken(refreshToken); | ||
@@ -40,14 +40,18 @@ | ||
async function updateInboundRoute(vaultApiUrl, tenantId, route, refreshToken) { | ||
const accessToken = await getAccessToken(refreshToken); | ||
const url = `${vaultApiUrl}/rule-chains/${route.id}`; | ||
async function updateRoute(tenantId, route) { | ||
console.log('updateRoute', route.data) | ||
const accessToken = await getAccessToken(); | ||
const url = `${vaultApiUrl}/rule-chains/${route.data[0].id}`; | ||
const params = { | ||
method: 'PUT', | ||
headers: makeHeaders(accessToken, tenantId), | ||
data: route, | ||
data: route.data, | ||
}; | ||
const response = await fetchJSONApi(url, params); | ||
return response.data.data; | ||
try { | ||
const response = await fetchJSONApi(url, params); | ||
return response.data.data; | ||
} catch (error) { | ||
console.log('updateRoute error', error); | ||
} | ||
} | ||
@@ -57,4 +61,4 @@ | ||
getRoutes, | ||
updateInboundRoute, | ||
createInboundRoute, | ||
updateRoute, | ||
createRoute, | ||
} |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
4796
133
3
3
+ Addedjs-yaml@^4.1.0
+ Addedargparse@2.0.1(transitive)
+ Addedjs-yaml@4.1.0(transitive)