@lowdefy/server-dev 4.0.0-alpha.6 → 4.0.0-alpha.9
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/next.config.js +6 -4
- package/package.json +36 -36
- package/src/components/App.js +0 -55
- package/src/components/Context.js +0 -62
- package/src/components/Head.js +0 -28
- package/src/components/LowdefyContext.js +0 -50
- package/src/components/Page.js +0 -54
- package/src/components/Reload.js +0 -43
- package/src/components/block/Block.js +0 -57
- package/src/components/block/CategorySwitch.js +0 -120
- package/src/components/block/Container.js +0 -87
- package/src/components/block/List.js +0 -94
- package/src/components/block/LoadingBlock.js +0 -22
- package/src/components/block/MountEvents.js +0 -46
- package/src/components/components.js +0 -25
- package/src/manager/BatchChanges.mjs +0 -66
- package/src/manager/getContext.mjs +0 -64
- package/src/manager/initialBuild.mjs +0 -24
- package/src/manager/processes/installPlugins.mjs +0 -36
- package/src/manager/processes/lowdefyBuild.mjs +0 -38
- package/src/manager/processes/nextBuild.mjs +0 -31
- package/src/manager/processes/reloadClients.mjs +0 -26
- package/src/manager/processes/startServer.mjs +0 -31
- package/src/manager/processes/startServerProcess.mjs +0 -34
- package/src/manager/run.mjs +0 -41
- package/src/manager/spawnProcess.mjs +0 -55
- package/src/manager/watchers/configWatcher.mjs +0 -28
- package/src/manager/watchers/envWatcher.mjs +0 -32
- package/src/manager/watchers/setupWatcher.mjs +0 -43
- package/src/manager/watchers/startWatchers.mjs +0 -64
- package/src/pages/404.js +0 -19
- package/src/pages/[pageId].js +0 -19
- package/src/pages/_app.js +0 -37
- package/src/pages/_document.js +0 -38
- package/src/pages/api/auth/[...nextauth].js +0 -28
- package/src/pages/api/page/[pageId].js +0 -29
- package/src/pages/api/ping.js +0 -19
- package/src/pages/api/reload.js +0 -52
- package/src/pages/api/request/[pageId]/[requestId].js +0 -44
- package/src/pages/api/root.js +0 -25
- package/src/pages/index.js +0 -19
- package/src/utils/callRequest.js +0 -27
- package/src/utils/request.js +0 -36
- package/src/utils/setPageId.js +0 -33
- package/src/utils/setupLink.js +0 -44
- package/src/utils/useMutateCache.js +0 -34
- package/src/utils/usePageConfig.js +0 -32
- package/src/utils/useRootConfig.js +0 -29
- package/src/utils/waitForRestartedServer.js +0 -32
|
@@ -1,94 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,46 +0,0 @@
|
|
|
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;
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
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;
|
|
@@ -1,64 +0,0 @@
|
|
|
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;
|
|
@@ -1,24 +0,0 @@
|
|
|
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;
|
|
@@ -1,36 +0,0 @@
|
|
|
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;
|
|
@@ -1,38 +0,0 @@
|
|
|
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;
|
|
@@ -1,31 +0,0 @@
|
|
|
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;
|
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
|
@@ -1,31 +0,0 @@
|
|
|
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 startServerProcess from './startServerProcess.mjs';
|
|
19
|
-
|
|
20
|
-
async function startServer(context) {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
context.serverProcessPromise = { resolve, reject };
|
|
23
|
-
try {
|
|
24
|
-
startServerProcess(context);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
reject(error);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default startServer;
|
|
@@ -1,34 +0,0 @@
|
|
|
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 '../spawnProcess.mjs';
|
|
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
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default startServerProcess;
|
package/src/manager/run.mjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
import { wait } from '@lowdefy/helpers';
|
|
19
|
-
import opener from 'opener';
|
|
20
|
-
import getContext from './getContext.mjs';
|
|
21
|
-
import initialBuild from './initialBuild.mjs';
|
|
22
|
-
import startServer from './processes/startServer.mjs';
|
|
23
|
-
import startWatchers from './watchers/startWatchers.mjs';
|
|
24
|
-
|
|
25
|
-
async function run() {
|
|
26
|
-
const context = await getContext();
|
|
27
|
-
await initialBuild(context);
|
|
28
|
-
await startWatchers(context);
|
|
29
|
-
try {
|
|
30
|
-
const serverPromise = startServer(context);
|
|
31
|
-
await wait(800);
|
|
32
|
-
// TODO: set correct port
|
|
33
|
-
opener(`http://localhost:3000`);
|
|
34
|
-
await serverPromise;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
context.shutdownServer();
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
run();
|
|
@@ -1,55 +0,0 @@
|
|
|
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 { spawn } from 'child_process';
|
|
18
|
-
|
|
19
|
-
function spawnProcess({ logger, command, args, processOptions, silent }) {
|
|
20
|
-
const process = spawn(command, args, processOptions);
|
|
21
|
-
|
|
22
|
-
process.stdout.on('data', (data) => {
|
|
23
|
-
if (!silent) {
|
|
24
|
-
data
|
|
25
|
-
.toString('utf8')
|
|
26
|
-
.split('\n')
|
|
27
|
-
.forEach((line) => {
|
|
28
|
-
if (line) {
|
|
29
|
-
logger.log(line);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
process.stderr.on('data', (data) => {
|
|
36
|
-
if (!silent) {
|
|
37
|
-
data
|
|
38
|
-
.toString('utf8')
|
|
39
|
-
.split('\n')
|
|
40
|
-
.forEach((line) => {
|
|
41
|
-
if (line) {
|
|
42
|
-
logger.warn(line);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
process.on('error', (error) => {
|
|
49
|
-
throw error;
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return process;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default spawnProcess;
|
|
@@ -1,28 +0,0 @@
|
|
|
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 setupWatcher from './setupWatcher.mjs';
|
|
18
|
-
|
|
19
|
-
async function configWatcher(context) {
|
|
20
|
-
const callback = async () => {
|
|
21
|
-
await context.lowdefyBuild();
|
|
22
|
-
context.reloadClients();
|
|
23
|
-
};
|
|
24
|
-
// TODO: Add ignored and watch paths
|
|
25
|
-
return setupWatcher({ callback, watchPaths: [context.directories.config] });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default configWatcher;
|