Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt removal #7211

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dist-pkg
.DS_Store
shell/utils/dynamic-importer.js
ksconfig.json
nuxt
storybook-static/
utils/dynamic-importer.js
shell/assets/fonts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/build-dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ echo Installing dependencies
yarn install:ci

echo Building
NUXT_ENV_commit=$GITHUB_SHA NUXT_ENV_version=$GITHUB_REF_NAME OUTPUT_DIR="$ARTIFACT_LOCATION" ROUTER_BASE="$ROUTER_BASE" RANCHER_ENV=$RANCHER_ENV API=$API RESOURCE_BASE=$RESOURCE_BASE EXCLUDES_PKG=$EXCLUDES_PKG yarn run build --spa
COMMIT=$GITHUB_SHA VERSION=$GITHUB_REF_NAME OUTPUT_DIR="$ARTIFACT_LOCATION" ROUTER_BASE="$ROUTER_BASE" RANCHER_ENV=$RANCHER_ENV API=$API RESOURCE_BASE=$RESOURCE_BASE EXCLUDES_PKG=$EXCLUDES_PKG yarn run build --spa

echo Creating tar
tar -czf $RELEASE_LOCATION.tar.gz -C $ARTIFACT_LOCATION .
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = { env: { test: { presets: [['@babel/env', { targets: { node: 'current' } }]] } } };
module.exports = require('./shell/babel.config.js');
2 changes: 1 addition & 1 deletion cypress/e2e/po/components/checkbox-input.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class CheckboxInputPo extends ComponentPo {
return new CheckboxInputPo(
self
.find('.checkbox-outer-container')
.contains(`${ label } `)
.contains(label)
.parent()
);
}
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/po/components/labeled-input.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class LabeledInputPo extends ComponentPo {
return new LabeledInputPo(
self
.find('.labeled-input', { includeShadowDom: true })
.contains(`${ label } `)
.contains(label)
.next()
);
}
Expand Down
11 changes: 8 additions & 3 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../tsconfig.default.json",
"extends": "../shell/tsconfig.default.json",
"compilerOptions": {
"noEmit": true,
"types": ["cypress"]
"types": [
"cypress"
]
},
"include": ["./**/*.ts", "../types/*.ts"]
"include": [
"./**/*.ts",
"../types/*.ts"
]
}
33 changes: 33 additions & 0 deletions docusaurus/docs/code-base-works/middleware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Middleware

## Location
The definitions of middleware reside in `shell/middleware`. Middleware added to the object in `shell/nuxt/middleware.js` will be initialized at the start of the app rendering.


## Notes
This file was generated by nuxt and will soon be redefined by hand. It's safe to add new middleware to this file.

## Pattern
Define the middleware in a file that resides within `shell/middleware`. Then add the instantiation to the object that resides in `shell/nuxt/middleware.js`.

shell/middleware/i18n.js
```js
export default async function({
isHMR, app, store, route, params, error, redirect
}) {
// If middleware is called from hot module replacement, ignore it
if (isHMR) {
return;
}

await store.dispatch('i18n/init');
}
```

shell/nuxt/middleware.js
```js
...
middleware['i18n'] = require('../middleware/i18n.js')
middleware['i18n'] = middleware['i18n'].default || middleware['i18n']
...
```
47 changes: 47 additions & 0 deletions docusaurus/docs/code-base-works/nuxt-plugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Nuxt Plugins

## Location
The definitions of plugins reside in `shell/plugins`. Plugins added to `shell/nuxt/index.js` will be initialized at the start of the app rendering.


## Notes
This file was generated by nuxt and will soon be redefined by hand. It's safe to add new plugins to this file.

## Pattern
Define the store in a file that resides within `shell/plugins`. Then add the plugins import and execution to `shell/nuxt/index.js`.

shell/plugins/version.js
```js
/**
* Fetch version metadata from backend /rancherversion API and store it
*
* This metadata does not change for an installation of Rancher
*/

import { setVersionData } from '@shell/config/version';

export default async function({ store }) {
try {
const response = await store.dispatch('rancher/request', {
url: '/rancherversion',
method: 'get',
redirectUnauthorized: false
});

setVersionData(response);
} catch (e) {
console.warn('Failed to fetch Rancher version metadata', e); // eslint-disable-line no-console
}
}
```

shell/nuxt/index.js
```js
...
import version from '../plugins/version';
...
if (process.client && typeof version === 'function') {
await version(app.context, inject);
}
...
```
22 changes: 22 additions & 0 deletions docusaurus/docs/code-base-works/routes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Routes

## Location

The core dashboard routes are defined in `shell/nuxt/router.js`.


## Notes
This file was generated by nuxt and will soon be redefined by hand. It's safe to add new routes to this file.

## Pattern
First instantiate a page component at the top of the file. Then define a new route at the bottom of the file by giving the page component a unique path and name
```js
const about = () => interopDefault(import('../pages/about.vue'))
...
{
path: "/about",
component: about,
name: "about"
}
...
```
18 changes: 18 additions & 0 deletions docusaurus/docs/code-base-works/stores.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Stores

## Location
The definitions of stores reside in `shell/store`. Stores added to `shell/nuxt/store.js` will be initialized at the start of the app rendering.


## Notes
This file was generated by nuxt and will soon be redefined by hand. It's safe to add new stores to this file.

## Pattern
Define the store in a file that resides within `shell/store`. Then add the store to `shell/nuxt/store.js`.

shell/nuxt/store.js
```js
...
resolveStoreModules(require('../store/i18n.js'), 'i18n.js')
...
```
4 changes: 4 additions & 0 deletions docusaurus/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ const sidebars = {
'code-base-works/helm-chart-apps',
'code-base-works/keyboard-shortcuts',
'code-base-works/kubernetes-resources-data-load',
'code-base-works/routes',
'code-base-works/middleware',
'code-base-works/stores',
'code-base-works/nuxt-plugins',
'code-base-works/machine-drivers',
'code-base-works/performance',
'code-base-works/sortable-table',
Expand Down
14 changes: 0 additions & 14 deletions jsconfig.json

This file was deleted.

28 changes: 16 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"pkg/rancher-components"
],
"scripts": {
"build-pkg": "./shell/scripts/build-pkg.sh",
"build-pkg": "yarn lint && ./shell/scripts/build-pkg.sh",
"publish-pkg": "./shell/scripts/publish-pkg.sh",
"serve-pkgs": "./shell/scripts/serve-pkgs",
"publish-shell": "./shell/scripts/publish-shell.sh",
Expand All @@ -24,20 +24,19 @@
"test": "jest --watch",
"test:ci": "jest --collectCoverage",
"install:ci": "yarn install --frozen-lockfile",
"nuxt": "./node_modules/.bin/nuxt",
"dev": "source ./scripts/version && ./node_modules/.bin/nuxt dev",
"mem-dev": "source ./scripts/version && node --max-old-space-size=8192 ./node_modules/.bin/nuxt dev",
"dev": "source ./scripts/version && NODE_ENV=dev ./node_modules/.bin/vue-cli-service serve",
"mem-dev": "source ./scripts/version && NODE_ENV=dev node --max-old-space-size=8192 ./node_modules/.bin/vue-cli-service serve",
"docker-dev": "docker run --rm --name dashboard-dev -p 8005:8005 -e API=$API -v $(pwd):/src -v dashboard_node:/src/node_modules rancher/dashboard:dev",
"docker:local:start": "docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -e CATTLE_BOOTSTRAP_PASSWORD=password -e CATTLE_PASSWORD_MIN_LENGTH=3 --name cypress --privileged rancher/rancher:v2.7-head",
"docker:local:stop": "docker kill cypress || docker rm cypress || true",
"build": "./node_modules/.bin/nuxt build --devtools",
"build": "yarn lint && ./node_modules/.bin/vue-cli-service build",
"build:lib": "cd pkg/rancher-components && yarn build:lib",
"analyze": "./node_modules/.bin/nuxt build --analyze",
"start": "./node_modules/.bin/nuxt start",
"analyze": "./node_modules/.bin/vue-cli-service build --report",
"start": "./node_modules/.bin/vue-cli-service serve",
"start:dev": "NODE_ENV=dev yarn start",
"start:prod": "DEV_PORTS=true NODE_ENV=production yarn start",
"generate": "./node_modules/.bin/nuxt generate",
"dev-debug": "node --inspect ./node_modules/.bin/nuxt",
"start:prod": "NODE_OPTIONS=--max_old_space_size=4096 DEV_PORTS=true NODE_ENV=production yarn start",
"generate": "yarn build",
"dev-debug": "node --inspect ./node_modules/.bin/vue-cli-service",
"cy:e2e": "cypress open --e2e --browser chrome",
"cy:open": "cypress open",
"cy:run": "cypress run --browser chrome",
Expand Down Expand Up @@ -109,12 +108,18 @@
"shell-quote": "1.7.3",
"sinon": "8.1.1",
"ts-node": "8.10.2",
"ufo": "0.7.11",
"unfetch": "4.2.0",
"url-parse": "1.5.10",
"v-tooltip": "2.0.3",
"vue-client-only": "2.1.0",
"vue-clipboard2": "0.3.1",
"vue-codemirror": "4.0.6",
"vue-js-modal": "1.3.35",
"vue-meta": "2.4.0",
"vue-no-ssr": "1.1.1",
"vue-resize": "0.4.5",
"vue-router": "3.6.5",
"vue-select": "3.18.3",
"vue-server-renderer": "2.6.14",
"vue-shortkey": "3.1.7",
Expand All @@ -141,14 +146,13 @@
"@nuxtjs/eslint-config-typescript": "6.0.1",
"@nuxtjs/eslint-module": "1.2.0",
"@nuxtjs/style-resources": "1.2.1",
"@types/copy-webpack-plugin": "^5.0.3",
"@types/jest": "27.4.1",
"@types/lodash": "4.14.184",
"@types/node": "16.4.3",
"@types/vue-select": "3.16.0",
"@typescript-eslint/eslint-plugin": "4.33.0",
"@typescript-eslint/parser": "4.33.0",
"@vue/cli-plugin-babel": "4.5.15",
"@vue/cli-plugin-typescript": "4.5.15",
"@vue/cli-service": "4.5.15",
"@vue/eslint-config-standard": "5.1.2",
"@vue/test-utils": "1.2.1",
Expand Down
3 changes: 1 addition & 2 deletions pkg/harvester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"registry": "http://localhost:4873"
},
"scripts": {
"dev": "./node_modules/.bin/nuxt dev",
"nuxt": "./node_modules/.bin/nuxt"
"dev": "./node_modules/.bin/vue-cli-service dev"
},
"engines": {
"node": ">=14"
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-embedded
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DIR=${GIT_TAG:-$COMMIT_BRANCH}
OUTPUT_DIR=dist/${DIR}-embedded

echo "Building..."
NUXT_ENV_commit=${COMMIT} NUXT_ENV_version=${VERSION} OUTPUT_DIR=$OUTPUT_DIR ROUTER_BASE='/dashboard' yarn run build
COMMIT=${COMMIT} VERSION=${VERSION} OUTPUT_DIR=$OUTPUT_DIR ROUTER_BASE='/dashboard' yarn run build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There' a change @aalves08 is bringing in that makes use of these, i think via the $config service. it would be good to validate that feature (once it's merged) still works fine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference this is the PR #7516

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part that adds the version env variable

source scripts/version

I did have to make changes to the vue.config.js since it doesn't have a concept of publicRuntimeConfig. I defined that using definePlugin and updated the nuxt/client.js since definePlugin didn't seem to support replacing the NUXT prefix.

richard-cox marked this conversation as resolved.
Show resolved Hide resolved

if [ -v EMBED_PKG ]; then
echo "Build and embed plugin from: $EMBED_PKG"
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-hosted
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ BASE=${BASE:-https://releases.rancher.com/dashboard/${DIR}}

echo "Building for ${BASE}..."

NUXT_ENV_commit=${COMMIT} NUXT_ENV_version=${VERSION} OUTPUT_DIR=dist/${DIR} ROUTER_BASE="/dashboard" RESOURCE_BASE="${BASE}" yarn run build --spa
COMMIT=${COMMIT} VERSION=${VERSION} OUTPUT_DIR=dist/${DIR} ROUTER_BASE="/dashboard" RESOURCE_BASE="${BASE}" yarn run build
2 changes: 1 addition & 1 deletion shell/assets/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
@import "./vendor/vue-select";
@import "./vendor/vue-js-modal";
@import "./vendor/code-mirror";
@import '@/node_modules/xterm/css/xterm.css';
@import 'node_modules/xterm/css/xterm.css';
22 changes: 11 additions & 11 deletions shell/assets/styles/fonts/_fontstack.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
font-style: normal;
font-weight: normal;
src: local(''),
url('~shell/assets/fonts/poppins/poppins-v15-latin-300.woff2') format('woff2'), /* Super Modern Browsers */
url('~shell/assets/fonts/poppins/poppins-v15-latin-300.woff') format('woff'), /* Modern Browsers */
url('~@shell/assets/fonts/poppins/poppins-v15-latin-300.woff2') format('woff2'), /* Super Modern Browsers */
url('~@shell/assets/fonts/poppins/poppins-v15-latin-300.woff') format('woff'), /* Modern Browsers */
}

/* poppins-500 - latin */
Expand All @@ -14,8 +14,8 @@
font-style: normal;
font-weight: bold;
src: local(''),
url('~shell/assets/fonts/poppins/poppins-v15-latin-500.woff2') format('woff2'), /* Super Modern Browsers */
url('~shell/assets/fonts/poppins/poppins-v15-latin-500.woff') format('woff'), /* Modern Browsers */
url('~@shell/assets/fonts/poppins/poppins-v15-latin-500.woff2') format('woff2'), /* Super Modern Browsers */
url('~@shell/assets/fonts/poppins/poppins-v15-latin-500.woff') format('woff'), /* Modern Browsers */
}

/* lato-regular - latin */
Expand All @@ -24,8 +24,8 @@
font-style: normal;
font-weight: normal;
src: local(''),
url('~shell/assets/fonts/lato/lato-v17-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('~shell/assets/fonts/lato/lato-v17-latin-regular.woff') format('woff'), /* Modern Browsers */
url('~@shell/assets/fonts/lato/lato-v17-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('~@shell/assets/fonts/lato/lato-v17-latin-regular.woff') format('woff'), /* Modern Browsers */
}

/* lato-700 - latin */
Expand All @@ -34,8 +34,8 @@
font-style: normal;
font-weight: bold;
src: local(''),
url('~shell/assets/fonts/lato/lato-v17-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
url('~shell/assets/fonts/lato/lato-v17-latin-700.woff') format('woff'), /* Modern Browsers */
url('~@shell/assets/fonts/lato/lato-v17-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
url('~@shell/assets/fonts/lato/lato-v17-latin-700.woff') format('woff'), /* Modern Browsers */
}

/* roboto-mono-regular - latin */
Expand All @@ -44,6 +44,6 @@
font-style: normal;
font-weight: normal;
src: local(''),
url('~shell/assets/fonts/roboto-mono/roboto-mono-v13-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('~shell/assets/fonts/roboto-mono/roboto-mono-v13-latin-regular.woff') format('woff'), /* Modern Browsers */
}
url('~@shell/assets/fonts/roboto-mono/roboto-mono-v13-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('~@shell/assets/fonts/roboto-mono/roboto-mono-v13-latin-regular.woff') format('woff'), /* Modern Browsers */
}
6 changes: 3 additions & 3 deletions shell/assets/styles/vendor/vue-js-modal.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~/node_modules/vue-js-modal/dist/styles.css';
@import 'node_modules/vue-js-modal/dist/styles.css';

.v--modal-overlay {
background-color: var(--overlay-bg);
Expand All @@ -10,7 +10,7 @@
}

.v--modal {
background-color: var(--modal-bg)!important;
background-color: var(--modal-bg) !important;
box-shadow: none;
border: 2px solid var(--modal-border);
}
}
13 changes: 13 additions & 0 deletions shell/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
presets: [
[
'@vue/cli-plugin-babel/preset',
{ useBuiltIns: false }
],
[
'@babel/preset-env',
{ targets: { node: 'current' } }
]
],
env: { test: { presets: [['@babel/env', { targets: { node: 'current' } }]] } }
};
Loading