@_tc/template-core 0.0.1-bate.41 → 0.0.1-bate.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -97,24 +97,28 @@ var watchFiles = async (callback) => {
97
97
  * 3. 移动内部的html 至 输出目录的根节点
98
98
  */
99
99
  function flattenHtmlPlugin(suffix = ".html") {
100
+ const suffixes = [...new Set(Array.isArray(suffix) ? suffix : [suffix])];
100
101
  return {
101
102
  name: "flatten-html",
102
103
  apply: "build",
103
104
  closeBundle() {
104
105
  const feDir = outDir();
105
106
  if (!(0, fs.existsSync)(feDir)) return;
106
- const htmlFiles = glob.sync("**/*.html", { cwd: feDir });
107
+ const htmlFiles = glob.sync("**/*.html", {
108
+ cwd: feDir,
109
+ dot: true
110
+ });
107
111
  for (const file of htmlFiles) {
108
112
  const src = path.default.join(feDir, file);
109
113
  let fileOName = path.default.basename(file, ".html");
110
114
  const entrySuffix = ".entry";
111
115
  if (fileOName.indexOf(entrySuffix) === -1) fileOName = fileOName + entrySuffix;
112
- const fileName = fileOName + suffix;
113
- const dest = path.default.join(feDir, fileName);
114
- if (src !== dest) {
115
- (0, fs.copyFileSync)(src, dest);
116
- (0, fs.unlinkSync)(src);
116
+ for (const currentSuffix of suffixes) {
117
+ const fileName = fileOName + currentSuffix;
118
+ const dest = path.default.join(feDir, fileName);
119
+ if (src !== dest) (0, fs.copyFileSync)(src, dest);
117
120
  }
121
+ if (!suffixes.some((currentSuffix) => src === path.default.join(feDir, fileOName + currentSuffix))) (0, fs.unlinkSync)(src);
118
122
  }
119
123
  const parents = [...new Set(htmlFiles.map((f) => path.default.dirname(f)))].sort().reverse();
120
124
  /**
@@ -132,7 +136,10 @@ function flattenHtmlPlugin(suffix = ".html") {
132
136
  /**
133
137
  * ------------------
134
138
  */
135
- const endFiles = glob.sync("**/*" + suffix, { cwd: feDir });
139
+ const endFiles = suffixes.flatMap((currentSuffix) => glob.sync("**/*" + currentSuffix, {
140
+ cwd: feDir,
141
+ dot: true
142
+ }));
136
143
  for (const f of endFiles) require_packages_common_log_index.logYellow("final file path -----> " + f);
137
144
  }
138
145
  };
@@ -164,7 +171,7 @@ var VBuildFE = async (input, OperatingEnv) => {
164
171
  base: "/dist",
165
172
  plugins: [
166
173
  (await import("@vitejs/plugin-react")).default(),
167
- flattenHtmlPlugin(".tpl"),
174
+ flattenHtmlPlugin([".tpl", ".html"]),
168
175
  (0, _tailwindcss_vite.default)()
169
176
  ],
170
177
  build: {
@@ -92,24 +92,28 @@ var watchFiles = async (callback) => {
92
92
  * 3. 移动内部的html 至 输出目录的根节点
93
93
  */
94
94
  function flattenHtmlPlugin(suffix = ".html") {
95
+ const suffixes = [...new Set(Array.isArray(suffix) ? suffix : [suffix])];
95
96
  return {
96
97
  name: "flatten-html",
97
98
  apply: "build",
98
99
  closeBundle() {
99
100
  const feDir = outDir();
100
101
  if (!existsSync(feDir)) return;
101
- const htmlFiles = glob.sync("**/*.html", { cwd: feDir });
102
+ const htmlFiles = glob.sync("**/*.html", {
103
+ cwd: feDir,
104
+ dot: true
105
+ });
102
106
  for (const file of htmlFiles) {
103
107
  const src = path.join(feDir, file);
104
108
  let fileOName = path.basename(file, ".html");
105
109
  const entrySuffix = ".entry";
106
110
  if (fileOName.indexOf(entrySuffix) === -1) fileOName = fileOName + entrySuffix;
107
- const fileName = fileOName + suffix;
108
- const dest = path.join(feDir, fileName);
109
- if (src !== dest) {
110
- copyFileSync(src, dest);
111
- unlinkSync(src);
111
+ for (const currentSuffix of suffixes) {
112
+ const fileName = fileOName + currentSuffix;
113
+ const dest = path.join(feDir, fileName);
114
+ if (src !== dest) copyFileSync(src, dest);
112
115
  }
116
+ if (!suffixes.some((currentSuffix) => src === path.join(feDir, fileOName + currentSuffix))) unlinkSync(src);
113
117
  }
114
118
  const parents = [...new Set(htmlFiles.map((f) => path.dirname(f)))].sort().reverse();
115
119
  /**
@@ -127,7 +131,10 @@ function flattenHtmlPlugin(suffix = ".html") {
127
131
  /**
128
132
  * ------------------
129
133
  */
130
- const endFiles = glob.sync("**/*" + suffix, { cwd: feDir });
134
+ const endFiles = suffixes.flatMap((currentSuffix) => glob.sync("**/*" + currentSuffix, {
135
+ cwd: feDir,
136
+ dot: true
137
+ }));
131
138
  for (const f of endFiles) logYellow("final file path -----> " + f);
132
139
  }
133
140
  };
@@ -159,7 +166,7 @@ var VBuildFE = async (input, OperatingEnv) => {
159
166
  base: "/dist",
160
167
  plugins: [
161
168
  (await import("@vitejs/plugin-react")).default(),
162
- flattenHtmlPlugin(".tpl"),
169
+ flattenHtmlPlugin([".tpl", ".html"]),
163
170
  tailwindcss()
164
171
  ],
165
172
  build: {
@@ -15,7 +15,7 @@ const generateSchemas = (schema) => {
15
15
  return [];
16
16
  return Object.keys(schema.properties).reduce((schemas, key) => {
17
17
  const fieldInfo = schema.properties[key];
18
- const option = fieldInfo.option;
18
+ const option = fieldInfo?.option;
19
19
  if (!option || option.visible === false)
20
20
  return schemas;
21
21
  const { comType = 'input', default: _defaultValue, visible: _visible, ...fieldProps } = option;
@@ -49,7 +49,7 @@ const generateDefaultValue = (schema, data) => {
49
49
  if (!schema?.properties)
50
50
  return defaultValue;
51
51
  Object.keys(schema.properties).forEach((key) => {
52
- const defaultFieldValue = schema.properties[key].option?.default;
52
+ const defaultFieldValue = schema.properties[key]?.option?.default;
53
53
  if (typeof defaultFieldValue !== 'undefined' && typeof defaultValue[key] === 'undefined') {
54
54
  defaultValue[key] = defaultFieldValue;
55
55
  }
@@ -1,4 +1,4 @@
1
- import { FormItemProps, InputNumberProps, InputProps, SelectProps } from '../../../packages/ui/react';
1
+ import type { FormFieldType, FormItemProps, SchemaFormAllPropsMap } from '../../../packages/ui/react';
2
2
  import { FetchInfo } from './fetchInfo';
3
3
  export type ComponentConfig = {
4
4
  createForm?: {
@@ -47,15 +47,9 @@ export type ComponentsOption = {
47
47
  editForm: ComponentsOption['createForm'];
48
48
  detailPanel: {};
49
49
  };
50
- export type ComponentOption = InputOption | SelectOption | InputNumberOption;
51
- type InputOption = {
52
- comType: 'input';
53
- } & InputProps;
54
- type InputNumberOption = {
55
- comType: 'inputNumber';
56
- } & InputNumberProps;
57
- type SelectOption = {
58
- comType: 'select';
59
- } & SelectProps;
60
- export {};
50
+ export type ComponentOption = {
51
+ [K in FormFieldType]: {
52
+ comType: K;
53
+ } & (K extends keyof SchemaFormAllPropsMap ? SchemaFormAllPropsMap[K] : unknown);
54
+ }[FormFieldType];
61
55
  //# sourceMappingURL=component.d.ts.map
@@ -1,4 +1,4 @@
1
- import { FormItemProps, InputNumberProps, InputProps, SelectProps } from '../../../fe/packages/ui/react';
1
+ import type { FormFieldType, FormItemProps, SchemaFormAllPropsMap } from '../../../fe/packages/ui/react';
2
2
  import { FetchInfo } from './fetchInfo';
3
3
  export type ComponentConfig = {
4
4
  createForm?: {
@@ -47,15 +47,9 @@ export type ComponentsOption = {
47
47
  editForm: ComponentsOption['createForm'];
48
48
  detailPanel: {};
49
49
  };
50
- export type ComponentOption = InputOption | SelectOption | InputNumberOption;
51
- type InputOption = {
52
- comType: 'input';
53
- } & InputProps;
54
- type InputNumberOption = {
55
- comType: 'inputNumber';
56
- } & InputNumberProps;
57
- type SelectOption = {
58
- comType: 'select';
59
- } & SelectProps;
60
- export {};
50
+ export type ComponentOption = {
51
+ [K in FormFieldType]: {
52
+ comType: K;
53
+ } & (K extends keyof SchemaFormAllPropsMap ? SchemaFormAllPropsMap[K] : unknown);
54
+ }[FormFieldType];
61
55
  //# sourceMappingURL=component.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@_tc/template-core",
3
- "version": "0.0.1-bate.41",
3
+ "version": "0.0.1-bate.43",
4
4
  "description": "A TypeScript Koa framework template - Monorepo root",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",