@lowdefy/server-dev 4.0.0-alpha.6 → 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 (42) hide show
  1. package/next.config.js +6 -4
  2. package/package.json +34 -32
  3. package/src/components/App.js +9 -7
  4. package/src/components/LowdefyContext.js +13 -13
  5. package/src/components/Page.js +2 -2
  6. package/src/components/Reload.js +2 -2
  7. package/src/components/block/CategorySwitch.js +2 -5
  8. package/src/components/block/Container.js +1 -2
  9. package/src/components/block/List.js +1 -2
  10. package/src/components/{components.js → createComponents.js} +8 -4
  11. package/src/components/createLinkComponent.js +97 -0
  12. package/src/manager/getContext.mjs +36 -21
  13. package/src/manager/{initialBuild.mjs → processes/initialBuild.mjs} +7 -4
  14. package/src/manager/processes/installPlugins.mjs +2 -2
  15. package/src/manager/processes/lowdefyBuild.mjs +4 -3
  16. package/src/manager/processes/nextBuild.mjs +4 -4
  17. package/src/manager/{watchers/configWatcher.mjs → processes/readDotEnv.mjs} +8 -8
  18. package/src/manager/processes/reloadClients.mjs +1 -1
  19. package/src/manager/processes/{startServerProcess.mjs → restartServer.mjs} +8 -15
  20. package/src/manager/processes/shutdownServer.mjs +35 -0
  21. package/src/manager/processes/startNextServer.mjs +45 -0
  22. package/src/manager/processes/startServer.mjs +3 -3
  23. package/src/manager/processes/startWatchers.mjs +31 -0
  24. package/src/manager/run.mjs +57 -6
  25. package/src/manager/{BatchChanges.mjs → utils/BatchChanges.mjs} +1 -0
  26. package/src/manager/utils/getLowdefyVersion.mjs +51 -0
  27. package/src/manager/{watchers → utils}/setupWatcher.mjs +12 -6
  28. package/src/manager/{spawnProcess.mjs → utils/spawnProcess.mjs} +0 -0
  29. package/src/manager/watchers/envWatcher.mjs +5 -3
  30. package/src/manager/watchers/lowdefyBuildWatcher.mjs +45 -0
  31. package/src/manager/watchers/nextBuildWatcher.mjs +93 -0
  32. package/src/pages/_app.js +4 -2
  33. package/src/pages/api/reload.js +0 -2
  34. package/src/pages/api/request/[pageId]/[requestId].js +1 -0
  35. package/src/utils/callRequest.js +2 -2
  36. package/src/utils/setPageId.js +3 -3
  37. package/src/utils/setupLink.js +22 -14
  38. package/src/utils/useMutateCache.js +3 -3
  39. package/src/utils/usePageConfig.js +2 -5
  40. package/src/utils/useRootConfig.js +4 -4
  41. package/src/utils/waitForRestartedServer.js +1 -1
  42. package/src/manager/watchers/startWatchers.mjs +0 -64
package/next.config.js CHANGED
@@ -7,6 +7,7 @@ module.exports = withLess({
7
7
  modifyVars: lowdefyConfig.theme.lessVariables,
8
8
  },
9
9
  },
10
+ basePath: process.env.LOWDEFY_BASE_PATH || lowdefyConfig.basePath,
10
11
  // reactStrictMode: true,
11
12
  webpack: (config, { isServer }) => {
12
13
  if (!isServer) {
@@ -23,11 +24,12 @@ module.exports = withLess({
23
24
  }
24
25
  return config;
25
26
  },
27
+ swcMinify: true,
28
+ compress: false,
29
+ outputFileTracing: false,
26
30
  poweredByHeader: false,
27
- // productionBrowserSourceMaps: true
28
- // experimental: {
29
- // concurrentFeatures: true,
30
- // },
31
+ generateEtags: false,
32
+ optimizeFonts: false,
31
33
  eslint: {
32
34
  ignoreDuringBuilds: true,
33
35
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "4.0.0-alpha.6",
3
+ "version": "4.0.0-alpha.7",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -40,45 +40,47 @@
40
40
  "next": "next"
41
41
  },
42
42
  "dependencies": {
43
- "@lowdefy/api": "4.0.0-alpha.6",
44
- "@lowdefy/block-utils": "4.0.0-alpha.6",
45
- "@lowdefy/blocks-antd": "4.0.0-alpha.6",
46
- "@lowdefy/blocks-basic": "4.0.0-alpha.6",
47
- "@lowdefy/blocks-color-selectors": "4.0.0-alpha.6",
48
- "@lowdefy/blocks-echarts": "4.0.0-alpha.6",
49
- "@lowdefy/blocks-loaders": "4.0.0-alpha.6",
50
- "@lowdefy/blocks-markdown": "4.0.0-alpha.6",
51
- "@lowdefy/build": "4.0.0-alpha.6",
52
- "@lowdefy/connection-axios-http": "4.0.0-alpha.6",
53
- "@lowdefy/engine": "4.0.0-alpha.6",
54
- "@lowdefy/helpers": "4.0.0-alpha.6",
55
- "@lowdefy/layout": "4.0.0-alpha.6",
56
- "@lowdefy/node-utils": "4.0.0-alpha.6",
57
- "@lowdefy/operators-change-case": "4.0.0-alpha.6",
58
- "@lowdefy/operators-diff": "4.0.0-alpha.6",
59
- "@lowdefy/operators-js": "4.0.0-alpha.6",
60
- "@lowdefy/operators-mql": "4.0.0-alpha.6",
61
- "@lowdefy/operators-nunjucks": "4.0.0-alpha.6",
62
- "@lowdefy/operators-uuid": "4.0.0-alpha.6",
63
- "@lowdefy/operators-yaml": "4.0.0-alpha.6",
64
- "chokidar": "3.5.2",
65
- "next": "12.0.3",
66
- "next-auth": "4.0.0-beta.6",
43
+ "@lowdefy/api": "4.0.0-alpha.7",
44
+ "@lowdefy/block-utils": "4.0.0-alpha.7",
45
+ "@lowdefy/blocks-antd": "4.0.0-alpha.7",
46
+ "@lowdefy/blocks-basic": "4.0.0-alpha.7",
47
+ "@lowdefy/blocks-color-selectors": "4.0.0-alpha.7",
48
+ "@lowdefy/blocks-echarts": "4.0.0-alpha.7",
49
+ "@lowdefy/blocks-loaders": "4.0.0-alpha.7",
50
+ "@lowdefy/blocks-markdown": "4.0.0-alpha.7",
51
+ "@lowdefy/build": "4.0.0-alpha.7",
52
+ "@lowdefy/connection-axios-http": "4.0.0-alpha.7",
53
+ "@lowdefy/engine": "4.0.0-alpha.7",
54
+ "@lowdefy/helpers": "4.0.0-alpha.7",
55
+ "@lowdefy/layout": "4.0.0-alpha.7",
56
+ "@lowdefy/node-utils": "4.0.0-alpha.7",
57
+ "@lowdefy/operators-change-case": "4.0.0-alpha.7",
58
+ "@lowdefy/operators-diff": "4.0.0-alpha.7",
59
+ "@lowdefy/operators-js": "4.0.0-alpha.7",
60
+ "@lowdefy/operators-mql": "4.0.0-alpha.7",
61
+ "@lowdefy/operators-nunjucks": "4.0.0-alpha.7",
62
+ "@lowdefy/operators-uuid": "4.0.0-alpha.7",
63
+ "@lowdefy/operators-yaml": "4.0.0-alpha.7",
64
+ "chokidar": "3.5.3",
65
+ "dotenv": "15.0.0",
66
+ "js-yaml": "4.1.0",
67
+ "next": "12.0.10",
68
+ "next-auth": "4.1.2",
67
69
  "opener": "1.5.2",
68
- "react": "18.0.0-alpha-327d5c484-20211106",
69
- "react-dom": "18.0.0-alpha-327d5c484-20211106",
70
+ "react": "18.0.0-rc.0",
71
+ "react-dom": "18.0.0-rc.0",
70
72
  "react-icons": "4.3.1",
71
- "swr": "1.0.1",
72
- "yargs": "17.3.0"
73
+ "swr": "1.1.2",
74
+ "yargs": "17.3.1"
73
75
  },
74
76
  "devDependencies": {
75
- "@next/eslint-plugin-next": "12.0.4",
77
+ "@next/eslint-plugin-next": "12.0.10",
76
78
  "less": "4.1.2",
77
79
  "less-loader": "10.2.0",
78
- "next-with-less": "2.0.2"
80
+ "next-with-less": "2.0.4"
79
81
  },
80
82
  "publishConfig": {
81
83
  "access": "public"
82
84
  },
83
- "gitHead": "2530e31af795b6a3c75ac8f72c8dbe0ab5d1251b"
85
+ "gitHead": "52ec14639d00de910cf9b8ab25bf933ca891cff5"
84
86
  }
@@ -16,6 +16,7 @@
16
16
 
17
17
  import React from 'react';
18
18
 
19
+ import { urlQuery } from '@lowdefy/helpers';
19
20
  import { useRouter } from 'next/router';
20
21
 
21
22
  import Page from './Page.js';
@@ -23,22 +24,23 @@ import Reload from './Reload.js';
23
24
  import setPageId from '../utils/setPageId.js';
24
25
  import setupLink from '../utils/setupLink.js';
25
26
  import useRootConfig from '../utils/useRootConfig.js';
27
+ import createComponents from './createComponents.js';
26
28
 
27
29
  const App = ({ lowdefy }) => {
28
30
  const router = useRouter();
29
- const { data: rootConfig } = useRootConfig();
31
+ const { data: rootConfig } = useRootConfig(router.basePath);
30
32
 
31
33
  window.lowdefy = lowdefy;
32
34
 
35
+ lowdefy._internal.router = router;
36
+ lowdefy._internal.link = setupLink(lowdefy);
37
+ lowdefy._internal.components = createComponents(lowdefy);
38
+
39
+ lowdefy.basePath = lowdefy._internal.router.basePath;
33
40
  lowdefy.home = rootConfig.home;
34
41
  lowdefy.lowdefyGlobal = rootConfig.lowdefyGlobal;
35
42
  lowdefy.menus = rootConfig.menus;
36
-
37
- lowdefy._internal.basePath = router.basePath;
38
- lowdefy._internal.pathname = router.pathname;
39
- lowdefy._internal.query = router.query;
40
- lowdefy._internal.router = router;
41
- lowdefy._internal.link = setupLink({ lowdefy });
43
+ lowdefy.urlQuery = urlQuery.parse(window.location.search.slice(1));
42
44
 
43
45
  const redirect = setPageId(lowdefy);
44
46
  if (redirect) {
@@ -16,35 +16,35 @@
16
16
 
17
17
  import React from 'react';
18
18
 
19
+ import actions from '../../build/plugins/actions.js';
19
20
  import callRequest from '../utils/callRequest.js';
20
21
  import blockComponents from '../../build/plugins/blocks.js';
21
22
  import operators from '../../build/plugins/operatorsClient.js';
22
- import components from './components.js';
23
23
 
24
- const LowdefyContext = ({ children }) => {
25
- const lowdefy = {
26
- _internal: {
24
+ const LowdefyContext = ({ children, lowdefy }) => {
25
+ if (!lowdefy._internal) {
26
+ lowdefy._internal = {
27
+ actions,
27
28
  blockComponents,
28
29
  callRequest,
29
- components,
30
+ components: {},
30
31
  document,
31
32
  operators,
32
33
  updaters: {},
33
34
  window,
34
35
  displayMessage: ({ content }) => {
35
- alert(content);
36
+ console.log(content);
36
37
  return () => undefined;
37
38
  },
38
39
  link: () => undefined,
39
- },
40
- contexts: {},
41
- inputs: {},
42
- lowdefyGlobal: {},
43
- };
40
+ };
41
+ lowdefy.contexts = {};
42
+ lowdefy.inputs = {};
43
+ lowdefy.lowdefyGlobal = {};
44
+ }
44
45
  lowdefy._internal.updateBlock = (blockId) =>
45
46
  lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
46
-
47
- return <>{children(lowdefy)}</>;
47
+ return <>{children}</>;
48
48
  };
49
49
 
50
50
  export default LowdefyContext;
@@ -24,9 +24,9 @@ import usePageConfig from '../utils/usePageConfig.js';
24
24
  const LoadingBlock = () => <div>Loading...</div>;
25
25
 
26
26
  const Page = ({ lowdefy }) => {
27
- const { data: pageConfig } = usePageConfig(lowdefy.pageId);
27
+ const { data: pageConfig } = usePageConfig(lowdefy.pageId, lowdefy.basePath);
28
28
  if (!pageConfig) {
29
- lowdefy._internal.router.push(`/404`);
29
+ lowdefy._internal.router.replace(`/404`);
30
30
  return <LoadingBlock />;
31
31
  }
32
32
  return (
@@ -20,9 +20,9 @@ import useMutateCache from '../utils/useMutateCache.js';
20
20
  import waitForRestartedServer from '../utils/waitForRestartedServer.js';
21
21
 
22
22
  const Reload = ({ children, lowdefy }) => {
23
- const mutateCache = useMutateCache();
23
+ const mutateCache = useMutateCache(lowdefy.basePath);
24
24
  useEffect(() => {
25
- const sse = new EventSource('/api/reload');
25
+ const sse = new EventSource(`${lowdefy.basePath}/api/reload`);
26
26
 
27
27
  sse.addEventListener('reload', () => {
28
28
  mutateCache();
@@ -64,12 +64,10 @@ const CategorySwitch = ({ block, Blocks, context, lowdefy }) => {
64
64
  setValue: block.setValue,
65
65
  triggerEvent: block.triggerEvent,
66
66
  })}
67
- // TODO: React throws a basePath warning
68
- basePath={lowdefy._internal.basePath}
67
+ basePath={lowdefy.basePath}
69
68
  blockId={block.blockId}
70
69
  components={lowdefy._internal.components}
71
70
  events={block.eval.events}
72
- homePageId={lowdefy.home.pageId}
73
71
  key={block.blockId}
74
72
  loading={block.loading}
75
73
  menus={lowdefy.menus}
@@ -98,11 +96,10 @@ const CategorySwitch = ({ block, Blocks, context, lowdefy }) => {
98
96
  registerMethod: block.registerMethod,
99
97
  triggerEvent: block.triggerEvent,
100
98
  })}
101
- basePath={lowdefy._internal.basePath}
99
+ basePath={lowdefy.basePath}
102
100
  blockId={block.blockId}
103
101
  components={lowdefy._internal.components}
104
102
  events={block.eval.events}
105
- homePageId={lowdefy.home.pageId}
106
103
  key={block.blockId}
107
104
  loading={block.loading}
108
105
  menus={lowdefy.menus}
@@ -65,12 +65,11 @@ const Container = ({ block, Blocks, Component, context, lowdefy }) => {
65
65
  registerMethod: block.registerMethod,
66
66
  triggerEvent: block.triggerEvent,
67
67
  })}
68
- basePath={lowdefy._internal.basePath}
68
+ basePath={lowdefy.basePath}
69
69
  blockId={block.blockId}
70
70
  components={lowdefy._internal.components}
71
71
  content={content}
72
72
  events={block.eval.events}
73
- homePageId={lowdefy.home.pageId}
74
73
  key={block.blockId}
75
74
  loading={block.loading}
76
75
  menus={lowdefy.menus}
@@ -72,11 +72,10 @@ const List = ({ block, Blocks, Component, context, lowdefy }) => {
72
72
  triggerEvent: block.triggerEvent,
73
73
  unshiftItem: block.unshiftItem,
74
74
  })}
75
- basePath={lowdefy._internal.basePath}
75
+ basePath={lowdefy.basePath}
76
76
  blockId={block.blockId}
77
77
  components={lowdefy._internal.components}
78
78
  events={block.eval.events}
79
- homePageId={lowdefy.home.pageId}
80
79
  key={block.blockId}
81
80
  list={contentList}
82
81
  loading={block.loading}
@@ -14,12 +14,16 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import Link from 'next/link';
18
17
  import { createIcon } from '@lowdefy/block-utils';
19
18
 
19
+ import createLinkComponent from './createLinkComponent.js';
20
20
  import icons from '../../build/plugins/icons.js';
21
21
 
22
- export default {
23
- Link,
24
- Icon: createIcon(icons),
22
+ const createComponents = (lowdefy) => {
23
+ return {
24
+ Link: createLinkComponent(lowdefy),
25
+ Icon: createIcon(icons),
26
+ };
25
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;
@@ -16,47 +16,62 @@
16
16
  /* eslint-disable no-console */
17
17
 
18
18
  import path from 'path';
19
+ import { createRequire } from 'module';
19
20
  import yargs from 'yargs';
20
21
  import { hideBin } from 'yargs/helpers';
21
22
 
23
+ import initialBuild from './processes/initialBuild.mjs';
24
+ import installPlugins from './processes/installPlugins.mjs';
22
25
  import lowdefyBuild from './processes/lowdefyBuild.mjs';
23
26
  import nextBuild from './processes/nextBuild.mjs';
24
- import installPlugins from './processes/installPlugins.mjs';
25
- import startServerProcess from './processes/startServerProcess.mjs';
27
+ import readDotEnv from './processes/readDotEnv.mjs';
26
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';
27
32
 
28
- const argv = yargs(hideBin(process.argv)).argv;
33
+ const argv = yargs(hideBin(process.argv)).array('watch').array('watchIgnore').argv;
34
+ const require = createRequire(import.meta.url);
29
35
 
30
36
  async function getContext() {
31
- const { packageManager = 'npm', verbose = false } = argv;
37
+ const env = process.env;
38
+
32
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
+ },
33
45
  directories: {
34
46
  build: path.resolve(process.cwd(), './build'),
35
- config: path.resolve(
36
- argv.configDirectory || process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()
37
- ),
47
+ config: path.resolve(argv.configDirectory || env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()),
38
48
  server: process.cwd(),
39
49
  },
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
- }
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,
53
61
  },
54
- verbose,
62
+ packageManager: argv.packageManager || env.LOWDEFY_PACKAGE_MANAGER || 'npm',
63
+ version: env.npm_package_version,
55
64
  };
65
+
66
+ context.initialBuild = initialBuild(context);
56
67
  context.installPlugins = installPlugins(context);
57
68
  context.lowdefyBuild = lowdefyBuild(context);
58
69
  context.nextBuild = nextBuild(context);
70
+ context.readDotEnv = readDotEnv(context);
59
71
  context.reloadClients = reloadClients(context);
72
+ context.restartServer = restartServer(context);
73
+ context.shutdownServer = shutdownServer(context);
74
+ context.startWatchers = startWatchers(context);
60
75
 
61
76
  return context;
62
77
  }
@@ -15,10 +15,13 @@
15
15
  limitations under the License.
16
16
  */
17
17
 
18
- async function initialBuild(context) {
19
- await context.lowdefyBuild();
20
- await context.installPlugins();
21
- await context.nextBuild();
18
+ function initialBuild(context) {
19
+ return async () => {
20
+ await context.lowdefyBuild();
21
+ await context.installPlugins();
22
+ await context.nextBuild();
23
+ await context.readDotEnv();
24
+ };
22
25
  }
23
26
 
24
27
  export default initialBuild;
@@ -21,14 +21,14 @@ const args = {
21
21
  yarn: ['install'],
22
22
  };
23
23
 
24
- function installPlugins({ packageManager, verbose }) {
24
+ function installPlugins({ packageManager, options }) {
25
25
  return async () => {
26
26
  console.log('Installing plugins...');
27
27
  await spawnProcess({
28
28
  logger: console,
29
29
  command: packageManager, // npm or yarn
30
30
  args: args[packageManager],
31
- silent: !verbose,
31
+ silent: !options.verbose,
32
32
  });
33
33
  };
34
34
  }
@@ -16,15 +16,16 @@
16
16
 
17
17
  import { spawnProcess } from '@lowdefy/node-utils';
18
18
 
19
- function lowdefyBuild({ packageManager, directories }) {
19
+ function lowdefyBuild({ bin, directories, options }) {
20
20
  return async () => {
21
21
  await spawnProcess({
22
+ command: 'node',
23
+ args: [bin.lowdefyBuild],
22
24
  logger: console,
23
- args: ['run', 'build:lowdefy'],
24
- command: packageManager,
25
25
  processOptions: {
26
26
  env: {
27
27
  ...process.env,
28
+ LOWDEFY_BUILD_REF_RESOLVER: options.refResolver,
28
29
  LOWDEFY_DIRECTORY_BUILD: directories.build,
29
30
  LOWDEFY_DIRECTORY_CONFIG: directories.config,
30
31
  LOWDEFY_DIRECTORY_SERVER: process.cwd(),
@@ -16,14 +16,14 @@
16
16
 
17
17
  import { spawnProcess } from '@lowdefy/node-utils';
18
18
 
19
- function nextBuild({ packageManager, verbose }) {
19
+ function nextBuild({ bin, options }) {
20
20
  return async () => {
21
21
  console.log('Building app...');
22
22
  await spawnProcess({
23
23
  logger: console,
24
- args: ['run', 'build:next'],
25
- command: packageManager,
26
- silent: !verbose,
24
+ command: 'node',
25
+ args: [bin.next, 'build'],
26
+ silent: !options.verbose,
27
27
  });
28
28
  };
29
29
  }
@@ -14,15 +14,15 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import setupWatcher from './setupWatcher.mjs';
17
+ import path from 'path';
18
+ import dotenv from 'dotenv';
19
+ import { readFile } from '@lowdefy/node-utils';
18
20
 
19
- async function configWatcher(context) {
20
- const callback = async () => {
21
- await context.lowdefyBuild();
22
- context.reloadClients();
21
+ function readDotEnv(context) {
22
+ return async () => {
23
+ const dotEnv = await readFile(path.join(context.directories.config, '.env'));
24
+ context.serverEnv = dotenv.parse(dotEnv || '');
23
25
  };
24
- // TODO: Add ignored and watch paths
25
- return setupWatcher({ callback, watchPaths: [context.directories.config] });
26
26
  }
27
27
 
28
- export default configWatcher;
28
+ export default readDotEnv;
@@ -19,7 +19,7 @@ import { writeFile } from '@lowdefy/node-utils';
19
19
 
20
20
  function reloadClients({ directories }) {
21
21
  return async () => {
22
- await writeFile({ filePath: path.join(directories.build, 'reload'), content: `${Date.now()}` });
22
+ await writeFile(path.join(directories.build, 'reload'), `${Date.now()}`);
23
23
  };
24
24
  }
25
25
 
@@ -14,21 +14,14 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import spawnProcess from '../spawnProcess.mjs';
17
+ import startNextServer from './startNextServer.mjs';
18
18
 
19
- function startServerProcess(context) {
20
- context.serverProcess = spawnProcess({
21
- logger: console,
22
- command: context.packageManager,
23
- args: ['run', 'next', 'start'],
24
- silent: false,
25
- });
26
- context.serverProcess.on('exit', (code) => {
27
- if (code !== 0) {
28
- context.serverProcessPromise.reject(new Error('Server error.'));
29
- }
30
- context.serverProcessPromise.resolve();
31
- });
19
+ function restartServer(context) {
20
+ return () => {
21
+ context.shutdownServer(); // Is this needed here?
22
+ console.log('Restarting server...');
23
+ startNextServer(context);
24
+ };
32
25
  }
33
26
 
34
- export default startServerProcess;
27
+ export default restartServer;