UNPKG

six-widget-buildsupport

Version:

SIX Widgets buildsupport

2 lines 2.9 kB
#!/usr/bin/env node "use strict";var n=require("child_process").exec,t=require("semver"),e=require("fs");function c(e,o,s){console.log("> Pushing widget version "+o),n('AWS_DEFAULT_REGION=eu-central-1 aws s3 cp --exclude="*" --include="*.js" --recursive dist/ s3://cdn.webfg.se/js/'+e+"/"+o+"/ --cache-control max-age="+s+' --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --metadata-directive REPLACE --content-type "application/javascript; charset=utf-8"',function(e,o){e?console.error(e):console.log(o)})}function a(e){console.log("> Pushing translations"),n('AWS_DEFAULT_REGION=eu-central-1 aws s3 cp --exclude="*" --include="*.json" --recursive dist/ s3://solutions-cdn.six.se/locales/ --cache-control max-age='+e+' --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --metadata-directive REPLACE --content-type "application/json; charset=utf-8"',function(e,o){e?console.error(e):console.log(o)})}function r(){console.log("> Pushing documentation");n('AWS_DEFAULT_REGION=eu-central-1 aws s3 cp --exclude="*" --include="*.html" --recursive dist/ s3://cdn.webfg.se/docs --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --metadata-directive REPLACE --content-type "text/html; charset=utf-8"',function(e,o){e?console.error(e):console.log(o)})}function s(e,o,s){console.log("> Pushing widget documentation for version "+o),n("AWS_DEFAULT_REGION=eu-central-1 aws s3 cp dist/*.md s3://cdn.webfg.se/docs/"+e+"/"+o+"/ --cache-control max-age="+s+' --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --metadata-directive REPLACE --content-type "text/markdown; charset=utf-8"',function(e,o){e?console.error(e):console.log(o)}),n("AWS_DEFAULT_REGION=eu-central-1 aws s3 cp CHANGELOG.md s3://cdn.webfg.se/docs/"+e+"/"+o+"/ --cache-control max-age="+s+' --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --metadata-directive REPLACE --content-type "text/markdown; charset=utf-8"',function(e,o){e?console.error(e):console.log(o)})}var i=function(){var e=process.env.PACKAGE_NAME||process.env.npm_package_name,o=process.env.PACKAGE_VERSION||process.env.npm_package_version;console.log('Pushing "'+e+'" version '+o+" to S3"),s(e,o,0),s(e,t.major(o)+"."+t.minor(o),0),s(e,t.major(o),0)},o=function(){var o=process.env.PACKAGE_NAME||process.env.npm_package_name,s=process.env.PACKAGE_VERSION||process.env.npm_package_version;"true"===process.env.PUSH_CDN?"six-widget-translations"===o?a(1200):"six-widget-documentation"===o?r():e.stat("./dist",function(e){e?console.log('No directory "dist" found. Will not push content to CDN.'):(console.log('Pushing "'+o+'" version '+s+" to S3"),c(o,s,86400),c(o,t.major(s)+"."+t.minor(s),1200),c(o,t.major(s),1200),i())}):console.log('PUSH_CDN is not set to "true" will not publish to cdn. To fix: export PUSH_CDN=true')};module.exports={pushWidgetDocumentation:i,push_cdn:o},module.parent||o();