From aba9c167e0a9faa955d331d5f1580debbf402988 Mon Sep 17 00:00:00 2001 From: Francesco Torchia Date: Tue, 10 Sep 2024 17:26:19 +0200 Subject: [PATCH] Vue3 migration - vue-migration.js launch + shell compatibility fixes Signed-off-by: Francesco Torchia --- .eslintrc.js | 392 +-- package.json | 23 +- pkg/harvester/components/DiskTags.vue | 6 +- pkg/harvester/components/FilterBySriov.vue | 4 +- pkg/harvester/components/FilterLabel.vue | 18 +- pkg/harvester/components/HarvesterUpgrade.vue | 6 +- .../HarvesterUpgradeProgressBarList.vue | 4 +- pkg/harvester/components/SettingList.vue | 2 +- .../novnc/NovncConsoleCustomKeys.vue | 2 +- .../components/novnc/NovncConsoleWrapper.vue | 2 +- .../components/settings/additional-ca.vue | 2 +- .../settings/auto-rotate-rke2-certs.vue | 10 +- .../components/settings/backup-target.vue | 16 +- .../settings/containerd-registry.vue | 37 +- .../components/settings/csi-driver-config.vue | 14 +- ...lt-vm-termination-grace-period-seconds.vue | 2 +- .../components/settings/http-proxy.vue | 8 +- .../components/settings/ntp-servers.vue | 4 +- .../components/settings/overcommit-config.vue | 12 +- .../components/settings/ssl-parameters.vue | 8 +- .../components/settings/storage-network.vue | 20 +- .../settings/support-bundle-image.vue | 6 +- .../settings/support-bundle-namespaces.vue | 4 +- .../settings/vm-force-reset-policy.vue | 4 +- .../HarvesterHostDisk.vue | 4 +- .../harvesterhci.io.host/HarvesterSeeder.vue | 6 +- .../VirtualMachineInstance.vue | 8 +- .../harvesterhci.io.host/VlanStatus/index.vue | 2 +- .../detail/harvesterhci.io.host/index.vue | 12 +- .../detail/harvesterhci.io.secret.vue | 6 +- .../index.vue | 12 +- .../index.vue | 2 +- .../harvesterhci.io.vmsnapshot/index.vue | 12 +- .../VirtualMachineBasics.vue | 6 +- .../VirtualMachineKeypairs.vue | 2 +- .../kubevirt.io.virtualmachine/index.vue | 12 +- .../loadbalancer.harvesterhci.io.ippool.vue | 2 +- ...dbalancer.harvesterhci.io.loadbalancer.vue | 2 +- .../network.harvesterhci.io.vlanconfig.vue | 2 +- pkg/harvester/dialog/CloneVmDialog.vue | 6 +- .../dialog/ConfirmRelatedToRemoveDialog.vue | 4 +- pkg/harvester/dialog/DeepCloneVmDialog.vue | 4 +- pkg/harvester/dialog/EnableVGpuDevice.vue | 2 +- .../dialog/HarvesterAddHotplugModal.vue | 6 +- pkg/harvester/dialog/HarvesterBackupModal.vue | 2 +- .../dialog/HarvesterCloneTemplate.vue | 8 +- .../dialog/HarvesterEjectCDROMDialog.vue | 4 +- .../dialog/HarvesterExportImageDialog.vue | 8 +- .../dialog/HarvesterMaintenanceDialog.vue | 6 +- .../dialog/HarvesterMigrationDialog.vue | 4 +- .../dialog/HarvesterRestoreDialog.vue | 2 +- .../dialog/HarvesterSupportBundle.vue | 8 +- .../dialog/HarvesterVMSnapshotDialog.vue | 6 +- .../HarvesterVlanConfigMigrateDialog.vue | 4 +- pkg/harvester/dialog/RestartVMDialog.vue | 4 +- .../dialog/RestoreSnapshotDialog.vue | 6 +- pkg/harvester/dialog/SnapshotDialog.vue | 2 +- pkg/harvester/dialog/VolumeCloneDialog.vue | 6 +- .../edit/harvesterhci.io.addon/generic.vue | 4 +- .../harvester-seeder.vue | 4 +- .../nvidia-driver-toolkit.vue | 10 +- .../pcidevices-controller.vue | 4 +- .../harvesterhci.io.addon/rancher-logging.vue | 20 +- .../rancher-monitoring.vue | 48 +- .../rancher-vcluster.vue | 10 +- .../vm-import-controller.vue | 32 +- .../edit/harvesterhci.io.cloudtemplate.vue | 8 +- .../harvesterhci.io.host/HarvesterDisk.vue | 8 +- .../HarvesterKsmtuned.vue | 8 +- .../harvesterhci.io.host/HarvesterSeeder.vue | 22 +- .../edit/harvesterhci.io.host/index.vue | 12 +- .../edit/harvesterhci.io.keypair.vue | 4 +- .../edit/harvesterhci.io.logging.output.vue | 6 +- .../index.vue | 2 +- ...sterhci.io.networkattachmentdefinition.vue | 16 +- pkg/harvester/edit/harvesterhci.io.secret.vue | 4 +- .../edit/harvesterhci.io.setting.vue | 12 +- .../edit/harvesterhci.io.storage/index.vue | 14 +- .../provisioners/custom.vue | 2 +- .../provisioners/driver.longhorn.io.vue | 12 +- .../harvesterhci.io.virtualmachinebackup.vue | 16 +- .../harvesterhci.io.virtualmachineimage.vue | 24 +- ...erhci.io.virtualmachinetemplateversion.vue | 30 +- .../edit/harvesterhci.io.vmsnapshot.vue | 14 +- pkg/harvester/edit/harvesterhci.io.volume.vue | 40 +- .../edit/harvesterhci.io.volumesnapshot.vue | 8 +- .../AccessCredentialsUsers.vue | 4 +- .../VirtualMachineAccessCredentials/index.vue | 4 +- .../type/basicAuth.vue | 6 +- .../type/sshkey.vue | 4 +- .../DataTemplate.vue | 6 +- .../VirtualMachineCloudConfig/index.vue | 10 +- .../VirtualMachineCpuMemory.vue | 8 +- .../VirtualMachineNetwork/base.vue | 20 +- .../VirtualMachineNetwork/index.vue | 5 +- .../CompatibilityMatrix.vue | 8 +- .../VirtualMachinePciDevices/index.vue | 4 +- .../VirtualMachineReserved.vue | 4 +- .../VirtualMachineSSHKey.vue | 8 +- .../VirtualMachineVGpuDevices/index.vue | 4 +- .../VirtualMachineVolume/index.vue | 8 +- .../VirtualMachineVolume/type/container.vue | 16 +- .../VirtualMachineVolume/type/existing.vue | 24 +- .../VirtualMachineVolume/type/vmImage.vue | 20 +- .../VirtualMachineVolume/type/volume.vue | 20 +- .../edit/kubevirt.io.virtualmachine/index.vue | 52 +- .../Priority.vue | 6 +- .../PriorityRow.vue | 12 +- .../Range.vue | 12 +- .../Selector.vue | 10 +- .../index.vue | 4 +- .../HealthCheck.vue | 4 +- .../Listeners.vue | 6 +- .../index.vue | 14 +- .../edit/management.cattle.io.project.vue | 8 +- .../index.vue | 2 +- .../NodeSelector.vue | 12 +- .../index.vue | 8 +- .../formatters/HarvesterDiskState.vue | 4 +- .../formatters/HarvesterListener.vue | 4 +- .../formatters/HarvesterVFAddress.vue | 8 +- .../formatters/HarvesterVGpuDevices.vue | 8 +- pkg/harvester/formatters/HarvesterVmState.vue | 2 +- pkg/harvester/formatters/StateWithPopover.vue | 4 +- pkg/harvester/list/harvesterhci.io.addon.vue | 8 +- .../list/harvesterhci.io.cloudtemplate.vue | 2 +- .../list/harvesterhci.io.dashboard.vue | 4 +- pkg/harvester/list/harvesterhci.io.host.vue | 2 +- ...erhci.io.monitoring.alertmanagerconfig.vue | 2 +- ...sterhci.io.networkattachmentdefinition.vue | 6 +- pkg/harvester/list/harvesterhci.io.secret.vue | 2 +- .../harvesterhci.io.virtualmachinebackup.vue | 2 +- .../harvesterhci.io.virtualmachineimage.vue | 2 +- ...erhci.io.virtualmachinetemplateversion.vue | 4 +- .../list/harvesterhci.io.vmsnapshot.vue | 2 +- pkg/harvester/list/harvesterhci.io.volume.vue | 8 +- .../list/harvesterhci.io.volumesnapshot.vue | 2 +- .../list/kubevirt.io.virtualmachine.vue | 8 +- ...network.harvesterhci.io.clusternetwork.vue | 2 +- .../pages/c/_cluster/airgapupgrade/index.vue | 12 +- .../_alertmanagerconfigid/receiver.vue | 2 +- .../pages/c/_cluster/brand/index.vue | 19 +- .../pages/c/_cluster/console/_uid/serial.vue | 2 +- .../pages/c/_cluster/console/_uid/vnc.vue | 2 +- .../pages/c/_cluster/projectsnamespaces.vue | 38 +- .../kubevirt.io.virtualmachine.vue | 6 +- pkg/harvester/routing/harvester-routing.ts | 4 +- tsconfig.json | 1 + vue-migrate.js | 687 ++++++ yarn.lock | 2167 ++++++----------- 150 files changed, 2297 insertions(+), 2244 deletions(-) create mode 100644 vue-migrate.js diff --git a/.eslintrc.js b/.eslintrc.js index 43575a44..c026fa66 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,175 +1,247 @@ module.exports = { - root: true, - env: { - browser: true, - node: true + "root": true, + "env": { + "browser": true, + "node": true }, - globals: { NodeJS: true, Timer: true }, - extends: [ - 'standard', - 'eslint:recommended', - '@nuxtjs/eslint-config-typescript', - 'plugin:cypress/recommended' + "globals": { + "NodeJS": true, + "Timer": true + }, + "extends": [ + "standard", + "eslint:recommended", + "@nuxtjs/eslint-config-typescript", + "plugin:cypress/recommended" ], - // add your custom rules here - rules: { - 'dot-notation': 'off', - 'generator-star-spacing': 'off', - 'guard-for-in': 'off', - 'linebreak-style': 'off', - 'new-cap': 'off', - 'no-empty': 'off', - 'no-extra-boolean-cast': 'off', - 'no-new': 'off', - 'no-plusplus': 'off', - 'no-useless-escape': 'off', - 'nuxt/no-cjs-in-config': 'off', - 'semi-spacing': 'off', - 'space-in-parens': 'off', - strict: 'off', - 'unicorn/no-new-buffer': 'off', - 'vue/html-self-closing': 'off', - 'vue/multi-word-component-names': 'off', - 'vue/no-reserved-component-names': 'off', - 'vue/no-unused-components': 'warn', - 'vue/no-v-html': 'error', - 'wrap-iife': 'off', - - 'array-bracket-spacing': 'warn', - 'arrow-parens': 'warn', - 'arrow-spacing': ['warn', { before: true, after: true }], - 'block-spacing': ['warn', 'always'], - 'brace-style': ['warn', '1tbs'], - 'comma-dangle': ['warn', 'only-multiline'], - 'comma-spacing': 'warn', - curly: 'warn', - eqeqeq: 'warn', - 'func-call-spacing': ['warn', 'never'], - 'implicit-arrow-linebreak': 'warn', - indent: ['warn', 2], - 'keyword-spacing': 'warn', - 'lines-between-class-members': ['warn', 'always', { exceptAfterSingleLine: true }], - 'multiline-ternary': ['warn', 'never'], - 'newline-per-chained-call': ['warn', { ignoreChainWithDepth: 4 }], - 'no-caller': 'warn', - 'no-cond-assign': ['warn', 'except-parens'], - 'no-console': 'warn', - 'no-debugger': 'warn', - 'no-eq-null': 'warn', - 'no-eval': 'warn', - 'no-trailing-spaces': 'warn', - 'no-undef': 'warn', - 'no-unused-vars': 'warn', - 'no-whitespace-before-property': 'warn', - 'object-curly-spacing': ['warn', 'always'], - 'object-property-newline': 'warn', - 'object-shorthand': 'warn', - 'padded-blocks': ['warn', 'never'], - 'prefer-arrow-callback': 'warn', - 'prefer-template': 'warn', - 'quote-props': 'warn', - 'rest-spread-spacing': 'warn', - semi: ['warn', 'always'], - 'space-before-function-paren': ['warn', 'never'], - 'space-infix-ops': 'warn', - 'spaced-comment': 'warn', - 'switch-colon-spacing': 'warn', - 'template-curly-spacing': ['warn', 'always'], - 'yield-star-spacing': ['warn', 'both'], - - 'key-spacing': ['warn', { - align: { - beforeColon: false, - afterColon: true, - on: 'value', - mode: 'minimum' - }, - multiLine: { - beforeColon: false, - afterColon: true - }, - }], - - 'object-curly-newline': ['warn', { - ObjectExpression: { - multiline: true, - minProperties: 3 - }, - ObjectPattern: { - multiline: true, - minProperties: 4 - }, - ImportDeclaration: { - multiline: true, - minProperties: 5 - }, - ExportDeclaration: { - multiline: true, - minProperties: 3 - } - }], - - 'padding-line-between-statements': [ - 'warn', + "rules": { + "dot-notation": "off", + "generator-star-spacing": "off", + "guard-for-in": "off", + "linebreak-style": "off", + "new-cap": "off", + "no-empty": "off", + "no-extra-boolean-cast": "off", + "no-new": "off", + "no-plusplus": "off", + "no-useless-escape": "off", + "nuxt/no-cjs-in-config": "off", + "semi-spacing": "off", + "space-in-parens": "off", + "strict": "off", + "unicorn/no-new-buffer": "off", + "vue/html-self-closing": "off", + "vue/multi-word-component-names": "off", + "vue/no-reserved-component-names": "off", + "vue/no-unused-components": "warn", + "vue/no-v-html": "error", + "wrap-iife": "off", + "array-bracket-spacing": "warn", + "arrow-parens": "warn", + "arrow-spacing": [ + "warn", { - blankLine: 'always', - prev: '*', - next: 'return', - }, - { - blankLine: 'always', - prev: 'function', - next: 'function', - }, - // This configuration would require blank lines after every sequence of variable declarations - { - blankLine: 'always', - prev: ['const', 'let', 'var'], - next: '*' - }, - { - blankLine: 'any', - prev: ['const', 'let', 'var'], - next: ['const', 'let', 'var'] + "before": true, + "after": true } ], - - quotes: [ - 'warn', - 'single', - { - avoidEscape: true, - allowTemplateLiterals: true - }, + "block-spacing": [ + "warn", + "always" ], - - 'space-unary-ops': [ - 'warn', + "brace-style": [ + "warn", + "1tbs" + ], + "comma-dangle": [ + "warn", + "only-multiline" + ], + "comma-spacing": "warn", + "curly": "warn", + "eqeqeq": "warn", + "func-call-spacing": [ + "warn", + "never" + ], + "implicit-arrow-linebreak": "warn", + "indent": [ + "warn", + 2 + ], + "keyword-spacing": "warn", + "lines-between-class-members": [ + "warn", + "always", { - words: true, - nonwords: false, + "exceptAfterSingleLine": true } ], - - // FIXME: The following is disabled due to new linter and old JS code. These should all be enabled and underlying issues fixed - 'vue/order-in-components': 'off', - 'vue/no-lone-template': 'off', - 'vue/v-slot-style': 'off', - 'vue/component-tags-order': 'off', - 'vue/no-mutating-props': 'off', - '@typescript-eslint/no-unused-vars': 'off', - 'array-callback-return': 'off', + "multiline-ternary": [ + "warn", + "never" + ], + "newline-per-chained-call": [ + "warn", + { + "ignoreChainWithDepth": 4 + } + ], + "no-caller": "warn", + "no-cond-assign": [ + "warn", + "except-parens" + ], + "no-console": "warn", + "no-debugger": "warn", + "no-eq-null": "warn", + "no-eval": "warn", + "no-trailing-spaces": "warn", + "no-undef": "warn", + "no-unused-vars": "warn", + "no-whitespace-before-property": "warn", + "object-curly-spacing": [ + "warn", + "always" + ], + "object-property-newline": "warn", + "object-shorthand": "warn", + "padded-blocks": [ + "warn", + "never" + ], + "prefer-arrow-callback": "warn", + "prefer-template": "warn", + "quote-props": "warn", + "rest-spread-spacing": "warn", + "semi": [ + "warn", + "always" + ], + "space-before-function-paren": [ + "warn", + "never" + ], + "space-infix-ops": "warn", + "spaced-comment": "warn", + "switch-colon-spacing": "warn", + "template-curly-spacing": [ + "warn", + "always" + ], + "yield-star-spacing": [ + "warn", + "both" + ], + "key-spacing": [ + "warn", + { + "align": { + "beforeColon": false, + "afterColon": true, + "on": "value", + "mode": "minimum" + }, + "multiLine": { + "beforeColon": false, + "afterColon": true + } + } + ], + "object-curly-newline": [ + "warn", + { + "ObjectExpression": { + "multiline": true, + "minProperties": 3 + }, + "ObjectPattern": { + "multiline": true, + "minProperties": 4 + }, + "ImportDeclaration": { + "multiline": true, + "minProperties": 5 + }, + "ExportDeclaration": { + "multiline": true, + "minProperties": 3 + } + } + ], + "padding-line-between-statements": [ + "warn", + { + "blankLine": "always", + "prev": "*", + "next": "return" + }, + { + "blankLine": "always", + "prev": "function", + "next": "function" + }, + { + "blankLine": "always", + "prev": [ + "const", + "let", + "var" + ], + "next": "*" + }, + { + "blankLine": "any", + "prev": [ + "const", + "let", + "var" + ], + "next": [ + "const", + "let", + "var" + ] + } + ], + "quotes": [ + "warn", + "single", + { + "avoidEscape": true, + "allowTemplateLiterals": true + } + ], + "space-unary-ops": [ + "warn", + { + "words": true, + "nonwords": false + } + ], + "vue/order-in-components": "off", + "vue/no-lone-template": "off", + "vue/v-slot-style": "off", + "vue/component-tags-order": "off", + "vue/no-mutating-props": "off", + "@typescript-eslint/no-unused-vars": "off", + "array-callback-return": "off", + "vue/one-component-per-file": "off", + "vue/no-deprecated-slot-attribute": "off", + "vue/require-explicit-emits": "off", + "vue/v-on-event-hyphenation": "off" }, - overrides: [ + "overrides": [ { - files: ['*.js'], - rules: { - // FIXME: The following is disabled due to new linter and old JS code. These should all be enabled and underlying issues fixed - 'prefer-regex-literals': 'off', - 'vue/component-definition-name-casing': 'off', - 'no-unreachable-loop': 'off', - 'computed-property-spacing': 'off', + "files": [ + "*.js" + ], + "rules": { + "prefer-regex-literals": "off", + "vue/component-definition-name-casing": "off", + "no-unreachable-loop": "off", + "computed-property-spacing": "off" } } ] -}; +} \ No newline at end of file diff --git a/package.json b/package.json index b72c5164..0a54bb3b 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,17 @@ "dependencies": { "@rancher/components": "0.3.0-alpha.1", "@rancher/shell": "2.0.0", + "@vue/cli-plugin-babel": "5.0.8", + "@vue/cli-plugin-typescript": "5.0.8", + "@vue/cli-service": "5.0.8", + "cache-loader": "^4.1.0", + "codemirror": ">=5.64.0 <6", + "codemirror-editor-vue3": "^2.7.0", "core-js": "3.25.3", "css-loader": "4.3.0", - "@vue/cli-plugin-babel": "5.0.8", - "@vue/cli-service": "5.0.8", - "@vue/cli-plugin-typescript": "5.0.8", - "cache-loader": "^4.1.0", - "yaml": "2.0.0", - "node-polyfill-webpack-plugin": "^3.0.0" + "diff_match_patch": "^0.1.1", + "node-polyfill-webpack-plugin": "^3.0.0", + "yaml": "2.0.0" }, "resolutions": { "@vue/cli-plugin-babel": "5.0.8", @@ -46,13 +49,13 @@ "publish-pkgs": "./node_modules/@rancher/shell/scripts/extension/publish", "parse-tag-name": "./node_modules/@rancher/shell/scripts/extension/parse-tag-name", "lint": "./node_modules/.bin/eslint --max-warnings 0 --ext .js,.ts,.vue .", - "test": "jest --watch" + "test": "jest --watch", + "migrate": "node ./vue-migrate.js" }, "devDependencies": { "@types/jest": "^29.5.12", "@types/lodash": "^4.17.5", - "@vue/vue2-jest": "^29.2.6", - "babel-plugin-transform-require-context": "^0.1.1", - "ts-jest": "^29.1.4" + "@vue/vue3-jest": "^27.0.0-alpha.1", + "babel-plugin-transform-require-context": "^0.1.1" } } diff --git a/pkg/harvester/components/DiskTags.vue b/pkg/harvester/components/DiskTags.vue index e3d2f531..95b36f2e 100644 --- a/pkg/harvester/components/DiskTags.vue +++ b/pkg/harvester/components/DiskTags.vue @@ -122,9 +122,7 @@ export default {
{{ tag }} @@ -157,7 +155,7 @@ export default { >
-