Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad605ff

Browse files
sarikeQIQI03
authored andcommitted
update: fix module preload and build issues etc.
- feat: select new item after bottom res copied - fix: module preload before first eval - fix: fix table edit's changeValue - fix: download tar by nodejs instead of curl - fix: oss query command check parameters not empty - fix: download tarball without curl when build - fix: cli crash in powershell
1 parent b65f23c commit ad605ff

File tree

16 files changed

+164
-107
lines changed

16 files changed

+164
-107
lines changed

client/packages/create-openblocks-plugin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
import fs from "fs-extra";
33
import path from "node:path";
4-
import { spawn } from "node:child_process";
4+
import { spawn } from "cross-spawn";
55
import { writeFileSync, existsSync } from "node:fs";
66
import chalk from "chalk";
77
import { createCommand } from "commander";

client/packages/create-openblocks-plugin/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "create-openblocks-plugin",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"bin": "./index.js",
55
"type": "module",
66
"dependencies": {
77
"chalk": "4",
88
"commander": "^9.4.1",
9+
"cross-spawn": "^7.0.3",
910
"fs-extra": "^10.1.0",
1011
"openblocks-dev-utils": "workspace:^"
1112
},

client/packages/openblocks-cli/actions/init.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from "path";
22
import fs from "fs-extra";
3-
import { spawn } from "child_process";
3+
import { spawn } from "cross-spawn";
44
import paths from "../config/paths.js";
55
import { createRequire } from "node:module";
66
const require = createRequire(import.meta.url);
@@ -84,9 +84,9 @@ export default async function initAction(options) {
8484

8585
const notCopiedFiles = ["package.json", "README.md", "README-template.md", "node_modules"];
8686
fs.copySync(templateDir, "./", {
87-
filter: (src) => notCopiedFiles.every((i) => !src.startsWith(`${templateDir}/${i}`)),
87+
filter: (src) => notCopiedFiles.every((i) => !src.startsWith(path.join(templateDir, i))),
8888
});
89-
fs.copyFile(`${templateDir}/README-template.md`, "./README.md");
89+
fs.copyFile(path.join(templateDir, "README-template.md"), "./README.md");
9090
console.log("template files copied");
9191

9292
const dependencies = [];

client/packages/openblocks-cli/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "openblocks-cli",
33
"description": "CLI tool used to start build publish openblocks components",
4-
"version": "0.0.22",
4+
"version": "0.0.24",
55
"bin": "./index.js",
66
"type": "module",
77
"exports": {
@@ -26,6 +26,7 @@
2626
"axios": "^1.1.3",
2727
"chalk": "4",
2828
"commander": "^9.4.1",
29+
"cross-spawn": "^7.0.3",
2930
"fs-extra": "^10.1.0",
3031
"openblocks-dev-utils": "workspace:^",
3132
"react": "^17",

client/packages/openblocks/src/components/table/EditableCell.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,3 @@ export function EditableCell<T extends JSONValue>(props: EditableCellProps<T>) {
129129
</ColumnTypeView>
130130
);
131131
}
132-
133-
export function updateChangeValueFn<T extends JSONValue>(
134-
dispatch: DispatchType,
135-
equalOriginFn: (value: T) => boolean
136-
) {
137-
return (value: T) => {
138-
dispatch(changeChildAction("changeValue", equalOriginFn(value) ? null : value));
139-
};
140-
}

client/packages/openblocks/src/comps/comps/moduleComp/moduleComp.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,21 +281,22 @@ class ModuleTmpComp extends ModuleCompBase {
281281
this.dispatch(customAction<ModuleReadyAction>({ type: "moduleReady", comp }));
282282
});
283283

284-
return setFieldsNoTypeCheck(this, { moduleRootComp, moduleDsl });
284+
return setFieldsNoTypeCheck(this, { moduleDsl });
285285
}
286286

287287
// module ready
288288
if (isMyCustomAction<ModuleReadyAction>(action, "moduleReady")) {
289-
if (!this.moduleRootComp) {
289+
const moduleRootComp = action.value.comp;
290+
if (!moduleRootComp) {
290291
return this;
291292
}
292293

293294
let updateFields: Record<string, any> = {
294295
isReady: true,
295-
moduleRootComp: action.value.comp,
296+
moduleRootComp,
296297
};
297298

298-
const moduleLayoutComp = this.moduleRootComp.children.ui.getModuleLayoutComp();
299+
const moduleLayoutComp = moduleRootComp.children.ui.getModuleLayoutComp();
299300
if (moduleLayoutComp) {
300301
const inputs = moduleLayoutComp.getInputs().map((i) => i.getView());
301302
const inputChild = this.children.inputs.setInputs(inputs);

client/packages/openblocks/src/comps/comps/tableComp/column/tableColumnComp.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { genRandomKey } from "comps/utils/idGenerator";
66
import { trans } from "i18n";
77
import _ from "lodash";
88
import {
9-
changeChildAction,
109
changeValueAction,
1110
ConstructorToComp,
1211
ConstructorToDataType,
@@ -16,7 +15,6 @@ import {
1615
fromRecord,
1716
multiChangeAction,
1817
withFunction,
19-
wrapChildAction,
2018
} from "openblocks-core";
2119
import { AlignClose, AlignLeft, AlignRight } from "openblocks-design";
2220
import { ColumnTypeComp, ColumnTypeCompMap } from "./columnTypeComp";

client/packages/openblocks/src/comps/comps/tableComp/tableComp.tsx

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ import { UICompBuilder, withPropertyViewFn, withViewFn } from "comps/generators"
1414
import { childrenToProps } from "comps/generators/multi";
1515
import { HidableView } from "comps/generators/uiCompBuilder";
1616
import { withDispatchHook } from "comps/generators/withDispatchHook";
17-
import { DepsConfig, NameConfig, withExposingConfigs } from "comps/generators/withExposing";
17+
import {
18+
depsConfig,
19+
DepsConfig,
20+
NameConfig,
21+
withExposingConfigs,
22+
} from "comps/generators/withExposing";
1823
import { withMethodExposing } from "comps/generators/withMethodExposing";
1924
import { trans } from "i18n";
2025
import _ from "lodash";
@@ -454,29 +459,27 @@ export const TableComp = withExposingConfigs(TableTmpComp, [
454459
},
455460
trans("table.selectedRowsDesc")
456461
),
457-
new DepsConfig(
458-
"changeSet",
459-
(children) => {
460-
return { columns: children.columns.exposingNode() };
461-
},
462-
(input) => {
462+
depsConfig({
463+
name: "changeSet",
464+
desc: trans("table.changeSetDesc"),
465+
depKeys: ["columns"],
466+
func: (input) => {
463467
const record: Record<string, Record<string, JSONValue>> = {};
464468
Object.values(input.columns).forEach((column: any) => {
465469
const dataIndex: string = column.dataIndex;
466470
// const title: string = column.title;
467471
const render = column.render; // {comp, map: [0].comp.changeValue, length}
468472
_.forEach(render.map, (value, key) => {
469473
const changeValue = value.comp?.changeValue;
470-
if (changeValue) {
474+
if (!_.isNil(changeValue)) {
471475
if (!record[key]) record[key] = {};
472476
record[key][dataIndex] = changeValue;
473477
}
474478
});
475479
});
476480
return record;
477481
},
478-
trans("table.changeSetDesc")
479-
),
482+
}),
480483
new DepsConfig(
481484
"pageNo",
482485
(children) => {
@@ -517,7 +520,7 @@ export const TableComp = withExposingConfigs(TableTmpComp, [
517520
},
518521
(input) => {
519522
const sortIndex = input.sort[0]?.column;
520-
const column = Object.values(input.columns).find(
523+
const column = Object.values(input.columns as any).find(
521524
(c: any) => c.dataIndex === sortIndex
522525
) as any;
523526
if (column?.isCustom && column?.title.value) {
@@ -528,18 +531,14 @@ export const TableComp = withExposingConfigs(TableTmpComp, [
528531
},
529532
trans("table.sortColumnDesc")
530533
),
531-
new DepsConfig(
532-
"sortDesc",
533-
(children) => {
534-
return {
535-
sort: children.sort.node(),
536-
};
537-
},
538-
(input) => {
534+
depsConfig({
535+
name: "sortDesc",
536+
desc: trans("table.sortDesc"),
537+
depKeys: ["sort"],
538+
func: (input) => {
539539
return input.sort[0]?.desc || false;
540540
},
541-
trans("table.sortDesc")
542-
),
541+
}),
543542
new DepsConfig(
544543
"pageOffset",
545544
(children) => {
@@ -579,7 +578,7 @@ export const TableComp = withExposingConfigs(TableTmpComp, [
579578
return getDisplayData(
580579
input.data,
581580
input.pagination,
582-
input.columns,
581+
input.columns as any,
583582
input.toolbar.filter,
584583
input.sort,
585584
input.toolbar.searchText.value,
@@ -593,11 +592,11 @@ export const TableComp = withExposingConfigs(TableTmpComp, [
593592
"filter",
594593
(children) => {
595594
return {
596-
toolbar: children.toolbar.node(),
595+
filter: children.toolbar.children.filter.node(),
597596
};
598597
},
599598
(input) => {
600-
return input.toolbar.filter;
599+
return input.filter;
601600
},
602601
trans("table.filterDesc")
603602
),

client/packages/openblocks/src/comps/comps/temporaryStateComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class TemporaryStateListComp
198198
]
199199
)
200200
);
201-
editorState.setSelectedBottomRes(name, BottomResTypeEnum.TempState);
201+
editorState.setSelectedBottomRes(newStateName, BottomResTypeEnum.TempState);
202202
}
203203

204204
delete(name: string) {

client/packages/openblocks/src/comps/comps/transformerListComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class TransformerListComp extends TransformerListCompBase implements Bott
176176
]
177177
)
178178
);
179-
editorState.setSelectedBottomRes(name, BottomResTypeEnum.Transformer);
179+
editorState.setSelectedBottomRes(newCompName, BottomResTypeEnum.Transformer);
180180
}
181181

182182
delete(name: string) {

client/packages/openblocks/src/comps/generators/uiCompBuilder.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
ToNodeType,
1313
ViewFnTypeForComp,
1414
} from "./multi";
15-
import { ExposingConfig, withExposingConfigs } from "./withExposing";
15+
import { ChildrenToComp, ExposingConfig, withExposingConfigs } from "./withExposing";
1616
import {
1717
ExposeMethodCompConstructor,
1818
MethodConfigsType,
@@ -55,7 +55,7 @@ export class UICompBuilder<ChildrenCompMap extends Record<string, Comp<unknown>>
5555
private childrenMap: ToConstructor<ChildrenCompMap>;
5656
private viewFn: ViewFnTypeForComp<ViewReturn, NewChildren<ChildrenCompMap>>;
5757
private propertyViewFn: PropertyViewFnTypeForComp<NewChildren<ChildrenCompMap>> = () => null;
58-
private stateConfigs: ExposingConfig<ChildrenCompMap>[] = [];
58+
private stateConfigs: ExposingConfig<ChildrenToComp<ChildrenCompMap>>[] = [];
5959
private methodConfigs: MethodConfigsType<ExposeMethodCompConstructor<any>> = [];
6060

6161
/**
@@ -74,7 +74,7 @@ export class UICompBuilder<ChildrenCompMap extends Record<string, Comp<unknown>>
7474
return this;
7575
}
7676

77-
setExposeStateConfigs(configs: ExposingConfig<ChildrenCompMap>[]) {
77+
setExposeStateConfigs(configs: ExposingConfig<ChildrenToComp<ChildrenCompMap>>[]) {
7878
this.stateConfigs = configs;
7979
return this;
8080
}

0 commit comments

Comments
 (0)