Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a globFileUploadParamsList option to set properties on uploaded f…
…iles
- Loading branch information
1 parent
37e26a6
commit f51697b
Showing
6 changed files
with
137 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,65 @@ | ||
import { Schema } from './schema'; | ||
import { GlobFileUploadParamsList, Schema } from './schema'; | ||
|
||
export const getAccessKeyId = (): string => { | ||
return process.env.NG_DEPLOY_AWS_ACCESS_KEY_ID as string || process.env.AWS_ACCESS_KEY_ID as string; | ||
return ( | ||
(process.env.NG_DEPLOY_AWS_ACCESS_KEY_ID as string) || | ||
(process.env.AWS_ACCESS_KEY_ID as string) | ||
); | ||
}; | ||
|
||
export const getSecretAccessKey = (): string => { | ||
return process.env.NG_DEPLOY_AWS_SECRET_ACCESS_KEY as string || process.env.AWS_SECRET_ACCESS_KEY as string; | ||
return ( | ||
(process.env.NG_DEPLOY_AWS_SECRET_ACCESS_KEY as string) || | ||
(process.env.AWS_SECRET_ACCESS_KEY as string) | ||
); | ||
}; | ||
|
||
export const getBucket = (builderConfig: Schema): string => { | ||
return process.env.NG_DEPLOY_AWS_BUCKET || (builderConfig.bucket as string); | ||
}; | ||
|
||
export const getRegion = (builderConfig: Schema): string => { | ||
return process.env.NG_DEPLOY_AWS_REGION || (builderConfig.region as string) || process.env.AWS_DEFAULT_REGION; | ||
return ( | ||
process.env.NG_DEPLOY_AWS_REGION || | ||
(builderConfig.region as string) || | ||
process.env.AWS_DEFAULT_REGION | ||
); | ||
}; | ||
|
||
export const getSubFolder = (builderConfig: Schema): string => { | ||
return process.env.NG_DEPLOY_AWS_SUB_FOLDER || (builderConfig.subFolder as string); | ||
return ( | ||
process.env.NG_DEPLOY_AWS_SUB_FOLDER || (builderConfig.subFolder as string) | ||
); | ||
}; | ||
|
||
const validateGlobFileUploadParamsList = ( | ||
paramsList: GlobFileUploadParamsList | ||
) => Array.isArray(paramsList) && !paramsList.some((params) => !params.glob); | ||
|
||
export const getGlobFileUploadParamsList = ( | ||
builderConfig: Schema | ||
): GlobFileUploadParamsList => { | ||
let globFileUploadParamsList = []; | ||
try { | ||
globFileUploadParamsList = process.env | ||
.NG_DEPLOY_AWS_GLOB_FILE_UPLOAD_PARAMS_LIST | ||
? JSON.parse(process.env.NG_DEPLOY_AWS_GLOB_FILE_UPLOAD_PARAMS_LIST) | ||
: builderConfig.globFileUploadParamsList || []; | ||
} catch (e) { | ||
console.error( | ||
'Invalid JSON for NG_DEPLOY_AWS_GLOB_FILE_UPLOAD_PARAMS_LIST', | ||
e | ||
); | ||
} | ||
|
||
return validateGlobFileUploadParamsList(globFileUploadParamsList) | ||
? globFileUploadParamsList | ||
: []; | ||
}; | ||
|
||
export const getCfDistributionId = (builderConfig: Schema): string => { | ||
return process.env.NG_DEPLOY_AWS_CF_DISTRIBUTION_ID || (builderConfig.cfDistributionId as string); | ||
return ( | ||
process.env.NG_DEPLOY_AWS_CF_DISTRIBUTION_ID || | ||
(builderConfig.cfDistributionId as string) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters