@lowdefy/build 0.0.0-experimental-20251203145918 → 0.0.0-experimental-20251203183323

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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* eslint-disable no-console */ /*
1
+ /*
2
2
  Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,7 +12,8 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import createContext from './createContext.js';
15
+ */ import createBuildProfiler from './utils/createBuildProfiler.js';
16
+ import createContext from './createContext.js';
16
17
  import createPluginTypesMap from './utils/createPluginTypesMap.js';
17
18
  import addDefaultPages from './build/addDefaultPages/addDefaultPages.js';
18
19
  import addKeys from './build/addKeys.js';
@@ -46,125 +47,128 @@ import writeRequests from './build/writeRequests.js';
46
47
  import writeTypes from './build/writeTypes.js';
47
48
  async function build(options) {
48
49
  const context = createContext(options);
49
- const components = await buildRefs({
50
- context
51
- });
52
- testSchema({
53
- components,
54
- context
55
- });
56
- buildApp({
57
- components,
58
- context
59
- });
60
- validateConfig({
61
- components,
62
- context
63
- });
64
- addDefaultPages({
65
- components,
66
- context
67
- });
68
- buildAuth({
69
- components,
70
- context
71
- });
72
- buildConnections({
73
- components,
74
- context
75
- });
76
- buildApi({
77
- components,
78
- context
79
- });
80
- buildPages({
81
- components,
82
- context
83
- });
84
- buildMenu({
85
- components,
86
- context
87
- });
88
- buildJs({
89
- components,
90
- context
91
- });
92
- addKeys({
93
- components,
94
- context
95
- });
96
- buildTypes({
97
- components,
98
- context
99
- });
100
- buildImports({
101
- components,
102
- context
103
- });
104
- await cleanBuildDirectory({
105
- context
106
- });
107
- await writeApp({
108
- components,
109
- context
110
- });
111
- await writeAuth({
112
- components,
113
- context
114
- });
115
- await writeConnections({
116
- components,
117
- context
118
- });
119
- await writeApi({
120
- components,
121
- context
122
- });
123
- await writeRequests({
124
- components,
125
- context
126
- });
127
- console.log('components.pages', components.pages.map((page)=>page.id));
128
- await writeMaps({
129
- components,
130
- context
131
- });
132
- await writePages({
133
- components,
134
- context
135
- });
136
- await writeConfig({
137
- components,
138
- context
139
- });
140
- await writeGlobal({
141
- components,
142
- context
143
- });
144
- await writeMenus({
145
- components,
146
- context
147
- });
148
- await writeTypes({
149
- components,
150
- context
151
- });
152
- await writePluginImports({
153
- components,
154
- context
155
- });
156
- await writeJs({
157
- components,
158
- context
159
- });
160
- await updateServerPackageJson({
161
- components,
162
- context
163
- });
164
- await copyPublicFolder({
165
- components,
166
- context
167
- });
50
+ const { time, printSummary } = createBuildProfiler({
51
+ logger: context.logger
52
+ });
53
+ const components = await time('buildRefs', ()=>buildRefs({
54
+ context
55
+ }));
56
+ await time('testSchema', ()=>testSchema({
57
+ components,
58
+ context
59
+ }));
60
+ await time('buildApp', ()=>buildApp({
61
+ components,
62
+ context
63
+ }));
64
+ await time('validateConfig', ()=>validateConfig({
65
+ components,
66
+ context
67
+ }));
68
+ await time('addDefaultPages', ()=>addDefaultPages({
69
+ components,
70
+ context
71
+ }));
72
+ await time('buildAuth', ()=>buildAuth({
73
+ components,
74
+ context
75
+ }));
76
+ await time('buildConnections', ()=>buildConnections({
77
+ components,
78
+ context
79
+ }));
80
+ await time('buildApi', ()=>buildApi({
81
+ components,
82
+ context
83
+ }));
84
+ await time('buildPages', ()=>buildPages({
85
+ components,
86
+ context
87
+ }));
88
+ await time('buildMenu', ()=>buildMenu({
89
+ components,
90
+ context
91
+ }));
92
+ await time('buildJs', ()=>buildJs({
93
+ components,
94
+ context
95
+ }));
96
+ await time('addKeys', ()=>addKeys({
97
+ components,
98
+ context
99
+ }));
100
+ await time('buildTypes', ()=>buildTypes({
101
+ components,
102
+ context
103
+ }));
104
+ await time('buildImports', ()=>buildImports({
105
+ components,
106
+ context
107
+ }));
108
+ await time('cleanBuildDirectory', ()=>cleanBuildDirectory({
109
+ context
110
+ }));
111
+ await time('writeApp', ()=>writeApp({
112
+ components,
113
+ context
114
+ }));
115
+ await time('writeAuth', ()=>writeAuth({
116
+ components,
117
+ context
118
+ }));
119
+ await time('writeConnections', ()=>writeConnections({
120
+ components,
121
+ context
122
+ }));
123
+ await time('writeApi', ()=>writeApi({
124
+ components,
125
+ context
126
+ }));
127
+ await time('writeRequests', ()=>writeRequests({
128
+ components,
129
+ context
130
+ }));
131
+ await time('writePages', ()=>writePages({
132
+ components,
133
+ context
134
+ }));
135
+ await time('writeConfig', ()=>writeConfig({
136
+ components,
137
+ context
138
+ }));
139
+ await time('writeGlobal', ()=>writeGlobal({
140
+ components,
141
+ context
142
+ }));
143
+ await time('writeMaps', ()=>writeMaps({
144
+ components,
145
+ context
146
+ }));
147
+ await time('writeMenus', ()=>writeMenus({
148
+ components,
149
+ context
150
+ }));
151
+ await time('writeTypes', ()=>writeTypes({
152
+ components,
153
+ context
154
+ }));
155
+ await time('writePluginImports', ()=>writePluginImports({
156
+ components,
157
+ context
158
+ }));
159
+ await time('writeJs', ()=>writeJs({
160
+ components,
161
+ context
162
+ }));
163
+ await time('updateServerPackageJson', ()=>updateServerPackageJson({
164
+ components,
165
+ context
166
+ }));
167
+ await time('copyPublicFolder', ()=>copyPublicFolder({
168
+ components,
169
+ context
170
+ }));
171
+ printSummary();
168
172
  }
169
173
  export { createPluginTypesMap };
170
174
  export default build;
@@ -0,0 +1,125 @@
1
+ /*
2
+ Copyright 2020-2024 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ function createBuildProfiler({ logger, prefix = '' }) {
16
+ const timings = new Map();
17
+ const isDebug = logger?.level === 'debug';
18
+ const track = (name)=>{
19
+ if (!isDebug) {
20
+ return;
21
+ }
22
+ if (!timings.has(name)) {
23
+ timings.set(name, {
24
+ total: 0,
25
+ count: 0,
26
+ min: Infinity,
27
+ max: 0
28
+ });
29
+ }
30
+ };
31
+ const time = async (name, fn)=>{
32
+ if (!isDebug) {
33
+ return fn();
34
+ }
35
+ track(name);
36
+ const start = performance.now();
37
+ const result = await fn();
38
+ const duration = performance.now() - start;
39
+ const entry = timings.get(name);
40
+ entry.total += duration;
41
+ entry.count += 1;
42
+ entry.min = Math.min(entry.min, duration);
43
+ entry.max = Math.max(entry.max, duration);
44
+ return result;
45
+ };
46
+ const timeSync = (name, fn)=>{
47
+ if (!isDebug) {
48
+ return fn();
49
+ }
50
+ track(name);
51
+ const start = performance.now();
52
+ const result = fn();
53
+ const duration = performance.now() - start;
54
+ const entry = timings.get(name);
55
+ entry.total += duration;
56
+ entry.count += 1;
57
+ entry.min = Math.min(entry.min, duration);
58
+ entry.max = Math.max(entry.max, duration);
59
+ return result;
60
+ };
61
+ const getTimings = ()=>{
62
+ const result = [];
63
+ timings.forEach((value, name)=>{
64
+ result.push({
65
+ name,
66
+ ...value,
67
+ avg: value.total / value.count
68
+ });
69
+ });
70
+ return result;
71
+ };
72
+ const printSummary = ()=>{
73
+ if (!isDebug || timings.size === 0) {
74
+ return;
75
+ }
76
+ const entries = getTimings();
77
+ const total = entries.reduce((sum, t)=>sum + t.total, 0);
78
+ const displayPrefix = prefix ? `[${prefix}] ` : '';
79
+ logger.debug('');
80
+ logger.debug(`⏱️ ${displayPrefix}Build Performance Summary:`);
81
+ logger.debug('─'.repeat(90));
82
+ const header = [
83
+ 'Step'.padEnd(30),
84
+ 'Total'.padStart(10),
85
+ '%'.padStart(6),
86
+ 'Count'.padStart(7),
87
+ 'Avg'.padStart(10),
88
+ 'Min'.padStart(10),
89
+ 'Max'.padStart(10)
90
+ ].join(' ');
91
+ logger.debug(header);
92
+ logger.debug('─'.repeat(90));
93
+ entries.sort((a, b)=>b.total - a.total).forEach(({ name, total: stepTotal, count, avg, min, max })=>{
94
+ const pct = (stepTotal / total * 100).toFixed(1);
95
+ const displayName = name.length > 28 ? `${name.slice(0, 25)}...` : name;
96
+ const row = [
97
+ displayName.padEnd(30),
98
+ `${stepTotal.toFixed(2).padStart(8)}ms`,
99
+ `${pct.padStart(6)}%`,
100
+ String(count).padStart(7),
101
+ `${avg.toFixed(2).padStart(8)}ms`,
102
+ `${min.toFixed(2).padStart(8)}ms`,
103
+ `${max.toFixed(2).padStart(8)}ms`
104
+ ].join(' ');
105
+ logger.debug(row);
106
+ });
107
+ logger.debug('─'.repeat(90));
108
+ logger.debug(`${'TOTAL'.padEnd(30)} ${total.toFixed(2).padStart(8)}ms`);
109
+ };
110
+ const createSubProfiler = (subPrefix)=>{
111
+ return createBuildProfiler({
112
+ logger,
113
+ prefix: prefix ? `${prefix}::${subPrefix}` : subPrefix
114
+ });
115
+ };
116
+ return {
117
+ time,
118
+ timeSync,
119
+ getTimings,
120
+ printSummary,
121
+ createSubProfiler,
122
+ isDebug
123
+ };
124
+ }
125
+ export default createBuildProfiler;
@@ -17,7 +17,6 @@ function createCheckDuplicateId({ message }) {
17
17
  const template = nunjucksFunction(message);
18
18
  const ids = new Set();
19
19
  function checkDuplicateId({ id, blockId, eventId, menuId, pageId }) {
20
- console.log('checkDuplicateId', ids.has(id.toLowerCase()), id, id.toLowerCase());
21
20
  if (ids.has(id.toLowerCase())) throw new Error(template({
22
21
  id,
23
22
  blockId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/build",
3
- "version": "0.0.0-experimental-20251203145918",
3
+ "version": "0.0.0-experimental-20251203183323",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -44,14 +44,14 @@
44
44
  "dist/*"
45
45
  ],
46
46
  "dependencies": {
47
- "@lowdefy/ajv": "0.0.0-experimental-20251203145918",
48
- "@lowdefy/blocks-basic": "0.0.0-experimental-20251203145918",
49
- "@lowdefy/blocks-loaders": "0.0.0-experimental-20251203145918",
50
- "@lowdefy/helpers": "0.0.0-experimental-20251203145918",
51
- "@lowdefy/node-utils": "0.0.0-experimental-20251203145918",
52
- "@lowdefy/nunjucks": "0.0.0-experimental-20251203145918",
53
- "@lowdefy/operators": "0.0.0-experimental-20251203145918",
54
- "@lowdefy/operators-js": "0.0.0-experimental-20251203145918",
47
+ "@lowdefy/ajv": "0.0.0-experimental-20251203183323",
48
+ "@lowdefy/blocks-basic": "0.0.0-experimental-20251203183323",
49
+ "@lowdefy/blocks-loaders": "0.0.0-experimental-20251203183323",
50
+ "@lowdefy/helpers": "0.0.0-experimental-20251203183323",
51
+ "@lowdefy/node-utils": "0.0.0-experimental-20251203183323",
52
+ "@lowdefy/nunjucks": "0.0.0-experimental-20251203183323",
53
+ "@lowdefy/operators": "0.0.0-experimental-20251203183323",
54
+ "@lowdefy/operators-js": "0.0.0-experimental-20251203183323",
55
55
  "ajv": "8.12.0",
56
56
  "json5": "2.2.3",
57
57
  "yaml": "2.3.4",
@@ -59,35 +59,35 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@jest/globals": "28.1.3",
62
- "@lowdefy/actions-core": "0.0.0-experimental-20251203145918",
63
- "@lowdefy/actions-pdf-make": "0.0.0-experimental-20251203145918",
64
- "@lowdefy/blocks-aggrid": "0.0.0-experimental-20251203145918",
65
- "@lowdefy/blocks-algolia": "0.0.0-experimental-20251203145918",
66
- "@lowdefy/blocks-antd": "0.0.0-experimental-20251203145918",
67
- "@lowdefy/blocks-color-selectors": "0.0.0-experimental-20251203145918",
68
- "@lowdefy/blocks-echarts": "0.0.0-experimental-20251203145918",
69
- "@lowdefy/blocks-google-maps": "0.0.0-experimental-20251203145918",
70
- "@lowdefy/blocks-markdown": "0.0.0-experimental-20251203145918",
71
- "@lowdefy/blocks-qr": "0.0.0-experimental-20251203145918",
72
- "@lowdefy/connection-axios-http": "0.0.0-experimental-20251203145918",
73
- "@lowdefy/connection-elasticsearch": "0.0.0-experimental-20251203145918",
74
- "@lowdefy/connection-google-sheets": "0.0.0-experimental-20251203145918",
75
- "@lowdefy/connection-knex": "0.0.0-experimental-20251203145918",
76
- "@lowdefy/connection-mongodb": "0.0.0-experimental-20251203145918",
77
- "@lowdefy/connection-redis": "0.0.0-experimental-20251203145918",
78
- "@lowdefy/connection-sendgrid": "0.0.0-experimental-20251203145918",
79
- "@lowdefy/connection-stripe": "0.0.0-experimental-20251203145918",
80
- "@lowdefy/operators-change-case": "0.0.0-experimental-20251203145918",
81
- "@lowdefy/operators-diff": "0.0.0-experimental-20251203145918",
82
- "@lowdefy/operators-moment": "0.0.0-experimental-20251203145918",
83
- "@lowdefy/operators-mql": "0.0.0-experimental-20251203145918",
84
- "@lowdefy/operators-nunjucks": "0.0.0-experimental-20251203145918",
85
- "@lowdefy/operators-uuid": "0.0.0-experimental-20251203145918",
86
- "@lowdefy/operators-yaml": "0.0.0-experimental-20251203145918",
87
- "@lowdefy/plugin-auth0": "0.0.0-experimental-20251203145918",
88
- "@lowdefy/plugin-aws": "0.0.0-experimental-20251203145918",
89
- "@lowdefy/plugin-csv": "0.0.0-experimental-20251203145918",
90
- "@lowdefy/plugin-next-auth": "0.0.0-experimental-20251203145918",
62
+ "@lowdefy/actions-core": "0.0.0-experimental-20251203183323",
63
+ "@lowdefy/actions-pdf-make": "0.0.0-experimental-20251203183323",
64
+ "@lowdefy/blocks-aggrid": "0.0.0-experimental-20251203183323",
65
+ "@lowdefy/blocks-algolia": "0.0.0-experimental-20251203183323",
66
+ "@lowdefy/blocks-antd": "0.0.0-experimental-20251203183323",
67
+ "@lowdefy/blocks-color-selectors": "0.0.0-experimental-20251203183323",
68
+ "@lowdefy/blocks-echarts": "0.0.0-experimental-20251203183323",
69
+ "@lowdefy/blocks-google-maps": "0.0.0-experimental-20251203183323",
70
+ "@lowdefy/blocks-markdown": "0.0.0-experimental-20251203183323",
71
+ "@lowdefy/blocks-qr": "0.0.0-experimental-20251203183323",
72
+ "@lowdefy/connection-axios-http": "0.0.0-experimental-20251203183323",
73
+ "@lowdefy/connection-elasticsearch": "0.0.0-experimental-20251203183323",
74
+ "@lowdefy/connection-google-sheets": "0.0.0-experimental-20251203183323",
75
+ "@lowdefy/connection-knex": "0.0.0-experimental-20251203183323",
76
+ "@lowdefy/connection-mongodb": "0.0.0-experimental-20251203183323",
77
+ "@lowdefy/connection-redis": "0.0.0-experimental-20251203183323",
78
+ "@lowdefy/connection-sendgrid": "0.0.0-experimental-20251203183323",
79
+ "@lowdefy/connection-stripe": "0.0.0-experimental-20251203183323",
80
+ "@lowdefy/operators-change-case": "0.0.0-experimental-20251203183323",
81
+ "@lowdefy/operators-diff": "0.0.0-experimental-20251203183323",
82
+ "@lowdefy/operators-moment": "0.0.0-experimental-20251203183323",
83
+ "@lowdefy/operators-mql": "0.0.0-experimental-20251203183323",
84
+ "@lowdefy/operators-nunjucks": "0.0.0-experimental-20251203183323",
85
+ "@lowdefy/operators-uuid": "0.0.0-experimental-20251203183323",
86
+ "@lowdefy/operators-yaml": "0.0.0-experimental-20251203183323",
87
+ "@lowdefy/plugin-auth0": "0.0.0-experimental-20251203183323",
88
+ "@lowdefy/plugin-aws": "0.0.0-experimental-20251203183323",
89
+ "@lowdefy/plugin-csv": "0.0.0-experimental-20251203183323",
90
+ "@lowdefy/plugin-next-auth": "0.0.0-experimental-20251203183323",
91
91
  "@swc/cli": "0.1.63",
92
92
  "@swc/core": "1.3.99",
93
93
  "@swc/jest": "0.2.29",