@lowdefy/server-dev 3.23.0-alpha.0 → 4.0.0-alpha.6

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.
Files changed (61) hide show
  1. package/.eslintrc.yaml +1 -0
  2. package/README.md +0 -24
  3. package/next.config.js +34 -0
  4. package/package.json +46 -34
  5. package/public/apple-touch-icon.png +0 -0
  6. package/public/favicon.ico +0 -0
  7. package/public/icon-512.png +0 -0
  8. package/public/icon.svg +17 -0
  9. package/public/logo-dark-theme.png +0 -0
  10. package/public/logo-light-theme.png +0 -0
  11. package/public/logo-square-dark-theme.png +0 -0
  12. package/public/logo-square-light-theme.png +0 -0
  13. package/public/manifest.webmanifest +16 -0
  14. package/src/components/App.js +55 -0
  15. package/src/components/Context.js +62 -0
  16. package/src/components/Head.js +28 -0
  17. package/src/components/LowdefyContext.js +50 -0
  18. package/src/components/Page.js +54 -0
  19. package/src/components/Reload.js +43 -0
  20. package/src/components/block/Block.js +57 -0
  21. package/src/components/block/CategorySwitch.js +120 -0
  22. package/src/components/block/Container.js +87 -0
  23. package/src/components/block/List.js +94 -0
  24. package/src/components/block/LoadingBlock.js +22 -0
  25. package/src/components/block/MountEvents.js +46 -0
  26. package/src/components/components.js +25 -0
  27. package/src/manager/BatchChanges.mjs +66 -0
  28. package/src/manager/getContext.mjs +64 -0
  29. package/src/manager/initialBuild.mjs +24 -0
  30. package/src/manager/processes/installPlugins.mjs +36 -0
  31. package/src/manager/processes/lowdefyBuild.mjs +38 -0
  32. package/src/manager/processes/nextBuild.mjs +31 -0
  33. package/src/manager/processes/reloadClients.mjs +26 -0
  34. package/src/manager/processes/startServer.mjs +31 -0
  35. package/src/manager/processes/startServerProcess.mjs +34 -0
  36. package/src/manager/run.mjs +41 -0
  37. package/src/manager/spawnProcess.mjs +55 -0
  38. package/src/manager/watchers/configWatcher.mjs +28 -0
  39. package/src/manager/watchers/envWatcher.mjs +32 -0
  40. package/src/manager/watchers/setupWatcher.mjs +43 -0
  41. package/src/manager/watchers/startWatchers.mjs +64 -0
  42. package/src/pages/404.js +19 -0
  43. package/src/pages/[pageId].js +19 -0
  44. package/src/pages/_app.js +37 -0
  45. package/src/pages/_document.js +38 -0
  46. package/src/pages/api/auth/[...nextauth].js +28 -0
  47. package/src/pages/api/page/[pageId].js +29 -0
  48. package/src/pages/api/ping.js +19 -0
  49. package/src/pages/api/reload.js +52 -0
  50. package/src/pages/api/request/[pageId]/[requestId].js +44 -0
  51. package/src/pages/api/root.js +25 -0
  52. package/src/pages/index.js +19 -0
  53. package/src/utils/callRequest.js +27 -0
  54. package/src/utils/request.js +36 -0
  55. package/src/utils/setPageId.js +33 -0
  56. package/src/utils/setupLink.js +44 -0
  57. package/src/utils/useMutateCache.js +34 -0
  58. package/src/utils/usePageConfig.js +32 -0
  59. package/src/utils/useRootConfig.js +29 -0
  60. package/src/utils/waitForRestartedServer.js +32 -0
  61. package/dist/server.js +0 -47
@@ -0,0 +1,120 @@
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
+ */
16
+
17
+ import React from 'react';
18
+ import { BlockLayout } from '@lowdefy/layout';
19
+ import { makeCssClass } from '@lowdefy/block-utils';
20
+
21
+ import Container from './Container.js';
22
+ import List from './List.js';
23
+
24
+ const CategorySwitch = ({ block, Blocks, context, lowdefy }) => {
25
+ if (!block.eval) return null; // Renderer updates before eval is executed for the first time on lists. See #520
26
+ if (block.eval.visible === false)
27
+ return <div id={`vs-${block.blockId}`} style={{ display: 'none' }} />;
28
+ const Component = lowdefy._internal.blockComponents[block.type];
29
+ switch (Component.meta.category) {
30
+ case 'list':
31
+ return (
32
+ <List
33
+ block={block}
34
+ Blocks={Blocks}
35
+ Component={Component}
36
+ context={context}
37
+ lowdefy={lowdefy}
38
+ />
39
+ );
40
+ case 'container':
41
+ return (
42
+ <Container
43
+ block={block}
44
+ Blocks={Blocks}
45
+ Component={Component}
46
+ context={context}
47
+ lowdefy={lowdefy}
48
+ />
49
+ );
50
+ case 'input':
51
+ return (
52
+ <BlockLayout
53
+ id={`bl-${block.blockId}`}
54
+ blockStyle={block.eval.style}
55
+ highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
56
+ layout={block.eval.layout || {}}
57
+ makeCssClass={makeCssClass}
58
+ >
59
+ <Component
60
+ methods={Object.assign(block.methods, {
61
+ makeCssClass,
62
+ registerEvent: block.registerEvent,
63
+ registerMethod: block.registerMethod,
64
+ setValue: block.setValue,
65
+ triggerEvent: block.triggerEvent,
66
+ })}
67
+ // TODO: React throws a basePath warning
68
+ basePath={lowdefy._internal.basePath}
69
+ blockId={block.blockId}
70
+ components={lowdefy._internal.components}
71
+ events={block.eval.events}
72
+ homePageId={lowdefy.home.pageId}
73
+ key={block.blockId}
74
+ loading={block.loading}
75
+ menus={lowdefy.menus}
76
+ pageId={lowdefy.pageId}
77
+ properties={block.eval.properties}
78
+ required={block.eval.required}
79
+ user={lowdefy.user}
80
+ validation={block.eval.validation}
81
+ value={block.value}
82
+ />
83
+ </BlockLayout>
84
+ );
85
+ default:
86
+ return (
87
+ <BlockLayout
88
+ id={`bl-${block.blockId}`}
89
+ blockStyle={block.eval.style}
90
+ highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
91
+ layout={block.eval.layout || {}}
92
+ makeCssClass={makeCssClass}
93
+ >
94
+ <Component
95
+ methods={Object.assign(block.methods, {
96
+ makeCssClass,
97
+ registerEvent: block.registerEvent,
98
+ registerMethod: block.registerMethod,
99
+ triggerEvent: block.triggerEvent,
100
+ })}
101
+ basePath={lowdefy._internal.basePath}
102
+ blockId={block.blockId}
103
+ components={lowdefy._internal.components}
104
+ events={block.eval.events}
105
+ homePageId={lowdefy.home.pageId}
106
+ key={block.blockId}
107
+ loading={block.loading}
108
+ menus={lowdefy.menus}
109
+ pageId={lowdefy.pageId}
110
+ properties={block.eval.properties}
111
+ required={block.eval.required}
112
+ user={lowdefy.user}
113
+ validation={block.eval.validation}
114
+ />
115
+ </BlockLayout>
116
+ );
117
+ }
118
+ };
119
+
120
+ export default CategorySwitch;
@@ -0,0 +1,87 @@
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
+ */
16
+
17
+ import React from 'react';
18
+ import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
19
+ import { makeCssClass } from '@lowdefy/block-utils';
20
+
21
+ import Block from './Block.js';
22
+
23
+ const Container = ({ block, Blocks, Component, context, lowdefy }) => {
24
+ const content = {};
25
+ // eslint-disable-next-line prefer-destructuring
26
+ const areas = Blocks.subBlocks[block.id][0].areas;
27
+ Object.keys(areas).forEach((areaKey) => {
28
+ content[areaKey] = (areaStyle) => (
29
+ <Area
30
+ id={`ar-${block.blockId}-${areaKey}`}
31
+ key={`ar-${block.blockId}-${areaKey}`}
32
+ area={layoutParamsToArea({
33
+ area: block.eval.areas[areaKey] || {},
34
+ areaKey,
35
+ layout: block.eval.layout || {},
36
+ })}
37
+ areaStyle={[areaStyle, block.eval.areas[areaKey] && block.eval.areas[areaKey].style]}
38
+ highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
39
+ makeCssClass={makeCssClass}
40
+ >
41
+ {areas[areaKey].blocks.map((bl) => (
42
+ <Block
43
+ key={`co-${bl.blockId}`}
44
+ Blocks={Blocks.subBlocks[block.id][0]}
45
+ block={bl}
46
+ context={context}
47
+ lowdefy={lowdefy}
48
+ />
49
+ ))}
50
+ </Area>
51
+ );
52
+ });
53
+ return (
54
+ <BlockLayout
55
+ id={`bl-${block.blockId}`}
56
+ blockStyle={block.eval.style}
57
+ highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
58
+ layout={block.eval.layout || {}}
59
+ makeCssClass={makeCssClass}
60
+ >
61
+ <Component
62
+ methods={Object.assign(block.methods, {
63
+ makeCssClass,
64
+ registerEvent: block.registerEvent,
65
+ registerMethod: block.registerMethod,
66
+ triggerEvent: block.triggerEvent,
67
+ })}
68
+ basePath={lowdefy._internal.basePath}
69
+ blockId={block.blockId}
70
+ components={lowdefy._internal.components}
71
+ content={content}
72
+ events={block.eval.events}
73
+ homePageId={lowdefy.home.pageId}
74
+ key={block.blockId}
75
+ loading={block.loading}
76
+ menus={lowdefy.menus}
77
+ pageId={lowdefy.pageId}
78
+ properties={block.eval.properties}
79
+ required={block.eval.required}
80
+ user={lowdefy.user}
81
+ validation={block.eval.validation}
82
+ />
83
+ </BlockLayout>
84
+ );
85
+ };
86
+
87
+ export default Container;
@@ -0,0 +1,94 @@
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
+ */
16
+
17
+ import React from 'react';
18
+ import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
19
+ import { makeCssClass } from '@lowdefy/block-utils';
20
+
21
+ import Block from './Block.js';
22
+
23
+ const List = ({ block, Blocks, Component, context, lowdefy }) => {
24
+ const content = {};
25
+ const contentList = [];
26
+ Blocks.subBlocks[block.id].forEach((SBlock) => {
27
+ Object.keys(SBlock.areas).forEach((areaKey) => {
28
+ content[areaKey] = (areaStyle) => (
29
+ <Area
30
+ id={`ar-${block.blockId}-${SBlock.id}-${areaKey}`}
31
+ key={`ar-${block.blockId}-${SBlock.id}-${areaKey}`}
32
+ area={layoutParamsToArea({
33
+ area: block.eval.areas[areaKey] || {},
34
+ areaKey,
35
+ layout: block.eval.layout || {},
36
+ })}
37
+ areaStyle={[areaStyle, block.eval.areas[areaKey] && block.eval.areas[areaKey].style]}
38
+ highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
39
+ makeCssClass={makeCssClass}
40
+ >
41
+ {SBlock.areas[areaKey].blocks.map((bl) => (
42
+ <Block
43
+ key={`ls-${bl.blockId}`}
44
+ Blocks={SBlock}
45
+ block={bl}
46
+ context={context}
47
+ lowdefy={lowdefy}
48
+ />
49
+ ))}
50
+ </Area>
51
+ );
52
+ });
53
+ contentList.push({ ...content });
54
+ });
55
+ return (
56
+ <BlockLayout
57
+ id={`bl-${block.blockId}`}
58
+ blockStyle={block.eval.style}
59
+ highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
60
+ layout={block.eval.layout || {}}
61
+ makeCssClass={makeCssClass}
62
+ >
63
+ <Component
64
+ methods={Object.assign(block.methods, {
65
+ makeCssClass,
66
+ moveItemDown: block.moveItemDown,
67
+ moveItemUp: block.moveItemUp,
68
+ pushItem: block.pushItem,
69
+ registerEvent: block.registerEvent,
70
+ registerMethod: block.registerMethod,
71
+ removeItem: block.removeItem,
72
+ triggerEvent: block.triggerEvent,
73
+ unshiftItem: block.unshiftItem,
74
+ })}
75
+ basePath={lowdefy._internal.basePath}
76
+ blockId={block.blockId}
77
+ components={lowdefy._internal.components}
78
+ events={block.eval.events}
79
+ homePageId={lowdefy.home.pageId}
80
+ key={block.blockId}
81
+ list={contentList}
82
+ loading={block.loading}
83
+ menus={lowdefy.menus}
84
+ pageId={lowdefy.pageId}
85
+ properties={block.eval.properties}
86
+ required={block.eval.required}
87
+ user={lowdefy.user}
88
+ validation={block.eval.validation}
89
+ />
90
+ </BlockLayout>
91
+ );
92
+ };
93
+
94
+ export default List;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ // import { Loading, makeCssClass } from '@lowdefy/block-utils';
3
+ // import { get } from '@lowdefy/helpers';
4
+ // import { BlockLayout } from '@lowdefy/layout';
5
+
6
+ const LoadingBlock = ({ block, lowdefy }) => (
7
+ <div>LoadingBlock</div>
8
+ // <BlockLayout
9
+ // id={`bl-loading-${block.blockId}`}
10
+ // blockStyle={get(block, 'eval.style') || get(block, 'meta.loading.style', { default: {} })}
11
+ // highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
12
+ // layout={get(block, 'eval.layout') || get(block, 'meta.loading.layout', { default: {} })}
13
+ // makeCssClass={makeCssClass}
14
+ // >
15
+ // <Loading
16
+ // properties={get(block, 'meta.loading.properties')}
17
+ // type={get(block, 'meta.loading.type')}
18
+ // />
19
+ // </BlockLayout>
20
+ );
21
+
22
+ export default LoadingBlock;
@@ -0,0 +1,46 @@
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
+ */
16
+
17
+ import React, { useEffect, useState } from 'react';
18
+
19
+ const MountEvents = ({ asyncEventName, context, eventName, triggerEvent, children }) => {
20
+ const [loading, setLoading] = useState(true);
21
+ const [error, setError] = useState(null);
22
+ useEffect(() => {
23
+ let mounted = true;
24
+ const mount = async () => {
25
+ try {
26
+ await triggerEvent({ name: eventName, context });
27
+ if (mounted) {
28
+ triggerEvent({ name: asyncEventName, context });
29
+ setLoading(false);
30
+ }
31
+ } catch (err) {
32
+ setError(err);
33
+ }
34
+ };
35
+ mount();
36
+ return () => {
37
+ mounted = false;
38
+ };
39
+ }, [context]);
40
+
41
+ if (error) throw error;
42
+
43
+ return <>{children(loading)}</>;
44
+ };
45
+
46
+ export default MountEvents;
@@ -0,0 +1,25 @@
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
+ */
16
+
17
+ import Link from 'next/link';
18
+ import { createIcon } from '@lowdefy/block-utils';
19
+
20
+ import icons from '../../build/plugins/icons.js';
21
+
22
+ export default {
23
+ Link,
24
+ Icon: createIcon(icons),
25
+ };
@@ -0,0 +1,66 @@
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
+ */
16
+
17
+ class BatchChanges {
18
+ constructor({ fn, minDelay }) {
19
+ this._call = this._call.bind(this);
20
+ this.args = [];
21
+ this.delay = minDelay || 500;
22
+ this.fn = fn;
23
+ this.minDelay = minDelay || 500;
24
+ this.repeat = false;
25
+ this.running = false;
26
+ }
27
+
28
+ newChange(...args) {
29
+ this.args.push(args);
30
+ this.delay = this.minDelay;
31
+ this._startTimer();
32
+ }
33
+
34
+ _startTimer() {
35
+ if (this.timer) {
36
+ clearTimeout(this.timer);
37
+ }
38
+ if (this.running) {
39
+ this.repeat = true;
40
+ } else {
41
+ this.timer = setTimeout(this._call, this.delay);
42
+ }
43
+ }
44
+
45
+ async _call() {
46
+ this.running = true;
47
+ try {
48
+ const args = this.args;
49
+ this.args = [];
50
+ await this.fn(args);
51
+ this.running = false;
52
+ if (this.repeat) {
53
+ this.repeat = false;
54
+ this._call();
55
+ }
56
+ } catch (error) {
57
+ this.running = false;
58
+ console.error(error);
59
+ this.delay *= 2;
60
+ console.warn(`Retrying in ${this.delay / 1000}s.`);
61
+ this._startTimer();
62
+ }
63
+ }
64
+ }
65
+
66
+ export default BatchChanges;
@@ -0,0 +1,64 @@
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
+ */
16
+ /* eslint-disable no-console */
17
+
18
+ import path from 'path';
19
+ import yargs from 'yargs';
20
+ import { hideBin } from 'yargs/helpers';
21
+
22
+ import lowdefyBuild from './processes/lowdefyBuild.mjs';
23
+ import nextBuild from './processes/nextBuild.mjs';
24
+ import installPlugins from './processes/installPlugins.mjs';
25
+ import startServerProcess from './processes/startServerProcess.mjs';
26
+ import reloadClients from './processes/reloadClients.mjs';
27
+
28
+ const argv = yargs(hideBin(process.argv)).argv;
29
+
30
+ async function getContext() {
31
+ const { packageManager = 'npm', verbose = false } = argv;
32
+ const context = {
33
+ directories: {
34
+ build: path.resolve(process.cwd(), './build'),
35
+ config: path.resolve(
36
+ argv.configDirectory || process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()
37
+ ),
38
+ server: process.cwd(),
39
+ },
40
+ packageManager,
41
+ restartServer: () => {
42
+ if (context.serverProcess) {
43
+ console.log('Restarting server...');
44
+ context.serverProcess.kill();
45
+ startServerProcess(context);
46
+ }
47
+ },
48
+ shutdownServer: () => {
49
+ if (context.serverProcess) {
50
+ console.log('Shutting down server...');
51
+ context.serverProcess.kill();
52
+ }
53
+ },
54
+ verbose,
55
+ };
56
+ context.installPlugins = installPlugins(context);
57
+ context.lowdefyBuild = lowdefyBuild(context);
58
+ context.nextBuild = nextBuild(context);
59
+ context.reloadClients = reloadClients(context);
60
+
61
+ return context;
62
+ }
63
+
64
+ export default getContext;
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ Copyright 2020-2021 Lowdefy, Inc
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+
18
+ async function initialBuild(context) {
19
+ await context.lowdefyBuild();
20
+ await context.installPlugins();
21
+ await context.nextBuild();
22
+ }
23
+
24
+ export default initialBuild;
@@ -0,0 +1,36 @@
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
+ */
16
+
17
+ import { spawnProcess } from '@lowdefy/node-utils';
18
+
19
+ const args = {
20
+ npm: ['install', '--legacy-peer-deps'],
21
+ yarn: ['install'],
22
+ };
23
+
24
+ function installPlugins({ packageManager, verbose }) {
25
+ return async () => {
26
+ console.log('Installing plugins...');
27
+ await spawnProcess({
28
+ logger: console,
29
+ command: packageManager, // npm or yarn
30
+ args: args[packageManager],
31
+ silent: !verbose,
32
+ });
33
+ };
34
+ }
35
+
36
+ export default installPlugins;
@@ -0,0 +1,38 @@
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
+ */
16
+
17
+ import { spawnProcess } from '@lowdefy/node-utils';
18
+
19
+ function lowdefyBuild({ packageManager, directories }) {
20
+ return async () => {
21
+ await spawnProcess({
22
+ logger: console,
23
+ args: ['run', 'build:lowdefy'],
24
+ command: packageManager,
25
+ processOptions: {
26
+ env: {
27
+ ...process.env,
28
+ LOWDEFY_DIRECTORY_BUILD: directories.build,
29
+ LOWDEFY_DIRECTORY_CONFIG: directories.config,
30
+ LOWDEFY_DIRECTORY_SERVER: process.cwd(),
31
+ },
32
+ },
33
+ silent: false,
34
+ });
35
+ };
36
+ }
37
+
38
+ export default lowdefyBuild;
@@ -0,0 +1,31 @@
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
+ */
16
+
17
+ import { spawnProcess } from '@lowdefy/node-utils';
18
+
19
+ function nextBuild({ packageManager, verbose }) {
20
+ return async () => {
21
+ console.log('Building app...');
22
+ await spawnProcess({
23
+ logger: console,
24
+ args: ['run', 'build:next'],
25
+ command: packageManager,
26
+ silent: !verbose,
27
+ });
28
+ };
29
+ }
30
+
31
+ export default nextBuild;
@@ -0,0 +1,26 @@
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
+ */
16
+
17
+ import path from 'path';
18
+ import { writeFile } from '@lowdefy/node-utils';
19
+
20
+ function reloadClients({ directories }) {
21
+ return async () => {
22
+ await writeFile({ filePath: path.join(directories.build, 'reload'), content: `${Date.now()}` });
23
+ };
24
+ }
25
+
26
+ export default reloadClients;