feat: 升级正式 #3

Merged
huangmh merged 37 commits from test into master 3 years ago
  1. 3
      .dockerignore
  2. 165
      .drone.yml
  3. 3
      .gitmodules
  4. 33
      .releaserc
  5. 23549
      package-lock.json
  6. 11
      package.json
  7. 3
      public/config.json
  8. 1
      src/base_mobile_map_sdk
  9. 17
      src/js/helpers/data-helper.js
  10. 2
      src/pages/Index/Index.js
  11. 12715
      yarn.lock

3
.dockerignore

@ -0,0 +1,3 @@
*
!build
!nginx.conf

165
.drone.yml

@ -0,0 +1,165 @@
kind: pipeline
type: docker
name: 程序部署
host_aliases:
- ip: 192.168.0.2
hostnames:
- git.1000my.com
clone:
pull: if-not-exists
depth: 1
trigger:
branch:
- test
- master
- dev
event:
- push
environment:
a: 1
volumes:
- name: dockersock
host:
path: /data/drone/docker/sock
- name: node
host:
path: /data/drone/node_modules-project-iot-qmgo
- name: localtime
host:
path: /etc/localtime
steps:
# 从dev合并到test 从dev合并到master
- name: 生成Release版本
pull: if-not-exists
# image: exment/drone-semantic-release:latest
image: registry.cn-hangzhou.aliyuncs.com/tgabc-namespace/tgabc:semantic-release-v21.0.1
environment:
# GOOS: linux
GITEA_TOKEN:
from_secret: gitea_token
# command: [ "--tagFormat", "test_${version}" ]
settings:
git_login:
from_secret: gitea_username
git_password:
from_secret: gitea_password
- name: test分支获取master信息
image: alpine/git:v2.36.2
commands:
- git fetch origin test
- git checkout test
- git merge origin/master
- git commit --amend -m "[skip ci]从master合并历史到test"
- git branch --set-upstream-to=origin/test test
- git pull
- git push --set-upstream origin test
- git checkout master
when:
branch:
- master
- name: 获取tag数据
image: alpine/git:v2.36.2
environment:
USER:
from_secret: gitea_username
PASSWD:
from_secret: gitea_password
commands:
- git config --global credential.helper store
- echo "https://$USER:$PASSWD@git.1000my.com" >> ~/.git-credentials
- cat ~/.git-credentials
- git fetch --tags
# - git submodule add -b master https://git.1000my.com/project_runteng/server_iot-common.git
# - git mv server_iot-common iot-common
# - git submodule sync
- git describe --tags `git rev-list --tags --max-count=1`
# 获取当前分支的tag
- git describe --abbrev=0 --tags > .tags
- cat .tags
# - git fetch --tags
# - git describe --tags `git rev-list --tags --max-count=1` > .tags
# - cat .tags
- name: 代码构建
pull: if-not-exists
# image: registry.k8s.1000my.com/library/node:16.15.0-slim
image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:node-14-slim-python2_3
environment:
USER:
from_secret: gitea_username
PASSWD:
from_secret: gitea_password
volumes:
- name: node
path: /drone/src/node_modules
settings:
mirror: https://docker.mirrors.ustc.edu.cn
commands:
- git config --global credential.helper store
- echo "https://$USER:$PASSWD@git.1000my.com" >> ~/.git-credentials
- ln -s /usr/bin/python2 /usr/bin/python
- python --version
- npm config set registry https://registry.npm.taobao.org
- npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
- npm install
- unset CI
- npm run build
when:
branch:
- dev
- test
- master
- name: 平台级对象存储cdn部署dev
pull: if-not-exists
image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:mysqlinit-base-python
environment:
obs_key:
from_secret: obs_key
obs_secret:
from_secret: obs_secret
commands:
# - sed -i "s@https://.*"@https://iot-${DRONE_BRANCH}.123.1000my.com"@" build/public/config.json
- obsutil config -i=$obs_key -k=$obs_secret -e=obs.cn-east-2.myhuaweicloud.com
- obsutil mkdir obs://qianmu-iot/base_qmgo_react-${DRONE_BRANCH}/
- obsutil cp -r -f -flat build obs://qianmu-iot/base_qmgo_react-${DRONE_BRANCH}/
when:
branch:
- dev
- test
- name: 正式环境-平台级对象存储cdn部署
pull: if-not-exists
image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:mysqlinit-base-python
environment:
obs_key:
from_secret: obs_key
obs_secret:
from_secret: obs_secret
commands:
# - sed -i "s@https://.*"@https://iot.1000my.com"@" build/public/config.json
- obsutil config -i=$obs_key -k=$obs_secret -e=obs.cn-east-2.myhuaweicloud.com
- obsutil mkdir obs://qianmu-iot/base_qmgo_react/
- obsutil cp -r -f -flat build obs://qianmu-iot/base_qmgo_react/
when:
branch:
- master
- name: dingTalk notification
pull: if-not-exists
image: lddsb/drone-dingtalk-message
failure: ignore
settings:
token: 11d0cb39a082a1799c7543343a72cbd76c483eba29842fa40e60642c38a53ea8
type: markdown
message_color: true
message_pic: true
sha_link: true
tips_title: "${CI_REPO_NAME}"
debug: true
success_color: "008000"
failure_color: "FF0000"
tpl_repo_short_name: "${CI_REPO_NAME}"
msg_at_mobiles: "@${CI_COMMIT_AUTHOR_NAME}"
success_pic: "https://raw.githubusercontent.com/Ethan-Liuu/picture/master/success.png"
failure_pic: "https://raw.githubusercontent.com/Ethan-Liuu/picture/master/failed.png"
tpl: "http://get.k8s.1000my.com/.shell/.tpl"
when:
status: [failure, success]

3
.gitmodules

@ -1,3 +0,0 @@
[submodule "src/base_mobile_map_sdk"]
path = src/base_mobile_map_sdk
url = https://git.1000my.com/common/base_mobile_map_sdk.git

33
.releaserc

@ -0,0 +1,33 @@
{
"branches": [
"master",
{
"name": "test",
"prerelease": "beta"
},
"test",
{
"name": "dev",
"prerelease": "pre-dev"
}
],
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "angular",
"releaseRules": [
{"type": "docs", "scope":"README", "release": "patch"},
{"type": "refactor", "release": "patch"},
{"type": "style", "release": "patch"}
],
"parserOpts": {
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]
}
}],
"@semantic-release/release-notes-generator",
["@saithodev/semantic-release-gitea", {
"giteaUrl": "https://git.1000my.com",
"assets": [
]
}]
]
}

23549
package-lock.json

File diff suppressed because it is too large

11
package.json

@ -4,21 +4,18 @@
"private": true,
"homepage": "./",
"dependencies": {
"@apollo/client": "^3.3.11",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"antd-mobile": "^2.3.4",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link-http": "^1.5.17",
"axios": "^0.21.1",
"graphql": "^15.5.0",
"node-sass": "^5.0.0",
"node-sass": "^8.0.0",
"qmmap": "git+https://git.1000my.com/common/base_mobile_map_sdk.git",
"qrcodejs2": "^0.0.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-infinite-scroller": "^1.2.4",
"react-infinite-scroller": "^1.2.6",
"react-lazy-load-image-component": "^1.5.1",
"react-modal": "^3.12.1",
"react-qr-reader": "^3.0.0-beta-1",
@ -29,7 +26,7 @@
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build && coscmd config -a AKIDjS6at7fjTAVgggDNCrogRiZTSL304DPR -s FPPGCXr4xgZRLKDC8tZGp7HTZXlqx0gU -b lg-cjdqwkbo-1256266248 -r ap-shanghai && coscmd delete qmgo -f && coscmd upload -r build qmgo",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},

3
public/config.json

@ -1,3 +0,0 @@
{
"baseUrl": "https://iot-dev.123.1000my.com"
}

1
src/base_mobile_map_sdk

@ -1 +0,0 @@
Subproject commit 7afaa35ec99dd70a799785e206537d76e2bb32d1

17
src/js/helpers/data-helper.js

@ -1,8 +1,13 @@
import axios from "axios";
import icons from "./image-helper";
let mallInfos = new Map();
let baseUrl = "https://iot-dev.123.1000my.com";
const href = window.location.href;
let baseUrl =
href.includes("localhost") || href.includes("-dev")
? "https://iot-dev.123.1000my.com"
: href.includes("-test")
? "https://project-iot.test.1000my.com"
: "https://iot.1000my.com";
const getMallInfo = async (code) => {
const { groundFloorOrder, scale, offsetToNorth } = {
@ -21,14 +26,6 @@ const getMallInfo = async (code) => {
cloud: "1000my",
offsetToNorth,
};
try {
const {
data: { baseUrl: baseUrlFromConfig },
} = await axios.get(process.env.PUBLIC_URL + "/config.json");
baseUrl = baseUrlFromConfig;
} catch (error) {
console.log(error);
}
const config = {
mapDataUrl: `${baseUrl}/api/data/v1/web/getMallMapData/${code}/Aeditor`,

2
src/pages/Index/Index.js

@ -1,5 +1,5 @@
import React, { useState, useEffect, useReducer, useRef } from "react";
import Qmmap from "../../base_mobile_map_sdk/index";
import Qmmap from "qmmap";
import { useHistory, useLocation } from "react-router-dom";
import { getMallInfo } from "../../js/helpers/data-helper";
import "./Index.scss";

12715
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save