GeezerVison is showing github.com — Merge branch 'release/1.0.5' · yaorb/lowcode-engine@a78f31a
File treeExpand file treeCollapse file tree Open diff view settings test-cases/react-app/demo3/expected/demo-project/src/pages/Test
builtin-simulator/bem-tools
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +44Lines changed: 44 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +name: lint & test | | 2 | + | | 3 | +on: | | 4 | + push: | | 5 | + paths: | | 6 | + - 'modules/**' | | 7 | + - '!modules/**.md' | | 8 | + pull_request: | | 9 | + paths: | | 10 | + - 'modules/**' | | 11 | + - '!modules/**.md' | | 12 | + | | 13 | +jobs: | | 14 | + lint: | | 15 | + runs-on: ubuntu-latest | | 16 | + steps: | | 17 | + - name: checkout | | 18 | + uses: actions/checkout@v2 | | 19 | + | | 20 | + - uses: actions/setup-node@v2 | | 21 | + with: | | 22 | + node-version: '14' | | 23 | + | | 24 | + - name: install | | 25 | + run: npm i | | 26 | + | | 27 | + - name: lint | | 28 | + run: npm run lint:modules | | 29 | + | | 30 | + test-code-generator: | | 31 | + runs-on: ubuntu-latest | | 32 | + steps: | | 33 | + - name: checkout | | 34 | + uses: actions/checkout@v2 | | 35 | + | | 36 | + - uses: actions/setup-node@v2 | | 37 | + with: | | 38 | + node-version: '14' | | 39 | + | | 40 | + - name: install | | 41 | + run: npm i && npm run setup:skip-build | | 42 | + | | 43 | + - name: test | | 44 | + run: cd modules/code-generator && npm i && npm run build && npm test |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/test packages.yml +9-1Lines changed: 9 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | name: lint & test | 2 | 2 |
| 3 | | -on: [push, pull_request] | | 3 | +on: | | 4 | + push: | | 5 | + paths: | | 6 | + - 'packages/**' | | 7 | + - '!packages/**.md' | | 8 | + pull_request: | | 9 | + paths: | | 10 | + - 'packages/**' | | 11 | + - '!packages/**.md' | 4 | 12 |
| 5 | 13 | jobs: | 6 | 14 | lint: | |
Collapse file Copy file name to clipboardExpand all lines: lerna.json +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | 2 | "lerna": "4.0.0", | 3 | | - "version": "1.0.3", | | 3 | + "version": "1.0.5", | 4 | 4 | "npmClient": "yarn", | 5 | 5 | "useWorkspaces": true, | 6 | 6 | "packages": [ | |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/CHANGELOG.md +21Lines changed: 21 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | 4 | 4 |
| | 5 | + | | 6 | + | | 7 | + | | 8 | +### Features | | 9 | + | | 10 | +* add getConvertedExtraKey / getOriginalExtraKey to utils ([8e7bb9d](https://github.com/alibaba/lowcode-engine/commit/8e7bb9d4b86454dd77c6928eb769cd764cad8630)) | | 11 | + | | 12 | + | | 13 | +### Bug Fixes | | 14 | + | | 15 | +* 🐛 出码: 解决 componentName 和 exportName 不一致时生成的 import 语句的问题 ([eefc091](https://github.com/alibaba/lowcode-engine/commit/eefc091ee7e86d6214d20d486212cb5aff237946)) | | 16 | +* component cannot be redisplayed by configuration after rendering is closed ([c54f369](https://github.com/alibaba/lowcode-engine/commit/c54f369e1860d818479dda9d6429f851c0b08fa6)) | | 17 | +* fix loop configuration auto fill empty array issue ([d087092](https://github.com/alibaba/lowcode-engine/commit/d087092fd712eff0556adacda692d3ff6f2f9f22)) | | 18 | +* make important true by default ([c63b6e1](https://github.com/alibaba/lowcode-engine/commit/c63b6e1bfadc3fc87ed41840952e02ffbff24fab)) | | 19 | +* make insertAfter & insertBefore work ([70fd372](https://github.com/alibaba/lowcode-engine/commit/70fd3720d098d6e227acb9281ee22feee66b9c0b)) | | 20 | +* npm源 ([437adcc](https://github.com/alibaba/lowcode-engine/commit/437adccf5f2dbb400de6e2bef10cfc4b65286f2b)) | | 21 | +* prop should return undefined when all items are undefined ([5bb9ec7](https://github.com/alibaba/lowcode-engine/commit/5bb9ec7a1dfaabfdb5369226b54d5f63a7999e59)) | | 22 | +* should not create new prop while querying fileName ([19c207d](https://github.com/alibaba/lowcode-engine/commit/19c207d29de045f473ba73baaf34e7294d40261a)) | | 23 | +* variable binding lost after modify the mock value ([ef95b56](https://github.com/alibaba/lowcode-engine/commit/ef95b5683273d8302bde1582de8afe3d87a808d8)) | | 24 | +* Workbench should receive the original skeleton other than shell skeleton ([d5c3ca1](https://github.com/alibaba/lowcode-engine/commit/d5c3ca1068ce2c2140980bd059d0da333574dc34)) | | 25 | + | 5 | 26 | | 6 | 27 |
| 7 | 28 | | |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/package.json +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | 2 | "name": "@alilc/lowcode-code-generator", | 3 | | - "version": "1.0.2", | | 3 | + "version": "1.0.3", | 4 | 4 | "description": "出码引擎 for LowCode Engine", | 5 | 5 | "license": "MIT", | 6 | 6 | "main": "lib/index.js", | |
Collapse file Copy file name to clipboard +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | export * from './run'; | 2 | | -export * from './init-solution'; | | 2 | +export * from './init-solution'; |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/plugins/common/esmodule.ts +53-19Lines changed: 53 additions & 19 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { flatMap } from 'lodash'; | | 1 | +import { flatMap, camelCase, get } from 'lodash'; | 2 | 2 | import { COMMON_CHUNK_NAME } from '../../const/generator'; | 3 | 3 |
| 4 | 4 | import { | @@ -71,6 +71,37 @@ function getDependencyIdentifier(info: IDependencyItem): string { | 71 | 71 | return info.aliasName || info.exportName; | 72 | 72 | } | 73 | 73 |
| | 74 | +function getExportNameOfDep(dep: IDependency): string { | | 75 | + if (dep.destructuring) { | | 76 | + return ( | | 77 | + dep.exportName || | | 78 | + dep.componentName || | | 79 | + throwNewError('destructuring dependency must have exportName or componentName') | | 80 | + ); | | 81 | + } | | 82 | + | | 83 | + if (!dep.subName) { | | 84 | + return ( | | 85 | + dep.componentName || | | 86 | + dep.exportName || | | 87 | + throwNewError('dependency item must have componentName or exportName') | | 88 | + ); | | 89 | + } | | 90 | + | | 91 | + return ( | | 92 | + dep.exportName || | | 93 | + `__$${camelCase( | | 94 | + get(dep, 'moduleName') || | | 95 | + get(dep, 'package') || | | 96 | + throwNewError('dep.moduleName or dep.package is undefined'), | | 97 | + )}_default` | | 98 | + ); | | 99 | +} | | 100 | + | | 101 | +function throwNewError(msg: string): never { | | 102 | + throw new Error(msg); | | 103 | +} | | 104 | + | 74 | 105 | function buildPackageImport( | 75 | 106 | pkg: string, | 76 | 107 | deps: IDependency[], | @@ -90,7 +121,7 @@ function buildPackageImport( | 90 | 121 |
| 91 | 122 | const depsInfo: IDependencyItem[] = deps.map((dep) => { | 92 | 123 | const info: IDependencyItem = { | 93 | | - exportName: dep.exportName, | | 124 | + exportName: getExportNameOfDep(dep), | 94 | 125 | isDefault: !dep.destructuring, | 95 | 126 | subName: dep.subName || undefined, | 96 | 127 | nodeIdentifier: dep.componentName || undefined, | @@ -171,24 +202,21 @@ function buildPackageImport( | 171 | 202 |
| 172 | 203 | // 发现 nodeIdentifier 与 exportName 或者 aliasName 冲突的场景 | 173 | 204 | const nodeIdentifiers = depsInfo.map((info) => info.nodeIdentifier).filter(Boolean); | 174 | | - const conflictInfos = flatMap( | 175 | | - Object.keys(exportItems), | 176 | | - (exportName) => { | 177 | | - const exportItem = exportItems[exportName]; | 178 | | - const usedNames = [ | 179 | | - ...exportItem.aliasNames, | 180 | | - ...(exportItem.needOriginExport || exportItem.aliasNames.length <= 0 ? [exportName] : []), | | 205 | + const conflictInfos = flatMap(Object.keys(exportItems), (exportName) => { | | 206 | + const exportItem = exportItems[exportName]; | | 207 | + const usedNames = [ | | 208 | + ...exportItem.aliasNames, | | 209 | + ...(exportItem.needOriginExport || exportItem.aliasNames.length <= 0 ? [exportName] : []), | | 210 | + ]; | | 211 | + const conflictNames = usedNames.filter((n) => nodeIdentifiers.indexOf(n) >= 0); | | 212 | + if (conflictNames.length > 0) { | | 213 | + return [ | | 214 | + ...(conflictNames.indexOf(exportName) >= 0 ? [[exportName, true, exportItem]] : []), | | 215 | + ...conflictNames.filter((n) => n !== exportName).map((n) => [n, false, exportItem]), | 181 | 216 | ]; | 182 | | - const conflictNames = usedNames.filter((n) => nodeIdentifiers.indexOf(n) >= 0); | 183 | | - if (conflictNames.length > 0) { | 184 | | - return [ | 185 | | - ...(conflictNames.indexOf(exportName) >= 0 ? [[exportName, true, exportItem]] : []), | 186 | | - ...conflictNames.filter((n) => n !== exportName).map((n) => [n, false, exportItem]), | 187 | | - ]; | 188 | | - } | 189 | | - return []; | 190 | | - }, | 191 | | - ); | | 217 | + } | | 218 | + return []; | | 219 | + }); | 192 | 220 |
| 193 | 221 | const conflictExports = conflictInfos.filter((c) => c[1]).map((c) => c[0] as string); | 194 | 222 | const conflictAlias = conflictInfos.filter((c) => !c[1]).map((c) => c[0] as string); | @@ -282,6 +310,12 @@ function buildPackageImport( | 282 | 310 | }, | 283 | 311 | }); | 284 | 312 | } else if (info.aliasName) { | | 313 | + // default 方式的导入会生成单独de import 语句,无需生成赋值语句 | | 314 | + if (info.isDefault && defaultExportNames.find((n) => n === info.aliasName)) { | | 315 | + delete aliasDefineStatements[info.aliasName]; | | 316 | + return; | | 317 | + } | | 318 | + | 285 | 319 | let contentStatement = ''; | 286 | 320 | if (aliasDefineStatements[info.aliasName]) { | 287 | 321 | contentStatement = aliasDefineStatements[info.aliasName]; | |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/test-cases/react-app/demo3/expected/demo-project/src/pages/Test/index.jsx +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,6 +9,8 @@ import Super, { | 9 | 9 | SearchTable as SearchTableExport, | 10 | 10 | } from "@alifd/next"; | 11 | 11 |
| | 12 | +import SuperOther from "@alifd/next"; | | 13 | + | 12 | 14 | import utils from "../../utils"; | 13 | 15 |
| 14 | 16 | import { i18n as _$$i18n } from "../../i18n"; | @@ -17,8 +19,6 @@ import "./index.css"; | 17 | 19 |
| 18 | 20 | const SuperSub = Super.Sub; | 19 | 21 |
| 20 | | -const SuperOther = Super; | 21 | | - | 22 | 22 | const SelectOption = Select.Option; | 23 | 23 |
| 24 | 24 | const SearchTable = SearchTableExport.default; | |
Collapse file Copy file name to clipboard +34Lines changed: 34 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "version": "1.0.0", | | 3 | + "componentsMap": [ | | 4 | + { | | 5 | + "package": "example-package", | | 6 | + "version": "1.2.3", | | 7 | + "exportName": "Bar", | | 8 | + "main": "lib/index.js", | | 9 | + "destructuring": false, | | 10 | + "subName": "", | | 11 | + "componentName": "Foo" | | 12 | + } | | 13 | + ], | | 14 | + "componentsTree": [ | | 15 | + { | | 16 | + "componentName": "Page", | | 17 | + "id": "node_ocl137q7oc1", | | 18 | + "fileName": "test", | | 19 | + "props": { "style": {} }, | | 20 | + "lifeCycles": {}, | | 21 | + "dataSource": { "list": [] }, | | 22 | + "state": {}, | | 23 | + "methods": {}, | | 24 | + "children": [ | | 25 | + { | | 26 | + "componentName": "Foo", | | 27 | + "id": "node_ocl137q7oc4", | | 28 | + "props": {} | | 29 | + } | | 30 | + ] | | 31 | + } | | 32 | + ], | | 33 | + "i18n": {} | | 34 | +} |
|