@lowdefy/build 4.0.0-alpha.1 → 4.0.0-alpha.4

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.
@@ -0,0 +1,63 @@
1
+ /*
2
+ Copyright 2020-2021 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
+ */ const iconPackages = {
16
+ 'react-icons/ai': /"(Ai[A-Z0-9]\w*)"/gm,
17
+ 'react-icons/bs': /"(Bs[A-Z0-9]\w*)"/gm,
18
+ 'react-icons/bi': /"(Bi[A-Z0-9]\w*)"/gm,
19
+ 'react-icons/di': /"(Di[A-Z0-9]\w*)"/gm,
20
+ 'react-icons/fi': /"(Fi[A-Z0-9]\w*)"/gm,
21
+ 'react-icons/fc': /"(Fc[A-Z0-9]\w*)"/gm,
22
+ 'react-icons/fa': /"(Fa[A-Z0-9]\w*)"/gm,
23
+ 'react-icons/gi': /"(Gi[A-Z0-9]\w*)"/gm,
24
+ 'react-icons/go': /"(Go[A-Z0-9]\w*)"/gm,
25
+ 'react-icons/gr': /"(Gr[A-Z0-9]\w*)"/gm,
26
+ 'react-icons/hi': /"(Hi[A-Z0-9]\w*)"/gm,
27
+ 'react-icons/im': /"(Im[A-Z0-9]\w*)"/gm,
28
+ 'react-icons/io': /"(IoIos[A-Z0-9]\w*)"/gm,
29
+ 'react-icons/io5': /"(Io[A-Z0-9]\w*)"/gm,
30
+ 'react-icons/md': /"(Md[A-Z0-9]\w*)"/gm,
31
+ 'react-icons/ri': /"(Ri[A-Z0-9]\w*)"/gm,
32
+ 'react-icons/si': /"(Si[A-Z0-9]\w*)"/gm,
33
+ 'react-icons/ti': /"(Ti[A-Z0-9]\w*)"/gm,
34
+ 'react-icons/vsc': /"(Vsc[A-Z0-9]\w*)"/gm,
35
+ 'react-icons/wi': /"(Wi[A-Z0-9]\w*)"/gm,
36
+ 'react-icons/cg': /"(Cg[A-Z0-9]\w*)"/gm
37
+ };
38
+ function buildIcons({ components }) {
39
+ components.icons = [];
40
+ Object.entries(iconPackages).forEach(([iconPackage, regex])=>{
41
+ const icons = new Set();
42
+ [
43
+ ...JSON.stringify(components.global || {
44
+ }).matchAll(regex)
45
+ ].map((match)=>icons.add(match[1])
46
+ );
47
+ [
48
+ ...JSON.stringify(components.menus || []).matchAll(regex)
49
+ ].map((match)=>icons.add(match[1])
50
+ );
51
+ [
52
+ ...JSON.stringify(components.pages || []).matchAll(regex)
53
+ ].map((match)=>icons.add(match[1])
54
+ );
55
+ components.icons.push({
56
+ icons: [
57
+ ...icons
58
+ ],
59
+ package: iconPackage
60
+ });
61
+ });
62
+ }
63
+ export default buildIcons;
@@ -0,0 +1,29 @@
1
+ /*
2
+ Copyright 2020-2021 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 buildStyles({ components , context }) {
16
+ components.styles = [];
17
+ const styles = new Set();
18
+ Object.entries(components.types.blocks).forEach(([blockName, block])=>{
19
+ styles.add(...(context.types.styles[block.package].default || []).map((style)=>`${block.package}/${style}`
20
+ ));
21
+ styles.add(...(context.types.styles[block.package][blockName] || []).map((style)=>`${block.package}/${style}`
22
+ ));
23
+ });
24
+ components.styles = [
25
+ ...styles
26
+ ].filter((style)=>!!style
27
+ );
28
+ }
29
+ export default buildStyles;
@@ -67,24 +67,17 @@ function buildTypes({ components , context }) {
67
67
  store: components.types.requests,
68
68
  typeClass: 'Request'
69
69
  });
70
- // buildTypeClass({
71
- // counter: typeCounters.operators.client,
72
- // definitions: context.types.operators.client,
73
- // store: components.types.operators.client,
74
- // typeClass: 'Operator',
75
- // });
76
- // buildTypeClass({
77
- // counter: typeCounters.operators.server,
78
- // definitions: context.types.operators.server,
79
- // store: components.types.operators.server,
80
- // typeClass: 'Operator',
81
- // });
82
- // TODO: Handle styles
83
- const blocksPackages = new Set();
84
- Object.values(components.types.blocks).forEach((typeDef)=>{
85
- blocksPackages.add(typeDef.package);
86
- });
87
- components.styles = context.types.styles.filter((style)=>blocksPackages.has(style.package)
88
- );
70
+ // buildTypeClass({
71
+ // counter: typeCounters.operators.client,
72
+ // definitions: context.types.operators.client,
73
+ // store: components.types.operators.client,
74
+ // typeClass: 'Operator',
75
+ // });
76
+ // buildTypeClass({
77
+ // counter: typeCounters.operators.server,
78
+ // definitions: context.types.operators.server,
79
+ // store: components.types.operators.server,
80
+ // typeClass: 'Operator',
81
+ // });
89
82
  }
90
83
  export default buildTypes;
@@ -17,7 +17,7 @@ const template = `{%- for block in blocks -%}
17
17
  import { {{ block.type }} } from '{{ block.package }}/blocks';
18
18
  {% endfor -%}
19
19
  export default {
20
- {%- for block in blocks -%}
20
+ {% for block in blocks -%}
21
21
  {{ block.type }},
22
22
  {% endfor -%}
23
23
  };
@@ -17,7 +17,7 @@ const template = `{%- for connection in connections -%}
17
17
  import { {{ connection.type }} } from '{{ connection.package }}/connections';
18
18
  {% endfor -%}
19
19
  export default {
20
- {%- for connection in connections -%}
20
+ {% for connection in connections -%}
21
21
  {{ connection.type }},
22
22
  {% endfor -%}
23
23
  };
@@ -0,0 +1,37 @@
1
+ /*
2
+ Copyright 2020-2021 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
+ */ import { nunjucksFunction } from '@lowdefy/nunjucks';
16
+ const template = `{%- for package in packages -%}
17
+ {%- for icon in package.icons -%}
18
+ import { {{ icon }} } from '{{ package.package }}';
19
+ {% endfor -%}
20
+ {% endfor -%}
21
+ export default {
22
+ {% for package in packages -%}
23
+ {%- for icon in package.icons -%}
24
+ {{ icon }},
25
+ {% endfor -%}{%- endfor -%}
26
+ };
27
+ `;
28
+ async function writeIconImports({ components , context }) {
29
+ const templateFn = nunjucksFunction(template);
30
+ await context.writeBuildArtifact({
31
+ filePath: 'plugins/icons.js',
32
+ content: templateFn({
33
+ packages: components.icons
34
+ })
35
+ });
36
+ }
37
+ export default writeIconImports;
@@ -0,0 +1,30 @@
1
+ /*
2
+ Copyright 2020-2021 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
+ */ import { nunjucksFunction } from '@lowdefy/nunjucks';
16
+ const template = `@import '@lowdefy/layout/style.less';
17
+ {% for style in styles -%}
18
+ @import '{{ style }}';
19
+ {% endfor -%}
20
+ `;
21
+ async function writeStyleImports({ components , context }) {
22
+ const templateFn = nunjucksFunction(template);
23
+ await context.writeBuildArtifact({
24
+ filePath: 'plugins/styles.less',
25
+ content: templateFn({
26
+ styles: components.styles
27
+ })
28
+ });
29
+ }
30
+ export default writeStyleImports;
@@ -3,58 +3,64 @@
3
3
  "blocks": {
4
4
  "Anchor": {
5
5
  "package": "@lowdefy/blocks-basic",
6
- "version": "4.0.0-alpha.1"
6
+ "version": "4.0.0-alpha.4"
7
7
  },
8
8
  "Box": {
9
9
  "package": "@lowdefy/blocks-basic",
10
- "version": "4.0.0-alpha.1"
10
+ "version": "4.0.0-alpha.4"
11
11
  },
12
12
  "DangerousHtml": {
13
13
  "package": "@lowdefy/blocks-basic",
14
- "version": "4.0.0-alpha.1"
14
+ "version": "4.0.0-alpha.4"
15
15
  },
16
16
  "Html": {
17
17
  "package": "@lowdefy/blocks-basic",
18
- "version": "4.0.0-alpha.1"
18
+ "version": "4.0.0-alpha.4"
19
19
  },
20
20
  "Icon": {
21
21
  "package": "@lowdefy/blocks-basic",
22
- "version": "4.0.0-alpha.1"
22
+ "version": "4.0.0-alpha.4"
23
23
  },
24
24
  "Img": {
25
25
  "package": "@lowdefy/blocks-basic",
26
- "version": "4.0.0-alpha.1"
26
+ "version": "4.0.0-alpha.4"
27
27
  },
28
28
  "List": {
29
29
  "package": "@lowdefy/blocks-basic",
30
- "version": "4.0.0-alpha.1"
30
+ "version": "4.0.0-alpha.4"
31
31
  },
32
32
  "Span": {
33
33
  "package": "@lowdefy/blocks-basic",
34
- "version": "4.0.0-alpha.1"
34
+ "version": "4.0.0-alpha.4"
35
35
  }
36
36
  },
37
37
  "connections": {
38
38
  "AxiosHttp": {
39
39
  "package": "@lowdefy/connection-axios-http",
40
- "version": "4.0.0-alpha.1"
40
+ "version": "4.0.0-alpha.4"
41
41
  }
42
42
  },
43
43
  "requests": {
44
44
  "AxiosHttp": {
45
45
  "package": "@lowdefy/connection-axios-http",
46
- "version": "4.0.0-alpha.1"
46
+ "version": "4.0.0-alpha.4"
47
47
  }
48
48
  },
49
49
  "operators": {
50
50
  "client": {},
51
51
  "server": {}
52
52
  },
53
- "styles": [
54
- {
55
- "path": "style.less",
56
- "package": "@lowdefy/blocks-basic",
57
- "version": "4.0.0-alpha.1"
53
+ "styles": {
54
+ "@lowdefy/blocks-basic": {
55
+ "default": [],
56
+ "Anchor": [],
57
+ "Box": [],
58
+ "DangerousHtml": [],
59
+ "Html": [],
60
+ "Icon": [],
61
+ "Img": [],
62
+ "List": [],
63
+ "Span": []
58
64
  }
59
- ]
65
+ }
60
66
  }
package/dist/index.js CHANGED
@@ -19,9 +19,11 @@ import createWriteBuildArtifact from './utils/files/writeBuildArtifact.js';
19
19
  import addDefaultPages from './build/addDefaultPages/addDefaultPages.js';
20
20
  import buildAuth from './build/buildAuth/buildAuth.js';
21
21
  import buildConnections from './build/buildConnections.js';
22
+ import buildIcons from './build/buildIcons.js';
22
23
  import buildMenu from './build/buildMenu.js';
23
24
  import buildPages from './build/buildPages/buildPages.js';
24
25
  import buildRefs from './build/buildRefs/buildRefs.js';
26
+ import buildStyles from './build/buildStyles.js';
25
27
  import buildTypes from './build/buildTypes.js';
26
28
  import cleanBuildDirectory from './build/cleanBuildDirectory.js';
27
29
  import testSchema from './build/testSchema.js';
@@ -29,13 +31,15 @@ import validateApp from './build/validateApp.js';
29
31
  import validateConfig from './build/validateConfig.js';
30
32
  import writeApp from './build/writeApp.js';
31
33
  import writeBlockImports from './build/writePluginImports/writeBlockImports.js';
32
- import writeConnectionImports from './build/writePluginImports/writeConnectionImports.js';
33
34
  import writeConfig from './build/writeConfig.js';
35
+ import writeConnectionImports from './build/writePluginImports/writeConnectionImports.js';
34
36
  import writeConnections from './build/writeConnections.js';
35
37
  import writeGlobal from './build/writeGlobal.js';
38
+ import writeIconImports from './build/writePluginImports/writeIconImports.js';
36
39
  import writeMenus from './build/writeMenus.js';
37
40
  import writePages from './build/writePages.js';
38
41
  import writeRequests from './build/writeRequests.js';
42
+ import writeStyleImports from './build/writePluginImports/writeStyleImports.js';
39
43
  import writeTypes from './build/writeTypes.js';
40
44
  async function createContext(options) {
41
45
  const { blocksServerUrl , buildDirectory , cacheDirectory , configDirectory , logger , refResolver } = options;
@@ -102,6 +106,9 @@ async function build(options) {
102
106
  components,
103
107
  context
104
108
  });
109
+ await buildIcons({
110
+ components
111
+ });
105
112
  await buildMenu({
106
113
  components,
107
114
  context
@@ -110,6 +117,10 @@ async function build(options) {
110
117
  components,
111
118
  context
112
119
  });
120
+ await buildStyles({
121
+ components,
122
+ context
123
+ });
113
124
  await cleanBuildDirectory({
114
125
  context
115
126
  });
@@ -153,8 +164,14 @@ async function build(options) {
153
164
  components,
154
165
  context
155
166
  });
156
- // TODO: write style file
157
- // TODO: write icons file
167
+ await writeStyleImports({
168
+ components,
169
+ context
170
+ });
171
+ await writeIconImports({
172
+ components,
173
+ context
174
+ });
158
175
  // TODO: add plugins to package.json
159
176
  } catch (error) {
160
177
  context.logger.error(error);
@@ -47,7 +47,8 @@ async function generateDefaultTypes() {
47
47
  server: {
48
48
  }
49
49
  },
50
- styles: []
50
+ styles: {
51
+ }
51
52
  };
52
53
  await Promise.all(defaultPackages.map(async (packageName)=>{
53
54
  const { default: types } = await import(`${packageName}/types`);
@@ -88,14 +89,8 @@ async function generateDefaultTypes() {
88
89
  packageName,
89
90
  version
90
91
  });
91
- if (type.isArray(types.styles)) {
92
- types.styles.forEach((pathName)=>{
93
- defaultTypes.styles.push({
94
- path: pathName,
95
- package: packageName,
96
- version: packageFile.devDependencies[packageName]
97
- });
98
- });
92
+ if (type.isObject(types.styles)) {
93
+ defaultTypes.styles[packageName] = types.styles;
99
94
  }
100
95
  }));
101
96
  await writeFile({
@@ -16,16 +16,10 @@
16
16
  */ import path from 'path';
17
17
  import build from '../index.js';
18
18
  async function run() {
19
- // TODO: resolve build with no config
20
- try {
21
- await build({
22
- logger: console,
23
- buildDirectory: path.resolve(process.cwd(), './.lowdefy/build'),
24
- cacheDirectory: path.resolve(process.cwd(), './.lowdefy/.cache'),
25
- configDirectory: process.cwd()
26
- });
27
- } catch (e) {
28
- console.error(e);
29
- }
19
+ await build({
20
+ logger: console,
21
+ buildDirectory: path.resolve(process.env.LOWDEFY_BUILD_DIRECTORY || path.join(process.cwd(), 'build')),
22
+ configDirectory: path.resolve(process.env.LOWDEFY_CONFIG_DIRECTORY || process.cwd())
23
+ });
30
24
  }
31
25
  run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/build",
3
- "version": "4.0.0-alpha.1",
3
+ "version": "4.0.0-alpha.4",
4
4
  "licence": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -41,18 +41,18 @@
41
41
  "test": "jest --coverage"
42
42
  },
43
43
  "dependencies": {
44
- "@lowdefy/ajv": "4.0.0-alpha.1",
45
- "@lowdefy/helpers": "4.0.0-alpha.1",
46
- "@lowdefy/node-utils": "4.0.0-alpha.1",
47
- "@lowdefy/nunjucks": "4.0.0-alpha.1",
44
+ "@lowdefy/ajv": "4.0.0-alpha.4",
45
+ "@lowdefy/helpers": "4.0.0-alpha.4",
46
+ "@lowdefy/node-utils": "4.0.0-alpha.4",
47
+ "@lowdefy/nunjucks": "4.0.0-alpha.4",
48
48
  "ajv": "8.8.2",
49
49
  "js-yaml": "4.1.0",
50
50
  "json5": "2.2.0",
51
51
  "uuid": "8.3.2"
52
52
  },
53
53
  "devDependencies": {
54
- "@lowdefy/blocks-basic": "4.0.0-alpha.1",
55
- "@lowdefy/connection-axios-http": "4.0.0-alpha.1",
54
+ "@lowdefy/blocks-basic": "4.0.0-alpha.4",
55
+ "@lowdefy/connection-axios-http": "4.0.0-alpha.4",
56
56
  "@swc/cli": "0.1.52",
57
57
  "@swc/core": "1.2.112",
58
58
  "@swc/jest": "0.2.9",
@@ -61,5 +61,5 @@
61
61
  "publishConfig": {
62
62
  "access": "public"
63
63
  },
64
- "gitHead": "c97a8fa6b5a641e7d50df09f5601a9c586eeb65a"
64
+ "gitHead": "537d166ba3f6e017b8a61c2a7e5c12fd0a48bf67"
65
65
  }