@lowdefy/server-dev 3.23.0 → 4.0.0-alpha.7

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 (67) hide show
  1. package/.eslintrc.yaml +1 -0
  2. package/README.md +0 -24
  3. package/next.config.js +36 -0
  4. package/package.json +48 -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 +57 -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 +117 -0
  22. package/src/components/block/Container.js +86 -0
  23. package/src/components/block/List.js +93 -0
  24. package/src/components/block/LoadingBlock.js +22 -0
  25. package/src/components/block/MountEvents.js +46 -0
  26. package/src/components/createComponents.js +29 -0
  27. package/src/components/createLinkComponent.js +97 -0
  28. package/src/manager/getContext.mjs +79 -0
  29. package/src/manager/processes/initialBuild.mjs +27 -0
  30. package/src/manager/processes/installPlugins.mjs +36 -0
  31. package/src/manager/processes/lowdefyBuild.mjs +39 -0
  32. package/src/manager/processes/nextBuild.mjs +31 -0
  33. package/src/manager/processes/readDotEnv.mjs +28 -0
  34. package/src/manager/processes/reloadClients.mjs +26 -0
  35. package/src/manager/processes/restartServer.mjs +27 -0
  36. package/src/manager/processes/shutdownServer.mjs +35 -0
  37. package/src/manager/processes/startNextServer.mjs +45 -0
  38. package/src/manager/processes/startServer.mjs +31 -0
  39. package/src/manager/processes/startWatchers.mjs +31 -0
  40. package/src/manager/run.mjs +92 -0
  41. package/src/manager/utils/BatchChanges.mjs +67 -0
  42. package/src/manager/utils/getLowdefyVersion.mjs +51 -0
  43. package/src/manager/utils/setupWatcher.mjs +49 -0
  44. package/src/manager/utils/spawnProcess.mjs +55 -0
  45. package/src/manager/watchers/envWatcher.mjs +34 -0
  46. package/src/manager/watchers/lowdefyBuildWatcher.mjs +45 -0
  47. package/src/manager/watchers/nextBuildWatcher.mjs +93 -0
  48. package/src/pages/404.js +19 -0
  49. package/src/pages/[pageId].js +19 -0
  50. package/src/pages/_app.js +39 -0
  51. package/src/pages/_document.js +38 -0
  52. package/src/pages/api/auth/[...nextauth].js +28 -0
  53. package/src/pages/api/page/[pageId].js +29 -0
  54. package/src/pages/api/ping.js +19 -0
  55. package/src/pages/api/reload.js +50 -0
  56. package/src/pages/api/request/[pageId]/[requestId].js +45 -0
  57. package/src/pages/api/root.js +25 -0
  58. package/src/pages/index.js +19 -0
  59. package/src/utils/callRequest.js +27 -0
  60. package/src/utils/request.js +36 -0
  61. package/src/utils/setPageId.js +33 -0
  62. package/src/utils/setupLink.js +52 -0
  63. package/src/utils/useMutateCache.js +34 -0
  64. package/src/utils/usePageConfig.js +29 -0
  65. package/src/utils/useRootConfig.js +29 -0
  66. package/src/utils/waitForRestartedServer.js +32 -0
  67. package/dist/server.js +0 -47
@@ -0,0 +1,117 @@
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
+ basePath={lowdefy.basePath}
68
+ blockId={block.blockId}
69
+ components={lowdefy._internal.components}
70
+ events={block.eval.events}
71
+ key={block.blockId}
72
+ loading={block.loading}
73
+ menus={lowdefy.menus}
74
+ pageId={lowdefy.pageId}
75
+ properties={block.eval.properties}
76
+ required={block.eval.required}
77
+ user={lowdefy.user}
78
+ validation={block.eval.validation}
79
+ value={block.value}
80
+ />
81
+ </BlockLayout>
82
+ );
83
+ default:
84
+ return (
85
+ <BlockLayout
86
+ id={`bl-${block.blockId}`}
87
+ blockStyle={block.eval.style}
88
+ highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
89
+ layout={block.eval.layout || {}}
90
+ makeCssClass={makeCssClass}
91
+ >
92
+ <Component
93
+ methods={Object.assign(block.methods, {
94
+ makeCssClass,
95
+ registerEvent: block.registerEvent,
96
+ registerMethod: block.registerMethod,
97
+ triggerEvent: block.triggerEvent,
98
+ })}
99
+ basePath={lowdefy.basePath}
100
+ blockId={block.blockId}
101
+ components={lowdefy._internal.components}
102
+ events={block.eval.events}
103
+ key={block.blockId}
104
+ loading={block.loading}
105
+ menus={lowdefy.menus}
106
+ pageId={lowdefy.pageId}
107
+ properties={block.eval.properties}
108
+ required={block.eval.required}
109
+ user={lowdefy.user}
110
+ validation={block.eval.validation}
111
+ />
112
+ </BlockLayout>
113
+ );
114
+ }
115
+ };
116
+
117
+ export default CategorySwitch;
@@ -0,0 +1,86 @@
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.basePath}
69
+ blockId={block.blockId}
70
+ components={lowdefy._internal.components}
71
+ content={content}
72
+ events={block.eval.events}
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
+ />
82
+ </BlockLayout>
83
+ );
84
+ };
85
+
86
+ export default Container;
@@ -0,0 +1,93 @@
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.basePath}
76
+ blockId={block.blockId}
77
+ components={lowdefy._internal.components}
78
+ events={block.eval.events}
79
+ key={block.blockId}
80
+ list={contentList}
81
+ loading={block.loading}
82
+ menus={lowdefy.menus}
83
+ pageId={lowdefy.pageId}
84
+ properties={block.eval.properties}
85
+ required={block.eval.required}
86
+ user={lowdefy.user}
87
+ validation={block.eval.validation}
88
+ />
89
+ </BlockLayout>
90
+ );
91
+ };
92
+
93
+ 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,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
+ */
16
+
17
+ import { createIcon } from '@lowdefy/block-utils';
18
+
19
+ import createLinkComponent from './createLinkComponent.js';
20
+ import icons from '../../build/plugins/icons.js';
21
+
22
+ const createComponents = (lowdefy) => {
23
+ return {
24
+ Link: createLinkComponent(lowdefy),
25
+ Icon: createIcon(icons),
26
+ };
27
+ };
28
+
29
+ export default createComponents;
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import NextLink from 'next/link';
3
+ import { createLink } from '@lowdefy/engine';
4
+ import { type } from '@lowdefy/helpers';
5
+
6
+ const createLinkComponent = (lowdefy) => {
7
+ const backLink = ({ ariaLabel, children, className, id, rel }) => (
8
+ <a
9
+ id={id}
10
+ onClick={() => lowdefy._internal.router.back()}
11
+ className={className}
12
+ rel={rel}
13
+ aria-label={ariaLabel || 'back'}
14
+ >
15
+ {type.isFunction(children) ? children(id) : children}
16
+ </a>
17
+ );
18
+ const newOriginLink = ({
19
+ ariaLabel,
20
+ children,
21
+ className,
22
+ id,
23
+ newTab,
24
+ pageId,
25
+ query,
26
+ rel,
27
+ url,
28
+ }) => {
29
+ return (
30
+ <a
31
+ id={id}
32
+ aria-label={ariaLabel}
33
+ className={className}
34
+ href={`${url}${query ? `?${query}` : ''}`}
35
+ rel={rel || (newTab && 'noopener noreferrer')}
36
+ target={newTab && '_blank'}
37
+ >
38
+ {type.isFunction(children) ? children(pageId || url || id) : children}
39
+ </a>
40
+ );
41
+ };
42
+ const sameOriginLink = ({
43
+ ariaLabel,
44
+ children,
45
+ className,
46
+ id,
47
+ newTab,
48
+ pageId,
49
+ pathname,
50
+ query,
51
+ rel,
52
+ replace,
53
+ scroll,
54
+ setInput,
55
+ url,
56
+ }) => {
57
+ if (newTab) {
58
+ return (
59
+ // eslint-disable-next-line react/jsx-no-target-blank
60
+ <a
61
+ id={id}
62
+ aria-label={ariaLabel}
63
+ className={className}
64
+ href={`${window.location.origin}${lowdefy.basePath}${pathname}${
65
+ query ? `?${query}` : ''
66
+ }`}
67
+ rel={rel || 'noopener noreferrer'}
68
+ target="_blank"
69
+ >
70
+ {type.isFunction(children) ? children(pageId || url || id) : children}
71
+ </a>
72
+ );
73
+ }
74
+ return (
75
+ <NextLink href={{ pathname, query }} replace={replace} scroll={scroll}>
76
+ <a id={id} aria-label={ariaLabel} className={className} rel={rel} onClick={setInput}>
77
+ {type.isFunction(children) ? children(pageId || url || id) : children}
78
+ </a>
79
+ </NextLink>
80
+ );
81
+ };
82
+ const noLink = ({ className, children, id }) => (
83
+ <span id={id} className={className}>
84
+ {type.isFunction(children) ? children(id) : children}
85
+ </span>
86
+ );
87
+ return createLink({
88
+ backLink,
89
+ lowdefy,
90
+ newOriginLink,
91
+ sameOriginLink,
92
+ noLink,
93
+ disabledLink: noLink,
94
+ });
95
+ };
96
+
97
+ export default createLinkComponent;
@@ -0,0 +1,79 @@
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 { createRequire } from 'module';
20
+ import yargs from 'yargs';
21
+ import { hideBin } from 'yargs/helpers';
22
+
23
+ import initialBuild from './processes/initialBuild.mjs';
24
+ import installPlugins from './processes/installPlugins.mjs';
25
+ import lowdefyBuild from './processes/lowdefyBuild.mjs';
26
+ import nextBuild from './processes/nextBuild.mjs';
27
+ import readDotEnv from './processes/readDotEnv.mjs';
28
+ import reloadClients from './processes/reloadClients.mjs';
29
+ import restartServer from './processes/restartServer.mjs';
30
+ import shutdownServer from './processes/shutdownServer.mjs';
31
+ import startWatchers from './processes/startWatchers.mjs';
32
+
33
+ const argv = yargs(hideBin(process.argv)).array('watch').array('watchIgnore').argv;
34
+ const require = createRequire(import.meta.url);
35
+
36
+ async function getContext() {
37
+ const env = process.env;
38
+
39
+ const context = {
40
+ bin: {
41
+ // TODO: The string replace is a little hacky and will fail if the location of the bin changes,
42
+ lowdefyBuild: require.resolve('@lowdefy/build').replace('index.js', 'scripts/run.js'),
43
+ next: require.resolve('next').replace('server/next.js', 'bin/next'),
44
+ },
45
+ directories: {
46
+ build: path.resolve(process.cwd(), './build'),
47
+ config: path.resolve(argv.configDirectory || env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()),
48
+ server: process.cwd(),
49
+ },
50
+ options: {
51
+ port: argv.port || env.PORT || 3000,
52
+ refResolver: argv.refResolver || env.LOWDEFY_BUILD_REF_RESOLVER,
53
+ watch:
54
+ argv.watch || env.LOWDEFY_SERVER_DEV_WATCH ? JSON.parse(env.LOWDEFY_SERVER_DEV_WATCH) : [],
55
+ watchIgnore:
56
+ argv.watchIgnore || env.LOWDEFY_SERVER_DEV_WATCH_IGNORE
57
+ ? JSON.parse(env.LOWDEFY_SERVER_DEV_WATCH_IGNORE)
58
+ : [],
59
+ // TODO: read option from from env
60
+ verbose: argv.verbose || false,
61
+ },
62
+ packageManager: argv.packageManager || env.LOWDEFY_PACKAGE_MANAGER || 'npm',
63
+ version: env.npm_package_version,
64
+ };
65
+
66
+ context.initialBuild = initialBuild(context);
67
+ context.installPlugins = installPlugins(context);
68
+ context.lowdefyBuild = lowdefyBuild(context);
69
+ context.nextBuild = nextBuild(context);
70
+ context.readDotEnv = readDotEnv(context);
71
+ context.reloadClients = reloadClients(context);
72
+ context.restartServer = restartServer(context);
73
+ context.shutdownServer = shutdownServer(context);
74
+ context.startWatchers = startWatchers(context);
75
+
76
+ return context;
77
+ }
78
+
79
+ export default getContext;
@@ -0,0 +1,27 @@
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
+ function initialBuild(context) {
19
+ return async () => {
20
+ await context.lowdefyBuild();
21
+ await context.installPlugins();
22
+ await context.nextBuild();
23
+ await context.readDotEnv();
24
+ };
25
+ }
26
+
27
+ 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, options }) {
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: !options.verbose,
32
+ });
33
+ };
34
+ }
35
+
36
+ export default installPlugins;
@@ -0,0 +1,39 @@
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({ bin, directories, options }) {
20
+ return async () => {
21
+ await spawnProcess({
22
+ command: 'node',
23
+ args: [bin.lowdefyBuild],
24
+ logger: console,
25
+ processOptions: {
26
+ env: {
27
+ ...process.env,
28
+ LOWDEFY_BUILD_REF_RESOLVER: options.refResolver,
29
+ LOWDEFY_DIRECTORY_BUILD: directories.build,
30
+ LOWDEFY_DIRECTORY_CONFIG: directories.config,
31
+ LOWDEFY_DIRECTORY_SERVER: process.cwd(),
32
+ },
33
+ },
34
+ silent: false,
35
+ });
36
+ };
37
+ }
38
+
39
+ export default lowdefyBuild;