fix: 解决出码的数据源依赖包问题 (#106)

* fix: 解决 package.json 中误添加了没有用到的数据源类型的 handler 的包的问题 (#56)

* test: 更新别的相关测试用例的期望值

* fix: 🐛 去掉 npm 上没有的依赖 (#68)

* chore: 🤖 fix release:beta script

* chore(release): 1.0.2-beta.0

* fix: 🐛 补充 icejs 模板中缺失的依赖包

* chore(release): 1.0.2-beta.1

* chore(release): 1.0.2
This commit is contained in:
Clarence Pan 2022-03-10 11:34:14 +08:00 committed by GitHub
parent 4a01c97ea6
commit 6a642e86da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 355 additions and 210 deletions

View File

@ -2,6 +2,43 @@
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.
### [1.0.2](https://github.com/alibaba/lowcode-engine/compare/@alilc/lowcode-code-generator@1.0.2-beta.1...@alilc/lowcode-code-generator@1.0.2) (2022-03-08)
### [1.0.2-beta.1](https://github.com/alibaba/lowcode-engine/compare/@alilc/lowcode-code-generator@1.0.2-beta.0...@alilc/lowcode-code-generator@1.0.2-beta.1) (2022-03-08)
### Bug Fixes
* 🐛 补充 icejs 模板中缺失的依赖包 ([a94553e](https://github.com/alibaba/lowcode-engine/commit/a94553e503d439b67478df6a34950d9e3d15a063))
### [1.0.2-beta.0](https://github.com/alibaba/lowcode-engine/compare/@alilc/lowcode-code-generator@1.0.0...@alilc/lowcode-code-generator@1.0.2-beta.0) (2022-03-08)
### Features
* 在 skeleton 增加几个方法和事件 ([a7d436a](https://github.com/alibaba/lowcode-engine/commit/a7d436a0525a0ce0c7229710077111f283b452f4))
* modify npm private control & version ([ee55d02](https://github.com/alibaba/lowcode-engine/commit/ee55d024a7f964ccf35a0efabec817364cea8041))
* modify yuque link in README ([d522034](https://github.com/alibaba/lowcode-engine/commit/d522034879d20a7b5ed12f8fe02a30662a2ea7c6))
* remove CHANGELOG.md ([b996414](https://github.com/alibaba/lowcode-engine/commit/b996414c436b5d2439c8368eb4e001cdbcd02892))
* remove module field in material-parser package.json ([6141c27](https://github.com/alibaba/lowcode-engine/commit/6141c273c9c32eea22b5374679fe625e6ea15394))
* rename build:umd ([23c7959](https://github.com/alibaba/lowcode-engine/commit/23c795931e1d5cf43e9c21cd902441c69c1ecc63))
* replace tnpm with npm ([36caf0f](https://github.com/alibaba/lowcode-engine/commit/36caf0f18980c16f7ebb82ac845ad6b33e033567))
* support UMD packageing for react-renderer ([982d0d6](https://github.com/alibaba/lowcode-engine/commit/982d0d676b3dfbfc10a2190c0040126d6925ed37))
### Bug Fixes
* 🐛 去掉 npm 上没有的依赖 ([#68](https://github.com/alibaba/lowcode-engine/issues/68)) ([e7ce779](https://github.com/alibaba/lowcode-engine/commit/e7ce77987eb05871dd1675d2a88367c5569bfbff))
* 兼容 setters 为空的情况 ([56b459a](https://github.com/alibaba/lowcode-engine/commit/56b459a017a8350a911ef20f0166d1e62b6390e4))
* 解决 package.json 中误添加了没有用到的数据源类型的 handler 的包的问题 ([#56](https://github.com/alibaba/lowcode-engine/issues/56)) ([76341c8](https://github.com/alibaba/lowcode-engine/commit/76341c8456b227192bb65537dc3d16033db0b3a1))
* 解决出码的一些问题 ([#87](https://github.com/alibaba/lowcode-engine/issues/87)) ([4a01c97](https://github.com/alibaba/lowcode-engine/commit/4a01c97ea6bf23eb677888ba1aba54e5c9f4f630))
* 修复 setup 的逻辑 ([1cfb15a](https://github.com/alibaba/lowcode-engine/commit/1cfb15aebea9796af23b2135f2aa4409d81283d7))
* 修正一些对内的地址 ([07cc1f2](https://github.com/alibaba/lowcode-engine/commit/07cc1f2954530c64a1a3d260e8d532c9e19892e8))
* 增加必要的方法 ([1b38a81](https://github.com/alibaba/lowcode-engine/commit/1b38a812653656aa02100a3b1b2a581188d1b3ef))
* fix tsconfig of material-parser ([46725cb](https://github.com/alibaba/lowcode-engine/commit/46725cb9f3166912c8f5b42f1e0b1177158c1ee3))
* lint&fix auto generated types.ts ([7dde970](https://github.com/alibaba/lowcode-engine/commit/7dde9701c7960b29523abddf32421cdbac47016d))
* 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))
### [1.0.1](https://github.com/alibaba/lowcode-engine/compare/@alilc/lowcode-code-generator@1.0.0...@alilc/lowcode-code-generator@1.0.1) (2022-03-08)

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-code-generator",
"version": "1.0.1",
"version": "1.0.2",
"description": "出码引擎 for LowCode Engine",
"license": "MIT",
"main": "lib/index.js",
@ -41,7 +41,7 @@
"test:cov": "jest --coverage",
"test:update-snapshots": "cross-env UPDATE_EXPECTED=true jest -u",
"analyze:standalone": "ANALYZE=true node scripts/build-standalone",
"release:beta": "standard-version -t @alilc/lowcode-code-generator\\@ --prerelease beta && git push --follow-tags && npm publish --tag beta",
"release:beta": "standard-version -t @alilc/lowcode-code-generator\\@ -r patch --prerelease beta && git push --follow-tags && npm publish --tag beta",
"release:patch": "standard-version -t @alilc/lowcode-code-generator\\@ -r patch && git push --follow-tags && npm publish",
"release:minor": "standard-version -t @alilc/lowcode-code-generator\\@ -r minor && git push --follow-tags && npm publish",
"prepublishOnly": "npm run build",

View File

@ -319,6 +319,7 @@ export class SchemaParser implements ISchemaParser {
containersDeps,
utilsDeps,
packages: npms || [],
dataSourcesTypes: this.collectDataSourcesTypes(schema),
},
};
}
@ -350,6 +351,27 @@ export class SchemaParser implements ISchemaParser {
}
return schema;
}
private collectDataSourcesTypes(schema: ProjectSchema): string[] {
const dataSourcesTypes = new Set<string>();
// 数据源的默认类型为 fetch
const defaultDataSourceType = 'fetch';
// 收集应用级别的数据源
schema.dataSource?.list?.forEach((ds) => {
dataSourcesTypes.add(ds.type || defaultDataSourceType);
});
// 收集容器级别的数据源(页面/组件/区块)
schema.componentsTree.forEach((rootNode) => {
rootNode.dataSource?.list?.forEach((ds) => {
dataSourcesTypes.add(ds.type || defaultDataSourceType);
});
});
return Array.from(dataSourcesTypes.values());
}
}
export default SchemaParser;

View File

@ -10,6 +10,7 @@ import {
ICodeStruct,
IProjectInfo,
} from '../../../../../types';
import { buildDataSourceDependencies } from '../../../../../utils/dataSource';
interface IIceJsPackageJSON extends PackageJSON {
ideMode: {
@ -22,7 +23,31 @@ interface IIceJsPackageJSON extends PackageJSON {
originTemplate: string;
}
const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
export type IceJsPackageJsonPluginConfig = {
/**
*
*/
datasourceConfig?: {
/** 数据源引擎的版本 */
engineVersion?: string;
/** 数据源引擎的包名 */
enginePackage?: string;
/** 数据源 handlers 的版本 */
handlersVersion?: {
[key: string]: string;
};
/** 数据源 handlers 的包名 */
handlersPackages?: {
[key: string]: string;
};
};
/** 包名 */
packageName?: string;
/** 版本 */
packageVersion?: string;
};
const pluginFactory: BuilderComponentPluginFactory<IceJsPackageJsonPluginConfig> = (cfg) => {
const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => {
const next: ICodeStruct = {
...pre,
@ -31,21 +56,21 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
const ir = next.ir as IProjectInfo;
const packageJson: IIceJsPackageJSON = {
name: '@alifd/scaffold-lite-js',
version: '0.1.5',
name: cfg?.packageName || 'icejs-demo-app',
version: cfg?.packageVersion || '0.1.5',
description: '轻量级模板,使用 JavaScript仅包含基础的 Layout。',
dependencies: {
moment: '^2.24.0',
react: '^16.4.1',
'react-dom': '^16.4.1',
'react-router': '^5.2.1',
'@alifd/theme-design-pro': '^0.x',
'@alilc/lowcode-datasource-engine': '*',
// TODO: 如何动态获取下面这些依赖?
'@alilc/lowcode-datasource-url-params-handler': '*',
'@alilc/lowcode-datasource-fetch-handler': '*',
'@alilc/lowcode-datasource-mtop-handler': '*',
'@alilc/lowcode-datasource-mopen-handler': '*',
'intl-messageformat': '^9.3.6',
'@ice/store': '^1.4.3',
'@loadable/component': '^5.15.2',
// 数据源相关的依赖:
...buildDataSourceDependencies(ir, cfg?.datasourceConfig),
},
devDependencies: {
'@ice/spec': '^1.0.0',
@ -54,7 +79,6 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
eslint: '^6.0.1',
'ice.js': '^1.0.0',
stylelint: '^13.2.0',
'@ali/build-plugin-ice-def': '^0.1.0',
},
scripts: {
start: 'icejs start',

View File

@ -23,8 +23,7 @@ export default function getFile(): [string[], ResultFile] {
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}
`,

View File

@ -1,4 +1,3 @@
import changeCase from 'change-case';
import { NpmInfo, PackageJSON } from '@alilc/lowcode-types';
import { COMMON_CHUNK_NAME } from '../../../../../const/generator';
@ -14,6 +13,7 @@ import { isNpmInfo } from '../../../../../utils/schema';
import { getErrorMessage } from '../../../../../utils/errors';
import { calcCompatibleVersion } from '../../../../../utils/version';
import { RaxFrameworkOptions } from '../types/RaxFrameworkOptions';
import { buildDataSourceDependencies } from '../../../../../utils/dataSource';
const pluginFactory: BuilderComponentPluginFactory<RaxFrameworkOptions> = (cfg) => {
const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => {
@ -26,7 +26,7 @@ const pluginFactory: BuilderComponentPluginFactory<RaxFrameworkOptions> = (cfg)
const npmDeps = getNpmDependencies(ir);
const packageJson: PackageJSON = {
name: cfg?.packageName || '@alilc/rax-app-demo',
name: cfg?.packageName || 'rax-demo-app',
private: true,
version: cfg?.packageVersion || '1.0.0',
scripts: {
@ -39,18 +39,7 @@ const pluginFactory: BuilderComponentPluginFactory<RaxFrameworkOptions> = (cfg)
},
dependencies: {
// 数据源相关的依赖:
[cfg?.datasourceConfig?.enginePackage || '@alilc/lowcode-datasource-engine']:
cfg?.datasourceConfig?.engineVersion || 'latest',
// TODO: [p1] 如何动态获取下究竟用了哪些类型的数据源?
...['url-params', 'fetch', 'mtop', 'mopen'].reduce(
(acc, dsType) => ({
...acc,
[cfg?.datasourceConfig?.handlersPackages?.[dsType] ||
`@alilc/lowcode-datasource-${changeCase.kebab(dsType)}-handler`]:
cfg?.datasourceConfig?.handlersVersion?.[dsType] || 'latest',
}),
{},
),
...buildDataSourceDependencies(ir, cfg?.datasourceConfig),
// 环境判断
'universal-env': '^3.2.0',

View File

@ -42,6 +42,7 @@ export interface IProjectInfo {
packages: INpmPackage[];
meta?: { name?: string; title?: string } | Record<string, any>;
config?: Record<string, any>;
dataSourcesTypes?: string[];
}
export interface IPageMeta {

View File

@ -0,0 +1,43 @@
import changeCase from 'change-case';
import type { IProjectInfo } from '../types/intermediate';
export type DataSourceDependenciesConfig = {
/** 数据源引擎的版本 */
engineVersion?: string;
/** 数据源引擎的包名 */
enginePackage?: string;
/** 数据源 handlers 的版本 */
handlersVersion?: {
[key: string]: string;
};
/** 数据源 handlers 的包名 */
handlersPackages?: {
[key: string]: string;
};
};
export function buildDataSourceDependencies(
ir: IProjectInfo,
cfg: DataSourceDependenciesConfig = {},
): Record<string, string> {
return {
// 数据源引擎的依赖包
[cfg.enginePackage || '@alilc/lowcode-datasource-engine']: cfg.engineVersion || 'latest',
// 各种数据源的 handlers 的依赖包
...(ir.dataSourcesTypes || []).reduce(
(acc, dsType) => ({
...acc,
[getDataSourceHandlerPackageName(dsType)]: cfg.handlersVersion?.[dsType] || 'latest',
}),
{},
),
};
function getDataSourceHandlerPackageName(dsType: string) {
return (
cfg.handlersPackages?.[dsType] ||
`@alilc/lowcode-datasource-${changeCase.kebab(dsType)}-handler`
);
}
}

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,6 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -14,8 +14,6 @@
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,6 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,6 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,6 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,6 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,6 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,6 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,6 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,6 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -13,9 +13,6 @@
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,6 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -1,5 +1,5 @@
{
"name": "@alilc/rax-app-demo",
"name": "rax-demo-app",
"private": true,
"version": "1.0.0",
"scripts": {
@ -12,10 +12,7 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alilc/lowcode-datasource-mtop-handler": "latest",
"@alilc/lowcode-datasource-mopen-handler": "latest",
"@alilc/lowcode-datasource-http-handler": "latest",
"universal-env": "^3.2.0",
"intl-messageformat": "^9.3.6",
"rax": "^1.1.0",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,19 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alifd/next": "1.19.18"
},
"devDependencies": {
@ -21,8 +22,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,18 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/b6-page": "^0.1.0",
"@alilc/b6-text": "^0.1.0",
"@alilc/b6-compact-legao-builtin": "1.x",
@ -25,8 +25,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,17 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"@alifd/next": "1.19.18"
},
"devDependencies": {
@ -21,8 +20,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,17 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"@alifd/next": "1.19.18"
},
"devDependencies": {
@ -21,8 +20,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,18 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alife/container": "latest",
"@alife/mc-assets-1935": "0.1.9"
},
@ -22,8 +22,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,17 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"undefined": "*",
"@alife/container": "0.3.7",
"@alilc/antd-lowcode": "0.5.4",
@ -24,8 +23,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,19 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-url-params-handler": "latest",
"@alilc/lowcode-datasource-fetch-handler": "latest",
"@alifd/next": "1.19.18"
},
"devDependencies": {
@ -21,8 +22,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,17 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"undefined": "*",
"@alilc/antd-lowcode": "0.8.0",
"@alife/container": "0.3.7"
@ -23,8 +22,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,18 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-http-handler": "latest",
"@alilc/lowcode-components": "^1.0.0"
},
"devDependencies": {
@ -21,8 +21,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,18 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"@alilc/lowcode-datasource-jsonp-handler": "latest",
"@alifd/next": "1.19.18"
},
"devDependencies": {
@ -21,8 +21,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,17 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"undefined": "*",
"@alilc/antd-lowcode-materials": "0.9.4",
"@alife/mc-assets-1935": "0.1.42",
@ -24,8 +23,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -15,8 +15,7 @@
"zh-cn"
]
}
],
"@ali/build-plugin-ice-def"
]
]
}

View File

@ -1,18 +1,17 @@
{
"name": "@alifd/scaffold-lite-js",
"name": "icejs-demo-app",
"version": "0.1.5",
"description": "轻量级模板,使用 JavaScript仅包含基础的 Layout。",
"dependencies": {
"moment": "^2.24.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^5.2.1",
"@alifd/theme-design-pro": "^0.x",
"@alilc/lowcode-datasource-engine": "*",
"@alilc/lowcode-datasource-url-params-handler": "*",
"@alilc/lowcode-datasource-fetch-handler": "*",
"@alilc/lowcode-datasource-mtop-handler": "*",
"@alilc/lowcode-datasource-mopen-handler": "*",
"intl-messageformat": "^9.3.6",
"@ice/store": "^1.4.3",
"@loadable/component": "^5.15.2",
"@alilc/lowcode-datasource-engine": "latest",
"undefined": "*",
"@alilc/antd-lowcode-materials": "0.11.0",
"@alife/mc-assets-1935": "0.1.43",
@ -24,8 +23,7 @@
"build-plugin-moment-locales": "^0.1.0",
"eslint": "^6.0.1",
"ice.js": "^1.0.0",
"stylelint": "^13.2.0",
"@ali/build-plugin-ice-def": "^0.1.0"
"stylelint": "^13.2.0"
},
"scripts": {
"start": "icejs start",

View File

@ -0,0 +1,57 @@
{
"version": "1.0.0",
"componentsMap": [
{
"package": "@alilc/lowcode-materials",
"version": "^1.0.0",
"exportName": "Page",
"destructuring": true,
"componentName": "Page"
},
{
"package": "@alilc/lowcode-materials",
"version": "^1.0.0",
"exportName": "Typography",
"destructuring": true,
"subName": "Text",
"componentName": "Text"
}
],
"componentsTree": [
{
"componentName": "Page",
"id": "node_dockcviv8fo1",
"props": {},
"fileName": "test",
"dataSource": {
"list": [
{
"id": "test",
"type": "fetch",
"options": {
"uri": "https://xxx.com/api/xxx"
}
}
]
},
"css": "body {\n font-size: 12px;\n}\n\n.botton {\n width: 100px;\n color: #ff00ff;\n}",
"lifeCycles": {},
"hidden": false,
"title": "",
"isLocked": false,
"condition": true,
"conditionGroup": "",
"state": {},
"children": [
{
"componentName": "Text",
"props": {
"text": "hello world"
}
}
]
}
],
"i18n": {}
}

View File

@ -0,0 +1,49 @@
import CodeGenerator from '../../src';
import * as fs from 'fs';
import * as path from 'path';
const testCaseBaseName = path.basename(__filename, '.test.ts');
test(testCaseBaseName, async () => {
const inputSchemaJsonFile = path.join(__dirname, `${testCaseBaseName}.schema.json`);
const outputDir = path.join(__dirname, `${testCaseBaseName}.generated`);
await exportProject(inputSchemaJsonFile, outputDir);
const generatedPackageJsonText = fs.readFileSync(
path.join(outputDir, 'demo-project/package.json'),
'utf-8',
);
const generatedPackageJson = JSON.parse(generatedPackageJsonText);
expect(generatedPackageJson.dependencies).toBeTruthy();
// 里面有的数据源则应该生成对应的 dependencies
expect(generatedPackageJson.dependencies).toMatchObject({
'@alilc/lowcode-datasource-engine': 'latest',
'@alilc/lowcode-datasource-fetch-handler': 'latest',
});
// 里面没有的,则不应该生成对应的 dependencies
expect(generatedPackageJson.dependencies).not.toMatchObject({
'@alilc/lowcode-datasource-url-params-handler': 'latest',
'@alilc/lowcode-datasource-mtop-handler': 'latest',
'@alilc/lowcode-datasource-mopen-handler': 'latest',
});
});
function exportProject(inputPath: string, outputPath: string) {
const schemaJson = fs.readFileSync(inputPath, { encoding: 'utf8' });
const newSchema = schemaJson;
const builder = CodeGenerator.solutions.icejs();
return builder.generateProject(newSchema).then(async (result) => {
// displayResultInConsole(result);
const publisher = CodeGenerator.publishers.disk();
await publisher.publish({
project: result,
outputPath,
projectSlug: 'demo-project',
createProjectFolder: true,
});
return result;
});
}