fix(packages): delete types and utils buildscripts

This commit is contained in:
1ncounter 2024-03-23 14:05:25 +08:00
parent 3592356c90
commit 62c535bf2a
62 changed files with 372 additions and 581 deletions

View File

@ -1,13 +0,0 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
quote_type = single
[*.md]
trim_trailing_whitespace = false

11
TODOS.md Normal file
View File

@ -0,0 +1,11 @@
## project
### docs for contributing:
1. init
2. develop
3. debug
4. build
5. test
6. publish
7. github workflows

View File

@ -1,6 +0,0 @@
module.exports = {
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
[require.resolve('@babel/plugin-proposal-class-properties'), { loose: true }],
],
};

View File

@ -1,37 +0,0 @@
{
"lerna": "4.0.0",
"version": "1.3.2",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*",
"runtime/*"
],
"command": {
"bootstrap": {
"npmClientArgs": [
"--no-package-lock"
]
},
"version": {
"allowBranch": [
"master",
"main",
"release/*",
"daily/*",
"refactor/*"
]
},
"publish": {
"npmClient": "npm",
"verifyRegistry": false,
"verifyAccess": false,
"ignoreChanges": [
"**/*.md",
"**/test/**"
],
"message": "chore(release): publish %v",
"conventionalCommits": true
}
}
}

View File

@ -1,19 +1,7 @@
{
"private": true,
"workspaces": {
"packages": [
"packages/*",
"runtime/*",
"examples/*"
],
"nohoist": [
"**/css-modules-typescript-loader",
"**/@alifc/theme-lowcode-*",
"**/jest"
]
},
"scripts": {
"dev": "pnpm --filter playground dev",
"playground": "pnpm --filter playground dev",
"build": "./scripts/build.sh",
"build:npm": "lerna run build --stream",
"build:umd": "lerna run build:umd --stream",
@ -30,13 +18,9 @@
"pub:preminor": "npm run watchdog:build && lerna publish preminor --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"pub:prepatch": "npm run watchdog:build && lerna publish prepatch --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"pub:prerelease": "npm run watchdog:build && lerna publish prerelease --yes --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"setup": "node ./scripts/setup.js",
"setup:test": "./scripts/setup-for-test.sh",
"setup:skip-build": "./scripts/setup-skip-build.sh",
"start": "node ./scripts/start.js",
"test": "lerna run test --stream",
"test:snapshot": "lerna run test:snapshot",
"watchdog:build": "node ./scripts/watchdog.js",
"sync": "./scripts/sync.sh",
"syncOss": "node ./scripts/sync-oss.js"
},

View File

@ -1,6 +1,5 @@
const { execSync } = require('child_process');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const fse = require('fs-extra');
// get version from git branch name,
// e.g. release/1.0.7 => 1.0.7
@ -25,16 +24,16 @@ const releaseVersion = getVersion();
module.exports = ({ context, onGetWebpackConfig }) => {
onGetWebpackConfig((config) => {
config.resolve
.plugin('tsconfigpaths')
.use(TsconfigPathsPlugin, [{
config.resolve.plugin('tsconfigpaths').use(TsconfigPathsPlugin, [
{
configFile: './tsconfig.json',
}]);
config
.plugin('define')
.use(context.webpack.DefinePlugin, [{
},
]);
config.plugin('define').use(context.webpack.DefinePlugin, [
{
VERSION_PLACEHOLDER: JSON.stringify(releaseVersion),
}]);
},
]);
config.plugins.delete('hot');
config.devServer.hot(false);
});

View File

@ -1,3 +0,0 @@
lib
es
node_modules

View File

@ -1,6 +0,0 @@
module.exports = {
printWidth: 80,
singleQuote: true,
trailingComma: 'all',
tabSize: 2,
};

View File

@ -1,5 +0,0 @@
{
"plugins": [
"@alilc/build-plugin-lce"
]
}

View File

@ -1,25 +1,28 @@
{
"name": "@alilc/lowcode-types",
"version": "1.3.3",
"version": "2.0.0-beta.0",
"description": "Types for Ali lowCode engine",
"files": [
"es",
"lib"
],
"main": "lib/index.js",
"module": "es/index.js",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "build-scripts build"
"build": "tsc"
},
"dependencies": {
"@alilc/lowcode-datasource-types": "^1.0.0",
"react": "^16.9",
"@alifd/next": "^1.27.8",
"react": "^18.2.0",
"strict-event-emitter-types": "^2.0.0"
},
"devDependencies": {
"@alib/build-scripts": "^0.1.18",
"@types/node": "^13.7.1",
"@types/react": "^16"
"@types/react": "^18"
},
"peerDependencies": {
"react": "^18.2.0"
},
"publishConfig": {
"access": "public",

View File

@ -1,18 +0,0 @@
export * from './isActionContentObject';
export * from './isCustomView';
export * from './isDOMText';
export * from './isDynamicSetter';
export * from './isI18nData';
export * from './isJSBlock';
export * from './isJSExpression';
export * from './isJSFunction';
export * from './isJSSlot';
export * from './isLowCodeComponentType';
export * from './isNodeSchema';
export * from './isPlainObject';
export * from './isProCodeComponentType';
export * from './isProjectSchema';
export * from './isReactClass';
export * from './isReactComponent';
export * from './isSetterConfig';
export * from './isTitleConfig';

View File

@ -1,8 +0,0 @@
import { IPublicTypeActionContentObject } from '../shell';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isActionContentObject(obj: any): obj is IPublicTypeActionContentObject {
return obj && typeof obj === 'object';
}

View File

@ -1,10 +0,0 @@
import { isValidElement } from 'react';
import { isReactComponent } from './isReactComponent';
import { IPublicTypeCustomView } from '../shell/type/custom-view';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isCustomView(obj: any): obj is IPublicTypeCustomView {
return obj && (isValidElement(obj) || isReactComponent(obj));
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeDOMText } from '../shell/type/dom-text';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isDOMText(data: any): data is IPublicTypeDOMText {
return typeof data === 'string';
}

View File

@ -1,9 +0,0 @@
import { isReactClass } from './isReactClass';
import { IPublicTypeDynamicSetter } from '../shell/type/dynamic-setter';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isDynamicSetter(obj: any): obj is IPublicTypeDynamicSetter {
return obj && typeof obj === 'function' && !isReactClass(obj);
}

View File

@ -1,7 +0,0 @@
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isI18nData(obj: any): boolean {
return obj && obj.type === 'i18n';
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeJSBlock } from '../shell/type/value-type';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isJSBlock(data: any): data is IPublicTypeJSBlock {
return data && data.type === 'JSBlock';
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeJSExpression } from '../shell/type/value-type';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isJSExpression(data: any): data is IPublicTypeJSExpression {
return data && data.type === 'JSExpression' && data.extType !== 'function';
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeJSFunction } from '../shell/type/value-type';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isJSFunction(x: any): x is IPublicTypeJSFunction {
return typeof x === 'object' && x && x.type === 'JSFunction';
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeJSSlot } from '../shell/type/value-type';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isJSSlot(data: any): data is IPublicTypeJSSlot {
return data && data.type === 'JSSlot';
}

View File

@ -1,9 +0,0 @@
import { isProCodeComponentType } from './isProCodeComponentType';
import { IPublicTypeComponentMap, IPublicTypeLowCodeComponent } from '../shell/type/npm';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isLowCodeComponentType(desc: IPublicTypeComponentMap): desc is IPublicTypeLowCodeComponent {
return !isProCodeComponentType(desc);
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeNodeSchema } from '../shell';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isNodeSchema(data: any): data is IPublicTypeNodeSchema {
return data && data.componentName;
}

View File

@ -1,10 +0,0 @@
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isPlainObject(value: any): value is Record<string, unknown> {
if (typeof value !== 'object') {
return false;
}
const proto = Object.getPrototypeOf(value);
return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null;
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeComponentMap, IPublicTypeProCodeComponent } from '../shell/type/npm';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isProCodeComponentType(desc: IPublicTypeComponentMap): desc is IPublicTypeProCodeComponent {
return 'package' in desc;
}

View File

@ -1,6 +0,0 @@
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isProjectSchema(data: any): boolean {
return data && data.componentsTree;
}

View File

@ -1,8 +0,0 @@
import { ComponentClass, Component } from 'react';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isReactClass(obj: any): obj is ComponentClass<any> {
return obj && obj.prototype && (obj.prototype.isReactComponent || obj.prototype instanceof Component);
}

View File

@ -1,9 +0,0 @@
import { ComponentType } from 'react';
import { isReactClass } from './isReactClass';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isReactComponent(obj: any): obj is ComponentType<any> {
return obj && (isReactClass(obj) || typeof obj === 'function');
}

View File

@ -1,9 +0,0 @@
import { IPublicTypeSetterConfig } from '../shell/type/setter-config';
import { isCustomView } from './isCustomView';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isSetterConfig(obj: any): obj is IPublicTypeSetterConfig {
return obj && typeof obj === 'object' && 'componentName' in obj && !isCustomView(obj);
}

View File

@ -1,10 +0,0 @@
import { isI18nData } from './isI18nData';
import { isPlainObject } from './isPlainObject';
import { IPublicTypeTitleConfig } from '../shell/type/title-config';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isTitleConfig(obj: any): obj is IPublicTypeTitleConfig {
return isPlainObject(obj) && !isI18nData(obj);
}

View File

@ -1,10 +1,9 @@
import * as Node from './node';
export interface EventConfig {
[Node.Prop.Change]: (options: Node.Prop.ChangeOptions) => any;
[Node.Prop.InnerChange]: (options: Node.Prop.ChangeOptions) => any;
[Node.Rerender]: (options: Node.RerenderOptions) => void;
[eventName: string]: any;
}
export * as Node from './node';
export * as Node from './node';

View File

@ -6,11 +6,5 @@ export interface ChangeOptions {
oldValue: any;
}
/**
* Node Prop
* @Deprecated Please Replace With InnerPropChange
*/
export const Change = 'node.prop.change';
/** Node Prop 变化事件 */
export const InnerChange = 'node.innerProp.change';
export const InnerChange = 'node.innerProp.change';

View File

@ -7,5 +7,3 @@ export * from './assets';
export * as GlobalEvent from './event';
export * from './shell';
export * from './shell-model-factory';
// TODO: remove this in future versions
export * from './deprecated';

View File

@ -1,7 +1,41 @@
import React, { ReactElement } from 'react';
import { IPublicTypeContextMenuAction, IPublicTypeHelpTipConfig, IPublicTypeTipConfig, IPublicTypeTitleContent } from '../type';
import { Balloon, Breadcrumb, Button, Card, Checkbox, DatePicker, Dialog, Dropdown, Form, Icon, Input, Loading, Message, Overlay, Pagination, Radio, Search, Select, SplitButton, Step, Switch, Tab, Table, Tree, TreeSelect, Upload, Divider } from '@alifd/next';
import { IconProps } from '@alifd/next/types/icon';
import React, { ReactElement, ComponentProps } from 'react';
import {
IPublicTypeContextMenuAction,
IPublicTypeHelpTipConfig,
IPublicTypeTipConfig,
IPublicTypeTitleContent,
} from '../type';
import {
Balloon,
Breadcrumb,
Button,
Card,
Checkbox,
DatePicker,
Dialog,
Dropdown,
Form,
Icon,
Input,
Loading,
Message,
Overlay,
Pagination,
Radio,
Search,
Select,
SplitButton,
Step,
Switch,
Tab,
Table,
Tree,
TreeSelect,
Upload,
Divider,
} from '@alifd/next';
type IconProps = ComponentProps<typeof Icon>;
export interface IPublicApiCommonUI {
Balloon: typeof Balloon;

View File

@ -1,5 +1,10 @@
import { ReactElement, ReactNode } from 'react';
import { IPublicTypeI18nData, IPublicTypeTitleConfig } from './';
import type { ReactElement, ReactNode } from 'react';
import type { IPublicTypeI18nData, IPublicTypeTitleConfig } from './';
// eslint-disable-next-line max-len
export type IPublicTypeTitleContent = string | IPublicTypeI18nData | ReactElement | ReactNode | IPublicTypeTitleConfig;
export type IPublicTypeTitleContent =
| string
| IPublicTypeI18nData
| ReactElement
| ReactNode
| IPublicTypeTitleConfig;

View File

@ -1,5 +1,11 @@
import { ReactElement, ComponentType } from 'react';
import { IPublicTypeI18nData, IPublicTypeIconType, IPublicTypeTitleContent, IPublicTypeWidgetConfigArea, TipContent } from './';
import type { ReactElement, ComponentType } from 'react';
import type {
IPublicTypeI18nData,
IPublicTypeIconType,
IPublicTypeTitleContent,
IPublicTypeWidgetConfigArea,
TipContent,
} from './';
export type IPublicTypeHelpTipConfig = string | { url?: string; content?: string | ReactElement };
@ -36,7 +42,12 @@ export interface IPublicTypeWidgetBaseConfig {
*/
area?: IPublicTypeWidgetConfigArea;
props?: Record<string, any>;
content?: string | ReactElement | ComponentType<any> | IPublicTypePanelConfig[] | IPublicTypePanelConfig;
content?:
| string
| ReactElement
| ComponentType<any>
| IPublicTypePanelConfig[]
| IPublicTypePanelConfig;
contentProps?: Record<string, any>;
/**
@ -96,4 +107,4 @@ export interface IPublicTypePanelDockPanelProps {
area?: IPublicTypeWidgetConfigArea;
}
export type IPublicTypeSkeletonConfig = IPublicTypePanelDockConfig | IPublicTypeWidgetBaseConfig;
export type IPublicTypeSkeletonConfig = IPublicTypePanelDockConfig | IPublicTypeWidgetBaseConfig;

View File

@ -1,9 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "lib"
"outDir": "dist"
},
"include": [
"./src/"
]
"include": ["src"]
}

View File

@ -1,5 +0,0 @@
{
"plugins": [
"@alilc/build-plugin-lce"
]
}

View File

@ -1,6 +0,0 @@
{
"plugins": [
"@alilc/build-plugin-lce",
"@alilc/lowcode-test-mate/plugin/index.ts"
]
}

View File

@ -1,21 +0,0 @@
const fs = require('fs');
const { join } = require('path');
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
const jestConfig = {
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
collectCoverage: false,
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!**/node_modules/**',
'!**/vendor/**',
],
setupFilesAfterEnv: ['./jest.setup.js'],
};
// 只对本仓库内的 pkg 做 mapping
jestConfig.moduleNameMapper = {};
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';
module.exports = jestConfig;

View File

@ -1 +0,0 @@
import '@testing-library/jest-dom';

View File

@ -1,32 +1,36 @@
{
"name": "@alilc/lowcode-utils",
"version": "1.3.2",
"version": "2.0.0-beta.0",
"description": "Utils for Ali lowCode engine",
"files": [
"lib",
"es"
],
"main": "lib/index.js",
"module": "es/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "build-scripts test --config build.test.json --jest-coverage",
"build": "build-scripts build"
"build": "tsc"
},
"dependencies": {
"@alifd/next": "^1.19.16",
"@alilc/lowcode-types": "1.3.2",
"lodash": "^4.17.21",
"mobx": "^6.3.0",
"@alifd/next": "^1.27.8",
"@alilc/lowcode-types": "workspace:*",
"classnames": "^2.5.1",
"lodash-es": "^4.17.21",
"mobx": "^6.12.1",
"prop-types": "^15.8.1",
"react": "^16"
"react": "^18.2.0",
"react-is": "^18.2.0"
},
"devDependencies": {
"@alib/build-scripts": "^0.1.18",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^11.2.7",
"@types/node": "^13.7.1",
"@types/react": "^16",
"react-dom": "^16.14.0"
"@testing-library/react": "^14.2.2",
"@types/lodash-es": "^4.17.12",
"@types/react": "^18.2.67",
"@types/react-is": "^18.2.4",
"@types/prop-types": "^15.7.12"
},
"peerDependencies": {
"react": "^18.2.0"
},
"publishConfig": {
"access": "public",

View File

@ -1,12 +1,24 @@
import { AssetType, AssetLevels, AssetLevel } from '@alilc/lowcode-types';
import type { AssetItem, Asset, AssetList, AssetBundle, IPublicTypeAssetsJson } from '@alilc/lowcode-types';
import type {
AssetItem,
Asset,
AssetList,
AssetBundle,
IPublicTypeAssetsJson,
} from '@alilc/lowcode-types';
import { isCSSUrl } from './is-css-url';
import { createDefer } from './create-defer';
import { load, evaluate } from './script';
// API 向下兼容
export { AssetType, AssetLevels, AssetLevel } from '@alilc/lowcode-types';
export type { AssetItem, Asset, AssetList, AssetBundle, IPublicTypeAssetsJson } from '@alilc/lowcode-types';
export type {
AssetItem,
Asset,
AssetList,
AssetBundle,
IPublicTypeAssetsJson,
} from '@alilc/lowcode-types';
export function isAssetItem(obj: any): obj is AssetItem {
return obj && obj.type;
@ -17,9 +29,9 @@ export function isAssetBundle(obj: any): obj is AssetBundle {
}
export function assetBundle(
assets?: Asset | AssetList | null,
level?: AssetLevel,
): AssetBundle | null {
assets?: Asset | AssetList | null,
level?: AssetLevel,
): AssetBundle | null {
if (!assets) {
return null;
}
@ -38,7 +50,12 @@ urls: [
"view1.js mobile|pc",
"view2.js <device selector>"
] */
export function assetItem(type: AssetType, content?: string | null, level?: AssetLevel, id?: string): AssetItem | null {
export function assetItem(
type: AssetType,
content?: string | null,
level?: AssetLevel,
id?: string,
): AssetItem | null {
if (!content) {
return null;
}
@ -50,7 +67,10 @@ export function assetItem(type: AssetType, content?: string | null, level?: Asse
};
}
export function mergeAssets(assets: IPublicTypeAssetsJson, incrementalAssets: IPublicTypeAssetsJson): IPublicTypeAssetsJson {
export function mergeAssets(
assets: IPublicTypeAssetsJson,
incrementalAssets: IPublicTypeAssetsJson,
): IPublicTypeAssetsJson {
if (incrementalAssets.packages) {
assets.packages = [...(assets.packages || []), ...incrementalAssets.packages];
}
@ -65,7 +85,11 @@ export function mergeAssets(assets: IPublicTypeAssetsJson, incrementalAssets: IP
return assets;
}
function mergeAssetsComponentList(assets: IPublicTypeAssetsJson, incrementalAssets: IPublicTypeAssetsJson, listName: keyof IPublicTypeAssetsJson): void {
function mergeAssetsComponentList(
assets: IPublicTypeAssetsJson,
incrementalAssets: IPublicTypeAssetsJson,
listName: keyof Omit<IPublicTypeAssetsJson, 'version' | 'sort'>,
): void {
if (incrementalAssets[listName]) {
if (assets[listName]) {
// 根据title进行合并
@ -131,7 +155,10 @@ export class StylePoint {
element.setAttribute('data-id', this.id);
}
element.appendChild(document.createTextNode(content));
document.head.insertBefore(element, this.placeholder.parentNode === document.head ? this.placeholder.nextSibling : null);
document.head.insertBefore(
element,
this.placeholder.parentNode === document.head ? this.placeholder.nextSibling : null,
);
document.head.removeChild(this.placeholder);
this.placeholder = element;
}
@ -162,7 +189,10 @@ export class StylePoint {
if (this.id) {
element.setAttribute('data-id', this.id);
}
document.head.insertBefore(element, this.placeholder.parentNode === document.head ? this.placeholder.nextSibling : null);
document.head.insertBefore(
element,
this.placeholder.parentNode === document.head ? this.placeholder.nextSibling : null,
);
document.head.removeChild(this.placeholder);
this.placeholder = element;
return i.promise();
@ -175,7 +205,12 @@ function parseAssetList(scripts: any, styles: any, assets: AssetList, level?: As
}
}
function parseAsset(scripts: any, styles: any, asset: Asset | undefined | null, level?: AssetLevel) {
function parseAsset(
scripts: any,
styles: any,
asset: Asset | undefined | null,
level?: AssetLevel,
) {
if (!asset) {
return;
}
@ -219,7 +254,7 @@ export class AssetLoader {
async load(asset: Asset) {
const styles: any = {};
const scripts: any = {};
AssetLevels.forEach(lv => {
AssetLevels.forEach((lv) => {
styles[lv] = [];
scripts[lv] = [];
});
@ -237,12 +272,23 @@ export class AssetLoader {
scripts[AssetLevel.App],
);
await Promise.all(
styleQueue.map(({ content, level, type, id }) => this.loadStyle(content, level!, type === AssetType.CSSUrl, id)),
styleQueue.map(({ content, level, type, id }) =>
this.loadStyle(content, level!, type === AssetType.CSSUrl, id),
),
);
await Promise.all(
scriptQueue.map(({ content, type, scriptType }) =>
this.loadScript(content, type === AssetType.JSUrl, scriptType),
),
);
await Promise.all(scriptQueue.map(({ content, type, scriptType }) => this.loadScript(content, type === AssetType.JSUrl, scriptType)));
}
private loadStyle(content: string | undefined | null, level: AssetLevel, isUrl?: boolean, id?: string) {
private loadStyle(
content: string | undefined | null,
level: AssetLevel,
isUrl?: boolean,
id?: string,
) {
if (!content) {
return;
}

View File

@ -1,5 +1,9 @@
import { ComponentType, forwardRef, createElement, FunctionComponent } from 'react';
import { IPublicTypeNpmInfo, IPublicTypeComponentSchema, IPublicTypeProjectSchema } from '@alilc/lowcode-types';
import {
IPublicTypeNpmInfo,
IPublicTypeComponentSchema,
IPublicTypeProjectSchema,
} from '@alilc/lowcode-types';
import { isESModule } from './is-es-module';
import { isReactComponent, acceptsRef, wrapReactClass } from './is-react';
import { isObject } from './is-object';
@ -19,9 +23,9 @@ export function accessLibrary(library: string | Record<string, unknown>) {
return (window as any)[library] || generateHtmlComp(library);
}
export function generateHtmlComp(library: string) {
export function generateHtmlComp(library: string): any {
if (['a', 'img', 'div', 'span', 'svg'].includes(library)) {
return forwardRef((props, ref) => {
return forwardRef((props: any, ref) => {
return createElement(library, { ref, ...props }, props.children);
});
}
@ -92,12 +96,20 @@ function isMixinComponent(components: any) {
return false;
}
return Object.keys(components).some(componentName => isReactComponent(components[componentName]));
return Object.keys(components).some((componentName) =>
isReactComponent(components[componentName]),
);
}
export function buildComponents(libraryMap: LibraryMap,
componentsMap: { [componentName: string]: IPublicTypeNpmInfo | ComponentType<any> | IPublicTypeComponentSchema },
createComponent: (schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>) => Component | null) {
export function buildComponents(
libraryMap: LibraryMap,
componentsMap: {
[componentName: string]: IPublicTypeNpmInfo | ComponentType<any> | IPublicTypeComponentSchema;
},
createComponent: (
schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>,
) => Component | null,
) {
const components: any = {};
Object.keys(componentsMap).forEach((componentName) => {
let component = componentsMap[componentName];
@ -150,14 +162,17 @@ interface LibrayMap {
interface ProjectUtils {
[packageName: string]: any;
}
export function getProjectUtils(librayMap: LibrayMap, utilsMetadata: UtilsMetadata[]): ProjectUtils {
export function getProjectUtils(
librayMap: LibrayMap,
utilsMetadata: UtilsMetadata[],
): ProjectUtils {
const projectUtils: ProjectUtils = {};
if (utilsMetadata) {
utilsMetadata.forEach(meta => {
utilsMetadata.forEach((meta) => {
if (librayMap[meta?.npm?.package]) {
const lib = accessLibrary(librayMap[meta?.npm.package]);
if (lib?.destructuring) {
Object.keys(lib).forEach(name => {
Object.keys(lib).forEach((name) => {
if (name === 'destructuring') return;
projectUtils[name] = lib[name];
});
@ -168,4 +183,4 @@ export function getProjectUtils(librayMap: LibrayMap, utilsMetadata: UtilsMetada
});
}
return projectUtils;
}
}

View File

@ -1,5 +1,7 @@
import * as ReactIs from 'react-is';
// @ts-expect-error
import { default as ReactPropTypesSecret } from 'prop-types/lib/ReactPropTypesSecret';
// @ts-expect-error
import { default as factoryWithTypeCheckers } from 'prop-types/factoryWithTypeCheckers';
import { IPublicTypePropType } from '@alilc/lowcode-types';
import { isRequiredPropType } from './check-types/is-required-prop-type';
@ -41,15 +43,24 @@ export function transformPropTypesRuleToString(rule: IPublicTypePropType | strin
return 'PropTypes.any';
}
export function checkPropTypes(value: any, name: string, rule: any, componentName: string): boolean {
export function checkPropTypes(
value: any,
name: string,
rule: any,
componentName: string,
): boolean {
let ruleFunction = rule;
if (typeof rule === 'object') {
// eslint-disable-next-line no-new-func
ruleFunction = new Function(`"use strict"; const PropTypes = arguments[0]; return ${transformPropTypesRuleToString(rule)}`)(PropTypes2);
ruleFunction = new Function(
`"use strict"; const PropTypes = arguments[0]; return ${transformPropTypesRuleToString(rule)}`,
)(PropTypes2);
}
if (typeof rule === 'string') {
// eslint-disable-next-line no-new-func
ruleFunction = new Function(`"use strict"; const PropTypes = arguments[0]; return ${transformPropTypesRuleToString(rule)}`)(PropTypes2);
ruleFunction = new Function(
`"use strict"; const PropTypes = arguments[0]; return ${transformPropTypesRuleToString(rule)}`,
)(PropTypes2);
}
if (!ruleFunction || typeof ruleFunction !== 'function') {
logger.warn('checkPropTypes should have a function type rule argument');

View File

@ -1,8 +1,15 @@
import { Menu, Icon } from '@alifd/next';
import { IPublicEnumContextMenuType, IPublicModelNode, IPublicModelPluginContext, IPublicTypeContextMenuAction, IPublicTypeContextMenuItem } from '@alilc/lowcode-types';
import { Logger } from '@alilc/lowcode-utils';
import {
IPublicEnumContextMenuType,
IPublicModelNode,
IPublicModelPluginContext,
IPublicTypeContextMenuAction,
IPublicTypeContextMenuItem,
} from '@alilc/lowcode-types';
import { Logger } from './logger';
import classNames from 'classnames';
import React from 'react';
import './context-menu.scss';
const logger = new Logger({ level: 'warn', bizName: 'utils' });
@ -24,9 +31,7 @@ const Tree = (props: {
const { node } = props;
if (!node) {
return (
<div className="engine-context-menu-tree-wrap">{ props.children }</div>
);
return <div className="engine-context-menu-tree-wrap">{props.children}</div>;
}
const { common } = props.options.pluginContext || {};
@ -40,7 +45,7 @@ const Tree = (props: {
};
return (
<Tree {...props} node={node.parent} >
<Tree {...props} node={node.parent}>
<div
className="engine-context-menu-title"
onClick={() => {
@ -49,21 +54,22 @@ const Tree = (props: {
}}
style={style}
>
{props.options.nodes?.[0].id === node.id ? (<Icon className="engine-context-menu-tree-selecte-icon" size="small" type="success" />) : null}
{props.options.nodes?.[0].id === node.id ? (
<Icon className="engine-context-menu-tree-selecte-icon" size="small" type="success" />
) : null}
{intl(node.title)}
</div>
<div
className="engine-context-menu-tree-children"
>
{ props.children }
</div>
<div className="engine-context-menu-tree-children">{props.children}</div>
</Tree>
);
};
let destroyFn: Function | undefined;
export function parseContextMenuAsReactNode(menus: IPublicTypeContextMenuItem[], options: IOptions): React.ReactNode[] {
export function parseContextMenuAsReactNode(
menus: IPublicTypeContextMenuItem[],
options: IOptions,
): React.ReactNode[] {
const { common, commonUI } = options.pluginContext || {};
const { intl = (title: any) => title } = common?.utils || {};
const { HelpTip } = commonUI || {};
@ -77,7 +83,7 @@ export function parseContextMenuAsReactNode(menus: IPublicTypeContextMenuItem[],
if (menu.type === IPublicEnumContextMenuType.MENU_ITEM) {
if (menu.items && menu.items.length) {
children.push((
children.push(
<PopupItem
className={classNames('engine-context-menu-item', {
disabled: menu.disabled,
@ -86,12 +92,12 @@ export function parseContextMenuAsReactNode(menus: IPublicTypeContextMenuItem[],
label={<div className="engine-context-menu-text">{intl(menu.title)}</div>}
>
<Menu className="next-context engine-context-menu">
{ parseContextMenuAsReactNode(menu.items, options) }
{parseContextMenuAsReactNode(menu.items, options)}
</Menu>
</PopupItem>
));
</PopupItem>,
);
} else {
children.push((
children.push(
<Item
className={classNames('engine-context-menu-item', {
disabled: menu.disabled,
@ -103,27 +109,29 @@ export function parseContextMenuAsReactNode(menus: IPublicTypeContextMenuItem[],
key={menu.name}
>
<div className="engine-context-menu-text">
{ menu.title ? intl(menu.title) : null }
{ menu.help ? <HelpTip size="xs" help={menu.help} direction="right" /> : null }
{menu.title ? intl(menu.title) : null}
{menu.help ? <HelpTip size="xs" help={menu.help} direction="right" /> : null}
</div>
</Item>
));
</Item>,
);
}
}
if (menu.type === IPublicEnumContextMenuType.NODE_TREE) {
children.push((
<Tree node={options.nodes?.[0]} options={options} />
));
children.push(<Tree node={options.nodes?.[0]} options={options} />);
}
});
return children;
}
export function parseContextMenuProperties(menus: (IPublicTypeContextMenuAction | Omit<IPublicTypeContextMenuAction, 'items'>)[], options: IOptions & {
event?: MouseEvent;
}, level = 1): IPublicTypeContextMenuItem[] {
export function parseContextMenuProperties(
menus: (IPublicTypeContextMenuAction | Omit<IPublicTypeContextMenuAction, 'items'>)[],
options: IOptions & {
event?: MouseEvent;
},
level = 1,
): IPublicTypeContextMenuItem[] {
destroyFn?.();
const { nodes, destroy } = options;
@ -133,14 +141,9 @@ export function parseContextMenuProperties(menus: (IPublicTypeContextMenuAction
}
return menus
.filter(menu => !menu.condition || (menu.condition && menu.condition(nodes || [])))
.filter((menu) => !menu.condition || (menu.condition && menu.condition(nodes || [])))
.map((menu) => {
const {
name,
title,
type = IPublicEnumContextMenuType.MENU_ITEM,
help,
} = menu;
const { name, title, type = IPublicEnumContextMenuType.MENU_ITEM, help } = menu;
const result: IPublicTypeContextMenuItem = {
name,
@ -151,7 +154,7 @@ export function parseContextMenuProperties(menus: (IPublicTypeContextMenuAction
destroy?.();
menu.action?.(nodes || [], options.event);
},
disabled: menu.disabled && menu.disabled(nodes || []) || false,
disabled: (menu.disabled && menu.disabled(nodes || [])) || false,
};
if ('items' in menu && menu.items) {
@ -169,7 +172,7 @@ export function parseContextMenuProperties(menus: (IPublicTypeContextMenuAction
return menus.concat([currentMenu]);
}
const index = menus.find(item => item.name === currentMenu.name);
const index = menus.find((item) => item.name === currentMenu.name);
if (!index) {
return menus.concat([currentMenu]);
} else {
@ -192,20 +195,29 @@ function getMenuItemHeight() {
return menuItemHeight;
}
export function createContextMenu(children: React.ReactNode[], {
event,
offset = [0, 0],
}: {
event: MouseEvent | React.MouseEvent;
offset?: [number, number];
}) {
export function createContextMenu(
children: React.ReactNode[],
{
event,
offset = [0, 0],
}: {
event: MouseEvent | React.MouseEvent;
offset?: [number, number];
},
) {
event.preventDefault();
event.stopPropagation();
const viewportWidth = window.innerWidth;
const viewportHeight = window.innerHeight;
const dividerCount = React.Children.count(children.filter(child => React.isValidElement(child) && child.type === Divider));
const popupItemCount = React.Children.count(children.filter(child => React.isValidElement(child) && (child.type === PopupItem || child.type === Item)));
const dividerCount = React.Children.count(
children.filter((child) => React.isValidElement(child) && child.type === Divider),
);
const popupItemCount = React.Children.count(
children.filter(
(child) => React.isValidElement(child) && (child.type === PopupItem || child.type === Item),
),
);
const menuHeight = popupItemCount * parseInt(getMenuItemHeight(), 10) + dividerCount * 8 + 16;
const menuWidthLimit = 200;
let x = event.clientX + offset[0];
@ -227,4 +239,4 @@ export function createContextMenu(children: React.ReactNode[], {
destroyFn = (menuInstance as any).destroy;
return destroyFn;
}
}

View File

@ -7,9 +7,9 @@ import { isESModule } from './is-es-module';
const URL_RE = /^(https?:)\/\//i;
export function createIcon(
icon?: IPublicTypeIconType | null,
props?: Record<string, unknown>,
): ReactNode {
icon?: IPublicTypeIconType | null,
props?: Record<string, unknown>,
): ReactNode {
if (!icon) {
return null;
}
@ -36,5 +36,5 @@ export function createIcon(
});
}
return <Icon {...icon} {...props} />;
return <Icon {...(icon as any)} {...props} />;
}

View File

@ -4,7 +4,7 @@
*/
// 需要通过 Env 来判断是否需要
import { some } from 'lodash';
import { some } from 'lodash-es';
const pseudoMap = ['hover', 'focus', 'active', 'visited'];
@ -37,7 +37,7 @@ function isString(str: any): str is string {
}
function hyphenate(str: string): string {
return str.replace(RE_CAMEL, w => `-${w}`).toLowerCase();
return str.replace(RE_CAMEL, (w) => `-${w}`).toLowerCase();
}
function camelize(str: string): string {
@ -63,30 +63,30 @@ function toNativeStyle(runtime: Record<string, string> | undefined) {
return {};
}
if (runtime.default) {
const normalized: Record<string, string> = {};
const normalized: any = {};
Object.keys(runtime).forEach((pseudo) => {
if (pseudo === 'extra') {
normalized[pseudo] = runtime[pseudo];
return;
}
normalized[pseudo] = toNativeStyle(runtime[pseudo]);
normalized[pseudo] = toNativeStyle(runtime[pseudo] as any);
});
return normalized;
}
const normalized = {};
const normalized: any = {};
Object.keys(runtime).forEach((key) => {
normalized[camelize(key)] = runtime[key];
});
return normalized;
}
function normalizeStyle(style) {
function normalizeStyle(style: any): any {
if (!style) {
return {};
}
if (style.default) {
const normalized = {};
const normalized: Record<string, string> = {};
Object.keys(style).forEach((pseudo) => {
if (pseudo === 'extra') {
normalized[pseudo] = style[pseudo];
@ -104,12 +104,11 @@ function normalizeStyle(style) {
return normalized;
}
function toCss(runtime) {
function toCss(runtime: Record<string, string>) {
if (!runtime) {
return (
`:root {
return `:root {
}`);
}`;
}
if (runtime.default) {
@ -125,17 +124,15 @@ function toCss(runtime) {
`:root${pseudo === 'default' ? '' : `${prefix}${pseudo}`} {
${runtimeToCss(normalizeStyle(runtime[pseudo]))}
}\n`,
);
);
});
return css.join('\n');
}
return (
`:root {
return `:root {
${runtimeToCss(normalizeStyle(runtime))}
}
`
);
`;
}
function cssToRuntime(css: string) {
@ -152,45 +149,48 @@ function cssToRuntime(css: string) {
runtime.extra = runtime.extra || [];
runtime.extra.push(cssItem.trim());
} else {
const res = /:root:?(.*)?{(.*)/ig.exec(cssItem.replace(/[\r\n]+/ig, '').trim());
const res = /:root:?(.*)?{(.*)/gi.exec(cssItem.replace(/[\r\n]+/gi, '').trim());
if (res) {
let pseudo: string | undefined;
if (res[1] && res[1].trim() && some(pseudoMap, pse => res[1].indexOf(pse) === 0)) {
if (res[1] && res[1].trim() && some(pseudoMap, (pse) => res[1].indexOf(pse) === 0)) {
pseudo = res[1].trim();
} else if (res[1] && res[1].trim()) {
pseudo = res[1];
}
const s: Record<string, string> = {};
res[2].split(';').reduce<string[]>((prev, next) => {
if (next.indexOf('base64') > -1) {
prev[prev.length - 1] += `;${next}`;
} else {
prev.push(next);
}
return prev;
}, []).forEach((item) => {
if (item) {
if (PROPS_REG.test(item)) {
const props = item.match(PROPS_REG);
const key = props?.[1];
const value = props?.[2];
if (key && value) {
s[key.trim()] = value.trim();
res[2]
.split(';')
.reduce<string[]>((prev, next) => {
if (next.indexOf('base64') > -1) {
prev[prev.length - 1] += `;${next}`;
} else {
prev.push(next);
}
return prev;
}, [])
.forEach((item) => {
if (item) {
if (PROPS_REG.test(item)) {
const props = item.match(PROPS_REG);
const key = props?.[1];
const value = props?.[2];
if (key && value) {
s[key.trim()] = value.trim();
}
}
}
}
});
});
runtime[pseudo || 'default'] = s;
(runtime as any)[pseudo || 'default'] = s;
}
}
});
return runtime;
}
function cssToStyle(css) {
function cssToStyle(css: any) {
try {
if (isString(css)) {
return toNativeStyle(cssToRuntime(css).default);
@ -205,12 +205,4 @@ function cssToStyle(css) {
return {};
}
export {
hyphenate,
camelize,
toNativeStyle,
normalizeStyle,
toCss,
cssToRuntime,
cssToStyle,
};
export { hyphenate, camelize, toNativeStyle, normalizeStyle, toCss, cssToRuntime, cssToStyle };

View File

@ -1,6 +1,6 @@
import { isObject } from './is-object';
export function isPlainObject<T extends object = object>(value: any): value is T {
export function isPlainObject<T extends object = Record<PropertyKey, any>>(value: any): value is T {
if (!isObject(value)) {
return false;
}

View File

@ -57,11 +57,13 @@ export function isReactComponent(obj: any): obj is ComponentType<any> {
return false;
}
return Boolean(isReactClass(obj) || typeof obj === 'function' || isForwardRefType(obj) || isMemoType(obj));
return Boolean(
isReactClass(obj) || typeof obj === 'function' || isForwardRefType(obj) || isMemoType(obj),
);
}
export function wrapReactClass(view: FunctionComponent) {
let ViewComponentClass = class extends Component {
let ViewComponentClass = class extends Component<any, any> {
render() {
const { children, ...other } = this.props;
return createElement(view, other, children);

View File

@ -1,6 +1,5 @@
import { isI18NObject } from './is-object';
import { get } from 'lodash';
import { get } from 'lodash-es';
import { IPublicEnumTransformStage, IPublicModelComponentMeta } from '@alilc/lowcode-types';
import { Logger } from './logger';
@ -22,7 +21,7 @@ export function isVariable(obj: any): obj is Variable {
export function isUseI18NSetter(prototype: any, propName: string) {
const configure = prototype?.options?.configure;
if (Array.isArray(configure)) {
return configure.some(c => {
return configure.some((c) => {
return c.name === propName && c?.setter?.type?.displayName === 'I18nSetter';
});
}
@ -64,14 +63,14 @@ export function waitForThing(obj: any, path: string): Promise<any> {
export function arrShallowEquals(arr1: any[], arr2: any[]): boolean {
if (!Array.isArray(arr1) || !Array.isArray(arr2)) return false;
if (arr1.length !== arr2.length) return false;
return arr1.every(item => arr2.includes(item));
return arr1.every((item) => arr2.includes(item));
}
/**
* meta vc prototype
* @param meta
*/
export function isFromVC(meta: IPublicModelComponentMeta) {
export function isFromVC(meta: IPublicModelComponentMeta) {
return !!meta?.getMetadata().configure?.advanced;
}
@ -79,14 +78,7 @@ export function executePendingFn(fn: () => void, timeout: number = 2000) {
return setTimeout(fn, timeout);
}
const stageList = [
'render',
'serilize',
'save',
'clone',
'init',
'upgrade',
];
const stageList = ['render', 'serilize', 'save', 'clone', 'init', 'upgrade'];
/**
*
@ -95,7 +87,9 @@ const stageList = [
*/
export function compatStage(stage: IPublicEnumTransformStage | number): IPublicEnumTransformStage {
if (typeof stage === 'number') {
console.warn('stage 直接指定为数字的使用方式已经过时,将在下一版本移除,请直接使用 IPublicEnumTransformStage.Render|Serilize|Save|Clone|Init|Upgrade');
console.warn(
'stage 直接指定为数字的使用方式已经过时,将在下一版本移除,请直接使用 IPublicEnumTransformStage.Render|Serilize|Save|Clone|Init|Upgrade',
);
return stageList[stage - 1] as IPublicEnumTransformStage;
}
return stage as IPublicEnumTransformStage;
@ -103,7 +97,7 @@ export function compatStage(stage: IPublicEnumTransformStage | number): IPublicE
export function invariant(check: any, message: string, thing?: any) {
if (!check) {
throw new Error(`Invariant failed: ${ message }${thing ? ` in '${thing}'` : ''}`);
throw new Error(`Invariant failed: ${message}${thing ? ` in '${thing}'` : ''}`);
}
}
@ -132,4 +126,4 @@ export function shouldUseVariableSetter(
) {
if (propSupportVariable === false) return false;
return propSupportVariable || globalSupportVariable;
}
}

View File

@ -23,7 +23,7 @@ export function compatibleLegaoSchema(props: any): any {
}
if (Array.isArray(props)) {
return props.map(k => compatibleLegaoSchema(k));
return props.map((k) => compatibleLegaoSchema(k));
}
if (!isPlainObject(props)) {
@ -78,7 +78,10 @@ export function compatibleLegaoSchema(props: any): any {
return newProps;
}
export function getNodeSchemaById(schema: IPublicTypeNodeSchema, nodeId: string): IPublicTypeNodeSchema | undefined {
export function getNodeSchemaById(
schema: IPublicTypeNodeSchema,
nodeId: string,
): IPublicTypeNodeSchema | undefined {
let found: IPublicTypeNodeSchema | undefined;
if (schema.id === nodeId) {
return schema;
@ -123,7 +126,10 @@ function getNodeSchemaFromPropsById(props: any, nodeId: string): IPublicTypeNode
* TODO: not sure if this is used anywhere
* @deprecated
*/
export function applyActivities(pivotSchema: IPublicTypeRootSchema, activities: any): IPublicTypeRootSchema {
export function applyActivities(
pivotSchema: IPublicTypeRootSchema,
activities: any,
): IPublicTypeRootSchema {
let schema = { ...pivotSchema };
if (!Array.isArray(activities)) {
activities = [activities];

View File

@ -1,9 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "lib"
"outDir": "dist",
"paths": {
"@alilc/lowcode-*": ["packages/*"]
}
},
"include": [
"./src/"
]
"include": ["src"]
}

8
playground/tsconfig.json Normal file
View File

@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"paths": {
"@alilc/renderer-react": ["runtime/renderer-react"]
}
}
}

View File

@ -1,4 +1,6 @@
packages:
- 'runtime/*'
- 'packages/types'
- 'packages/utils'
- 'playground'
- 'docs'

View File

@ -14,10 +14,13 @@
"test:watch": "vitest"
},
"dependencies": {
"@alilc/lowcode-types": "1.3.2",
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@types/lodash-es": "^4.17.12"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}

View File

@ -13,8 +13,9 @@
"test": "vitest"
},
"dependencies": {
"@alilc/renderer-core": "workspace:*",
"@alilc/runtime-router": "workspace:*",
"@vue/reactivity": "^3.4.21",
"@alilc/renderer-core": "^2.0.0-beta.0",
"lodash-es": "^4.17.21",
"hoist-non-react-statics": "^3.3.2",
"use-sync-external-store": "^1.2.0",
@ -22,7 +23,6 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@alilc/runtime-router": "1.0.0-beta.0",
"@testing-library/react": "^14.2.0",
"@types/lodash-es": "^4.17.12",
"@types/hoist-non-react-statics": "^3.3.5",
@ -34,5 +34,9 @@
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}

View File

@ -13,7 +13,7 @@
"test": "vitest"
},
"dependencies": {
"@alilc/renderer-core": "^2.0.0-beta.0",
"@alilc/renderer-core": "workspace:*",
"lodash-es": "^4.17.21",
"path-to-regexp": "^6.2.1",
"qs": "^6.12.0"
@ -21,5 +21,9 @@
"devDependencies": {
"@types/lodash-es": "^4.17.12",
"@types/qs": "^6.9.13"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}

View File

@ -1,13 +0,0 @@
#!/usr/bin/env bash
rm -rf node_modules package-lock.json yarn.lock
lerna clean -y
find ./packages -type f -name "package-lock.json" -exec rm -f {} \;
lerna bootstrap
lerna exec --stream \
--scope @alilc/lowcode-editor-core \
--scope @alilc/lowcode-types \
--scope @alilc/lowcode-utils \
-- npm run build

View File

@ -1,26 +0,0 @@
#!/usr/bin/env node
const os = require('os');
const del = require('del');
const gulp = require('gulp');
const execa = require('execa');
async function deleteRootDirLockFile() {
await del('package-lock.json');
await del('yarn.lock');
}
async function clean() {
await execa.command('lerna clean -y', { stdio: 'inherit', encoding: 'utf-8' });
}
async function deletePackagesDirLockFile() {
await del('packages/**/package-lock.json');
}
async function bootstrap() {
await execa.command('lerna bootstrap --force-local', { stdio: 'inherit', encoding: 'utf-8' });
}
const setup = gulp.series(deleteRootDirLockFile, clean, deletePackagesDirLockFile, bootstrap);
os.type() === 'Windows_NT' ? setup() : execa.command('scripts/setup.sh', { stdio: 'inherit', encoding: 'utf-8' });

View File

@ -1,10 +0,0 @@
#!/usr/bin/env node
const os = require('os');
const execa = require('execa');
async function start() {
const [, , pkgName = '@alilc/lowcode-ignitor'] = process.argv;
await execa.command(`lerna exec --scope ${pkgName} -- npm start`, { stdio: 'inherit', encoding: 'utf-8' });
}
os.type() === 'Windows_NT' ? start() : execa.command('scripts/start.sh', { stdio: 'inherit', encoding: 'utf-8' });

View File

@ -1,24 +0,0 @@
#!/usr/bin/env node
const fs = require('fs');
const { join } = require('path');
const packagesDir = join(__dirname, '../packages');
const blacklistPkgNames = ['code-generator', 'material-parser'];
const dirs = fs.readdirSync(packagesDir);
dirs
.filter(dir => {
return !dir.startsWith('.') && !blacklistPkgNames.includes(dir);
})
.forEach(dir => {
const pkgDir = join(packagesDir, dir);
const pkg = JSON.parse(fs.readFileSync(join(pkgDir, 'package.json'), 'utf-8'));
if (pkg.private) return;
const { files } = pkg;
files.forEach(file => {
const fileDir = join(pkgDir, file);
if (!fs.existsSync(fileDir)) {
throw new Error(`${fileDir} does not exist, plz run build`);
}
});
});

View File

@ -31,11 +31,7 @@
// skip type checking of declaration files
"skipLibCheck": true,
"baseUrl": "./packages",
"useDefineForClassFields": true,
"paths": {
"@alilc/lowcode-*": ["./*/src"]
},
"outDir": "lib"
"useDefineForClassFields": true
},
"exclude": ["**/tests/*", "**/*.test.ts", "**/lib", "**/es", "node_modules"]
}