28c8ac91bc
* update bindata on ui-v2/ changes * Revert "Remove GIT_SHA environment variable" This reverts commit f620f9aefd41362ce76c3a8e0f4addf402ee0ca2. * Revert "Hardcode in an app version for ember-cli-app-version" This reverts commit 5ae493d79b34ef2143d78a44c21a63623140bba8. * revert modtime change in #8712
163 lines
5.5 KiB
JavaScript
163 lines
5.5 KiB
JavaScript
'use strict';
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
module.exports = function (environment, $ = process.env) {
|
|
let ENV = {
|
|
modulePrefix: 'consul-ui',
|
|
environment,
|
|
rootURL: '/ui/',
|
|
locationType: 'auto',
|
|
// We use a complete dynamically (from Consul) configured
|
|
// torii provider. We provide this object here to
|
|
// prevent ember from giving a log message when starting ember up
|
|
torii: {},
|
|
EmberENV: {
|
|
FEATURES: {
|
|
// Here you can enable experimental features on an ember canary build
|
|
// e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
|
|
},
|
|
EXTEND_PROTOTYPES: {
|
|
// Prevent Ember Data from overriding Date.parse.
|
|
Date: false,
|
|
},
|
|
},
|
|
APP: {
|
|
// Here you can pass flags/options to your application instance
|
|
// when it is created
|
|
},
|
|
resizeServiceDefaults: {
|
|
injectionFactories: ['view', 'controller', 'component'],
|
|
},
|
|
};
|
|
// TODO: These should probably go onto APP
|
|
ENV = Object.assign({}, ENV, {
|
|
CONSUL_UI_DISABLE_REALTIME: typeof process.env.CONSUL_UI_DISABLE_REALTIME !== 'undefined',
|
|
CONSUL_UI_DISABLE_ANCHOR_SELECTION:
|
|
typeof process.env.CONSUL_UI_DISABLE_ANCHOR_SELECTION !== 'undefined',
|
|
CONSUL_COPYRIGHT_YEAR: (function (val) {
|
|
if (val) {
|
|
return val;
|
|
}
|
|
return require('child_process')
|
|
.execSync('git show -s --format=%ci HEAD')
|
|
.toString()
|
|
.trim()
|
|
.split('-')
|
|
.shift();
|
|
})(process.env.CONSUL_COPYRIGHT_YEAR),
|
|
CONSUL_GIT_SHA: (function (val) {
|
|
if (val) {
|
|
return val;
|
|
}
|
|
|
|
return require('child_process')
|
|
.execSync('git rev-parse --short HEAD')
|
|
.toString()
|
|
.trim();
|
|
})(process.env.CONSUL_GIT_SHA),
|
|
CONSUL_VERSION: (function (val) {
|
|
if (val) {
|
|
return val;
|
|
}
|
|
// see /scripts/dist.sh:8
|
|
const version_go = `${path.dirname(path.dirname(__dirname))}/version/version.go`;
|
|
const contents = fs.readFileSync(version_go).toString();
|
|
return contents
|
|
.split('\n')
|
|
.find(function (item, i, arr) {
|
|
return item.indexOf('Version =') !== -1;
|
|
})
|
|
.trim()
|
|
.split('"')[1];
|
|
})(process.env.CONSUL_VERSION),
|
|
CONSUL_BINARY_TYPE: process.env.CONSUL_BINARY_TYPE ? process.env.CONSUL_BINARY_TYPE : 'oss',
|
|
CONSUL_ACLS_ENABLED: false,
|
|
CONSUL_NSPACES_ENABLED: false,
|
|
CONSUL_SSO_ENABLED: false,
|
|
|
|
CONSUL_HOME_URL: 'https://www.consul.io',
|
|
CONSUL_REPO_ISSUES_URL: 'https://github.com/hashicorp/consul/issues/new/choose',
|
|
CONSUL_DOCS_URL: 'https://www.consul.io/docs',
|
|
CONSUL_DOCS_LEARN_URL: 'https://learn.hashicorp.com',
|
|
CONSUL_DOCS_API_URL: 'https://www.consul.io/api',
|
|
CONSUL_COPYRIGHT_URL: 'https://www.hashicorp.com',
|
|
});
|
|
const isTestLike = ['staging', 'test'].indexOf(environment) > -1;
|
|
const isDevLike = ['development', 'staging', 'test'].indexOf(environment) > -1;
|
|
const isProdLike = ['production', 'staging'].indexOf(environment) > -1;
|
|
switch (true) {
|
|
case environment === 'test':
|
|
ENV = Object.assign({}, ENV, {
|
|
locationType: 'none',
|
|
CONSUL_NSPACES_TEST: true,
|
|
CONSUL_NSPACES_ENABLED:
|
|
typeof $['CONSUL_NSPACES_ENABLED'] !== 'undefined'
|
|
? !!JSON.parse(String($['CONSUL_NSPACES_ENABLED']).toLowerCase())
|
|
: true,
|
|
CONSUL_SSO_ENABLED:
|
|
typeof $['CONSUL_SSO_ENABLED'] !== 'undefined'
|
|
? !!JSON.parse(String($['CONSUL_SSO_ENABLED']).toLowerCase())
|
|
: false,
|
|
'@hashicorp/ember-cli-api-double': {
|
|
'auto-import': false,
|
|
enabled: true,
|
|
endpoints: {
|
|
'/v1': '/node_modules/@hashicorp/consul-api-double/v1',
|
|
},
|
|
},
|
|
APP: Object.assign({}, ENV.APP, {
|
|
LOG_ACTIVE_GENERATION: false,
|
|
LOG_VIEW_LOOKUPS: false,
|
|
|
|
rootElement: '#ember-testing',
|
|
autoboot: false,
|
|
}),
|
|
});
|
|
break;
|
|
case environment === 'staging':
|
|
ENV = Object.assign({}, ENV, {
|
|
CONSUL_NSPACES_ENABLED: true,
|
|
CONSUL_SSO_ENABLED: true,
|
|
'@hashicorp/ember-cli-api-double': {
|
|
enabled: true,
|
|
endpoints: {
|
|
'/v1': '/node_modules/@hashicorp/consul-api-double/v1',
|
|
},
|
|
},
|
|
});
|
|
break;
|
|
case environment === 'production':
|
|
ENV = Object.assign({}, ENV, {
|
|
// These values are placeholders that are replaced when Consul renders
|
|
// the index.html based on runtime config. They can't use Go template
|
|
// syntax since this object ends up JSON and URLencoded in an HTML meta
|
|
// tag which obscured the Go template tag syntax.
|
|
//
|
|
// __RUNTIME_BOOL_Xxxx__ will be replaced with either "true" or "false"
|
|
// depending on whether the named variable is true or valse in the data
|
|
// returned from `uiTemplateDataFromConfig`.
|
|
CONSUL_ACLS_ENABLED: '__RUNTIME_BOOL_ACLsEnabled__',
|
|
CONSUL_SSO_ENABLED: '__RUNTIME_BOOL_SSOEnabled__',
|
|
CONSUL_NSPACES_ENABLED: '__RUNTIME_BOOL_NSpacesEnabled__',
|
|
});
|
|
break;
|
|
}
|
|
switch (true) {
|
|
case isTestLike:
|
|
ENV = Object.assign({}, ENV, {
|
|
CONSUL_ACLS_ENABLED: true,
|
|
// 'APP': Object.assign({}, ENV.APP, {
|
|
// 'LOG_RESOLVER': true,
|
|
// 'LOG_ACTIVE_GENERATION': true,
|
|
// 'LOG_TRANSITIONS': true,
|
|
// 'LOG_TRANSITIONS_INTERNAL': true,
|
|
// 'LOG_VIEW_LOOKUPS': true,
|
|
// })
|
|
});
|
|
break;
|
|
case isProdLike:
|
|
break;
|
|
}
|
|
return ENV;
|
|
};
|