diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..6c22212 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,47 @@ +version: 2 +jobs: + build: + docker: + - image: circleci/node:latest + + working_directory: ~/repo + + steps: + - checkout + + # 恢复缓存 + - restore_cache: + key: node-modules-{{ checksum "package.json" }} + # 安装依赖 + - run: + name: Install Dependencies + command: yarn --frozen-lockfile + # 格式化代码 + - run: + name: Format Code + command: yarn lint + # 写缓存 + - save_cache: + key: node-modules-{{ checksum "package-lock.json" }} + paths: + - ./node_modules + - ~/.cache/yarn + # 代码打包构建 + # - run: + # name: Run Build + # command: yarn build + # 跑单元测试代码 + - run: + name: Run Tests + command: yarn test + no_output_timeout: 300m + # 跑端对端测试代码 + - run: + name: Run E2E Tests + command: yarn e2e + no_output_timeout: 300m + # 集成文档 + - run: + name: Generate Doc + command: yarn doc + no_output_timeout: 300m \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 411d18e..f9fdc40 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,6 @@ module.exports = { extends: [ - 'airbnb', - 'airbnb/hooks', + 'standard', 'plugin:import/typescript', 'plugin:unicorn/recommended', 'prettier', @@ -18,30 +17,33 @@ module.exports = { // 修复 tsx 文件引用 tsx 文件报错的问题 'react/jsx-filename-extension': ['error', { extensions: ['.ts', '.tsx'] }], 'unicorn/prevent-abbreviations': 'off', + "semi": [2, "always"],//语句强制分号结尾 + "semi-spacing": [0, { "before": false, "after": true }],//分号前后空格 + "no-var": 0,//禁用var,用let和const代替 + "no-use-before-define": 2,//未定义前不能使用 + "no-unused-expressions": 2,//禁止无用的表达式 }, - overrides: [ - { - files: ['*.ts', '*.tsx'], - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - extends: [ - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:@typescript-eslint/recommended', - 'prettier/@typescript-eslint', + overrides: [{ + files: ['*.ts', '*.tsx'], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + extends: [ + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'prettier/@typescript-eslint', + ], + rules: { + '@typescript-eslint/no-explicit-any': 'off', + 'no-param-reassign': 'off', + 'import/extensions': [ + // airbnb 配置导致 tsx 文件引用一直报错 + 'error', + 'ignorePackages', + { + ts: 'never', + tsx: 'never', + }, ], - rules: { - '@typescript-eslint/no-explicit-any': 'off', - 'no-param-reassign': 'off', - 'import/extensions': [ - // airbnb 配置导致 tsx 文件引用一直报错 - 'error', - 'ignorePackages', - { - ts: 'never', - tsx: 'never', - }, - ], - }, }, - ], -}; + },], +}; \ No newline at end of file diff --git a/__tests__/core/src/api/index.test.js b/__tests__/core/src/api/index.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/api/index.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/common/baseCell.test.js b/__tests__/core/src/common/baseCell.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/common/baseCell.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/common/const.test.js b/__tests__/core/src/common/const.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/common/const.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/common/previewCell.test.js b/__tests__/core/src/common/previewCell.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/common/previewCell.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/common/shortcuts.test.js b/__tests__/core/src/common/shortcuts.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/common/shortcuts.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/components/colorPicker.test.js b/__tests__/core/src/components/colorPicker.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/components/colorPicker.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/components/miniMapSimpleNode.test.js b/__tests__/core/src/components/miniMapSimpleNode.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/components/miniMapSimpleNode.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/components/xIcon.test.js b/__tests__/core/src/components/xIcon.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/components/xIcon.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/mods/flowChart.test.js b/__tests__/core/src/mods/flowChart.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/mods/flowChart.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/mods/header.test.jsx b/__tests__/core/src/mods/header.test.jsx new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/mods/header.test.jsx @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/mods/layout.test.js b/__tests__/core/src/mods/layout.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/mods/layout.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/mods/settingBar.test.js b/__tests__/core/src/mods/settingBar.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/mods/settingBar.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/mods/sideBar.test.js b/__tests__/core/src/mods/sideBar.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/mods/sideBar.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/mods/toolBar.test.js b/__tests__/core/src/mods/toolBar.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/mods/toolBar.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/utils/flowChartUtils.test.js b/__tests__/core/src/utils/flowChartUtils.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/utils/flowChartUtils.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/__tests__/core/src/utils/index.test.js b/__tests__/core/src/utils/index.test.js new file mode 100644 index 0000000..6977bfc --- /dev/null +++ b/__tests__/core/src/utils/index.test.js @@ -0,0 +1,5 @@ +describe('test', () => { + it('test suite', () => { + + }) +}) \ No newline at end of file diff --git a/config/cli.jest.config.js b/config/cli.jest.config.js new file mode 100644 index 0000000..808091d --- /dev/null +++ b/config/cli.jest.config.js @@ -0,0 +1,11 @@ +module.exports = { + clearMocks: true, + coverageDirectory: "coverage", + coverageProvider: "v8", + testEnvironment: "node", + rootDir: '../', + moduleFileExtensions: ['js', 'json', 'jsx', 'node'], + testMatch: [ + "/__tests__/cli/src/**/*.(spec|test).[jt]s?(x)" + ] +}; \ No newline at end of file diff --git a/config/core.jest.config.js b/config/core.jest.config.js new file mode 100644 index 0000000..80d5924 --- /dev/null +++ b/config/core.jest.config.js @@ -0,0 +1,11 @@ +module.exports = { + clearMocks: true, + coverageDirectory: "coverage", + coverageProvider: "v8", + testEnvironment: "node", + rootDir: '../', + moduleFileExtensions: ['js', 'json', 'jsx', 'node'], + testMatch: [ + "/__tests__/core/src/**/*.(spec|test).[jt]s?(x)" + ] +}; \ No newline at end of file diff --git a/config/editor.jest.config.js b/config/editor.jest.config.js new file mode 100644 index 0000000..a93d82a --- /dev/null +++ b/config/editor.jest.config.js @@ -0,0 +1,11 @@ +module.exports = { + clearMocks: true, + coverageDirectory: "coverage", + coverageProvider: "v8", + testEnvironment: "node", + rootDir: '../', + moduleFileExtensions: ['js', 'json', 'jsx', 'node'], + testMatch: [ + "/__tests__/json-schema-editor/src/**/*.(spec|test).[jt]s?(x)" + ] +}; \ No newline at end of file diff --git a/config/plugin.jest.config.js b/config/plugin.jest.config.js new file mode 100644 index 0000000..ff80c52 --- /dev/null +++ b/config/plugin.jest.config.js @@ -0,0 +1,11 @@ +module.exports = { + clearMocks: true, + coverageDirectory: "coverage", + coverageProvider: "v8", + testEnvironment: "node", + rootDir: '../', + moduleFileExtensions: ['js', 'json', 'jsx', 'node'], + testMatch: [ + "/__tests__/plugin-store/src/**/*.(spec|test).[jt]s?(x)" + ] +}; \ No newline at end of file diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json new file mode 100644 index 0000000..da18d93 --- /dev/null +++ b/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} \ No newline at end of file diff --git a/cypress/integration/examples/actions.spec.js b/cypress/integration/examples/actions.spec.js new file mode 100644 index 0000000..4594336 --- /dev/null +++ b/cypress/integration/examples/actions.spec.js @@ -0,0 +1,28 @@ +/// + +context('Actions', () => { + // 1. 打开http://localhost:8001/ + beforeEach(() => { + cy.visit('http://localhost:8001/') + }) + + // 2. 测试是否能将左侧的组件拖动到画布中 + it('the components on the left can be dragged into the canvas', () => { + + }) + + // 3. 测试是否可修改节点的显示名称、逻辑触发名称、代码、投放配置schema、依赖 + it('you can modify the display name, logical trigger name, code, delivery configuration schema, and dependencies of the node', () => { + + }) + + // 4. 测试能够run起来一个最小流程(写好代码) + it('A minimal process can be run', () => { + + }) + + // 5. 测试更改节点位置,输出结果不变 + it('ensure that the node position is changed and the output result remains unchanged', () => { + + }) +}) \ No newline at end of file diff --git a/cypress/integration/examples/dataSave.spec.js b/cypress/integration/examples/dataSave.spec.js new file mode 100644 index 0000000..4594336 --- /dev/null +++ b/cypress/integration/examples/dataSave.spec.js @@ -0,0 +1,28 @@ +/// + +context('Actions', () => { + // 1. 打开http://localhost:8001/ + beforeEach(() => { + cy.visit('http://localhost:8001/') + }) + + // 2. 测试是否能将左侧的组件拖动到画布中 + it('the components on the left can be dragged into the canvas', () => { + + }) + + // 3. 测试是否可修改节点的显示名称、逻辑触发名称、代码、投放配置schema、依赖 + it('you can modify the display name, logical trigger name, code, delivery configuration schema, and dependencies of the node', () => { + + }) + + // 4. 测试能够run起来一个最小流程(写好代码) + it('A minimal process can be run', () => { + + }) + + // 5. 测试更改节点位置,输出结果不变 + it('ensure that the node position is changed and the output result remains unchanged', () => { + + }) +}) \ No newline at end of file diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js new file mode 100644 index 0000000..aa9918d --- /dev/null +++ b/cypress/plugins/index.js @@ -0,0 +1,21 @@ +/// +// *********************************************************** +// This example plugins/index.js can be used to load plugins +// +// You can change the location of this file or turn off loading +// the plugins file with the 'pluginsFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/plugins-guide +// *********************************************************** + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) + +/** + * @type {Cypress.PluginConfig} + */ +module.exports = (on, config) => { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config +} diff --git a/cypress/support/commands.js b/cypress/support/commands.js new file mode 100644 index 0000000..ca4d256 --- /dev/null +++ b/cypress/support/commands.js @@ -0,0 +1,25 @@ +// *********************************************** +// This example commands.js shows you how to +// create various custom commands and overwrite +// existing commands. +// +// For more comprehensive examples of custom +// commands please read more here: +// https://on.cypress.io/custom-commands +// *********************************************** +// +// +// -- This is a parent command -- +// Cypress.Commands.add("login", (email, password) => { ... }) +// +// +// -- This is a child command -- +// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) +// +// +// -- This is a dual command -- +// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) +// +// +// -- This will overwrite an existing command -- +// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/cypress/support/index.js b/cypress/support/index.js new file mode 100644 index 0000000..d68db96 --- /dev/null +++ b/cypress/support/index.js @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/index.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') diff --git a/docs/api/CONTRIBUTING.md b/docs/api/CONTRIBUTING.md new file mode 100644 index 0000000..4ddd5ae --- /dev/null +++ b/docs/api/CONTRIBUTING.md @@ -0,0 +1,8 @@ +# 为iMove做贡献 + +* 请先fork一份到自己的项目下,不要直接在仓库下建分支。 +* commit信息要以`[组件名]:描述信息`的形式填写,例如`[canvas]:fix xxx bug`。 +* 如果您已经修复了错误或者添加了应测试的代码,请添加测试! +* 确保提交PR之前请先rebase,保持commit记录的整洁性。 +* 确保PR是提交到`dev`分支,而不是`master`分支。 +* 如果修复的是bug,请在PR中给出描述信息。 \ No newline at end of file diff --git a/docs/api/ctx.md b/docs/api/ctx.md new file mode 100644 index 0000000..38f94b2 --- /dev/null +++ b/docs/api/ctx.md @@ -0,0 +1 @@ +# 上下文(ctx) \ No newline at end of file diff --git a/docs/api/data.md b/docs/api/data.md new file mode 100644 index 0000000..e4023f6 --- /dev/null +++ b/docs/api/data.md @@ -0,0 +1 @@ +# 数据读写(data) \ No newline at end of file diff --git a/docs/api/edge.md b/docs/api/edge.md new file mode 100644 index 0000000..4408baa --- /dev/null +++ b/docs/api/edge.md @@ -0,0 +1 @@ +# 边(edge) \ No newline at end of file diff --git a/docs/api/group.md b/docs/api/group.md new file mode 100644 index 0000000..170bf16 --- /dev/null +++ b/docs/api/group.md @@ -0,0 +1 @@ +# 节点组(group) \ No newline at end of file diff --git a/docs/api/layout.md b/docs/api/layout.md new file mode 100644 index 0000000..112baf8 --- /dev/null +++ b/docs/api/layout.md @@ -0,0 +1 @@ +# 布局(layout) \ No newline at end of file diff --git a/docs/api/module.md b/docs/api/module.md new file mode 100644 index 0000000..2e9c1d5 --- /dev/null +++ b/docs/api/module.md @@ -0,0 +1 @@ +# 逻辑元件(module) \ No newline at end of file diff --git a/docs/api/node.md b/docs/api/node.md new file mode 100644 index 0000000..d188824 --- /dev/null +++ b/docs/api/node.md @@ -0,0 +1 @@ +# 节点(node) \ No newline at end of file diff --git a/docs/api/schema.md b/docs/api/schema.md new file mode 100644 index 0000000..aed4d7d --- /dev/null +++ b/docs/api/schema.md @@ -0,0 +1 @@ +# 流程图(schema) \ No newline at end of file diff --git a/docs/config/index.md b/docs/config/index.md new file mode 100644 index 0000000..083c452 --- /dev/null +++ b/docs/config/index.md @@ -0,0 +1 @@ +## 配置文档 \ No newline at end of file diff --git a/docs/docs/index.md b/docs/docs/index.md new file mode 100644 index 0000000..f9c18ee --- /dev/null +++ b/docs/docs/index.md @@ -0,0 +1 @@ +## 使用文档 \ No newline at end of file diff --git a/docs/guide/index.md b/docs/guide/index.md new file mode 100644 index 0000000..991cb10 --- /dev/null +++ b/docs/guide/index.md @@ -0,0 +1 @@ +## 问题指引 \ No newline at end of file diff --git a/docs/plugins/index.md b/docs/plugins/index.md new file mode 100644 index 0000000..6a57d4d --- /dev/null +++ b/docs/plugins/index.md @@ -0,0 +1 @@ +## 插件文档 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index bbb2535..e8828eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13021,4 +13021,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 43c3016..1a42879 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,18 @@ "scripts": { "lint-eslint": "eslint --cache --ext .js,.jsx,.ts,.tsx ./packages/**/src", "check-types": "tsc --noEmit", - "lint": "npm run lint-eslint & npm run check-types" + "lint": "npm run lint-eslint & npm run check-types", + "test": "jest --coverage", + "e2e": "cypress open", + "doc": "dumi dev" + }, + "jest": { + "projects": [ + "config/cli.jest.config.js", + "config/core.jest.config.js", + "config/editor.jest.config.js", + "config/plugin.jest.config.js" + ] }, "devDependencies": { "@babel/core": "^7.9.0", @@ -23,6 +34,9 @@ "@svgr/rollup": "^5.3.1", "@typescript-eslint/eslint-plugin": "^2.29.0", "@typescript-eslint/parser": "^2.29.0", + "cypress": "^6.0.0", + "enzyme": "^3.11.0", + "enzyme-adapter-react-16": "^1.15.5", "eslint": "^6.8.0", "eslint-config-airbnb": "^18.1.0", "eslint-config-prettier": "^6.10.1", @@ -32,17 +46,23 @@ "eslint-plugin-react": "^7.19.0", "eslint-plugin-react-hooks": "^3.0.0", "eslint-plugin-unicorn": "^18.0.1", + "jest": "^26.6.3", + "jest-environment-jsdom-fourteen": "^1.0.1", "lerna": "^3.20.2", "prettier": "^2.0.4", + "react-app-polyfill": "^2.0.0", "rollup": "^2.6.1", "rollup-plugin-babel": "^4.4.0", "rollup-plugin-size-snapshot": "^0.11.0", + "snazzy": "^9.0.0", + "standard": "^16.0.3", "typescript": "^3.8.3" }, "dependencies": { "@babel/runtime": "^7.9.2", "@babel/runtime-corejs3": "^7.9.2", "core-js": "^3.6.5", + "dumi": "^1.0.37", "ora": "^4.0.3" } -} +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index fd955b4..7e2a0b3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,5 @@ { "compilerOptions": { - /* Basic Options */ "target": "esnext", "module": "commonjs", "allowJs": false, @@ -12,4 +11,4 @@ "experimentalDecorators": true, "skipLibCheck": true } -} +} \ No newline at end of file