From c671d113c96788be4a7b09bfda70bb3967565eee Mon Sep 17 00:00:00 2001 From: yaziming Date: Fri, 19 Jun 2020 16:57:00 +0800 Subject: [PATCH] =?UTF-8?q?=20*=20=E5=A2=9E=E5=8A=A0Docker=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E7=8E=AF=E5=A2=83=20=20*=20=E6=9B=B4=E6=96=B0Dockerfi?= =?UTF-8?q?le=E6=9E=84=E5=BB=BA=E6=96=87=E4=BB=B6=EF=BC=8C=E5=8D=87?= =?UTF-8?q?=E7=BA=A7NodeJS=E4=BE=9D=E8=B5=96=E7=89=88=E6=9C=AC=E3=80=82=20?= =?UTF-8?q?=20*=20=E9=81=B5=E5=BE=AAESLint=E9=87=8D=E6=96=B0=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=83=A8=E5=88=86=E8=AD=A6=E5=91=8A=20=20*=20=E7=99=BB?= =?UTF-8?q?=E5=BD=95Token=E5=A4=B1=E6=95=88=E5=A2=9E=E5=8A=A0=E7=99=BB?= =?UTF-8?q?=E5=87=BA=E6=8F=90=E7=A4=BA=20=20*=20=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E9=97=AE=E9=A2=98=E5=A2=9E=E5=8A=A0=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=20=20*=20?= =?UTF-8?q?=E5=8D=87=E7=BA=A7UI=E4=BE=9D=E8=B5=96=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 7 + Dockerfile | 22 +- Dockerfile.local | 27 +- docker-compose.local.yml | 85 + docker-compose.yml | 4 +- frontend/.editorconfig | 12 +- frontend/.eslintrc.js | 248 +- frontend/babel.config.js | 2 +- frontend/jest.config.js | 8 +- frontend/jsconfig.json | 9 + frontend/package.json | 90 +- frontend/src/App.vue | 109 +- frontend/src/api/request.js | 65 +- frontend/src/assets/logo.svg | 16 +- frontend/src/components/Breadcrumb/index.vue | 102 +- .../components/Common/CrawlConfirmDialog.vue | 432 +- frontend/src/components/Common/DialogView.vue | 236 +- .../components/Common/ParametersDialog.vue | 184 +- frontend/src/components/Config/ConfigList.vue | 1485 +- frontend/src/components/Cron/index.vue | 496 +- frontend/src/components/Cron/language/en.js | 13 +- .../Documentation/Documentation.vue | 153 +- .../Environment/EnvironmentList.vue | 76 +- frontend/src/components/File/FileDetail.vue | 146 +- frontend/src/components/File/FileList.vue | 657 +- frontend/src/components/Hamburger/index.vue | 25 +- .../src/components/InfoView/NodeInfoView.vue | 81 +- .../components/InfoView/SpiderInfoView.vue | 318 +- .../src/components/InfoView/TaskInfoView.vue | 140 +- .../src/components/Node/NodeInstallation.vue | 407 +- .../Node/NodeInstallationMatrix.vue | 491 +- frontend/src/components/Node/NodeNetwork.vue | 307 +- .../src/components/Overview/NodeOverview.vue | 46 +- .../components/Overview/SpiderOverview.vue | 60 +- .../src/components/Overview/TaskOverview.vue | 84 +- frontend/src/components/Pagination/index.vue | 129 +- frontend/src/components/PanThumb/index.vue | 40 +- .../components/Schedule/ScheduleTaskList.vue | 50 +- .../src/components/Scrapy/SpiderScrapy.vue | 753 +- frontend/src/components/Screenfull/index.vue | 52 +- frontend/src/components/ScrollPane/index.vue | 88 +- .../src/components/ScrollView/LogItem.vue | 132 +- .../src/components/ScrollView/LogView.vue | 353 +- .../src/components/Settings/GitSettings.vue | 341 +- .../src/components/Share/dropdownMenu.vue | 40 +- frontend/src/components/SizeSelect/index.vue | 72 +- .../components/Spider/CopySpiderDialog.vue | 86 +- frontend/src/components/Stats/MetricCard.vue | 69 +- frontend/src/components/Stats/SpiderStats.vue | 255 +- .../src/components/Status/StatusLegend.vue | 30 +- frontend/src/components/Status/StatusTag.vue | 98 +- frontend/src/components/Sticky/index.vue | 134 +- frontend/src/components/SvgIcon/index.vue | 44 +- .../components/TableView/DeployTableView.vue | 63 +- .../components/TableView/FieldsTableView.vue | 280 +- .../components/TableView/GeneralTableView.vue | 107 +- .../TableView/SettingFieldsTableView.vue | 199 +- .../components/TableView/TaskTableView.vue | 166 +- frontend/src/components/ThemePicker/index.vue | 207 +- .../Tinymce/components/editorImage 2.vue | 119 +- .../Tinymce/components/editorImage.vue | 119 +- frontend/src/components/Tinymce/index.vue | 254 +- frontend/src/components/Tinymce/toolbar.js | 4 +- frontend/src/components/UploadExcel/index.vue | 188 +- frontend/src/i18n/en.js | 8 +- frontend/src/i18n/zh.js | 10 +- frontend/src/main.js | 12 +- frontend/src/router/index.js | 17 +- frontend/src/store/modules/app.js | 4 +- frontend/src/store/modules/deploy.js | 4 +- frontend/src/store/modules/dialogView.js | 4 +- frontend/src/store/modules/doc.js | 8 +- frontend/src/store/modules/file.js | 27 +- frontend/src/store/modules/lang.js | 4 +- frontend/src/store/modules/node.js | 88 +- frontend/src/store/modules/project.js | 10 +- frontend/src/store/modules/schedule.js | 17 +- frontend/src/store/modules/setting.js | 4 +- frontend/src/store/modules/site.js | 22 +- frontend/src/store/modules/spider.js | 150 +- frontend/src/store/modules/stats.js | 2 +- frontend/src/store/modules/tagsView.js | 26 +- frontend/src/store/modules/task.js | 85 +- frontend/src/store/modules/user.js | 67 +- frontend/src/store/modules/version.js | 2 +- frontend/src/utils/auth.js | 16 +- frontend/src/utils/encrypt.js | 4 +- frontend/src/utils/html.js | 2 +- frontend/src/utils/i18n.js | 2 +- frontend/src/utils/index.js | 4 +- frontend/src/utils/log.js | 4 +- frontend/src/utils/request.js | 123 + frontend/src/utils/stats.js | 6 +- frontend/src/utils/validate.js | 4 +- frontend/src/views/404.vue | 19 +- .../src/views/challenge/ChallengeList.vue | 83 +- frontend/src/views/deploy/DeployDetail.vue | 6 +- frontend/src/views/deploy/DeployList.vue | 230 +- frontend/src/views/doc/Disclaimer.vue | 65 +- frontend/src/views/feedback/Feedback.vue | 114 +- frontend/src/views/home/Home.vue | 128 +- frontend/src/views/layout/Layout.vue | 110 +- .../src/views/layout/components/AppMain.vue | 14 +- .../src/views/layout/components/Navbar.vue | 218 +- .../views/layout/components/Sidebar/Item.vue | 52 +- .../views/layout/components/Sidebar/Link.vue | 42 +- .../layout/components/Sidebar/SidebarItem.vue | 137 +- .../views/layout/components/Sidebar/index.vue | 77 +- .../src/views/layout/components/TagsView.vue | 297 +- .../src/views/layout/mixin/ResizeHandler.js | 10 +- frontend/src/views/login/index.vue | 505 +- frontend/src/views/node/NodeDetail.vue | 186 +- frontend/src/views/node/NodeList.vue | 425 +- frontend/src/views/project/ProjectList.vue | 258 +- frontend/src/views/schedule/ScheduleList.vue | 870 +- frontend/src/views/setting/Setting.vue | 592 +- frontend/src/views/site/SiteList.vue | 492 +- frontend/src/views/spider/SpiderDetail.vue | 421 +- frontend/src/views/spider/SpiderList.vue | 1348 +- frontend/src/views/spider/SpiderSchedules.vue | 96 +- frontend/src/views/task/TaskDetail.vue | 430 +- frontend/src/views/task/TaskList.vue | 671 +- frontend/src/views/user/UserList.vue | 273 +- frontend/vue.config.js | 32 +- frontend/yarn.lock | 11877 ++++++++++------ workspace/docker-compose.yml | 54 +- workspace/dockerfiles/golang/Dockerfile | 19 +- workspace/dockerfiles/node/.dockerignore | 1 + workspace/dockerfiles/node/Dockerfile | 3 +- 129 files changed, 18024 insertions(+), 13982 deletions(-) create mode 100644 docker-compose.local.yml create mode 100644 frontend/jsconfig.json create mode 100644 frontend/src/utils/request.js create mode 100644 workspace/dockerfiles/node/.dockerignore diff --git a/.dockerignore b/.dockerignore index 7ca015570..63c05d488 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,4 +3,11 @@ logs *.log dist/ **/node_modules/ + **/tmp/ +**/vendor/ +.github/ +.devops +k8s +workspace +.git/ diff --git a/Dockerfile b/Dockerfile index 17449cbd6..70e075f09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.13 AS backend-build +FROM golang:latest AS backend-build WORKDIR /go/src/app COPY ./backend . @@ -8,16 +8,16 @@ ENV GOPROXY https://goproxy.io RUN go install -v ./... -FROM node:8.16.0-alpine AS frontend-build +FROM node:latest AS frontend-build ADD ./frontend /app WORKDIR /app # install frontend -RUN npm config set unsafe-perm true -RUN npm install -g yarn && yarn install +#RUN npm config set unsafe-perm true +#RUN npm install -g yarn && yarn install -RUN npm run build:prod +RUN yarn install && yarn run build:prod # images FROM ubuntu:latest @@ -31,19 +31,21 @@ ENV CRAWLAB_IS_DOCKER Y # install packages RUN chmod 777 /tmp \ && apt-get update \ - && apt-get install -y curl git net-tools iputils-ping ntp ntpdate python3 python3-pip nginx wget \ + && apt-get install -y curl git net-tools iputils-ping ntp ntpdate python3 python3-pip nginx wget dumb-init \ && ln -s /usr/bin/pip3 /usr/local/bin/pip \ && ln -s /usr/bin/python3 /usr/local/bin/python -# install dumb-init -RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 -RUN chmod +x /usr/local/bin/dumb-init # install backend RUN pip install scrapy pymongo bs4 requests crawlab-sdk scrapy-splash # add files -ADD . /app +COPY ./backend/conf /app/backend/conf +COPY ./backend/data /app/backend/data +COPY ./backend/scripts /app/backend/scripts +COPY ./backend/template /app/backend/template +COPY ./nginx /app/nginx +COPY ./docker_init.sh /app/docker_init.sh # copy backend files RUN mkdir -p /opt/bin diff --git a/Dockerfile.local b/Dockerfile.local index 31148d4f1..5d0cda60c 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -1,23 +1,21 @@ -FROM golang:1.13 AS backend-build +FROM golang:latest AS backend-build WORKDIR /go/src/app COPY ./backend . ENV GO111MODULE on -ENV GOPROXY https://goproxy.io +ENV GOPROXY https://goproxy.cn RUN go install -v ./... -FROM node:8.16.0-alpine AS frontend-build +FROM node:latest AS frontend-build ADD ./frontend /app WORKDIR /app # install frontend -RUN npm config set unsafe-perm true -RUN npm install -g cnpm --registry=https://registry.npm.taobao.org && cnpm install - -RUN npm run build:prod +RUN yarn config set registry https://registry.npm.taobao.org && \ + yarn install && yarn run build:prod # images FROM ubuntu:latest @@ -28,22 +26,27 @@ ENV DEBIAN_FRONTEND noninteractive # set CRAWLAB_IS_DOCKER ENV CRAWLAB_IS_DOCKER Y + + # install packages RUN chmod 777 /tmp \ + && sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \ && apt-get update \ - && apt-get install -y curl git net-tools iputils-ping ntp ntpdate python3 python3-pip nginx wget \ + && apt-get install -y curl git net-tools iputils-ping ntp ntpdate python3 python3-pip nginx wget dumb-init\ && ln -s /usr/bin/pip3 /usr/local/bin/pip \ && ln -s /usr/bin/python3 /usr/local/bin/python -# install dumb-init -RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 -RUN chmod +x /usr/local/bin/dumb-init # install backend RUN pip install scrapy pymongo bs4 requests crawlab-sdk scrapy-splash -i https://pypi.tuna.tsinghua.edu.cn/simple # add files -ADD . /app +COPY ./backend/conf /app/backend/conf +COPY ./backend/data /app/backend/data +COPY ./backend/scripts /app/backend/scripts +COPY ./backend/template /app/backend/template +COPY ./nginx /app/nginx +COPY ./docker_init.sh /app/docker_init.sh # copy backend files RUN mkdir -p /opt/bin diff --git a/docker-compose.local.yml b/docker-compose.local.yml new file mode 100644 index 000000000..96def4751 --- /dev/null +++ b/docker-compose.local.yml @@ -0,0 +1,85 @@ +version: '3.3' +services: + master: + build: + context: ./ + dockerfile: Dockerfile.local + container_name: local_master + environment: + # CRAWLAB_API_ADDRESS: "https://:" # backend API address 后端 API 地址. 适用于 https 或者源码部署 + CRAWLAB_SERVER_MASTER: "Y" # whether to be master node 是否为主节点,主节点为 Y,工作节点为 N + CRAWLAB_MONGO_HOST: "mongo" # MongoDB host address MongoDB 的地址,在 docker compose 网络中,直接引用服务名称 + # CRAWLAB_MONGO_PORT: "27017" # MongoDB port MongoDB 的端口 + # CRAWLAB_MONGO_DB: "crawlab_test" # MongoDB database MongoDB 的数据库 + # CRAWLAB_MONGO_USERNAME: "username" # MongoDB username MongoDB 的用户名 + # CRAWLAB_MONGO_PASSWORD: "password" # MongoDB password MongoDB 的密码 + # CRAWLAB_MONGO_AUTHSOURCE: "admin" # MongoDB auth source MongoDB 的验证源 + CRAWLAB_REDIS_ADDRESS: "redis" # Redis host address Redis 的地址,在 docker compose 网络中,直接引用服务名称 + # CRAWLAB_REDIS_PORT: "6379" # Redis port Redis 的端口 + # CRAWLAB_REDIS_DATABASE: "1" # Redis database Redis 的数据库 + # CRAWLAB_REDIS_PASSWORD: "password" # Redis password Redis 的密码 + # CRAWLAB_LOG_LEVEL: "info" # log level 日志级别. 默认为 info + # CRAWLAB_LOG_ISDELETEPERIODICALLY: "N" # whether to periodically delete log files 是否周期性删除日志文件. 默认不删除 + # CRAWLAB_LOG_DELETEFREQUENCY: "@hourly" # frequency of deleting log files 删除日志文件的频率. 默认为每小时 + # CRAWLAB_TASK_WORKERS: 8 # number of task executors 任务执行器个数(并行执行任务数) + # CRAWLAB_SERVER_REGISTER_TYPE: "mac" # node register type 节点注册方式. 默认为 mac 地址,也可设置为 ip(防止 mac 地址冲突) + # CRAWLAB_SERVER_REGISTER_IP: "127.0.0.1" # node register ip 节点注册IP. 节点唯一识别号,只有当 CRAWLAB_SERVER_REGISTER_TYPE 为 "ip" 时才生效 + # CRAWLAB_SERVER_LANG_NODE: "Y" # whether to pre-install Node.js 预安装 Node.js 语言环境 + # CRAWLAB_SERVER_LANG_JAVA: "Y" # whether to pre-install Java 预安装 Java 语言环境 + # CRAWLAB_SERVER_LANG_DOTNET: "Y" # whether to pre-install .Net core 预安装 .Net Core 语言环境 + # CRAWLAB_SERVER_LANG_PHP: "Y" # whether to pre-install PHP 预安装 PHP 语言环境 + # CRAWLAB_SETTING_ALLOWREGISTER: "N" # whether to allow user registration 是否允许用户注册 + # CRAWLAB_SETTING_ENABLETUTORIAL: "N" # whether to enable tutorial 是否启用教程 + # CRAWLAB_SETTING_RUNONMASTER: "N" # whether to run on master node 是否在主节点上运行任务 + # CRAWLAB_SETTING_DEMOSPIDERS: "Y" # whether to init demo spiders 是否使用Demo爬虫 + # CRAWLAB_SETTING_CHECKSCRAPY: "Y" # whether to automatically check if the spider is scrapy 是否自动检测爬虫为scrapy + # CRAWLAB_NOTIFICATION_MAIL_SERVER: smtp.exmaple.com # STMP server address STMP 服务器地址 + # CRAWLAB_NOTIFICATION_MAIL_PORT: 465 # STMP server port STMP 服务器端口 + # CRAWLAB_NOTIFICATION_MAIL_SENDEREMAIL: admin@exmaple.com # sender email 发送者邮箱 + # CRAWLAB_NOTIFICATION_MAIL_SENDERIDENTITY: admin@exmaple.com # sender ID 发送者 ID + # CRAWLAB_NOTIFICATION_MAIL_SMTP_USER: username # SMTP username SMTP 用户名 + # CRAWLAB_NOTIFICATION_MAIL_SMTP_PASSWORD: password # SMTP password SMTP 密码 + ports: + - "8080:8080" # frontend port mapping 前端端口映射 + depends_on: + - mongo + - redis + # volumes: + # - "/var/crawlab/log:/var/logs/crawlab" # log persistent 日志持久化 + worker: + build: + context: ./ + dockerfile: Dockerfile.local + container_name: local_master + environment: + CRAWLAB_SERVER_MASTER: "N" + CRAWLAB_MONGO_HOST: "mongo" + CRAWLAB_REDIS_ADDRESS: "redis" + depends_on: + - mongo + - redis + # environment: + # MONGO_INITDB_ROOT_USERNAME: username + # MONGO_INITDB_ROOT_PASSWORD: password + # volumes: + # - "/var/crawlab/log:/var/logs/crawlab" # log persistent 日志持久化 + mongo: + image: mongo:latest + restart: always + # volumes: + # - "/opt/crawlab/mongo/data/db:/data/db" # make data persistent 持久化 + # ports: + # - "27017:27017" # expose port to host machine 暴露接口到宿主机 + redis: + image: redis:latest + restart: always + # command: redis-server --requirepass "password" # set redis password 设置 Redis 密码 + # volumes: + # - "/opt/crawlab/redis/data:/data" # make data persistent 持久化 + # ports: + # - "6379:6379" # expose port to host machine 暴露接口到宿主机 + # splash: # use Splash to run spiders on dynamic pages + # image: scrapinghub/splash + # container_name: splash + # ports: + # - "8050:8050" diff --git a/docker-compose.yml b/docker-compose.yml index 13013eee5..f82c33c70 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ version: '3.3' services: - master: + master: image: tikazyq/crawlab:latest container_name: master environment: @@ -37,7 +37,7 @@ services: # CRAWLAB_NOTIFICATION_MAIL_SENDERIDENTITY: admin@exmaple.com # sender ID 发送者 ID # CRAWLAB_NOTIFICATION_MAIL_SMTP_USER: username # SMTP username SMTP 用户名 # CRAWLAB_NOTIFICATION_MAIL_SMTP_PASSWORD: password # SMTP password SMTP 密码 - ports: + ports: - "8080:8080" # frontend port mapping 前端端口映射 depends_on: - mongo diff --git a/frontend/.editorconfig b/frontend/.editorconfig index 7053c49a0..a20656db1 100644 --- a/frontend/.editorconfig +++ b/frontend/.editorconfig @@ -1,5 +1,13 @@ -[*.{js,jsx,ts,tsx,vue}] +root = true + +[*] +charset = utf-8 indent_style = space indent_size = 2 -trim_trailing_whitespace = true +end_of_line = lf insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false \ No newline at end of file diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 5dadb0d80..1e0172ba8 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -1,20 +1,254 @@ module.exports = { root: true, env: { - node: true + browser: true, + node: true, + es6: true }, - 'extends': [ - 'plugin:vue/essential', - '@vue/standard' + extends: ['plugin:vue/recommended', 'eslint:recommended'], + overrides: [ + { + files: [ + '*.vue' + ], + rules: { + indent: 'off' + } + }, + { + files: [ + '**/__tests__/*.{j,t}s?(x)', + '**/tests/unit/**/*.spec.{j,t}s?(x)' + ], + env: { + jest: true + } + } ], rules: { + + 'vue/max-attributes-per-line': [ + 2, { + 'singleline': 10, + 'multiline': { + 'max': 1, + 'allowFirstLine': false + } + }], + 'vue/singleline-html-element-content-newline': 'off', + 'vue/multiline-html-element-content-newline': 'off', + 'vue/name-property-casing': ['error', 'PascalCase'], + 'vue/no-v-html': 'off', + 'vue/no-template-shadow': 'off', + 'vue/this-in-template': 'off', + 'vue/script-indent': [ + 'error', 2, { + 'baseIndent': 1, + 'switchCase': 0, + 'ignores': [] + }], + 'accessor-pairs': 2, + 'arrow-spacing': [ + 2, { + 'before': true, + 'after': true + }], + 'block-spacing': [2, 'always'], + 'brace-style': [ + 2, '1tbs', { + 'allowSingleLine': true + }], + 'camelcase': [ + 0, { + 'properties': 'always' + }], + 'comma-dangle': [2, 'never'], + 'comma-spacing': [ + 2, { + 'before': false, + 'after': true + }], + 'comma-style': [2, 'last'], + 'constructor-super': 2, + 'curly': [2, 'multi-line'], + 'dot-location': [2, 'property'], + 'eol-last': 2, + 'eqeqeq': ['error', 'always', { 'null': 'ignore' }], + 'generator-star-spacing': [ + 2, { + 'before': true, + 'after': true + }], + 'handle-callback-err': [2, '^(err|error)$'], + 'indent': [ + 2, 2, { + 'SwitchCase': 1 + }], + 'jsx-quotes': [2, 'prefer-single'], + 'key-spacing': [ + 2, { + 'beforeColon': false, + 'afterColon': true + }], + 'keyword-spacing': [ + 2, { + 'before': true, + 'after': true + }], + 'new-cap': [ + 2, { + 'newIsCap': true, + 'capIsNew': false + }], + 'new-parens': 2, + 'no-array-constructor': 2, + 'no-caller': 2, 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' + 'no-class-assign': 2, + 'no-cond-assign': 2, + 'no-const-assign': 2, + 'no-control-regex': 0, + 'no-delete-var': 2, + 'no-dupe-args': 2, + 'no-dupe-class-members': 2, + 'no-dupe-keys': 2, + 'no-duplicate-case': 2, + 'no-empty-character-class': 2, + 'no-empty-pattern': 2, + 'no-eval': 2, + 'no-ex-assign': 2, + 'no-extend-native': 2, + 'no-extra-bind': 2, + 'no-extra-boolean-cast': 2, + 'no-extra-parens': [2, 'functions'], + 'no-fallthrough': 2, + 'no-floating-decimal': 2, + 'no-func-assign': 2, + 'no-implied-eval': 2, + 'no-inner-declarations': [2, 'functions'], + 'no-invalid-regexp': 2, + 'no-irregular-whitespace': 2, + 'no-iterator': 2, + 'no-label-var': 2, + 'no-labels': [ + 2, { + 'allowLoop': false, + 'allowSwitch': false + }], + 'no-lone-blocks': 2, + 'no-mixed-spaces-and-tabs': 2, + 'no-multi-spaces': 2, + 'no-multi-str': 2, + 'no-multiple-empty-lines': [ + 2, { + 'max': 1 + }], + 'no-native-reassign': 2, + 'no-negated-in-lhs': 2, + 'no-new-object': 2, + 'no-new-require': 2, + 'no-new-symbol': 2, + 'no-new-wrappers': 2, + 'no-obj-calls': 2, + 'no-octal': 2, + 'no-octal-escape': 2, + 'no-path-concat': 2, + 'no-proto': 2, + 'no-redeclare': 2, + 'no-regex-spaces': 2, + 'no-return-assign': [2, 'except-parens'], + 'no-self-assign': 2, + 'no-self-compare': 2, + 'no-sequences': 2, + 'no-shadow-restricted-names': 2, + 'no-spaced-func': 2, + 'no-sparse-arrays': 2, + 'no-this-before-super': 2, + 'no-throw-literal': 2, + 'no-trailing-spaces': 2, + 'no-undef': 2, + 'no-undef-init': 2, + 'no-unexpected-multiline': 2, + 'no-unmodified-loop-condition': 2, + 'no-unneeded-ternary': [ + 2, { + 'defaultAssignment': false + }], + 'no-unreachable': 2, + 'no-unsafe-finally': 2, + 'no-unused-vars': [ + 2, { + 'vars': 'all', + 'args': 'none' + }], + 'no-useless-call': 2, + 'no-useless-computed-key': 2, + 'no-useless-constructor': 2, + 'no-useless-escape': 0, + 'no-whitespace-before-property': 2, + 'no-with': 2, + 'one-var': [ + 2, { + 'initialized': 'never' + }], + 'operator-linebreak': [ + 2, 'after', { + 'overrides': { + '?': 'before', + ':': 'before' + } + }], + 'padded-blocks': [2, 'never'], + 'quotes': [ + 2, 'single', { + 'avoidEscape': true, + 'allowTemplateLiterals': true + }], + 'semi': [2, 'never'], + 'semi-spacing': [ + 2, { + 'before': false, + 'after': true + }], + 'space-before-blocks': [2, 'always'], + 'space-before-function-paren': [2, 'never'], + 'space-in-parens': [2, 'never'], + 'space-infix-ops': 2, + 'space-unary-ops': [ + 2, { + 'words': true, + 'nonwords': false + }], + 'spaced-comment': [ + 2, 'always', { + 'markers': [ + 'global', + 'globals', + 'eslint', + 'eslint-disable', + '*package', + '!', + ','] + }], + 'template-curly-spacing': [2, 'never'], + 'use-isnan': 2, + 'valid-typeof': 2, + 'wrap-iife': [2, 'any'], + 'yield-star-spacing': [2, 'both'], + 'yoda': [2, 'never'], + 'prefer-const': 2, + 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, + 'object-curly-spacing': [ + 2, 'always', { + objectsInObjects: false + }], + 'array-bracket-spacing': [2, 'never'] }, parserOptions: { - parser: 'babel-eslint' + parser: 'babel-eslint', + sourceType: 'module' }, globals: { - '_hmt': 1 + '_hmt': 'readonly' } } diff --git a/frontend/babel.config.js b/frontend/babel.config.js index ba179669a..e9558405f 100644 --- a/frontend/babel.config.js +++ b/frontend/babel.config.js @@ -1,5 +1,5 @@ module.exports = { presets: [ - '@vue/app' + '@vue/cli-plugin-babel/preset' ] } diff --git a/frontend/jest.config.js b/frontend/jest.config.js index 29fee32be..2707cd474 100644 --- a/frontend/jest.config.js +++ b/frontend/jest.config.js @@ -5,19 +5,25 @@ module.exports = { 'json', 'vue' ], + transform: { '^.+\\.vue$': 'vue-jest', '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub', '^.+\\.jsx?$': 'babel-jest' }, + moduleNameMapper: { '^@/(.*)$': '/src/$1' }, + snapshotSerializers: [ 'jest-serializer-vue' ], + testMatch: [ '**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)' ], - testURL: 'http://localhost/' + + testURL: 'http://localhost/', + preset: '@vue/cli-plugin-unit-jest' } diff --git a/frontend/jsconfig.json b/frontend/jsconfig.json new file mode 100644 index 000000000..adc48451d --- /dev/null +++ b/frontend/jsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "paths": { + "@/*": ["src/*"] + } + }, + "exclude": ["node_modules", "dist"] +} diff --git a/frontend/package.json b/frontend/package.json index 3149be127..8e02d5fe5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,60 +4,64 @@ "private": true, "scripts": { "serve": "vue-cli-service serve --ip=0.0.0.0 --mode=development", - "serve:prod": "vue-cli-service serve --mode=production --ip=0.0.0.0", - "config": "vue ui", + "test:unit": "vue-cli-service test:unit", + "lint": "vue-cli-service lint", "build:dev": "vue-cli-service build --mode development", "build:prod": "vue-cli-service build --mode production", - "lint": "vue-cli-service lint", - "test:unit": "vue-cli-service test:unit" + "config": "vue ui", + "serve:prod": "vue-cli-service serve --mode=production --ip=0.0.0.0" }, "dependencies": { - "@fortawesome/fontawesome-svg-core": "^1.2.19", - "@fortawesome/free-brands-svg-icons": "^5.9.0", - "@fortawesome/free-regular-svg-icons": "^5.9.0", - "@fortawesome/free-solid-svg-icons": "^5.9.0", - "@fortawesome/vue-fontawesome": "^0.1.6", - "@tinymce/tinymce-vue": "^2.0.0", - "ansi-to-html": "^0.6.13", - "axios": "0.18.0", + "@fortawesome/fontawesome-svg-core": "^1.2.28", + "@fortawesome/free-brands-svg-icons": "^5.13.0", + "@fortawesome/free-regular-svg-icons": "^5.13.0", + "@fortawesome/free-solid-svg-icons": "^5.13.0", + "@fortawesome/vue-fontawesome": "^0.1.9", + "@tinymce/tinymce-vue": "^3.2.2", + "ansi-to-html": "^0.6.14", + "axios": "^0.19.2", "babel-polyfill": "^6.26.0", - "cross-env": "^5.2.0", - "dayjs": "^1.8.6", - "echarts": "^4.1.0", - "element-ui": "2.13.0", + "core-js": "^3.6.5", + "cross-env": "^7.0.2", + "dayjs": "^1.8.28", + "echarts": "^4.8.0", + "element-ui": "^2.13.2", "font-awesome": "^4.7.0", - "github-markdown-css": "^3.0.1", - "js-cookie": "2.2.0", - "normalize.css": "7.0.0", - "nprogress": "0.2.0", + "github-markdown-css": "^4.0.0", + "js-cookie": "^2.2.1", + "normalize.css": "^8.0.1", + "npm": "^6.14.5", + "nprogress": "^0.2.0", "path": "^0.12.7", "showdown": "^1.9.1", - "vcrontab": "^0.3.3", - "vue": "^2.5.22", - "vue-ba": "^1.2.5", + "vcrontab": "^0.3.5", + "vue": "^2.6.11", + "vue-ba": "^1.2.8", "vue-codemirror": "^4.0.6", "vue-codemirror-lite": "^1.0.4", - "vue-github-button": "^1.1.2", - "vue-i18n": "^8.9.0", - "vue-router": "^3.0.1", - "vue-tour": "^1.2.0", - "vue-virtual-scroll-list": "^1.3.9", - "vuex": "^3.0.1" + "vue-github-button": "^1.2.0", + "vue-i18n": "^8.18.1", + "vue-router": "^3.3.2", + "vue-tour": "^1.4.0", + "vue-virtual-scroll-list": "^2.2.6", + "vuex": "^3.4.0" }, "devDependencies": { - "@vue/cli-plugin-babel": "^3.4.0", - "@vue/cli-plugin-eslint": "^3.4.0", - "@vue/cli-plugin-unit-jest": "^3.4.0", - "@vue/cli-service": "^3.4.0", - "@vue/eslint-config-standard": "^4.0.0", - "@vue/test-utils": "^1.0.0-beta.20", - "babel-core": "7.0.0-bridge.0", - "babel-eslint": "^10.0.1", - "babel-jest": "^23.6.0", - "eslint": "^5.8.0", - "eslint-plugin-vue": "^5.0.0", - "node-sass": "^4.9.0", - "sass-loader": "^7.1.0", - "vue-template-compiler": "^2.5.21" + "@babel/core": "^7.10.2", + "@babel/register": "^7.10.1", + "@vue/cli-plugin-babel": "~4.4.0", + "@vue/cli-plugin-eslint": "^4.4.1", + "@vue/cli-plugin-unit-jest": "~4.4.0", + "@vue/cli-service": "^4.4.1", + "@vue/test-utils": "^1.0.3", + "autoprefixer": "^9.5.1", + "babel-core": "^7.0.0-bridge.0", + "babel-eslint": "^10.1.0", + "babel-jest": "^26.0.1", + "eslint": "^6.8.0", + "eslint-plugin-vue": "^6.2.2", + "node-sass": "^4.14.1", + "sass-loader": "^8.0.2", + "vue-template-compiler": "^2.6.11" } } diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 64942c3c0..0e68aa24b 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,66 +1,67 @@ diff --git a/frontend/src/components/Screenfull/index.vue b/frontend/src/components/Screenfull/index.vue index 479bf3e3d..6247b516a 100644 --- a/frontend/src/components/Screenfull/index.vue +++ b/frontend/src/components/Screenfull/index.vue @@ -5,38 +5,38 @@