From 6ebf484b1aa42e0d146b1f60242cb377f2a5e70c Mon Sep 17 00:00:00 2001 From: Sangeetha Date: Fri, 27 Oct 2023 10:07:57 +0100 Subject: [PATCH 1/5] Initial changes to remove webpack with vite and added some depencies for jest --- .env | 8 +- .env.production | 8 +- .env.uat | 8 +- .eslintrc.js | 10 +- babel.config.js | 3 - public/favicon.ico => favicon.ico | Bin public/index.html => index.html | 4 +- jest.config.js => jest.config.cjs | 7 +- package.json | 42 +- server.js | 6 +- src/api/PrintMyBarcode.js | 4 +- src/components/Plate.vue | 8 +- src/components/PlateList.vue | 2 +- src/components/PrintJob.vue | 4 +- src/components/Upload.vue | 4 +- src/components/wells/index.js | 10 +- src/router.js | 8 +- tests/unit/Alert.spec.js | 2 +- tests/unit/Plate.spec.js | 7 +- tests/unit/PrintJob.spec.js | 3 +- tests/unit/QuantFile.spec.js | 2 +- tests/unit/Replicates.spec.js | 2 +- tests/unit/Row.spec.js | 2 +- tests/unit/Upload.spec.js | 2 +- tests/unit/Wells.spec.js | 4 +- vite.config.js | 32 + yarn.lock | 9472 +++++++---------------------- 27 files changed, 2451 insertions(+), 7213 deletions(-) delete mode 100644 babel.config.js rename public/favicon.ico => favicon.ico (100%) rename public/index.html => index.html (82%) rename jest.config.js => jest.config.cjs (63%) create mode 100644 vite.config.js diff --git a/.env b/.env index fe12a308..71285b91 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ NODE_ENV=development -VUE_APP_SEQUENCESCAPE_BASE_URL=http://localhost:3000/api/v2 -VUE_APP_SEQUENCESCAPE_API_KEY=development -VUE_APP_PRINT_MY_BARCODE_BASE_URL=http://localhost:3000 -VUE_APP_LABEL_TEMPLATE_ID=33 +VITE_SEQUENCESCAPE_BASE_URL=http://localhost:3000/api/v2 +VITE_SEQUENCESCAPE_API_KEY=development +VITE_PRINT_MY_BARCODE_BASE_URL=http://localhost:3000 +VITE_LABEL_TEMPLATE_ID=33 diff --git a/.env.production b/.env.production index 6f168288..a27cfeb7 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,4 @@ -VUE_APP_SEQUENCESCAPE_BASE_URL=REPLACE_VUE_APP_SEQUENCESCAPE_BASE_URL -VUE_APP_SEQUENCESCAPE_API_KEY=REPLACE_VUE_APP_SEQUENCESCAPE_API_KEY -VUE_APP_PRINT_MY_BARCODE_BASE_URL=REPLACE_VUE_APP_PRINT_MY_BARCODE_BASE_URL -VUE_APP_LABEL_TEMPLATE_ID=REPLACE_VUE_APP_LABEL_TEMPLATE_ID +VITE_SEQUENCESCAPE_BASE_URL=REPLACE_VITE_SEQUENCESCAPE_BASE_URL +VITE_SEQUENCESCAPE_API_KEY=REPLACE_VITE_SEQUENCESCAPE_API_KEY +VITE_PRINT_MY_BARCODE_BASE_URL=REPLACE_VITE_PRINT_MY_BARCODE_BASE_URL +VITE_LABEL_TEMPLATE_ID=REPLACE_VITE_LABEL_TEMPLATE_ID diff --git a/.env.uat b/.env.uat index 6f168288..a27cfeb7 100644 --- a/.env.uat +++ b/.env.uat @@ -1,4 +1,4 @@ -VUE_APP_SEQUENCESCAPE_BASE_URL=REPLACE_VUE_APP_SEQUENCESCAPE_BASE_URL -VUE_APP_SEQUENCESCAPE_API_KEY=REPLACE_VUE_APP_SEQUENCESCAPE_API_KEY -VUE_APP_PRINT_MY_BARCODE_BASE_URL=REPLACE_VUE_APP_PRINT_MY_BARCODE_BASE_URL -VUE_APP_LABEL_TEMPLATE_ID=REPLACE_VUE_APP_LABEL_TEMPLATE_ID +VITE_SEQUENCESCAPE_BASE_URL=REPLACE_VITE_SEQUENCESCAPE_BASE_URL +VITE_SEQUENCESCAPE_API_KEY=REPLACE_VITE_SEQUENCESCAPE_API_KEY +VITE_PRINT_MY_BARCODE_BASE_URL=REPLACE_VITE_PRINT_MY_BARCODE_BASE_URL +VITE_LABEL_TEMPLATE_ID=REPLACE_VITE_LABEL_TEMPLATE_ID diff --git a/.eslintrc.js b/.eslintrc.js index 9f63f560..b3a673ff 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,14 +2,12 @@ module.exports = { root: true, env: { node: true, + es2022: true, }, - extends: ['plugin:vue/essential', 'eslint:recommended', 'prettier'], + extends: ['plugin:vue/vue3-recommended', 'eslint:recommended', 'prettier'], rules: { - 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-console': import.meta.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-debugger': import.meta.NODE_ENV === 'production' ? 'error' : 'off', 'prefer-const': 'error', }, - parserOptions: { - parser: 'babel-eslint', - }, } diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index c1b783ea..00000000 --- a/babel.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - presets: ['@vue/cli-plugin-babel/preset'], -} diff --git a/public/favicon.ico b/favicon.ico similarity index 100% rename from public/favicon.ico rename to favicon.ico diff --git a/public/index.html b/index.html similarity index 82% rename from public/index.html rename to index.html index 56d5287b..98272cd6 100644 --- a/public/index.html +++ b/index.html @@ -4,7 +4,7 @@ - + quanthub @@ -15,6 +15,6 @@ >
- + diff --git a/jest.config.js b/jest.config.cjs similarity index 63% rename from jest.config.js rename to jest.config.cjs index 6b1b01ce..2af86d6e 100644 --- a/jest.config.js +++ b/jest.config.cjs @@ -1,10 +1,12 @@ module.exports = { + preset: './node_modules/vite-jest/jest-preset.js', moduleFileExtensions: ['js', 'jsx', 'json', 'vue'], + extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'], transform: { - '^.+\\.vue$': 'vue-jest', + '^.+\\.vue$': '@vue/vue2-jest', '.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub', - '^.+\\.jsx?$': 'babel-jest', + // '^.+\\.jsx?$': 'babel-jest', }, moduleNameMapper: { '^@/(.*)$': '/src/$1', @@ -14,4 +16,5 @@ module.exports = { '**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)', ], testURL: 'http://localhost/', + // testEnvironment: "jest-environment-jsdom" } diff --git a/package.json b/package.json index bf0d7ad2..d211c2ec 100644 --- a/package.json +++ b/package.json @@ -3,23 +3,26 @@ "version": "2.1.0", "private": true, "scripts": { - "serve": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve", - "build": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build", - "test:unit": "vue-cli-service test:unit", - "test:e2e": "vue-cli-service test:e2e", - "lint": "vue-cli-service lint", + "dev": "vite", + "serve": "export NODE_OPTIONS=--openssl-legacy-provider && vite preview", + "build": "export NODE_OPTIONS=--openssl-legacy-provider && vite build", + "test:unit": " vite-jest", + "lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src", "prettier-check": "prettier --check .", - "prettify": "prettier --write .", - "test": "vue-cli-service test:unit && vue-cli-service test:e2e" + "prettify": "prettier --write ." }, "dependencies": { + "@vitejs/plugin-vue": "^1.6.1", "axios": "^0.21.4", "bootstrap-vue": "^2.23.1", + "buffer": "^6.0.3", "csv-parse": "^4.16.3", "isomorphic-fetch": "^2.2.1", "json-server": "^0.14.2", "jsorm": "^1.3.22", "mathjs": "^7.6.0", + "vite": "^2.5.4", + "vite-plugin-vue2": "1.9.0", "vue": "^2.7.5", "vue-router": "^3.5.4", "vue-simple-spinner": "^1.2.10" @@ -28,25 +31,26 @@ "@achrinza/node-ipc": "10.1.9" }, "devDependencies": { - "@vue/cli-plugin-babel": "~4.5.19", - "@vue/cli-plugin-e2e-cypress": "~4.5.19", - "@vue/cli-plugin-eslint": "~4.5.19", - "@vue/cli-plugin-unit-jest": "~4.5.19", - "@vue/cli-service": "4.5.15", "@vue/test-utils": "^1.3.0", - "babel-core": "7.0.0-bridge.0", - "babel-eslint": "^10.1.0", - "babel-jest": "^23.6.0", + "@vue/vue2-jest": "29", + "autoprefixer": "^10.4.16", "cypress": "8.6.0", "cypress-file-upload": "^5.0.8", "eslint": "^5.16.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-vue": "^5.2.3", + "esm": "^3.2.25", "flush-promises": "^1.0.2", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", + "jest-serializer-vue": "^3.1.0", "lint-staged": "^7.3.0", + "node-stdlib-browser": "^1.2.0", + "postcss": "^8.4.31", "prettier": "^2.8.7", - "sass": "^1.62.1", - "sass-loader": "^10.3.1", + "sass": "^1.69.4", + "vite-jest": "^0.1.4", + "vite-plugin-node-polyfills": "^0.15.0", "vue-template-compiler": "^2.7.5" }, "gitHooks": { @@ -54,11 +58,11 @@ }, "lint-staged": { "*.js": [ - "vue-cli-service lint", + "eslint", "git add" ], "*.vue": [ - "vue-cli-service lint", + "eslint", "git add" ], "**/*": "prettier --write --ignore-unknown" diff --git a/server.js b/server.js index 977723ab..01bbbcee 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,8 @@ // server.js -const jsonServer = require('json-server') -const bodyParser = require('body-parser') +// const jsonServer = require('json-server') +// const bodyParser = require('body-parser') +import jsonServer from 'json-server' +import bodyParser from 'body-parser' const server = jsonServer.create() const router = jsonServer.router() const middlewares = jsonServer.defaults() diff --git a/src/api/PrintMyBarcode.js b/src/api/PrintMyBarcode.js index 496a4db6..f4b8efcc 100644 --- a/src/api/PrintMyBarcode.js +++ b/src/api/PrintMyBarcode.js @@ -1,9 +1,9 @@ //TODO: Upgrade to SprayPaint? -const { JSORMBase, attr } = require('jsorm/dist/jsorm') +import { JSORMBase, attr } from 'jsorm/dist/jsorm' const ApplicationRecord = JSORMBase.extend({ static: { - baseUrl: process.env.VUE_APP_PRINT_MY_BARCODE_BASE_URL, + baseUrl: import.meta.env.VITE_PRINT_MY_BARCODE_BASE_URL, apiNamespace: '/v1', }, }) diff --git a/src/components/Plate.vue b/src/components/Plate.vue index 7bb20a28..59336887 100644 --- a/src/components/Plate.vue +++ b/src/components/Plate.vue @@ -69,10 +69,10 @@ // The assumption is made that the data exists in local storage from when it was uploaded. // The QuantType is assigned from local storage and a QuantType component is created. -import Row from '@/components/Row' +import Row from '@/components/Row.vue' import Grid from '@/Grid' import QuantType from '@/QuantType' -import Alert from '@/components/Alert' +import Alert from '@/components/Alert.vue' import { ReplicateList as Replicates } from '@/Replicates' import axios from 'axios' import Spinner from 'vue-simple-spinner' @@ -124,9 +124,9 @@ export default { headers: { 'Content-Type': 'application/vnd.api+json', 'X-Sequencescape-Client-Id': - process.env.VUE_APP_SEQUENCESCAPE_API_KEY, + import.meta.env.VITE_SEQUENCESCAPE_API_KEY, }, - baseURL: process.env.VUE_APP_SEQUENCESCAPE_BASE_URL, + baseURL: import.meta.env.VITE_SEQUENCESCAPE_BASE_URL, } }, request() { diff --git a/src/components/PlateList.vue b/src/components/PlateList.vue index 1d6cc548..7cf55b41 100644 --- a/src/components/PlateList.vue +++ b/src/components/PlateList.vue @@ -42,7 +42,7 @@