@@ -131,11 +131,12 @@ export const formatEnvelopeData = ({ context = 'dev', envelopeItems = [], scope
131
131
* @param {string } context - The deploy context or branch of the environment variable
132
132
* @param {object } env - The dictionary of environment variables
133
133
* @param {string } key - If present, fetch a single key (case-sensitive)
134
+ * @param {boolean } raw - Return a dictionary of raw key/value pairs for only the account and site sources
134
135
* @param {enum<any,builds,functions,runtime,post_processing> } scope - The scope of the environment variables
135
136
* @param {object } siteInfo - The site object
136
137
* @returns {object } An object of environment variables keys and their metadata
137
138
*/
138
- export const getEnvelopeEnv = async ( { api, context = 'dev' , env, key = '' , scope = 'any' , siteInfo } ) => {
139
+ export const getEnvelopeEnv = async ( { api, context = 'dev' , env, key = '' , raw = false , scope = 'any' , siteInfo } ) => {
139
140
const { account_slug : accountId , id : siteId } = siteInfo
140
141
141
142
const [ accountEnvelopeItems , siteEnvelopeItems ] = await Promise . all ( [
@@ -145,6 +146,18 @@ export const getEnvelopeEnv = async ({ api, context = 'dev', env, key = '', scop
145
146
146
147
const accountEnv = formatEnvelopeData ( { context, envelopeItems : accountEnvelopeItems , scope, source : 'account' } )
147
148
const siteEnv = formatEnvelopeData ( { context, envelopeItems : siteEnvelopeItems , scope, source : 'ui' } )
149
+
150
+ if ( raw ) {
151
+ const entries = Object . entries ( { ...accountEnv , ...siteEnv } )
152
+ return entries . reduce (
153
+ ( obj , [ envVarKey , metadata ] ) => ( {
154
+ ...obj ,
155
+ [ envVarKey ] : metadata . value ,
156
+ } ) ,
157
+ { } ,
158
+ )
159
+ }
160
+
148
161
const generalEnv = filterEnvBySource ( env , 'general' )
149
162
const internalEnv = filterEnvBySource ( env , 'internal' )
150
163
const addonsEnv = filterEnvBySource ( env , 'addons' )
0 commit comments