GeezerVison is showing github.com — fix: 解决出码的数据源依赖包问题 (#106) · selectgithub/lowcode-engine@6a642e8
File treeExpand file treeCollapse file tree Open diff view settings plugins/project/framework
demo01/expected/demo-project demo02/expected/demo-project demo03/expected/demo-project demo04/expected/demo-project demo05/expected/demo-project demo06-jsslot/expected/demo-project demo07-newline-in-props/expected/demo-project demo08-jsslot-with-multiple-children/expected/demo-project demo09-jsslot-with-conditional-children/expected/demo-project demo10-jsslot-with-loop-children/expected/demo-project demo11-utils-name-alias/expected/demo-project demo12-refs/expected/demo-project demo13-datasource-prop/expected/demo-project
demo1/expected/demo-project demo2-utils-name-alias/expected/demo-project demo2/expected/demo-project demo3/expected/demo-project demo4/expected/demo-project demo5/expected/demo-project demo6-literal-condition/expected/demo-project demo7-literal-condition2/expected/demo-project demo8-datasource-prop/expected/demo-project demo9-datasource-engine/expected/demo-project demo_10-jsslot/expected/demo-project demo_11-jsslot-2/expected/demo-project
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 clipboardExpand all lines: modules/code-generator/CHANGELOG.md +37Lines changed: 37 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 | + | | 9 | + | | 10 | +### Bug Fixes | | 11 | + | | 12 | +* 🐛 补充 icejs 模板中缺失的依赖包 ([a94553e](https://github.com/alibaba/lowcode-engine/commit/a94553e503d439b67478df6a34950d9e3d15a063)) | | 13 | + | | 14 | + | | 15 | + | | 16 | + | | 17 | +### Features | | 18 | + | | 19 | +* 在 skeleton 增加几个方法和事件 ([a7d436a](https://github.com/alibaba/lowcode-engine/commit/a7d436a0525a0ce0c7229710077111f283b452f4)) | | 20 | +* modify npm private control & version ([ee55d02](https://github.com/alibaba/lowcode-engine/commit/ee55d024a7f964ccf35a0efabec817364cea8041)) | | 21 | +* modify yuque link in README ([d522034](https://github.com/alibaba/lowcode-engine/commit/d522034879d20a7b5ed12f8fe02a30662a2ea7c6)) | | 22 | +* remove CHANGELOG.md ([b996414](https://github.com/alibaba/lowcode-engine/commit/b996414c436b5d2439c8368eb4e001cdbcd02892)) | | 23 | +* remove module field in material-parser package.json ([6141c27](https://github.com/alibaba/lowcode-engine/commit/6141c273c9c32eea22b5374679fe625e6ea15394)) | | 24 | +* rename build:umd ([23c7959](https://github.com/alibaba/lowcode-engine/commit/23c795931e1d5cf43e9c21cd902441c69c1ecc63)) | | 25 | +* replace tnpm with npm ([36caf0f](https://github.com/alibaba/lowcode-engine/commit/36caf0f18980c16f7ebb82ac845ad6b33e033567)) | | 26 | +* support UMD packageing for react-renderer ([982d0d6](https://github.com/alibaba/lowcode-engine/commit/982d0d676b3dfbfc10a2190c0040126d6925ed37)) | | 27 | + | | 28 | + | | 29 | +### Bug Fixes | | 30 | + | | 31 | +* 🐛 去掉 npm 上没有的依赖 ([#68](https://github.com/alibaba/lowcode-engine/issues/68)) ([e7ce779](https://github.com/alibaba/lowcode-engine/commit/e7ce77987eb05871dd1675d2a88367c5569bfbff)) | | 32 | +* 兼容 setters 为空的情况 ([56b459a](https://github.com/alibaba/lowcode-engine/commit/56b459a017a8350a911ef20f0166d1e62b6390e4)) | | 33 | +* 解决 package.json 中误添加了没有用到的数据源类型的 handler 的包的问题 ([#56](https://github.com/alibaba/lowcode-engine/issues/56)) ([76341c8](https://github.com/alibaba/lowcode-engine/commit/76341c8456b227192bb65537dc3d16033db0b3a1)) | | 34 | +* 解决出码的一些问题 ([#87](https://github.com/alibaba/lowcode-engine/issues/87)) ([4a01c97](https://github.com/alibaba/lowcode-engine/commit/4a01c97ea6bf23eb677888ba1aba54e5c9f4f630)) | | 35 | +* 修复 setup 的逻辑 ([1cfb15a](https://github.com/alibaba/lowcode-engine/commit/1cfb15aebea9796af23b2135f2aa4409d81283d7)) | | 36 | +* 修正一些对内的地址 ([07cc1f2](https://github.com/alibaba/lowcode-engine/commit/07cc1f2954530c64a1a3d260e8d532c9e19892e8)) | | 37 | +* 增加必要的方法 ([1b38a81](https://github.com/alibaba/lowcode-engine/commit/1b38a812653656aa02100a3b1b2a581188d1b3ef)) | | 38 | +* fix tsconfig of material-parser ([46725cb](https://github.com/alibaba/lowcode-engine/commit/46725cb9f3166912c8f5b42f1e0b1177158c1ee3)) | | 39 | +* lint&fix auto generated types.ts ([7dde970](https://github.com/alibaba/lowcode-engine/commit/7dde9701c7960b29523abddf32421cdbac47016d)) | | 40 | +* The outline tree does not display the loop flag when the loop is an empty array ([191e284](https://github.com/alibaba/lowcode-engine/commit/191e284f2fa190c2b3aecb4df31849b2bdc99d38)) | | 41 | + | 5 | 42 | | 6 | 43 |
| 7 | 44 |
| |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/package.json +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | 2 | "name": "@alilc/lowcode-code-generator", | 3 | | - "version": "1.0.1", | | 3 | + "version": "1.0.2", | 4 | 4 | "description": "出码引擎 for LowCode Engine", | 5 | 5 | "license": "MIT", | 6 | 6 | "main": "lib/index.js", | | 41 | 41 | "test:cov": "jest --coverage", | 42 | 42 | "test:update-snapshots": "cross-env UPDATE_EXPECTED=true jest -u", | 43 | 43 | "analyze:standalone": "ANALYZE=true node scripts/build-standalone", | 44 | | - "release:beta": "standard-version -t @alilc/lowcode-code-generator\\@ --prerelease beta && git push --follow-tags && npm publish --tag beta", | | 44 | + "release:beta": "standard-version -t @alilc/lowcode-code-generator\\@ -r patch --prerelease beta && git push --follow-tags && npm publish --tag beta", | 45 | 45 | "release:patch": "standard-version -t @alilc/lowcode-code-generator\\@ -r patch && git push --follow-tags && npm publish", | 46 | 46 | "release:minor": "standard-version -t @alilc/lowcode-code-generator\\@ -r minor && git push --follow-tags && npm publish", | 47 | 47 | "prepublishOnly": "npm run build", | |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/parser/SchemaParser.ts +22Lines changed: 22 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -319,6 +319,7 @@ export class SchemaParser implements ISchemaParser { | 319 | 319 | containersDeps, | 320 | 320 | utilsDeps, | 321 | 321 | packages: npms || [], | | 322 | + dataSourcesTypes: this.collectDataSourcesTypes(schema), | 322 | 323 | }, | 323 | 324 | }; | 324 | 325 | } | @@ -350,6 +351,27 @@ export class SchemaParser implements ISchemaParser { | 350 | 351 | } | 351 | 352 | return schema; | 352 | 353 | } | | 354 | + | | 355 | + private collectDataSourcesTypes(schema: ProjectSchema): string[] { | | 356 | + const dataSourcesTypes = new Set<string>(); | | 357 | + | | 358 | + // 数据源的默认类型为 fetch | | 359 | + const defaultDataSourceType = 'fetch'; | | 360 | + | | 361 | + // 收集应用级别的数据源 | | 362 | + schema.dataSource?.list?.forEach((ds) => { | | 363 | + dataSourcesTypes.add(ds.type || defaultDataSourceType); | | 364 | + }); | | 365 | + | | 366 | + // 收集容器级别的数据源(页面/组件/区块) | | 367 | + schema.componentsTree.forEach((rootNode) => { | | 368 | + rootNode.dataSource?.list?.forEach((ds) => { | | 369 | + dataSourcesTypes.add(ds.type || defaultDataSourceType); | | 370 | + }); | | 371 | + }); | | 372 | + | | 373 | + return Array.from(dataSourcesTypes.values()); | | 374 | + } | 353 | 375 | } | 354 | 376 |
| 355 | 377 | export default SchemaParser; |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/plugins/project/framework/icejs/plugins/packageJSON.ts +34-10Lines changed: 34 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,6 +10,7 @@ import { | 10 | 10 | ICodeStruct, | 11 | 11 | IProjectInfo, | 12 | 12 | } from '../../../../../types'; | | 13 | +import { buildDataSourceDependencies } from '../../../../../utils/dataSource'; | 13 | 14 |
| 14 | 15 | interface IIceJsPackageJSON extends PackageJSON { | 15 | 16 | ideMode: { | @@ -22,7 +23,31 @@ interface IIceJsPackageJSON extends PackageJSON { | 22 | 23 | originTemplate: string; | 23 | 24 | } | 24 | 25 |
| 25 | | -const pluginFactory: BuilderComponentPluginFactory<unknown> = () => { | | 26 | +export type IceJsPackageJsonPluginConfig = { | | 27 | + /** | | 28 | + * 数据源配置 | | 29 | + */ | | 30 | + datasourceConfig?: { | | 31 | + /** 数据源引擎的版本 */ | | 32 | + engineVersion?: string; | | 33 | + /** 数据源引擎的包名 */ | | 34 | + enginePackage?: string; | | 35 | + /** 数据源 handlers 的版本 */ | | 36 | + handlersVersion?: { | | 37 | + [key: string]: string; | | 38 | + }; | | 39 | + /** 数据源 handlers 的包名 */ | | 40 | + handlersPackages?: { | | 41 | + [key: string]: string; | | 42 | + }; | | 43 | + }; | | 44 | + /** 包名 */ | | 45 | + packageName?: string; | | 46 | + /** 版本 */ | | 47 | + packageVersion?: string; | | 48 | +}; | | 49 | + | | 50 | +const pluginFactory: BuilderComponentPluginFactory<IceJsPackageJsonPluginConfig> = (cfg) => { | 26 | 51 | const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => { | 27 | 52 | const next: ICodeStruct = { | 28 | 53 | ...pre, | @@ -31,21 +56,21 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => { | 31 | 56 | const ir = next.ir as IProjectInfo; | 32 | 57 |
| 33 | 58 | const packageJson: IIceJsPackageJSON = { | 34 | | - name: '@alifd/scaffold-lite-js', | 35 | | - version: '0.1.5', | | 59 | + name: cfg?.packageName || 'icejs-demo-app', | | 60 | + version: cfg?.packageVersion || '0.1.5', | 36 | 61 | description: '轻量级模板,使用 JavaScript,仅包含基础的 Layout。', | 37 | 62 | dependencies: { | 38 | 63 | moment: '^2.24.0', | 39 | 64 | react: '^16.4.1', | 40 | 65 | 'react-dom': '^16.4.1', | | 66 | + 'react-router': '^5.2.1', | 41 | 67 | '@alifd/theme-design-pro': '^0.x', | 42 | | - '@alilc/lowcode-datasource-engine': '*', | 43 | | - // TODO: 如何动态获取下面这些依赖? | 44 | | - '@alilc/lowcode-datasource-url-params-handler': '*', | 45 | | - '@alilc/lowcode-datasource-fetch-handler': '*', | 46 | | - '@alilc/lowcode-datasource-mtop-handler': '*', | 47 | | - '@alilc/lowcode-datasource-mopen-handler': '*', | 48 | 68 | 'intl-messageformat': '^9.3.6', | | 69 | + '@ice/store': '^1.4.3', | | 70 | + '@loadable/component': '^5.15.2', | | 71 | + | | 72 | + // 数据源相关的依赖: | | 73 | + ...buildDataSourceDependencies(ir, cfg?.datasourceConfig), | 49 | 74 | }, | 50 | 75 | devDependencies: { | 51 | 76 | '@ice/spec': '^1.0.0', | @@ -54,7 +79,6 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => { | 54 | 79 | eslint: '^6.0.1', | 55 | 80 | 'ice.js': '^1.0.0', | 56 | 81 | stylelint: '^13.2.0', | 57 | | - '@ali/build-plugin-ice-def': '^0.1.0', | 58 | 82 | }, | 59 | 83 | scripts: { | 60 | 84 | start: 'icejs start', | |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/plugins/project/framework/icejs/template/files/build.json.ts +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,8 +23,7 @@ export default function getFile(): [string[], ResultFile] { | 23 | 23 | "zh-cn" | 24 | 24 | ] | 25 | 25 | } | 26 | | - ], | 27 | | - "@ali/build-plugin-ice-def" | | 26 | + ] | 28 | 27 | ] | 29 | 28 | } | 30 | 29 | `, | |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/plugins/project/framework/rax/plugins/packageJSON.ts +3-14Lines changed: 3 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import changeCase from 'change-case'; | 2 | 1 | import { NpmInfo, PackageJSON } from '@alilc/lowcode-types'; | 3 | 2 | import { COMMON_CHUNK_NAME } from '../../../../../const/generator'; | 4 | 3 |
| @@ -14,6 +13,7 @@ import { isNpmInfo } from '../../../../../utils/schema'; | 14 | 13 | import { getErrorMessage } from '../../../../../utils/errors'; | 15 | 14 | import { calcCompatibleVersion } from '../../../../../utils/version'; | 16 | 15 | import { RaxFrameworkOptions } from '../types/RaxFrameworkOptions'; | | 16 | +import { buildDataSourceDependencies } from '../../../../../utils/dataSource'; | 17 | 17 |
| 18 | 18 | const pluginFactory: BuilderComponentPluginFactory<RaxFrameworkOptions> = (cfg) => { | 19 | 19 | const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => { | @@ -26,7 +26,7 @@ const pluginFactory: BuilderComponentPluginFactory<RaxFrameworkOptions> = (cfg) | 26 | 26 | const npmDeps = getNpmDependencies(ir); | 27 | 27 |
| 28 | 28 | const packageJson: PackageJSON = { | 29 | | - name: cfg?.packageName || '@alilc/rax-app-demo', | | 29 | + name: cfg?.packageName || 'rax-demo-app', | 30 | 30 | private: true, | 31 | 31 | version: cfg?.packageVersion || '1.0.0', | 32 | 32 | scripts: { | @@ -39,18 +39,7 @@ const pluginFactory: BuilderComponentPluginFactory<RaxFrameworkOptions> = (cfg) | 39 | 39 | }, | 40 | 40 | dependencies: { | 41 | 41 | // 数据源相关的依赖: | 42 | | - [cfg?.datasourceConfig?.enginePackage || '@alilc/lowcode-datasource-engine']: | 43 | | - cfg?.datasourceConfig?.engineVersion || 'latest', | 44 | | - // TODO: [p1] 如何动态获取下究竟用了哪些类型的数据源? | 45 | | - ...['url-params', 'fetch', 'mtop', 'mopen'].reduce( | 46 | | - (acc, dsType) => ({ | 47 | | - ...acc, | 48 | | - [cfg?.datasourceConfig?.handlersPackages?.[dsType] || | 49 | | - `@alilc/lowcode-datasource-${changeCase.kebab(dsType)}-handler`]: | 50 | | - cfg?.datasourceConfig?.handlersVersion?.[dsType] || 'latest', | 51 | | - }), | 52 | | - {}, | 53 | | - ), | | 42 | + ...buildDataSourceDependencies(ir, cfg?.datasourceConfig), | 54 | 43 |
| 55 | 44 | // 环境判断 | 56 | 45 | 'universal-env': '^3.2.0', | |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/types/intermediate.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,6 +42,7 @@ export interface IProjectInfo { | 42 | 42 | packages: INpmPackage[]; | 43 | 43 | meta?: { name?: string; title?: string } | Record<string, any>; | 44 | 44 | config?: Record<string, any>; | | 45 | + dataSourcesTypes?: string[]; | 45 | 46 | } | 46 | 47 |
| 47 | 48 | export interface IPageMeta { | |
Collapse file Copy file name to clipboard +43Lines changed: 43 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import changeCase from 'change-case'; | | 2 | +import type { IProjectInfo } from '../types/intermediate'; | | 3 | + | | 4 | +export type DataSourceDependenciesConfig = { | | 5 | + /** 数据源引擎的版本 */ | | 6 | + engineVersion?: string; | | 7 | + /** 数据源引擎的包名 */ | | 8 | + enginePackage?: string; | | 9 | + /** 数据源 handlers 的版本 */ | | 10 | + handlersVersion?: { | | 11 | + [key: string]: string; | | 12 | + }; | | 13 | + /** 数据源 handlers 的包名 */ | | 14 | + handlersPackages?: { | | 15 | + [key: string]: string; | | 16 | + }; | | 17 | +}; | | 18 | + | | 19 | +export function buildDataSourceDependencies( | | 20 | + ir: IProjectInfo, | | 21 | + cfg: DataSourceDependenciesConfig = {}, | | 22 | +): Record<string, string> { | | 23 | + return { | | 24 | + // 数据源引擎的依赖包 | | 25 | + [cfg.enginePackage || '@alilc/lowcode-datasource-engine']: cfg.engineVersion || 'latest', | | 26 | + | | 27 | + // 各种数据源的 handlers 的依赖包 | | 28 | + ...(ir.dataSourcesTypes || []).reduce( | | 29 | + (acc, dsType) => ({ | | 30 | + ...acc, | | 31 | + [getDataSourceHandlerPackageName(dsType)]: cfg.handlersVersion?.[dsType] || 'latest', | | 32 | + }), | | 33 | + {}, | | 34 | + ), | | 35 | + }; | | 36 | + | | 37 | + function getDataSourceHandlerPackageName(dsType: string) { | | 38 | + return ( | | 39 | + cfg.handlersPackages?.[dsType] || | | 40 | + `@alilc/lowcode-datasource-${changeCase.kebab(dsType)}-handler` | | 41 | + ); | | 42 | + } | | 43 | +} |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/test-cases/rax-app/demo01/expected/demo-project/package.json +1-5Lines changed: 1 addition & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | | - "name": "@alilc/rax-app-demo", | | 2 | + "name": "rax-demo-app", | 3 | 3 | "private": true, | 4 | 4 | "version": "1.0.0", | 5 | 5 | "scripts": { | | 12 | 12 | }, | 13 | 13 | "dependencies": { | 14 | 14 | "@alilc/lowcode-datasource-engine": "latest", | 15 | | - "@alilc/lowcode-datasource-url-params-handler": "latest", | 16 | | - "@alilc/lowcode-datasource-fetch-handler": "latest", | 17 | | - "@alilc/lowcode-datasource-mtop-handler": "latest", | 18 | | - "@alilc/lowcode-datasource-mopen-handler": "latest", | 19 | 15 | "universal-env": "^3.2.0", | 20 | 16 | "intl-messageformat": "^9.3.6", | 21 | 17 | "rax": "^1.1.0", | |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/test-cases/rax-app/demo02/expected/demo-project/package.json +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | | - "name": "@alilc/rax-app-demo", | | 2 | + "name": "rax-demo-app", | 3 | 3 | "private": true, | 4 | 4 | "version": "1.0.0", | 5 | 5 | "scripts": { | | 14 | 14 | "@alilc/lowcode-datasource-engine": "latest", | 15 | 15 | "@alilc/lowcode-datasource-url-params-handler": "latest", | 16 | 16 | "@alilc/lowcode-datasource-fetch-handler": "latest", | 17 | | - "@alilc/lowcode-datasource-mtop-handler": "latest", | 18 | | - "@alilc/lowcode-datasource-mopen-handler": "latest", | 19 | 17 | "universal-env": "^3.2.0", | 20 | 18 | "intl-messageformat": "^9.3.6", | 21 | 19 | "rax": "^1.1.0", | |
|