@wildberries/service-cdn-uploader
Advanced tools
Comparing version 0.0.8 to 0.0.9
62
index.js
@@ -11,3 +11,9 @@ /* eslint-disable import/no-unresolved */ | ||
const pathToStaticFolder = path.join(process.cwd(), process.argv[2]); | ||
const pathUploadPostFix = path.join(process.cwd(), process.argv[3]) || ''; | ||
if (!pathToStaticFolder) { | ||
console.error('pathToStaticFolder parameter is empty'); | ||
process.exit(1); | ||
} | ||
const renderGoAuth = process.env.CDN_API_TOKEN; | ||
@@ -17,10 +23,7 @@ const APP_VERSION = process.env.CI_COMMIT_TAG; | ||
const WB_STATIC_URL = process.env.WB_STATIC_URL; | ||
const SERVICE_URL_DP = process.env.SERVICE_URL_DP; | ||
const IS_STAGE = process.env.IS_STAGE; | ||
const IS_DLDEVEL = process.env.IS_DLDEVEL; | ||
const IS_DEV = process.env.IS_DEV; | ||
const SERVICE_URL = process.env.SERVICE_URL; | ||
// FOR DEBUGGING | ||
// const WB_STATIC_URL = 'https://mstatic.wbstatic.net'; | ||
// const SERVICE_URL_DP = 'http://api.render-go.svc.k8s.datapro'; | ||
// const SERVICE_URL = 'http://api.render-go.svc.k8s.datapro'; | ||
// const APP_VERSION = 'v0.0.1'; | ||
@@ -34,5 +37,18 @@ // const APP_STATIC_NAMESPACE = 'suppliers-portal-business-card-frontend'; | ||
console.log('WB_STATIC_URL', WB_STATIC_URL); | ||
console.log('SERVICE_URL_DP', SERVICE_URL_DP); | ||
console.log('SERVICE_URL', SERVICE_URL); | ||
console.log('pathToStaticFolder', pathToStaticFolder); | ||
if ( | ||
!WB_STATIC_URL || | ||
!SERVICE_URL || | ||
!renderGoAuth || | ||
!APP_VERSION || | ||
!APP_STATIC_NAMESPACE | ||
) { | ||
console.error('NOT CORRECT VARIABLES'); | ||
process.exit(1); | ||
} | ||
const newStaticPath = `${APP_STATIC_NAMESPACE}/${APP_VERSION}${pathUploadPostFix}`; | ||
const fetchFile = ({ formData, fileName, staticPath, renderGoUrl, DC }) => | ||
@@ -68,3 +84,2 @@ fetch(renderGoUrl, { | ||
if (res.status === 200) { | ||
// eslint-disable-next-line no-console | ||
console.log(`File ${url} is available`); | ||
@@ -82,32 +97,3 @@ } else { | ||
const getNewStaticPath = () => { | ||
const BASE_PATH = `${APP_STATIC_NAMESPACE}/${APP_VERSION}`; | ||
if (IS_STAGE) { | ||
return `${BASE_PATH}-stage`; | ||
} | ||
if (IS_DLDEVEL) { | ||
return `${BASE_PATH}-dldevel`; | ||
} | ||
if (IS_DEV) { | ||
return `${BASE_PATH}-dev`; | ||
} | ||
return BASE_PATH; | ||
}; | ||
const pushStatic = async () => { | ||
if ( | ||
!WB_STATIC_URL || | ||
!SERVICE_URL_DP || | ||
!renderGoAuth || | ||
!APP_VERSION || | ||
!APP_STATIC_NAMESPACE | ||
) { | ||
console.error('NOT CORRECT VARIABLES'); | ||
process.exit(1); | ||
} | ||
await glob( | ||
@@ -127,4 +113,2 @@ `${pathToStaticFolder}/**/*`, | ||
files.map(async file => { | ||
const newStaticPath = getNewStaticPath(); | ||
const staticPath = file.replace( | ||
@@ -148,3 +132,3 @@ new RegExp(`(${pathToStaticFolder}/umd)|(${pathToStaticFolder})`), | ||
DC: 'DP', | ||
renderGoUrl: SERVICE_URL_DP, | ||
renderGoUrl: SERVICE_URL, | ||
}); | ||
@@ -151,0 +135,0 @@ |
{ | ||
"name": "@wildberries/service-cdn-uploader", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"main": "./index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
7
188392
4981