refactor(plg): updated UPC_ENV values

This commit is contained in:
Zack Spear
2020-10-15 21:02:37 -07:00
parent d62ec858d0
commit 8d1f7c561b

View File

@@ -1240,10 +1240,10 @@ unraid-user-profile {
<![CDATA[
<!-- RegWiz -->
<script type="text/javascript">
const UPC_ENV = localStorage.getItem('UPC_ENV') ? localStorage.getItem('UPC_ENV') : 'prod'; // @TODO - it would be great if this was auto-set when PLG was built
const UPC_ENV = localStorage.getItem('UPC_ENV') ? localStorage.getItem('UPC_ENV') : 'production'; // @TODO - it would be great if this was auto-set when PLG was built
const VUE_CDN_PREFIX = 'https://cdn.jsdelivr.net/npm/vue@2.6.12';
const injectJS = (src) => {
if (UPC_ENV !== 'prod') console.debug('[injectJS]', src);
if (UPC_ENV !== 'production') console.debug('[injectJS]', src);
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = src;
@@ -1253,15 +1253,15 @@ const injectJS = (src) => {
let vueFile = `${VUE_CDN_PREFIX}/dist/vue.min.js`;
let wcEntryFile = 'https://registration.unraid.net/wc/unraid.min.js';
// determine what source we should use
if (UPC_ENV !== 'prod') console.debug('[UPC_ENV]', UPC_ENV);
if (UPC_ENV !== 'production') console.debug('[UPC_ENV]', UPC_ENV);
switch (UPC_ENV) {
case 'stage':
// min version of stage
case 'staging':
// min version of staging
vueFile = `${VUE_CDN_PREFIX}/dist/vue.min.js`;
wcEntryFile = 'https://registration-dev.unraid.net/wc/unraid.min.js';
break;
case 'stage-debug':
// non-min version of stage
case 'staging-debug':
// non-min version of staging
vueFile = `${VUE_CDN_PREFIX}/dist/vue.js`;
wcEntryFile = 'https://registration-dev.unraid.net/wc/unraid.js';
break;
@@ -1270,7 +1270,7 @@ switch (UPC_ENV) {
vueFile = '<?autov('/webGui/javascript/vue.js') ?>';
wcEntryFile = '<?autov('/webGui/wc/unraid.min.js') ?>'; // @TODO / WIP - non-min files aren't downloaded just yet.
break;
case 'dev':
case 'development':
// local filesystem Vue.js + external "local" dev server for RegWiz development
vueFile = '<?autov('/webGui/javascript/vue.js') ?>';
wcEntryFile = 'https://launchpad.unraid.test:6969/wc/unraid.js';
@@ -1291,7 +1291,7 @@ let checkForVue = setInterval(() => {
// fallback if we take too long injecting the above
setTimeout(() => {
if (!window.Vue) {
if (UPC_ENV !== 'prod') console.debug('[UPC] fallback to filesystem JS');
if (UPC_ENV !== 'production') console.debug('[UPC] fallback to filesystem JS');
clearInterval(checkForVue); // stop initial check
injectJS("<?autov('/webGui/javascript/vue.min.js') ?>");
checkForVue = setInterval(() => { // reset check