@rancher/shell 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/images/providers/outscale.svg +19 -0
- package/assets/styles/app.scss +1 -1
- package/assets/styles/base/_basic.scss +18 -0
- package/assets/styles/base/_mixins.scss +0 -11
- package/assets/styles/base/_variables.scss +2 -4
- package/assets/styles/fonts/_fontstack.scss +11 -11
- package/assets/styles/global/_button.scss +12 -2
- package/assets/styles/vendor/vue-js-modal.scss +3 -3
- package/assets/translations/en-us.yaml +113 -22
- package/assets/translations/zh-hans.yaml +113 -24
- package/babel.config.js +13 -0
- package/chart/gatekeeper.vue +78 -0
- package/chart/istio.vue +135 -112
- package/chart/logging/index.vue +13 -4
- package/chart/monitoring/index.vue +15 -5
- package/chart/monitoring/steps/uninstall-v1.vue +2 -2
- package/chart/rancher-backup/index.vue +10 -3
- package/cloud-credential/aws.vue +1 -1
- package/cloud-credential/digitalocean.vue +1 -1
- package/cloud-credential/gcp.vue +1 -1
- package/cloud-credential/generic.vue +2 -2
- package/cloud-credential/linode.vue +1 -1
- package/cloud-credential/pnap.vue +1 -1
- package/components/ActionMenu.vue +3 -4
- package/components/AssignTo.vue +1 -1
- package/components/AsyncButton.vue +1 -1
- package/components/BannerGraphic.vue +1 -1
- package/components/BrandImage.vue +1 -4
- package/components/ButtonDropdown.vue +2 -3
- package/components/Carousel.vue +85 -37
- package/components/ChartPsp.vue +76 -0
- package/components/CruResource.vue +6 -2
- package/components/DashboardMetrics.vue +12 -10
- package/components/DetailText.vue +1 -1
- package/components/DisableAuthProviderModal.vue +1 -1
- package/components/EmberPage.vue +1 -1
- package/components/EtcdInfoBanner.vue +12 -7
- package/components/ExplorerMembers.vue +101 -6
- package/components/ExplorerProjectsNamespaces.vue +46 -3
- package/components/FileDiff.vue +6 -7
- package/components/GrafanaDashboard.vue +27 -23
- package/components/LazyImage.vue +10 -12
- package/components/LogItem.vue +1 -1
- package/components/Markdown.vue +1 -1
- package/components/PromptRemove.vue +2 -2
- package/components/PromptRestore.vue +1 -1
- package/components/ResourceDetail/Masthead.vue +16 -0
- package/components/ResourceDetail/index.vue +21 -4
- package/components/ResourceList/index.vue +1 -1
- package/components/ResourceTable.vue +4 -1
- package/components/SingleClusterInfo.vue +2 -2
- package/components/SortableTable/THead.vue +1 -1
- package/components/SortableTable/index.vue +28 -13
- package/components/SortableTable/selection.js +58 -50
- package/components/Wizard.vue +4 -2
- package/components/__tests__/AsyncButton.test.ts +3 -1
- package/components/__tests__/ChartPsp.test.ts +75 -0
- package/components/__tests__/CruResource.test.ts +3 -1
- package/components/auth/Principal.vue +1 -1
- package/components/auth/RoleDetailEdit.vue +2 -2
- package/components/fleet/FleetBundles.vue +3 -1
- package/components/fleet/FleetClusters.vue +1 -2
- package/components/fleet/FleetIntro.vue +9 -1
- package/components/fleet/FleetNoWorkspaces.vue +62 -0
- package/components/fleet/FleetSummary.vue +7 -1
- package/components/form/HookOption.vue +14 -10
- package/components/form/LabeledSelect.vue +14 -11
- package/components/form/Labels.vue +32 -27
- package/components/form/MatchExpressions.vue +19 -4
- package/components/form/Members/ClusterPermissionsEditor.vue +32 -7
- package/components/form/NameNsDescription.vue +32 -46
- package/components/form/ProjectMemberEditor.vue +46 -21
- package/components/form/ResourceSelector.vue +1 -1
- package/components/form/SecretSelector.vue +5 -1
- package/components/form/ServiceNameSelect.vue +1 -1
- package/components/form/SimpleSecretSelector.vue +9 -9
- package/components/form/Tolerations.vue +4 -1
- package/components/form/ValueFromResource.vue +14 -9
- package/components/form/WorkloadPorts.vue +2 -2
- package/components/form/__tests__/LabeledSelect.test.ts +138 -0
- package/components/form/__tests__/NameNsDescription.ts +59 -0
- package/components/formatter/InternalExternalIP.vue +6 -0
- package/components/formatter/InvolvedObjectLink.vue +54 -0
- package/components/formatter/Link.vue +20 -4
- package/components/formatter/LinkName.vue +6 -1
- package/components/formatter/ServiceTargets.vue +1 -1
- package/components/formatter/WorkloadHealthScale.vue +8 -2
- package/components/nav/Group.vue +2 -2
- package/components/nav/NamespaceFilter.vue +23 -11
- package/components/nav/TopLevelMenu.vue +2 -4
- package/components/nav/Type.vue +1 -1
- package/components/nav/WorkspaceSwitcher.vue +46 -5
- package/components/nuxt/nuxt-build-indicator.vue +143 -0
- package/components/nuxt/nuxt-child.js +122 -0
- package/components/nuxt/nuxt-error.vue +98 -0
- package/components/nuxt/nuxt-link.client.js +98 -0
- package/components/nuxt/nuxt-link.server.js +16 -0
- package/components/nuxt/nuxt-loading.vue +154 -0
- package/components/nuxt/nuxt.js +101 -0
- package/config/labels-annotations.js +17 -0
- package/config/middleware.js +12 -0
- package/config/product/auth.js +3 -2
- package/config/product/explorer.js +34 -6
- package/config/product/fleet.js +2 -0
- package/config/query-params.js +1 -0
- package/config/router.js +414 -0
- package/config/store.js +181 -0
- package/config/table-headers.js +54 -12
- package/config/types.js +18 -8
- package/config/uiplugins.js +30 -0
- package/content/docs/en-us/whats-new.md +10 -0
- package/content/docs/zh-hans/whats-new.md +11 -1
- package/core/plugin-routes.ts +23 -0
- package/core/plugin.ts +4 -2
- package/core/types.ts +258 -1
- package/creators/app/app.package.json +2 -1
- package/creators/app/files/.eslintrc.js +1 -1
- package/creators/app/files/babel.config.js +1 -18
- package/creators/app/files/tsconfig.json +0 -1
- package/creators/app/files/vue.config.js +6 -0
- package/creators/app/init +5 -5
- package/creators/pkg/files/.github/workflows/build-extension.yml +110 -0
- package/creators/pkg/files/tsconfig.json +0 -1
- package/creators/pkg/init +35 -4
- package/creators/pkg/pkg.package.json +3 -3
- package/creators/update/init +1 -1
- package/detail/constraints.gatekeeper.sh.constraint.vue +34 -17
- package/detail/fleet.cattle.io.clustergroup.vue +7 -1
- package/detail/fleet.cattle.io.gitrepo.vue +19 -11
- package/detail/harvesterhci.io.management.cluster.vue +3 -3
- package/detail/provisioning.cattle.io.cluster.vue +54 -12
- package/detail/workload/index.vue +3 -3
- package/dialog/AddClusterMemberDialog.vue +1 -1
- package/dialog/AddProjectMemberDialog.vue +2 -2
- package/dialog/AddonConfigConfirmationDialog.vue +27 -15
- package/dialog/DiagnosticTimingsDialog.vue +1 -1
- package/dialog/ForceMachineRemoveDialog.vue +1 -1
- package/dialog/GenericPrompt.vue +18 -6
- package/dialog/RotateEncryptionKeyDialog.vue +1 -1
- package/dialog/SaveAsRKETemplateDialog.vue +1 -1
- package/dialog/ScaleMachineDownDialog.vue +1 -1
- package/edit/auth/github.vue +8 -8
- package/edit/auth/googleoauth.vue +5 -5
- package/edit/auth/ldap/index.vue +1 -1
- package/edit/auth/oidc.vue +1 -1
- package/edit/auth/saml.vue +1 -1
- package/edit/cis.cattle.io.clusterscan.vue +1 -1
- package/edit/fleet.cattle.io.clustergroup.vue +6 -4
- package/edit/fleet.cattle.io.gitrepo.vue +32 -4
- package/edit/helm.cattle.io.projecthelmchart.vue +5 -1
- package/edit/logging.banzaicloud.io.output/index.vue +18 -5
- package/edit/logging.banzaicloud.io.output/providers/loki.vue +1 -0
- package/edit/management.cattle.io.fleetworkspace.vue +141 -6
- package/edit/management.cattle.io.podsecurityadmissionconfigurationtemplate.vue +4 -1
- package/edit/management.cattle.io.setting.vue +1 -1
- package/edit/monitoring.coreos.com.alertmanagerconfig/types/webhook.vue +2 -2
- package/edit/monitoring.coreos.com.receiver/tls.vue +18 -18
- package/edit/monitoring.coreos.com.receiver/types/webhook.banner.vue +4 -4
- package/edit/monitoring.coreos.com.receiver/types/webhook.vue +1 -1
- package/edit/namespace.vue +14 -10
- package/edit/networking.k8s.io.networkpolicy/PolicyRuleTarget.vue +126 -45
- package/edit/networking.k8s.io.networkpolicy/index.vue +1 -1
- package/edit/provisioning.cattle.io.cluster/MachinePool.vue +21 -4
- package/edit/provisioning.cattle.io.cluster/RegistryConfigs.vue +1 -0
- package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +202 -2
- package/edit/provisioning.cattle.io.cluster/import.vue +23 -25
- package/edit/provisioning.cattle.io.cluster/rke2.vue +344 -102
- package/edit/resources.cattle.io.backup.vue +1 -1
- package/edit/service.vue +1 -1
- package/edit/storage.k8s.io.storageclass/provisioners/driver.harvesterhci.io.vue +2 -2
- package/edit/workload/__tests__/Job.test.ts +3 -1
- package/edit/workload/index.vue +8 -3
- package/edit/workload/mixins/workload.js +22 -7
- package/edit/workload/storage/Mount.vue +3 -3
- package/initialize/App.js +206 -0
- package/initialize/client.js +863 -0
- package/initialize/index.js +364 -0
- package/layouts/default.vue +7 -3
- package/layouts/standalone.vue +13 -0
- package/list/catalog.cattle.io.clusterrepo.vue +1 -0
- package/list/fleet.cattle.io.bundle.vue +6 -3
- package/list/fleet.cattle.io.clusterregistrationtoken.vue +3 -1
- package/list/fleet.cattle.io.gitrepo.vue +44 -5
- package/list/management.cattle.io.fleetworkspace.vue +45 -0
- package/list/node.vue +69 -16
- package/list/provisioning.cattle.io.cluster.vue +30 -1
- package/list/rbac.authorization.k8s.io.clusterrolebinding.vue +48 -0
- package/list/workload.vue +6 -4
- package/machine-config/azure.vue +97 -38
- package/middleware/authenticated.js +34 -0
- package/mixins/chart.js +101 -2
- package/mixins/fetch.client.js +95 -0
- package/mixins/fetch.server.js +73 -0
- package/mixins/labeled-form-element.ts +2 -2
- package/mixins/resource-fetch.js +2 -2
- package/models/apps.statefulset.js +28 -0
- package/models/cluster/node.js +23 -2
- package/models/cluster.x-k8s.io.machine.js +4 -2
- package/models/clusterroletemplatebinding.js +7 -0
- package/models/constraints.gatekeeper.sh.constraint.js +46 -0
- package/models/fleet.cattle.io.cluster.js +19 -10
- package/models/fleet.cattle.io.gitrepo.js +7 -2
- package/models/management.cattle.io.cluster.js +1 -1
- package/models/management.cattle.io.fleetworkspace.js +12 -0
- package/models/management.cattle.io.gitreporestriction.js +5 -0
- package/models/management.cattle.io.podsecurityadmissionconfigurationtemplate.js +3 -0
- package/models/pod.js +4 -0
- package/models/provisioning.cattle.io.cluster.js +7 -5
- package/models/rbac.authorization.k8s.io.clusterrolebinding.js +16 -0
- package/models/rbac.authorization.k8s.io.rolebinding.js +16 -0
- package/package.json +13 -21
- package/pages/auth/setup.vue +2 -2
- package/pages/c/_cluster/apps/charts/__tests__/install.helper.test.ts +33 -0
- package/pages/c/_cluster/apps/charts/chart.vue +4 -4
- package/pages/c/_cluster/apps/charts/install.helpers.js +26 -0
- package/pages/c/_cluster/apps/charts/install.vue +98 -102
- package/pages/c/_cluster/explorer/EventsTable.vue +5 -19
- package/pages/c/_cluster/explorer/index.vue +29 -25
- package/pages/c/_cluster/explorer/tools/index.vue +8 -8
- package/pages/c/_cluster/fleet/index.vue +95 -34
- package/pages/c/_cluster/gatekeeper/index.vue +1 -1
- package/pages/c/_cluster/istio/index.vue +5 -5
- package/pages/c/_cluster/manager/cloudCredential/index.vue +1 -1
- package/pages/c/_cluster/monitoring/index.vue +7 -0
- package/pages/c/_cluster/uiplugins/InstallDialog.vue +8 -8
- package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +20 -7
- package/pages/c/_cluster/uiplugins/index.vue +49 -17
- package/pages/diagnostic.vue +32 -25
- package/pages/home.vue +9 -4
- package/pages/index.vue +10 -1
- package/pages/rio/mesh.vue +1 -2
- package/pkg/tsconfig.json +0 -1
- package/plugins/clean-html-directive.js +34 -0
- package/plugins/dashboard-store/actions.js +32 -9
- package/plugins/dashboard-store/index.js +1 -1
- package/plugins/dashboard-store/mutations.js +5 -2
- package/plugins/dashboard-store/resource-class.js +8 -1
- package/plugins/plugin.js +0 -14
- package/plugins/portal-vue.js +4 -0
- package/plugins/steve/mutations.js +3 -2
- package/plugins/steve/steve-description-class.js +5 -1
- package/plugins/steve/subscribe.js +63 -54
- package/plugins/steve-create-worker.js +14 -0
- package/promptRemove/management.cattle.io.globalrole.vue +2 -2
- package/promptRemove/management.cattle.io.project.vue +2 -2
- package/promptRemove/management.cattle.io.roletemplate.vue +2 -2
- package/promptRemove/pod.vue +1 -1
- package/public/index.html +65 -0
- package/rancher-components/components/Banner/Banner.test.ts +7 -1
- package/rancher-components/components/Banner/Banner.vue +2 -1
- package/rancher-components/components/Form/Checkbox/Checkbox.vue +2 -0
- package/rancher-components/components/Form/Radio/RadioButton.test.ts +31 -0
- package/rancher-components/components/Form/Radio/RadioButton.vue +14 -3
- package/scripts/build-pkg.sh +1 -0
- package/scripts/clean +6 -0
- package/scripts/extension/bundle +58 -0
- package/scripts/extension/helmpatch +89 -0
- package/scripts/extension/publish +333 -0
- package/scripts/serve-pkgs +6 -2
- package/scripts/test-plugins-build.sh +4 -0
- package/store/__tests__/index.test.ts +110 -0
- package/store/index.js +145 -58
- package/store/type-map.js +6 -2
- package/tsconfig.default.json +36 -0
- package/tsconfig.json +23 -0
- package/types/rancher/index.d.ts +2 -0
- package/types/shell/index.d.ts +466 -320
- package/utils/__tests__/grafana.test.ts +44 -0
- package/utils/__tests__/string.test.ts +12 -0
- package/utils/auth.js +65 -0
- package/utils/axios.js +190 -0
- package/utils/cookie-universal-nuxt.js +10 -0
- package/utils/dom.js +15 -0
- package/utils/grafana.js +35 -16
- package/utils/monitoring.js +2 -1
- package/utils/nuxt.js +659 -0
- package/utils/position.js +5 -8
- package/utils/router.scrollBehavior.js +80 -0
- package/utils/select.js +1 -3
- package/utils/socket.js +1 -0
- package/utils/string.js +13 -0
- package/utils/time.js +9 -0
- package/vue.config.js +690 -0
- package/chart/rancher-alerting-drivers.vue +0 -53
- package/chart/rancher-gatekeeper.vue +0 -37
- package/creators/app/files/nuxt.config.js +0 -6
- package/models/management.cattle.io.podsecurityadmissionconfigurationtemplate.ts +0 -4
- package/nuxt.config.js +0 -798
- package/plugins/dashboard-store/extensions.js +0 -22
package/nuxt.config.js
DELETED
|
@@ -1,798 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import serveStatic from 'serve-static';
|
|
4
|
-
import webpack from 'webpack';
|
|
5
|
-
|
|
6
|
-
import { STANDARD } from './config/private-label';
|
|
7
|
-
import { generateDynamicTypeImport } from './pkg/auto-import';
|
|
8
|
-
import { directiveSsr as t } from './plugins/i18n';
|
|
9
|
-
import { trimWhitespaceSsr as trimWhitespace } from './plugins/trim-whitespace';
|
|
10
|
-
|
|
11
|
-
const createProxyMiddleware = require('http-proxy-middleware');
|
|
12
|
-
|
|
13
|
-
// Global variables
|
|
14
|
-
let api = process.env.API || 'http://localhost:8989';
|
|
15
|
-
|
|
16
|
-
if ( !api.startsWith('http') ) {
|
|
17
|
-
api = `https://${ api }`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// needed for proxies
|
|
21
|
-
export const API_PATH = api;
|
|
22
|
-
|
|
23
|
-
const dev = (process.env.NODE_ENV !== 'production');
|
|
24
|
-
const devPorts = dev || process.env.DEV_PORTS === 'true';
|
|
25
|
-
|
|
26
|
-
// human readable version used on rancher dashboard about page
|
|
27
|
-
const dashboardVersion = process.env.DASHBOARD_VERSION;
|
|
28
|
-
|
|
29
|
-
const prime = process.env.PRIME;
|
|
30
|
-
|
|
31
|
-
const pl = process.env.PL || STANDARD;
|
|
32
|
-
const perfTest = (process.env.PERF_TEST === 'true'); // Enable performance testing when in dev
|
|
33
|
-
const instrumentCode = (process.env.TEST_INSTRUMENT === 'true'); // Instrument code for code coverage in e2e tests
|
|
34
|
-
|
|
35
|
-
// Allow skipping of eslint check
|
|
36
|
-
// 0 = Skip browser and console checks
|
|
37
|
-
// 1 = Skip browser check
|
|
38
|
-
// 2 = Do not skip any checks
|
|
39
|
-
const skipEsLintCheckStr = (process.env.SKIP_ESLINT || '');
|
|
40
|
-
let skipEsLintCheck = parseInt(skipEsLintCheckStr, 10) || 2;
|
|
41
|
-
|
|
42
|
-
// ===============================================================================================
|
|
43
|
-
// Nuxt configuration
|
|
44
|
-
// ===============================================================================================
|
|
45
|
-
|
|
46
|
-
// Expose a function that can be used by an app to provide a nuxt configuration for building an application
|
|
47
|
-
// This takes the directory of the application as tehfirst argument so that we can derive folder locations
|
|
48
|
-
// from it, rather than from the location of this file
|
|
49
|
-
export default function(dir, _appConfig) {
|
|
50
|
-
// Paths to the shell folder when it is included as a node dependency
|
|
51
|
-
let SHELL = 'node_modules/@rancher/shell';
|
|
52
|
-
let SHELL_ABS = path.join(dir, 'node_modules/@rancher/shell');
|
|
53
|
-
let NUXT_SHELL = '~~node_modules/@rancher/shell';
|
|
54
|
-
let COMPONENTS_DIR = path.join(SHELL_ABS, 'rancher-components');
|
|
55
|
-
let typescript = {};
|
|
56
|
-
|
|
57
|
-
if (fs.existsSync(SHELL_ABS)) {
|
|
58
|
-
const stat = fs.lstatSync(SHELL_ABS);
|
|
59
|
-
|
|
60
|
-
// If @rancher/shell is a symlink, then use the components folder for it
|
|
61
|
-
if (stat.isSymbolicLink()) {
|
|
62
|
-
const REAL_SHELL_ABS = fs.realpathSync(SHELL_ABS); // In case the shell is being linked via 'yarn link'
|
|
63
|
-
|
|
64
|
-
COMPONENTS_DIR = path.join(REAL_SHELL_ABS, '..', 'pkg', 'rancher-components', 'src', 'components');
|
|
65
|
-
|
|
66
|
-
// For now, skip eslint check when being linked via yarn link - pkg folder is linked otherwise
|
|
67
|
-
// This will change when we remove nuxt
|
|
68
|
-
skipEsLintCheck = true;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// If we have a local folder named 'shell' then use that rather than the one in node_modules
|
|
73
|
-
// This will be the case in the main dashboard repository.
|
|
74
|
-
if (fs.existsSync(path.join(dir, 'shell'))) {
|
|
75
|
-
SHELL = './shell';
|
|
76
|
-
SHELL_ABS = path.join(dir, 'shell');
|
|
77
|
-
NUXT_SHELL = '~~/shell';
|
|
78
|
-
COMPONENTS_DIR = path.join(dir, 'pkg', 'rancher-components', 'src', 'components');
|
|
79
|
-
|
|
80
|
-
// Skip eslint check that runs as part of nuxt build in the console
|
|
81
|
-
if (skipEsLintCheck > 0) {
|
|
82
|
-
typescript = { typeCheck: { eslint: { files: './shell/**/*.{ts,js,vue}' } } };
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Instrument code for tests
|
|
87
|
-
const babelPlugins = [
|
|
88
|
-
// TODO: Browser support
|
|
89
|
-
// ['@babel/plugin-transform-modules-commonjs'],
|
|
90
|
-
['@babel/plugin-proposal-private-property-in-object', { loose: true }]
|
|
91
|
-
];
|
|
92
|
-
|
|
93
|
-
if (instrumentCode) {
|
|
94
|
-
babelPlugins.push('babel-plugin-istanbul');
|
|
95
|
-
|
|
96
|
-
console.warn('Instrumenting code for coverage'); // eslint-disable-line no-console
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// ===============================================================================================
|
|
100
|
-
// Functions for the UI Plugins
|
|
101
|
-
// ===============================================================================================
|
|
102
|
-
|
|
103
|
-
const appConfig = _appConfig || {};
|
|
104
|
-
const excludes = appConfig.excludes || [];
|
|
105
|
-
const autoLoad = appConfig.autoLoad || [];
|
|
106
|
-
|
|
107
|
-
const serverMiddleware = [];
|
|
108
|
-
const autoLoadPackages = [];
|
|
109
|
-
const watcherIgnores = [
|
|
110
|
-
/.shell/,
|
|
111
|
-
/dist-pkg/,
|
|
112
|
-
/scripts\/standalone/
|
|
113
|
-
];
|
|
114
|
-
|
|
115
|
-
autoLoad.forEach((pkg) => {
|
|
116
|
-
// Need the version number of each file
|
|
117
|
-
const pkgPackageFile = require(path.join(dir, 'pkg', pkg, 'package.json'));
|
|
118
|
-
const pkgRef = `${ pkg }-${ pkgPackageFile.version }`;
|
|
119
|
-
|
|
120
|
-
autoLoadPackages.push({
|
|
121
|
-
name: `app-autoload-${ pkgRef }`,
|
|
122
|
-
content: `/pkg/${ pkgRef }/${ pkgRef }.umd.min.js`
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// Anything auto-loaded should also be excluded
|
|
126
|
-
if (!excludes.includes(pkg)) {
|
|
127
|
-
excludes.push(pkg);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// Find any UI packages in node_modules
|
|
132
|
-
const NM = path.join(dir, 'node_modules');
|
|
133
|
-
const pkg = require(path.join(dir, 'package.json'));
|
|
134
|
-
const nmPackages = {};
|
|
135
|
-
|
|
136
|
-
if (pkg && pkg.dependencies) {
|
|
137
|
-
Object.keys(pkg.dependencies).forEach((pkg) => {
|
|
138
|
-
const f = require(path.join(NM, pkg, 'package.json'));
|
|
139
|
-
|
|
140
|
-
// The package.json must have the 'rancher' property to mark it as a UI package
|
|
141
|
-
if (f.rancher) {
|
|
142
|
-
const id = `${ f.name }-${ f.version }`;
|
|
143
|
-
|
|
144
|
-
nmPackages[id] = f.main;
|
|
145
|
-
|
|
146
|
-
// Add server middleware to serve up the files for this UI package
|
|
147
|
-
serverMiddleware.push({
|
|
148
|
-
path: `/pkg/${ id }`,
|
|
149
|
-
handler: serveStatic(path.join(NM, pkg))
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
serverMiddleware.push({
|
|
156
|
-
path: '/uiplugins-catalog',
|
|
157
|
-
handler: (req, res, next) => {
|
|
158
|
-
const p = req.url.split('?');
|
|
159
|
-
|
|
160
|
-
try {
|
|
161
|
-
const proxy = createProxyMiddleware({
|
|
162
|
-
target: p[1],
|
|
163
|
-
pathRewrite: { '^.*': p[0] }
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
return proxy(req, res, next);
|
|
167
|
-
} catch (e) {
|
|
168
|
-
console.error(e); // eslint-disable-line no-console
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
function includePkg(name) {
|
|
174
|
-
if (name.startsWith('.') || name === 'node_modules') {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return !excludes || (excludes && !excludes.includes(name));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
excludes.forEach((e) => {
|
|
182
|
-
watcherIgnores.push(new RegExp(`/pkg.${ e }`));
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
// For each package in the pkg folder that is being compiled into the application,
|
|
186
|
-
// Add in the code to automatically import the types from that package
|
|
187
|
-
// This imports models, edit, detail, list etc
|
|
188
|
-
// When built as a UI package, shell/pkg/vue.config.js does the same thing
|
|
189
|
-
const autoImportTypes = {};
|
|
190
|
-
const VirtualModulesPlugin = require('webpack-virtual-modules');
|
|
191
|
-
let reqs = '';
|
|
192
|
-
const pkgFolder = path.relative(dir, './pkg');
|
|
193
|
-
|
|
194
|
-
if (fs.existsSync(pkgFolder)) {
|
|
195
|
-
const items = fs.readdirSync(path.relative(dir, './pkg'));
|
|
196
|
-
|
|
197
|
-
// Ignore hidden folders
|
|
198
|
-
items.filter(name => !name.startsWith('.')).forEach((name) => {
|
|
199
|
-
const f = require(path.join(dir, 'pkg', name, 'package.json'));
|
|
200
|
-
|
|
201
|
-
// Package file must have rancher field to be a plugin
|
|
202
|
-
if (includePkg(name) && f.rancher) {
|
|
203
|
-
reqs += `$plugin.initPlugin('${ name }', require(\'~/pkg/${ name }\')); `;
|
|
204
|
-
|
|
205
|
-
// // Serve the code for the UI package in case its used for dynamic loading (but not if the same package was provided in node_modules)
|
|
206
|
-
// if (!nmPackages[name]) {
|
|
207
|
-
// const pkgPackageFile = require(path.join(dir, 'pkg', name, 'package.json'));
|
|
208
|
-
// const pkgRef = `${ name }-${ pkgPackageFile.version }`;
|
|
209
|
-
|
|
210
|
-
// serverMiddleware.push({ path: `/pkg/${ pkgRef }`, handler: serveStatic(`${ dir }/dist-pkg/${ pkgRef }`) });
|
|
211
|
-
// }
|
|
212
|
-
autoImportTypes[`@rancher/auto-import/${ name }`] = generateDynamicTypeImport(`@pkg/${ name }`, path.join(dir, `pkg/${ name }`));
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
Object.keys(nmPackages).forEach((m) => {
|
|
218
|
-
reqs += `$plugin.loadAsync('${ m }', '/pkg/${ m }/${ nmPackages[m] }');`;
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
// Generate a virtual module '@rancher/dyanmic.js` which imports all of the packages that should be built into the application
|
|
222
|
-
// This is imported in 'shell/extensions/extension-loader.js` which ensures the all code for plugins to be included is imported in the application
|
|
223
|
-
const virtualModules = new VirtualModulesPlugin({ 'node_modules/@rancher/dynamic.js': `export default function ($plugin) { ${ reqs } };` });
|
|
224
|
-
const autoImport = new webpack.NormalModuleReplacementPlugin(/^@rancher\/auto-import$/, (resource) => {
|
|
225
|
-
const ctx = resource.context.split('/');
|
|
226
|
-
const pkg = ctx[ctx.length - 1];
|
|
227
|
-
|
|
228
|
-
resource.request = `@rancher/auto-import/${ pkg }`;
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
// @pkg imports must be resolved to the package that it importing them - this allows a package to use @pkg as an alis
|
|
232
|
-
// to the root of that particular package
|
|
233
|
-
const pkgImport = new webpack.NormalModuleReplacementPlugin(/^@pkg/, (resource) => {
|
|
234
|
-
const ctx = resource.context.split('/');
|
|
235
|
-
// Find 'pkg' folder in the contxt
|
|
236
|
-
const index = ctx.findIndex(s => s === 'pkg');
|
|
237
|
-
|
|
238
|
-
if (index !== -1 && (index + 1) < ctx.length) {
|
|
239
|
-
const pkg = ctx[index + 1];
|
|
240
|
-
let p = path.resolve(dir, 'pkg', pkg, resource.request.substr(5));
|
|
241
|
-
|
|
242
|
-
if (resource.request.startsWith(`@pkg/${ pkg }`)) {
|
|
243
|
-
p = path.resolve(dir, 'pkg', resource.request.substr(5));
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
resource.request = p;
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
// Serve up the dist-pkg folder under /pkg
|
|
251
|
-
serverMiddleware.push({ path: `/pkg/`, handler: serveStatic(`${ dir }/dist-pkg/`) });
|
|
252
|
-
// Add the standard dashboard server middleware after the middleware added to serve up UI packages
|
|
253
|
-
serverMiddleware.push(path.resolve(dir, SHELL, 'server', 'server-middleware'));
|
|
254
|
-
|
|
255
|
-
// ===============================================================================================
|
|
256
|
-
// Dashboard nuxt configuration
|
|
257
|
-
// ===============================================================================================
|
|
258
|
-
|
|
259
|
-
require('events').EventEmitter.defaultMaxListeners = 20;
|
|
260
|
-
require('dotenv').config();
|
|
261
|
-
|
|
262
|
-
let routerBasePath = '/';
|
|
263
|
-
let resourceBase = '';
|
|
264
|
-
let outputDir = 'dist';
|
|
265
|
-
|
|
266
|
-
if ( typeof process.env.ROUTER_BASE !== 'undefined' ) {
|
|
267
|
-
routerBasePath = process.env.ROUTER_BASE;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if ( typeof process.env.RESOURCE_BASE !== 'undefined' ) {
|
|
271
|
-
resourceBase = process.env.RESOURCE_BASE;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if ( typeof process.env.OUTPUT_DIR !== 'undefined' ) {
|
|
275
|
-
outputDir = process.env.OUTPUT_DIR;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if ( resourceBase && !resourceBase.endsWith('/') ) {
|
|
279
|
-
resourceBase += '/';
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
console.log(`Build: ${ dev ? 'Development' : 'Production' }`); // eslint-disable-line no-console
|
|
283
|
-
|
|
284
|
-
if ( !dev ) {
|
|
285
|
-
console.log(`Version: ${ dashboardVersion }`); // eslint-disable-line no-console
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if ( resourceBase ) {
|
|
289
|
-
console.log(`Resource Base URL: ${ resourceBase }`); // eslint-disable-line no-console
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
if ( routerBasePath !== '/' ) {
|
|
293
|
-
console.log(`Router Base Path: ${ routerBasePath }`); // eslint-disable-line no-console
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if ( pl !== STANDARD ) {
|
|
297
|
-
console.log(`PL: ${ pl }`); // eslint-disable-line no-console
|
|
298
|
-
}
|
|
299
|
-
const rancherEnv = process.env.RANCHER_ENV || 'web';
|
|
300
|
-
|
|
301
|
-
console.log(`API: '${ api }'. Env: '${ rancherEnv }'`); // eslint-disable-line no-console
|
|
302
|
-
|
|
303
|
-
// Nuxt modules
|
|
304
|
-
let nuxtModules = [
|
|
305
|
-
'@nuxtjs/proxy',
|
|
306
|
-
'@nuxtjs/axios',
|
|
307
|
-
'@nuxtjs/eslint-module',
|
|
308
|
-
'@nuxtjs/webpack-profile',
|
|
309
|
-
'cookie-universal-nuxt',
|
|
310
|
-
'portal-vue/nuxt',
|
|
311
|
-
path.join(NUXT_SHELL, 'plugins/dashboard-store/rehydrate-all'),
|
|
312
|
-
];
|
|
313
|
-
|
|
314
|
-
// Remove es-lint nuxt module if env var configures this
|
|
315
|
-
if (skipEsLintCheck < 2) {
|
|
316
|
-
nuxtModules = nuxtModules.filter(s => !s.includes('eslint-module'));
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
const config = {
|
|
320
|
-
dev,
|
|
321
|
-
|
|
322
|
-
// Configuration visible to the client, https://nuxtjs.org/api/configuration-env
|
|
323
|
-
env: {
|
|
324
|
-
dev,
|
|
325
|
-
pl,
|
|
326
|
-
perfTest,
|
|
327
|
-
rancherEnv,
|
|
328
|
-
harvesterPkgUrl: process.env.HARVESTER_PKG_URL,
|
|
329
|
-
api
|
|
330
|
-
},
|
|
331
|
-
|
|
332
|
-
// vars accessible via this.$config https://nuxtjs.org/docs/configuration-glossary/configuration-runtime-config/
|
|
333
|
-
publicRuntimeConfig: { rancherEnv, dashboardVersion },
|
|
334
|
-
|
|
335
|
-
buildDir: dev ? '.nuxt' : '.nuxt-prod',
|
|
336
|
-
|
|
337
|
-
buildModules: [
|
|
338
|
-
'@nuxtjs/style-resources',
|
|
339
|
-
'@nuxt/typescript-build'
|
|
340
|
-
],
|
|
341
|
-
styleResources: {
|
|
342
|
-
// only import functions, mixins, or variables, NEVER import full styles https://github.com/nuxt-community/style-resources-module#warning
|
|
343
|
-
hoistUseStatements: true,
|
|
344
|
-
scss: [
|
|
345
|
-
path.resolve(SHELL_ABS, 'assets/styles/base/_variables.scss'),
|
|
346
|
-
path.resolve(SHELL_ABS, 'assets/styles/base/_functions.scss'),
|
|
347
|
-
path.resolve(SHELL_ABS, 'assets/styles/base/_mixins.scss'),
|
|
348
|
-
],
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
loadingIndicator: path.join(SHELL_ABS, 'static/loading-indicator.html'),
|
|
352
|
-
|
|
353
|
-
loading: path.join(SHELL_ABS, 'components/nav/GlobalLoading.vue'),
|
|
354
|
-
|
|
355
|
-
// Axios: https://axios.nuxtjs.org/options
|
|
356
|
-
axios: {
|
|
357
|
-
https: true,
|
|
358
|
-
proxy: true,
|
|
359
|
-
retry: { retries: 0 },
|
|
360
|
-
// debug: true
|
|
361
|
-
},
|
|
362
|
-
|
|
363
|
-
content: {
|
|
364
|
-
dir: path.resolve(SHELL_ABS, 'content'),
|
|
365
|
-
markdown: { prism: { theme: false } },
|
|
366
|
-
liveEdit: false
|
|
367
|
-
},
|
|
368
|
-
|
|
369
|
-
router: {
|
|
370
|
-
base: routerBasePath,
|
|
371
|
-
middleware: ['i18n'],
|
|
372
|
-
prefetchLinks: false
|
|
373
|
-
},
|
|
374
|
-
|
|
375
|
-
alias: {
|
|
376
|
-
'~shell': SHELL_ABS,
|
|
377
|
-
'@shell': SHELL_ABS,
|
|
378
|
-
'@pkg': path.join(dir, 'pkg'),
|
|
379
|
-
'@components': COMPONENTS_DIR,
|
|
380
|
-
},
|
|
381
|
-
|
|
382
|
-
modulesDir: [
|
|
383
|
-
path.resolve(dir),
|
|
384
|
-
'./node_modules',
|
|
385
|
-
SHELL_ABS
|
|
386
|
-
],
|
|
387
|
-
|
|
388
|
-
dir: {
|
|
389
|
-
assets: path.posix.join(SHELL, 'assets'),
|
|
390
|
-
layouts: path.posix.join(SHELL, 'layouts'),
|
|
391
|
-
middleware: path.posix.join(SHELL, 'middleware'),
|
|
392
|
-
pages: path.posix.join(SHELL, 'pages'),
|
|
393
|
-
static: path.posix.join(SHELL, 'static'),
|
|
394
|
-
store: path.posix.join(SHELL, 'store'),
|
|
395
|
-
},
|
|
396
|
-
|
|
397
|
-
watchers: { webpack: { ignore: watcherIgnores } },
|
|
398
|
-
|
|
399
|
-
build: {
|
|
400
|
-
publicPath: resourceBase,
|
|
401
|
-
parallel: true,
|
|
402
|
-
cache: true,
|
|
403
|
-
hardSource: true,
|
|
404
|
-
|
|
405
|
-
// Uses the Webpack Build Analyzer to generate a report of the bundle contents
|
|
406
|
-
// analyze: { analyzerMode: 'static' },
|
|
407
|
-
|
|
408
|
-
uglify: {
|
|
409
|
-
uglifyOptions: { compress: !dev },
|
|
410
|
-
cache: './node_modules/.cache/uglify'
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
'html.minify': {
|
|
414
|
-
collapseBooleanAttributes: !dev,
|
|
415
|
-
decodeEntities: !dev,
|
|
416
|
-
minifyCSS: !dev,
|
|
417
|
-
minifyJS: !dev,
|
|
418
|
-
processConditionalComments: !dev,
|
|
419
|
-
removeEmptyAttributes: !dev,
|
|
420
|
-
removeRedundantAttributes: !dev,
|
|
421
|
-
trimCustomFragments: !dev,
|
|
422
|
-
useShortDoctype: !dev
|
|
423
|
-
},
|
|
424
|
-
|
|
425
|
-
// Don't include `[name]` in prod file names
|
|
426
|
-
// This flattens out the folder structure (avoids crazy paths like `_nuxt/pages/account/create-key/pages/c/_cluster/_product/_resource/_id/pages/c/_cluster/_product/_resource`)
|
|
427
|
-
// and uses nuxt's workaround to address issues with filenames containing `//` (see https://github.com/nuxt/nuxt.js/issues/8274)
|
|
428
|
-
filenames: { chunk: ({ isDev }) => isDev ? '[name].js' : '[contenthash].js' },
|
|
429
|
-
// @TODO figure out how to split chunks up better, by product
|
|
430
|
-
// optimization: {
|
|
431
|
-
// splitChunks: {
|
|
432
|
-
// cacheGroups: {
|
|
433
|
-
// styles: {
|
|
434
|
-
// name: 'styles',
|
|
435
|
-
// test: /\.(css|vue)$/,
|
|
436
|
-
// chunks: 'all',
|
|
437
|
-
// enforce: true
|
|
438
|
-
// },
|
|
439
|
-
// }
|
|
440
|
-
// }
|
|
441
|
-
// },
|
|
442
|
-
|
|
443
|
-
plugins: [
|
|
444
|
-
virtualModules,
|
|
445
|
-
autoImport,
|
|
446
|
-
new VirtualModulesPlugin(autoImportTypes),
|
|
447
|
-
pkgImport,
|
|
448
|
-
],
|
|
449
|
-
|
|
450
|
-
extend(config, { isClient, isDev }) {
|
|
451
|
-
if ( isDev ) {
|
|
452
|
-
config.devtool = 'cheap-module-source-map';
|
|
453
|
-
} else {
|
|
454
|
-
config.devtool = 'source-map';
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
if ( resourceBase ) {
|
|
458
|
-
config.output.publicPath = resourceBase;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// Remove default image handling rules
|
|
462
|
-
for ( let i = config.module.rules.length - 1 ; i >= 0 ; i-- ) {
|
|
463
|
-
if ( /svg/.test(config.module.rules[i].test) ) {
|
|
464
|
-
config.module.rules.splice(i, 1);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
config.resolve.symlinks = false;
|
|
469
|
-
|
|
470
|
-
// Ensure we process files in the @rancher/shell folder
|
|
471
|
-
config.module.rules.forEach((r) => {
|
|
472
|
-
if ('test.js'.match(r.test)) {
|
|
473
|
-
if (r.exclude) {
|
|
474
|
-
const orig = r.exclude;
|
|
475
|
-
|
|
476
|
-
r.exclude = function(modulePath) {
|
|
477
|
-
if (modulePath.indexOf(SHELL_ABS) === 0) {
|
|
478
|
-
return false;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
return orig(modulePath);
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
// And substitute our own loader for images
|
|
488
|
-
config.module.rules.unshift({
|
|
489
|
-
test: /\.(png|jpe?g|gif|svg|webp)$/,
|
|
490
|
-
use: [
|
|
491
|
-
{
|
|
492
|
-
loader: 'url-loader',
|
|
493
|
-
options: {
|
|
494
|
-
name: '[path][name].[ext]',
|
|
495
|
-
limit: 1,
|
|
496
|
-
esModule: false
|
|
497
|
-
},
|
|
498
|
-
}
|
|
499
|
-
]
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
// Handler for yaml files (used for i18n files, for example)
|
|
503
|
-
config.module.rules.unshift({
|
|
504
|
-
test: /\.ya?ml$/i,
|
|
505
|
-
loader: 'js-yaml-loader',
|
|
506
|
-
options: { name: '[path][name].[ext]' },
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
// Handler for csv files (e.g. ec2 instance data)
|
|
510
|
-
config.module.rules.unshift({
|
|
511
|
-
test: /\.csv$/i,
|
|
512
|
-
loader: 'csv-loader',
|
|
513
|
-
options: {
|
|
514
|
-
dynamicTyping: true,
|
|
515
|
-
header: true,
|
|
516
|
-
skipEmptyLines: true
|
|
517
|
-
},
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
// Ensure there is a fallback for browsers that don't support web workers
|
|
521
|
-
config.module.rules.unshift({
|
|
522
|
-
test: /web-worker.[a-z-]+.js/i,
|
|
523
|
-
loader: 'worker-loader',
|
|
524
|
-
options: { inline: 'fallback' },
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
// Prevent warning in log with the md files in the content folder
|
|
528
|
-
config.module.rules.push({
|
|
529
|
-
test: /\.md$/,
|
|
530
|
-
use: [
|
|
531
|
-
{
|
|
532
|
-
loader: 'frontmatter-markdown-loader',
|
|
533
|
-
options: { mode: ['body'] }
|
|
534
|
-
}
|
|
535
|
-
]
|
|
536
|
-
});
|
|
537
|
-
},
|
|
538
|
-
|
|
539
|
-
// extractCSS: true,
|
|
540
|
-
cssSourceMap: true,
|
|
541
|
-
babel: {
|
|
542
|
-
presets({ isServer }) {
|
|
543
|
-
return [
|
|
544
|
-
[
|
|
545
|
-
require.resolve('@nuxt/babel-preset-app'),
|
|
546
|
-
{
|
|
547
|
-
// buildTarget: isServer ? 'server' : 'client',
|
|
548
|
-
corejs: { version: 3 },
|
|
549
|
-
targets: isServer ? { node: '12' } : { browsers: ['last 2 versions'] },
|
|
550
|
-
modern: !isServer
|
|
551
|
-
}
|
|
552
|
-
],
|
|
553
|
-
'@babel/preset-typescript',
|
|
554
|
-
];
|
|
555
|
-
},
|
|
556
|
-
plugins: babelPlugins
|
|
557
|
-
}
|
|
558
|
-
},
|
|
559
|
-
|
|
560
|
-
render: {
|
|
561
|
-
bundleRenderer: {
|
|
562
|
-
directives: {
|
|
563
|
-
trimWhitespace,
|
|
564
|
-
t,
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
},
|
|
568
|
-
|
|
569
|
-
// modern: true, -- now part of preset above
|
|
570
|
-
|
|
571
|
-
generate: { dir: outputDir },
|
|
572
|
-
|
|
573
|
-
// Global CSS
|
|
574
|
-
css: [
|
|
575
|
-
path.resolve(SHELL_ABS, 'assets/styles/app.scss')
|
|
576
|
-
],
|
|
577
|
-
|
|
578
|
-
head: {
|
|
579
|
-
title: process.env.npm_package_name || '',
|
|
580
|
-
meta: [
|
|
581
|
-
{ charset: 'utf-8' },
|
|
582
|
-
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
|
583
|
-
{
|
|
584
|
-
hid: 'description',
|
|
585
|
-
name: 'description',
|
|
586
|
-
content: process.env.npm_package_description || ''
|
|
587
|
-
},
|
|
588
|
-
...autoLoadPackages,
|
|
589
|
-
],
|
|
590
|
-
link: [{
|
|
591
|
-
hid: 'icon',
|
|
592
|
-
rel: 'icon',
|
|
593
|
-
type: 'image/x-icon',
|
|
594
|
-
href: `${ resourceBase || '/' }favicon.png`
|
|
595
|
-
}]
|
|
596
|
-
},
|
|
597
|
-
|
|
598
|
-
// Nuxt modules
|
|
599
|
-
modules: nuxtModules,
|
|
600
|
-
|
|
601
|
-
// Vue plugins
|
|
602
|
-
plugins: [
|
|
603
|
-
// Extensions
|
|
604
|
-
path.relative(dir, path.join(SHELL, 'core/plugins.js')),
|
|
605
|
-
path.relative(dir, path.join(SHELL, 'core/plugins-loader.js')), // Load builtin plugins
|
|
606
|
-
|
|
607
|
-
// Third-party
|
|
608
|
-
path.join(NUXT_SHELL, 'plugins/axios'),
|
|
609
|
-
path.join(NUXT_SHELL, 'plugins/tooltip'),
|
|
610
|
-
path.join(NUXT_SHELL, 'plugins/vue-clipboard2'),
|
|
611
|
-
path.join(NUXT_SHELL, 'plugins/v-select'),
|
|
612
|
-
path.join(NUXT_SHELL, 'plugins/directives'),
|
|
613
|
-
path.join(NUXT_SHELL, 'plugins/transitions'),
|
|
614
|
-
{ src: path.join(NUXT_SHELL, 'plugins/vue-js-modal') },
|
|
615
|
-
{ src: path.join(NUXT_SHELL, 'plugins/js-yaml'), ssr: false },
|
|
616
|
-
{ src: path.join(NUXT_SHELL, 'plugins/resize'), ssr: false },
|
|
617
|
-
{ src: path.join(NUXT_SHELL, 'plugins/shortkey'), ssr: false },
|
|
618
|
-
|
|
619
|
-
// First-party
|
|
620
|
-
path.join(NUXT_SHELL, 'plugins/i18n'),
|
|
621
|
-
path.join(NUXT_SHELL, 'plugins/global-formatters'),
|
|
622
|
-
path.join(NUXT_SHELL, 'plugins/trim-whitespace'),
|
|
623
|
-
{ src: path.join(NUXT_SHELL, 'plugins/extend-router') },
|
|
624
|
-
{ src: path.join(NUXT_SHELL, 'plugins/console'), ssr: false },
|
|
625
|
-
{ src: path.join(NUXT_SHELL, 'plugins/int-number'), ssr: false },
|
|
626
|
-
{ src: path.join(NUXT_SHELL, 'plugins/nuxt-client-init'), ssr: false },
|
|
627
|
-
path.join(NUXT_SHELL, 'plugins/replaceall'),
|
|
628
|
-
path.join(NUXT_SHELL, 'plugins/back-button'),
|
|
629
|
-
{ src: path.join(NUXT_SHELL, 'plugins/plugin'), ssr: false }, // Load dyanmic plugins
|
|
630
|
-
{ src: path.join(NUXT_SHELL, 'plugins/codemirror-loader'), ssr: false },
|
|
631
|
-
{ src: path.join(NUXT_SHELL, 'plugins/formatters'), ssr: false }, // Populate formatters cache for sorted table
|
|
632
|
-
{ src: path.join(NUXT_SHELL, 'plugins/version'), ssr: false }, // Makes a fetch to the backend to get version metadata
|
|
633
|
-
],
|
|
634
|
-
|
|
635
|
-
// Proxy: https://github.com/nuxt-community/proxy-module#options
|
|
636
|
-
proxy: {
|
|
637
|
-
...appConfig.proxies,
|
|
638
|
-
'/k8s': proxyWsOpts(api), // Straight to a remote cluster (/k8s/clusters/<id>/)
|
|
639
|
-
'/pp': proxyWsOpts(api), // For (epinio) standalone API
|
|
640
|
-
'/api': proxyWsOpts(api), // Management k8s API
|
|
641
|
-
'/apis': proxyWsOpts(api), // Management k8s API
|
|
642
|
-
'/v1': proxyWsOpts(api), // Management Steve API
|
|
643
|
-
'/v3': proxyWsOpts(api), // Rancher API
|
|
644
|
-
'/v3-public': proxyOpts(api), // Rancher Unauthed API
|
|
645
|
-
'/api-ui': proxyOpts(api), // Browser API UI
|
|
646
|
-
'/meta': proxyMetaOpts(api), // Browser API UI
|
|
647
|
-
'/v1-*': proxyOpts(api), // SAML, KDM, etc
|
|
648
|
-
'/rancherversion': proxyPrimeOpts(api), // Rancher version endpoint
|
|
649
|
-
// These are for Ember embedding
|
|
650
|
-
'/c/*/edit': proxyOpts('https://127.0.0.1:8000'), // Can't proxy all of /c because that's used by Vue too
|
|
651
|
-
'/k/': proxyOpts('https://127.0.0.1:8000'),
|
|
652
|
-
'/g/': proxyOpts('https://127.0.0.1:8000'),
|
|
653
|
-
'/n/': proxyOpts('https://127.0.0.1:8000'),
|
|
654
|
-
'/p/': proxyOpts('https://127.0.0.1:8000'),
|
|
655
|
-
'/assets': proxyOpts('https://127.0.0.1:8000'),
|
|
656
|
-
'/translations': proxyOpts('https://127.0.0.1:8000'),
|
|
657
|
-
'/engines-dist': proxyOpts('https://127.0.0.1:8000'),
|
|
658
|
-
},
|
|
659
|
-
|
|
660
|
-
// Nuxt server
|
|
661
|
-
server: {
|
|
662
|
-
https: (devPorts ? {
|
|
663
|
-
key: fs.readFileSync(path.resolve(dir, SHELL, 'server/server.key')),
|
|
664
|
-
cert: fs.readFileSync(path.resolve(dir, SHELL, 'server/server.crt'))
|
|
665
|
-
} : null),
|
|
666
|
-
port: (devPorts ? 8005 : 80),
|
|
667
|
-
host: '0.0.0.0',
|
|
668
|
-
},
|
|
669
|
-
|
|
670
|
-
// Server middleware
|
|
671
|
-
serverMiddleware,
|
|
672
|
-
|
|
673
|
-
// Eslint module options
|
|
674
|
-
eslint: {
|
|
675
|
-
cache: path.join(dir, 'node_modules/.cache/eslint'),
|
|
676
|
-
exclude: [
|
|
677
|
-
'.nuxt'
|
|
678
|
-
]
|
|
679
|
-
},
|
|
680
|
-
|
|
681
|
-
// Typescript eslint
|
|
682
|
-
typescript,
|
|
683
|
-
|
|
684
|
-
ssr: false,
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
return config;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
// ===============================================================================================
|
|
691
|
-
// Functions for the request proxying used in dev
|
|
692
|
-
// ===============================================================================================
|
|
693
|
-
|
|
694
|
-
export function proxyMetaOpts(target) {
|
|
695
|
-
return {
|
|
696
|
-
target,
|
|
697
|
-
followRedirects: true,
|
|
698
|
-
secure: !dev,
|
|
699
|
-
onProxyReq,
|
|
700
|
-
onProxyReqWs,
|
|
701
|
-
onError,
|
|
702
|
-
onProxyRes,
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
export function proxyOpts(target) {
|
|
707
|
-
return {
|
|
708
|
-
target,
|
|
709
|
-
secure: !devPorts,
|
|
710
|
-
onProxyReq,
|
|
711
|
-
onProxyReqWs,
|
|
712
|
-
onError,
|
|
713
|
-
onProxyRes,
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
// Intercept the /rancherversion API call wnad modify the 'RancherPrime' value
|
|
718
|
-
// if configured to do so by the environment variable PRIME
|
|
719
|
-
export function proxyPrimeOpts(target) {
|
|
720
|
-
const opts = proxyOpts(target);
|
|
721
|
-
|
|
722
|
-
// Don't intercept if the PRIME environment variable is not set
|
|
723
|
-
if (!prime?.length) {
|
|
724
|
-
return opts;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
opts.onProxyRes = (proxyRes, req, res) => {
|
|
728
|
-
const _end = res.end;
|
|
729
|
-
let body = '';
|
|
730
|
-
|
|
731
|
-
proxyRes.on( 'data', (data) => {
|
|
732
|
-
data = data.toString('utf-8');
|
|
733
|
-
body += data;
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
res.write = () => {};
|
|
737
|
-
|
|
738
|
-
res.end = () => {
|
|
739
|
-
let output = body;
|
|
740
|
-
|
|
741
|
-
try {
|
|
742
|
-
const out = JSON.parse(body);
|
|
743
|
-
|
|
744
|
-
out.RancherPrime = prime;
|
|
745
|
-
output = JSON.stringify(out);
|
|
746
|
-
} catch (err) {}
|
|
747
|
-
|
|
748
|
-
res.setHeader('content-length', output.length );
|
|
749
|
-
res.setHeader('content-type', 'application/json' );
|
|
750
|
-
res.setHeader('transfer-encoding', '');
|
|
751
|
-
res.setHeader('cache-control', 'no-cache');
|
|
752
|
-
res.writeHead(proxyRes.statusCode);
|
|
753
|
-
_end.apply(res, [output]);
|
|
754
|
-
};
|
|
755
|
-
};
|
|
756
|
-
|
|
757
|
-
return opts;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
export function onProxyRes(proxyRes, req, res) {
|
|
761
|
-
if (devPorts) {
|
|
762
|
-
proxyRes.headers['X-Frame-Options'] = 'ALLOWALL';
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
export function proxyWsOpts(target) {
|
|
767
|
-
return {
|
|
768
|
-
...proxyOpts(target),
|
|
769
|
-
ws: true,
|
|
770
|
-
changeOrigin: true,
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
export function onProxyReq(proxyReq, req) {
|
|
775
|
-
if (!(proxyReq._currentRequest && proxyReq._currentRequest._headerSent)) {
|
|
776
|
-
proxyReq.setHeader('x-api-host', req.headers['host']);
|
|
777
|
-
proxyReq.setHeader('x-forwarded-proto', 'https');
|
|
778
|
-
// console.log(proxyReq.getHeaders());
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
export function onProxyReqWs(proxyReq, req, socket, options, head) {
|
|
783
|
-
req.headers.origin = options.target.href;
|
|
784
|
-
proxyReq.setHeader('origin', options.target.href);
|
|
785
|
-
proxyReq.setHeader('x-api-host', req.headers['host']);
|
|
786
|
-
proxyReq.setHeader('x-forwarded-proto', 'https');
|
|
787
|
-
// console.log(proxyReq.getHeaders());
|
|
788
|
-
|
|
789
|
-
socket.on('error', (err) => {
|
|
790
|
-
console.error('Proxy WS Error:', err); // eslint-disable-line no-console
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
export function onError(err, req, res) {
|
|
795
|
-
res.statusCode = 598;
|
|
796
|
-
console.error('Proxy Error:', err); // eslint-disable-line no-console
|
|
797
|
-
res.write(JSON.stringify(err));
|
|
798
|
-
}
|