lowdefy 3.23.2 → 4.0.0-alpha.10
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/dist/commands/build/build.js +58 -0
- package/dist/commands/dev/dev.js +46 -0
- package/dist/commands/dev/runDevServer.js +39 -0
- package/dist/commands/init/init.js +36 -0
- package/dist/commands/init/lowdefyFile.js +67 -0
- package/dist/commands/start/runStart.js +36 -0
- package/dist/commands/start/start.js +27 -0
- package/dist/index.js +42 -1
- package/dist/utils/BatchChanges.js +61 -0
- package/dist/utils/addCustomPluginsAsDeps.js +32 -0
- package/dist/utils/checkForUpdatedVersions.js +53 -0
- package/dist/utils/copyPluginsFolder.js +23 -0
- package/dist/utils/createPrint.js +73 -0
- package/dist/utils/errorHandler.js +49 -0
- package/dist/utils/fetchNpmTarball.js +56 -0
- package/dist/utils/findOpenPort.js +58 -0
- package/dist/utils/getCliJson.js +32 -0
- package/dist/utils/getDirectories.js +31 -0
- package/dist/utils/getLowdefyYaml.js +57 -0
- package/dist/utils/getOptions.js +23 -0
- package/dist/utils/getPackageManager.js +54 -0
- package/dist/utils/getSendTelemetry.js +54 -0
- package/dist/utils/getServer.js +45 -0
- package/dist/utils/installServer.js +43 -0
- package/dist/utils/runCommand.js +41 -0
- package/dist/utils/runLowdefyBuild.js +43 -0
- package/dist/utils/runNextBuild.js +36 -0
- package/dist/utils/startUp.js +48 -0
- package/package.json +22 -47
- package/dist/shell/185.59f79d0f067f50c8b219.js +0 -1
- package/dist/shell/246.b57dcf8b9c7a314f7bb9.js +0 -2
- package/dist/shell/246.b57dcf8b9c7a314f7bb9.js.LICENSE.txt +0 -8
- package/dist/shell/454.a5de9976bd8feff1520a.js +0 -2
- package/dist/shell/454.a5de9976bd8feff1520a.js.LICENSE.txt +0 -14
- package/dist/shell/612.7f060bf72e99bef9b828.js +0 -1
- package/dist/shell/625.859c7a1f9e198e3ae56f.js +0 -1
- package/dist/shell/706.055a587fb77f64a5299e.js +0 -2
- package/dist/shell/706.055a587fb77f64a5299e.js.LICENSE.txt +0 -8
- package/dist/shell/909.623901103ad312dc3ad4.js +0 -2
- package/dist/shell/909.623901103ad312dc3ad4.js.LICENSE.txt +0 -45
- package/dist/shell/922.8370fab8ada1985a0f4f.js +0 -2
- package/dist/shell/922.8370fab8ada1985a0f4f.js.LICENSE.txt +0 -14
- package/dist/shell/index.html +0 -58
- package/dist/shell/main.a0212229781d28e55f9b.js +0 -1
- package/dist/shell/public/apple-touch-icon.png +0 -0
- package/dist/shell/public/icon-32.png +0 -0
- package/dist/shell/public/icon-512.png +0 -0
- package/dist/shell/public/icon.svg +0 -17
- package/dist/shell/public/logo-dark-theme.png +0 -0
- package/dist/shell/public/logo-light-theme.png +0 -0
- package/dist/shell/public/logo-square-dark-theme.png +0 -0
- package/dist/shell/public/logo-square-light-theme.png +0 -0
- package/dist/shell/public/manifest.webmanifest +0 -16
- package/dist/shell/runtime.254c3f4383f818e0d6a3.js +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import addCustomPluginsAsDeps from '../../utils/addCustomPluginsAsDeps.js';
|
|
16
|
+
import copyPluginsFolder from '../../utils/copyPluginsFolder.js';
|
|
17
|
+
import getServer from '../../utils/getServer.js';
|
|
18
|
+
import installServer from '../../utils/installServer.js';
|
|
19
|
+
import runLowdefyBuild from '../../utils/runLowdefyBuild.js';
|
|
20
|
+
import runNextBuild from '../../utils/runNextBuild.js';
|
|
21
|
+
async function build({ context }) {
|
|
22
|
+
context.print.info('Starting build.');
|
|
23
|
+
const directory = context.directories.server;
|
|
24
|
+
await getServer({
|
|
25
|
+
context,
|
|
26
|
+
packageName: '@lowdefy/server',
|
|
27
|
+
directory
|
|
28
|
+
});
|
|
29
|
+
await copyPluginsFolder({
|
|
30
|
+
context,
|
|
31
|
+
directory
|
|
32
|
+
});
|
|
33
|
+
await addCustomPluginsAsDeps({
|
|
34
|
+
context,
|
|
35
|
+
directory
|
|
36
|
+
});
|
|
37
|
+
await installServer({
|
|
38
|
+
context,
|
|
39
|
+
directory
|
|
40
|
+
});
|
|
41
|
+
await runLowdefyBuild({
|
|
42
|
+
context,
|
|
43
|
+
directory
|
|
44
|
+
});
|
|
45
|
+
await installServer({
|
|
46
|
+
context,
|
|
47
|
+
directory
|
|
48
|
+
});
|
|
49
|
+
await runNextBuild({
|
|
50
|
+
context,
|
|
51
|
+
directory
|
|
52
|
+
});
|
|
53
|
+
await context.sendTelemetry({
|
|
54
|
+
sendTypes: true
|
|
55
|
+
});
|
|
56
|
+
context.print.succeed(`Build successful.`);
|
|
57
|
+
}
|
|
58
|
+
export default build;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import addCustomPluginsAsDeps from '../../utils/addCustomPluginsAsDeps.js';
|
|
16
|
+
import copyPluginsFolder from '../../utils/copyPluginsFolder.js';
|
|
17
|
+
import installServer from '../../utils/installServer.js';
|
|
18
|
+
import runDevServer from './runDevServer.js';
|
|
19
|
+
import getServer from '../../utils/getServer.js';
|
|
20
|
+
async function dev({ context }) {
|
|
21
|
+
const directory = context.directories.dev;
|
|
22
|
+
context.print.info('Starting development server.');
|
|
23
|
+
await getServer({
|
|
24
|
+
context,
|
|
25
|
+
packageName: '@lowdefy/server-dev',
|
|
26
|
+
directory
|
|
27
|
+
});
|
|
28
|
+
await copyPluginsFolder({
|
|
29
|
+
context,
|
|
30
|
+
directory
|
|
31
|
+
});
|
|
32
|
+
await addCustomPluginsAsDeps({
|
|
33
|
+
context,
|
|
34
|
+
directory
|
|
35
|
+
});
|
|
36
|
+
await installServer({
|
|
37
|
+
context,
|
|
38
|
+
directory
|
|
39
|
+
});
|
|
40
|
+
context.sendTelemetry();
|
|
41
|
+
await runDevServer({
|
|
42
|
+
context,
|
|
43
|
+
directory
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export default dev;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
+
async function runDevServer({ context , directory }) {
|
|
17
|
+
await spawnProcess({
|
|
18
|
+
logger: context.print,
|
|
19
|
+
args: [
|
|
20
|
+
'run',
|
|
21
|
+
'start'
|
|
22
|
+
],
|
|
23
|
+
command: context.packageManager,
|
|
24
|
+
processOptions: {
|
|
25
|
+
cwd: directory,
|
|
26
|
+
env: {
|
|
27
|
+
...process.env,
|
|
28
|
+
LOWDEFY_BUILD_REF_RESOLVER: context.options.refResolver,
|
|
29
|
+
LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
|
|
30
|
+
LOWDEFY_PACKAGE_MANAGER: context.packageManager,
|
|
31
|
+
LOWDEFY_SERVER_DEV_WATCH: JSON.stringify(context.options.watch),
|
|
32
|
+
LOWDEFY_SERVER_DEV_WATCH_IGNORE: JSON.stringify(context.options.watchIgnore),
|
|
33
|
+
PORT: context.options.port
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
silent: false
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export default runDevServer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import path from 'path';
|
|
16
|
+
import fs from 'fs';
|
|
17
|
+
import { writeFile } from '@lowdefy/node-utils';
|
|
18
|
+
import lowdefyFile from './lowdefyFile.js';
|
|
19
|
+
async function init({ context }) {
|
|
20
|
+
const lowdefyFilePath = path.resolve('./lowdefy.yaml');
|
|
21
|
+
const fileExists = fs.existsSync(lowdefyFilePath);
|
|
22
|
+
if (fileExists) {
|
|
23
|
+
throw new Error('Cannot initialize a Lowdefy project, a "lowdefy.yaml" file already exists');
|
|
24
|
+
}
|
|
25
|
+
context.print.log(`Initializing Lowdefy project`);
|
|
26
|
+
await writeFile(lowdefyFilePath, lowdefyFile({
|
|
27
|
+
version: context.cliVersion
|
|
28
|
+
}));
|
|
29
|
+
context.print.log(`Created 'lowdefy.yaml'.`);
|
|
30
|
+
await writeFile(path.resolve('./.gitignore'), `.lowdefy/**
|
|
31
|
+
.env`);
|
|
32
|
+
context.print.log(`Created '.gitignore'.`);
|
|
33
|
+
await context.sendTelemetry();
|
|
34
|
+
context.print.succeed(`Project initialized.`);
|
|
35
|
+
}
|
|
36
|
+
export default init;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ export default (({ version })=>`
|
|
16
|
+
lowdefy: ${version}
|
|
17
|
+
name: Lowdefy starter
|
|
18
|
+
|
|
19
|
+
pages:
|
|
20
|
+
- id: welcome
|
|
21
|
+
type: PageHeaderMenu
|
|
22
|
+
properties:
|
|
23
|
+
title: Welcome
|
|
24
|
+
areas:
|
|
25
|
+
content:
|
|
26
|
+
justify: center
|
|
27
|
+
blocks:
|
|
28
|
+
- id: content_card
|
|
29
|
+
type: Card
|
|
30
|
+
style:
|
|
31
|
+
maxWidth: 800
|
|
32
|
+
blocks:
|
|
33
|
+
- id: content
|
|
34
|
+
type: Result
|
|
35
|
+
properties:
|
|
36
|
+
title: Welcome to your Lowdefy app
|
|
37
|
+
subTitle: We are excited to see what you are going to build
|
|
38
|
+
icon:
|
|
39
|
+
name: AiOutlineHeart
|
|
40
|
+
color: '#f00'
|
|
41
|
+
areas:
|
|
42
|
+
extra:
|
|
43
|
+
blocks:
|
|
44
|
+
- id: docs_button
|
|
45
|
+
type: Button
|
|
46
|
+
properties:
|
|
47
|
+
size: large
|
|
48
|
+
title: Let's build something
|
|
49
|
+
color: '#1890ff'
|
|
50
|
+
events:
|
|
51
|
+
onClick:
|
|
52
|
+
- id: link_to_docs
|
|
53
|
+
type: Link
|
|
54
|
+
params:
|
|
55
|
+
url: https://docs.lowdefy.com
|
|
56
|
+
newTab: true
|
|
57
|
+
footer:
|
|
58
|
+
blocks:
|
|
59
|
+
- id: footer
|
|
60
|
+
type: Paragraph
|
|
61
|
+
properties:
|
|
62
|
+
type: secondary
|
|
63
|
+
content: |
|
|
64
|
+
Made by a Lowdefy 🤖
|
|
65
|
+
|
|
66
|
+
`
|
|
67
|
+
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
+
async function runStart({ context , directory }) {
|
|
17
|
+
context.print.spin(`Running "${context.packageManager} run start".`);
|
|
18
|
+
await spawnProcess({
|
|
19
|
+
logger: context.print,
|
|
20
|
+
args: [
|
|
21
|
+
'run',
|
|
22
|
+
'start'
|
|
23
|
+
],
|
|
24
|
+
command: context.packageManager,
|
|
25
|
+
processOptions: {
|
|
26
|
+
cwd: directory,
|
|
27
|
+
env: {
|
|
28
|
+
...process.env,
|
|
29
|
+
LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
|
|
30
|
+
PORT: context.options.port
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
silent: false
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export default runStart;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import runStart from './runStart.js';
|
|
16
|
+
// TODO: Handle "spawn yarn ENOENT" error if no built server exists.
|
|
17
|
+
async function build({ context }) {
|
|
18
|
+
context.print.info('Starting server.');
|
|
19
|
+
context.sendTelemetry({
|
|
20
|
+
sendTypes: true
|
|
21
|
+
});
|
|
22
|
+
await runStart({
|
|
23
|
+
context,
|
|
24
|
+
directory: context.directories.server
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export default build;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
(()=>{"use strict";var e={153:(e,t,o)=>{o.r(t);const r=require("commander");var n=o.n(r);const i=JSON.parse('{"name":"lowdefy","version":"3.23.2","license":"Apache-2.0","description":"Lowdefy CLI","homepage":"https://lowdefy.com","keywords":["lowdefy","cli"],"bugs":{"url":"https://github.com/lowdefy/lowdefy/issues"},"contributors":[{"name":"Sam Tolmay","url":"https://github.com/SamTolmay"},{"name":"Gerrie van Wyk","url":"https://github.com/Gervwyk"}],"repository":{"type":"git","url":"https://github.com/lowdefy/lowdefy.git"},"bin":"dist/index.js","files":["dist/*"],"main":"dist/index.js","scripts":{"build":"yarn webpack","clean":"rm -rf dist && rm -rf .lowdefy","cli":"yarn node ./dist/index.js","cli:build":"yarn build && yarn node ./dist/index.js","prepare":"yarn build","test":"FORCE_COLOR=3 jest --coverage","webpack":"webpack --config webpack.config.js"},"dependencies":{"@lowdefy/helpers":"3.23.2","@lowdefy/node-utils":"3.23.2","apollo-server-express":"2.25.0","axios":"0.21.4","chalk":"4.1.1","chokidar":"3.5.1","commander":"7.2.0","decompress":"4.2.1","decompress-targz":"4.1.1","dotenv":"10.0.0","express":"4.17.1","fs-extra":"10.0.0","graphql":"15.5.0","js-yaml":"4.1.0","mssql":"7.1.0","mysql":"2.18.1","opener":"1.5.2","ora":"5.4.0","pg":"8.6.0","reload":"3.1.1","saslprep":"1.0.3","sqlite3":"5.0.2","uuid":"8.3.2"},"devDependencies":{"@babel/cli":"7.14.3","@babel/core":"7.14.3","@babel/preset-env":"7.14.4","@babel/preset-react":"7.13.13","@lowdefy/block-tools":"3.23.2","babel-jest":"26.6.3","babel-loader":"8.2.2","clean-webpack-plugin":"3.0.0","copy-webpack-plugin":"9.0.0","css-loader":"5.2.6","html-webpack-plugin":"5.3.1","jest":"26.6.3","react":"17.0.2","react-dom":"17.0.2","style-loader":"2.0.0","webpack":"5.38.1","webpack-cli":"4.7.0"},"publishConfig":{"access":"public"}}'),a=require("path");var s=o.n(a);const c=require("fs-extra");var l=o.n(c);const d=require("fs");var p=o.n(d);const u=require("axios");var y=o.n(u);const f=require("decompress");var w=o.n(f);const h=require("decompress-targz");var m=o.n(h);const g=async function({packageName:e,version:t,directory:o}){const r=`https://registry.npmjs.org/${e}`;let n,i;try{n=await y().get(r)}catch(t){if(t.response&&404===t.response.status)throw new Error(`Package "${e}" could not be found at ${r}.`);throw t}if(!n||!n.data)throw new Error(`Package "${e}" could not be found at ${r}.`);if(!n.data.versions[t])throw new Error(`Invalid version. "${e}" does not have version "${t}".`);try{i=await y().get(n.data.versions[t].dist.tarball,{responseType:"arraybuffer"})}catch(o){if(o.response&&404===o.response.status)throw new Error(`Package "${e}" tarball could not be found at ${n.data.versions[t].dist.tarball}.`);throw o}if(!i||!i.data)throw new Error(`Package "${e}" tarball could not be found at ${n.data.versions[t].dist.tarball}.`);await w()(i.data,o,{plugins:[m()()]})},v=async function({module:e,packageName:t,version:r,context:n}){const i=r.replace(/[-.]/g,"_"),a=s().resolve(n.cacheDirectory,`scripts/${e}/${i}`);return p().existsSync(s().resolve(a,"package/dist/remoteEntry.js"))||(n.print.spin(`Fetching ${t}@${r} to cache.`),await g({packageName:t,version:r,directory:a}),n.print.log(`Fetched ${t}@${r} to cache.`)),async function({directory:e,module:t,remoteEntry:r="remoteEntry.js"}){return(await(async e=>(o.S.default&&await o.I("default"),new Promise((t=>{const r=require(e);new Promise((e=>{o.S.default?e(r.init(o.S.default)):e()})).then((()=>{t(r)}))}))))(s().resolve(`${e}/${r}`))).get(t).then((e=>e()))}({directory:s().resolve(a,"package/dist"),module:`./${e}`})},b=require("child_process"),x=require("@lowdefy/node-utils"),D=require("opener");var k=o.n(D);const _=require("chokidar");var S=o.n(_);const L=class{constructor({fn:e,context:t,minDelay:o}){this.fn=e,this.context=t,this.delay=o||500,this.minDelay=o||500,this._call=this._call.bind(this)}newChange(){this.delay=this.minDelay,this._startTimer()}_startTimer(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(this._call,this.delay)}async _call(){try{await this.fn()}catch(e){this.context.print.error(e.message,{timestamp:!0}),this.delay*=2,this.context.print.warn(`Retrying in ${this.delay/1e3}s.`,{timestamp:!0}),this._startTimer()}}},$=require("express");var C=o.n($);const P=require("reload");var j=o.n(P);const q=require("@lowdefy/helpers"),T=require("net");var F=o.n(T);const O=async function({context:e,gqlServer:t}){const o=async(t,o)=>{let r=await(0,x.readFile)(s().resolve(__dirname,"shell/index.html")),n=await(0,x.readFile)(s().resolve(e.outputDirectory,"app.json"));n=JSON.parse(n),r=r.replace("\x3c!-- __LOWDEFY_APP_HEAD_HTML__ --\x3e",(0,q.get)(n,"html.appendHead",{default:""})),r=r.replace("\x3c!-- __LOWDEFY_APP_BODY_HTML__ --\x3e",(0,q.get)(n,"html.appendBody",{default:""})),o.send(r)},r=C()();r.set("port",parseInt(e.options.port)),t.applyMiddleware({app:r,path:"/api/graphql"});const n=await async function(){return new Promise(((e,t)=>{const o=F().createServer();o.on("error",t),o.listen(0,(()=>{const{port:t}=o.address();o.on("close",e.bind(null,t)),o.close()}))}))}(),i=await j()(r,{route:"/api/dev/reload.js",port:n});return r.get("/",o),r.use("/public",C().static(s().resolve(process.cwd(),"public"))),r.use(C().static(s().resolve(__dirname,"shell"))),r.use("/api/dev/rendererRemoteEntryUrl",((t,o)=>{let r;r=e.options.blocksServerUrl?`${e.options.blocksServerUrl}/renderer/remoteEntry.js`:`https://blocks-cdn.lowdefy.com/v${e.lowdefyVersion}/renderer/remoteEntry.js`,o.json(r)})),r.use(o),{expressApp:r,reloadFn:i.reload}},E=require("apollo-server-express"),N=require("dotenv");var I=o.n(N);const V=require("js-yaml");var A=o.n(V);const R=async function({baseDirectory:e,command:t}){let o,r=await(0,x.readFile)(s().resolve(e,"lowdefy.yaml"));if(r||(r=await(0,x.readFile)(s().resolve(e,"lowdefy.yml"))),!r){if(!["init","clean-cache"].includes(t))throw new Error(`Could not find "lowdefy.yaml" file in specified base directory ${e}.`);return{cliConfig:{}}}try{o=A().load(r)}catch(e){throw new Error(`Could not parse "lowdefy.yaml" file. Received error ${e.message}.`)}if(!o.lowdefy)throw new Error('No version specified in "lowdefy.yaml" file. Specify a version in the "lowdefy" field.');if(!q.type.isString(o.lowdefy)||!o.lowdefy.match(/\d+\.\d+\.\d+(-\w+\.\d+)?/))throw new Error(`Version number specified in "lowdefy.yaml" file is not valid. Received ${JSON.stringify(o.lowdefy)}.`);return{lowdefyVersion:o.lowdefy,cliConfig:(0,q.get)(o,"cli",{default:{}})}},{version:M}=i,U=`\nlowdefy: ${M}\nname: Lowdefy starter\n\npages:\n - id: welcome\n type: PageHeaderMenu\n properties:\n title: Welcome\n areas:\n content:\n justify: center\n blocks:\n - id: content_card\n type: Card\n style:\n maxWidth: 800\n blocks:\n - id: content\n type: Result\n properties:\n title: Welcome to your Lowdefy app\n subTitle: We are excited to see what you are going to build\n icon:\n name: HeartTwoTone\n color: '#f00'\n areas:\n extra:\n blocks:\n - id: docs_button\n type: Button\n properties:\n size: large\n title: Let's build something\n color: '#1890ff'\n events:\n onClick:\n - id: link_to_docs\n type: Link\n params:\n url: https://docs.lowdefy.com\n newTab: true\n footer:\n blocks:\n - id: footer\n type: Paragraph\n properties:\n type: secondary\n content: |\n Made by a Lowdefy 🤖\n\n`,B=require("ora");var H=o.n(B);const Y=require("chalk");var J=o.n(Y);let W;const z=function(){return W||("true"===process.env.CI?(W=function(){const{error:e,info:t,log:o,warn:r}=console;return{type:"basic",error:e,info:t,log:o,spin:o,succeed:o,warn:r}}(),W):(W=function(){const e=H()({spinner:"random",prefixText:()=>J().dim(function(){const e=new Date(Date.now()),t=e.getHours(),o=e.getMinutes(),r=e.getSeconds();return`${t>9?"":"0"}${t}:${o>9?"":"0"}${o}:${r>9?"":"0"}${r}`}()),color:"blue"});return{type:"ora",error:t=>e.fail(J().red(t)),info:t=>e.info(J().blue(t)),log:t=>e.start(t).stopAndPersist({symbol:"∙"}),spin:t=>e.start(t),succeed:t=>e.succeed(J().green(t)),warn:t=>e.warn(J().yellow(t))}}(),W))},{version:G}=i,K=require("uuid"),{version:Q}=i,X=async function({context:e,options:t={},command:o}){e.command=o.name(),e.cliVersion=Q,e.commandLineOptions=t,e.print=z(),e.baseDirectory=s().resolve(t.baseDirectory||process.cwd());const{cliConfig:r,lowdefyVersion:n}=await R(e);e.cliConfig=r,e.lowdefyVersion=n;const{appId:i}=await async function({baseDirectory:e}){const t=s().resolve(e,"./.lowdefy/cli.json"),o=await(0,x.readFile)(t);if(!o){const e=(0,K.v4)();return await(0,x.writeFile)({filePath:t,content:JSON.stringify({appId:e},null,2)}),{appId:e}}return JSON.parse(o)}(e);e.appId=i,e.options=function({commandLineOptions:e,cliConfig:t}){return{...t,...e}}(e);const{cacheDirectory:a,outputDirectory:c}=function({baseDirectory:e,options:t}){const o=s().resolve(e,"./.lowdefy/.cache");let r;return r=t.outputDirectory?s().resolve(t.outputDirectory):s().resolve(e,"./.lowdefy/build"),{cacheDirectory:o,outputDirectory:r}}(e);return e.cacheDirectory=a,e.outputDirectory=c,await async function({cliVersion:e,lowdefyVersion:t,print:o}){try{const r=(await y().get("https://registry.npmjs.org/lowdefy")).data["dist-tags"].latest;e!==r&&o.warn(`\n-------------------------------------------------------------\n You are using an outdated Lowdefy CLI.\n Please update to version ${r}.\n To always use the latest version, run 'npx lowdefy@latest'.\n-------------------------------------------------------------`),t&&t!==r&&o.warn(`\n-------------------------------------------------------------\n Your app is using an outdated Lowdefy version, ${t}.\n Please update your app to version ${r}.\n View the changelog here:\n https://github.com/lowdefy/lowdefy/blob/main/CHANGELOG.md\n-------------------------------------------------------------`)}catch(e){o.warn("Failed to check for latest Lowdefy version.")}}(e),e.sendTelemetry=function({appId:e,cliVersion:t,command:o,lowdefyVersion:r,options:n}){return n.disableTelemetry?()=>{}:async function({data:n={}}={}){try{await y().request({method:"post",url:"https://api.lowdefy.net/telemetry/cli",headers:{"User-Agent":`Lowdefy CLI v${t}`},data:{...n,app_id:e,cli_version:t,command:o,lowdefy_version:r}})}catch(e){}}}(e),q.type.isNone(n)?e.print.log(`Running 'lowdefy ${e.command}'.`):e.print.log(`Running 'lowdefy ${e.command}'. Lowdefy app version ${n}.`),e},Z=function(e){return async function(t,o){const r={};try{return await X({context:r,options:t,command:o}),await e({context:r})}catch(e){await async function({context:e,error:t}){z().error(t.message),e.disableTelemetry||await async function({error:e,context:t={}}){try{await y().request({method:"post",url:"https://api.lowdefy.net/errors",headers:{"User-Agent":`Lowdefy CLI v${G}`},data:{source:"cli",cliVersion:G,command:t.command,lowdefyVersion:t.lowdefyVersion,message:e.message,name:e.name,stack:e.stack}})}catch(e){}}({context:e,error:t})}({context:r,error:e})}}},{description:ee,version:te}=i;n().name("lowdefy").description(ee).version(te,"-v, --version"),n().command("build").description("Build a Lowdefy deployment.").usage("[options]").option("--base-directory <base-directory>","Change base directory. Default is the current working directory.").option("--blocks-server-url <blocks-server-url>","The URL from where Lowdefy blocks will be served.").option("--disable-telemetry","Disable telemetry.").option("--output-directory <output-directory>",'Change the directory to which build artifacts are saved. Default is "<base-directory>/.lowdefy/build".').option("--ref-resolver <ref-resolver-function-path>","Path to a JavaScript file containing a _ref resolver function to be used as the app default _ref resolver.").action(Z((async function({context:e}){const{default:t}=await v({module:"build",packageName:"@lowdefy/build",version:e.lowdefyVersion,context:e});e.print.log(`Cleaning block meta cache at "${s().resolve(e.cacheDirectory,"./meta")}".`),await l().emptyDir(s().resolve(e.cacheDirectory,"./meta")),e.print.info("Starting build."),await t({blocksServerUrl:e.options.blocksServerUrl,cacheDirectory:e.cacheDirectory,configDirectory:e.baseDirectory,logger:e.print,outputDirectory:e.outputDirectory,refResolver:e.options.refResolver}),await e.sendTelemetry(),e.print.log(`Build artifacts saved at ${e.outputDirectory}.`),e.print.succeed("Build successful.")}))),n().command("build-netlify").description("Build a Lowdefy deployment to deploy in netlify.").usage("[options]").option("--base-directory <base-directory>","Change base directory. Default is the current working directory.").option("--blocks-server-url <blocks-server-url>","The URL from where Lowdefy blocks will be served.").option("--disable-telemetry","Disable telemetry.").option("--ref-resolver <ref-resolver-function-path>","Path to a JavaScript file containing a _ref resolver function to be used as the app default _ref resolver.").action(Z((async function({context:e}){e.netlifyDir=s().resolve(e.baseDirectory,"./.lowdefy/netlify"),e.print.info("Starting build.");const t=await async function({context:e}){e.print.log("Fetching Lowdefy build script.");const{default:t}=await v({module:"build",packageName:"@lowdefy/build",version:e.lowdefyVersion,context:e});return e.print.log("Fetched Lowdefy build script."),t}({context:e});await async function({context:e,buildScript:t}){e.print.log("Starting Lowdefy build.");const o=s().resolve(e.netlifyDir,"./package/dist/functions/graphql/build");await t({blocksServerUrl:e.options.blocksServerUrl,cacheDirectory:e.cacheDirectory,configDirectory:e.baseDirectory,logger:e.print,outputDirectory:o,refResolver:e.options.refResolver}),e.print.log(`Build artifacts saved at ${o}.`)}({context:e,buildScript:t}),e.print.info("Installing Lowdefy server."),await async function({context:e}){e.print.log("Fetching Lowdefy Netlify server."),await g({packageName:"@lowdefy/server-netlify",version:e.lowdefyVersion,directory:e.netlifyDir}),e.print.log("Fetched Lowdefy Netlify server.")}({context:e}),await async function({context:e}){await l().copy(s().resolve(e.netlifyDir,"package/package.json"),s().resolve("./package.json")),await l().remove(s().resolve("./package-lock.json")),await l().remove(s().resolve("./package-lock.json")),await l().emptyDir(s().resolve("./node_modules")),e.print.log("npm install production.");let t=(0,b.spawnSync)("npm",["install","--production","--legacy-peer-deps"]);(function({context:e,processOutput:t,message:o}){if(1===t.status)throw e.print.error(t.stderr.toString("utf8")),new Error(o)})({context:e,processOutput:t,message:"Failed to npm install Netlify server."}),e.print.log("npm install successful."),e.print.log(t.stdout.toString("utf8"))}({context:e}),e.print.log("Moving artifacts."),await async function({context:e}){await l().copy(s().resolve(e.netlifyDir,"package/dist/shell"),s().resolve("./.lowdefy/publish")),e.print.log('Netlify publish artifacts moved to "./lowdefy/publish".')}({context:e}),await async function({context:e}){await l().copy(s().resolve(e.netlifyDir,"package/dist/functions"),s().resolve("./.lowdefy/functions")),e.print.log('Netlify functions artifacts moved to "./lowdefy/functions".')}({context:e}),await async function({context:e}){e.print.log("Moving public assets."),await l().ensureDir(s().resolve("./public")),await l().copy(s().resolve("./public"),s().resolve("./.lowdefy/publish/public")),e.print.log('Public assets moved to "./lowdefy/publish/public".')}({context:e}),e.print.log("Build artifacts."),await async function({context:e}){e.print.log("Starting Lowdefy index.html build.");let t=await(0,x.readFile)(s().resolve("./.lowdefy/functions/graphql/build/app.json"));t=JSON.parse(t);const o=s().resolve("./.lowdefy/publish/index.html");let r=await(0,x.readFile)(o);r=r.replace("\x3c!-- __LOWDEFY_APP_HEAD_HTML__ --\x3e",t.html.appendHead),r=r.replace("\x3c!-- __LOWDEFY_APP_BODY_HTML__ --\x3e",t.html.appendBody),await(0,x.writeFile)({filePath:o,content:r}),e.print.log("Lowdefy index.html build complete.")}({context:e}),await e.sendTelemetry({data:{netlify:"true"===process.env.NETLIFY}}),e.print.succeed("Netlify build completed successfully.")}))),n().command("clean-cache").description("Clean cached scripts and block meta descriptions.").usage("[options]").option("--base-directory <base-directory>","Change base directory. Default is the current working directory.").option("--disable-telemetry","Disable telemetry.").action(Z((async function({context:e}){e.print.log(`Cleaning cache at "${e.cacheDirectory}".`),await l().emptyDir(e.cacheDirectory),await e.sendTelemetry(),e.print.succeed("Cache cleaned.")}))),n().command("dev").description("Start a Lowdefy development server.").usage("[options]").option("--base-directory <base-directory>","Change base directory. Default is the current working directory.").option("--blocks-server-url <blocks-server-url>","The URL from where Lowdefy blocks will be served.").option("--disable-telemetry","Disable telemetry.").option("--port <port>","Change the port the server is hosted at. Default is 3000.").option("--ref-resolver <ref-resolver-function-path>","Path to a JavaScript file containing a _ref resolver function to be used as the app default _ref resolver.").option("--watch <paths...>","A list of paths to files or directories that should be watched for changes.").option("--watch-ignore <paths...>","A list of paths to files or directories that should be ignored by the file watcher. Globs are supported.").action(Z((async function({context:e}){await async function({context:e}){I().config({silent:!0}),e.options.port||(e.options.port=3e3),e.print.log(`Cleaning block meta cache at "${s().resolve(e.cacheDirectory,"./meta")}".`),await l().emptyDir(s().resolve(e.cacheDirectory,"./meta"))}({context:e});const t=async function({context:e}){const t=await async function({context:e}){const{default:t}=await v({module:"build",packageName:"@lowdefy/build",version:e.lowdefyVersion,context:e});return async function(){e.print.log("Building configuration."),await t({blocksServerUrl:e.options.blocksServerUrl,cacheDirectory:e.cacheDirectory,configDirectory:e.baseDirectory,logger:e.print,outputDirectory:e.outputDirectory,refResolver:e.options.refResolver}),e.print.succeed("Built successfully.")}}({context:e});try{await t()}catch(e){}return t}({context:e}),o=async function({context:e}){const t=await async function({context:e}){const{typeDefs:t,resolvers:o,createContext:r}=await v({module:"graphql",packageName:"@lowdefy/graphql-federated",version:e.lowdefyVersion,context:e}),n=r({CONFIGURATION_BASE_PATH:e.outputDirectory,development:!0,logger:console,getSecrets:(0,x.createGetSecretsFromEnv)()});return new E.ApolloServer({typeDefs:t,resolvers:o,context:n})}({context:e});return O({context:e,gqlServer:t})}({context:e}),[r,{expressApp:n,reloadFn:i}]=await Promise.all([t,o]);(function({build:e,context:t,reloadFn:o}){const{watch:r=[],watchIgnore:n=[]}=t.options,i=r.map((e=>s().resolve(e))),a=new L({fn:async()=>{await e(),o()},context:t}),c=S().watch([".",...i],{ignored:[/(^|[/\\])\../,...n],persistent:!0,ignoreInitial:!0});c.on("add",(()=>a.newChange())),c.on("change",(()=>a.newChange())),c.on("unlink",(()=>a.newChange()))})({build:r,context:e,reloadFn:i}),function({context:e}){const t=new L({fn:async()=>{e.print.warn(".env file changed. You should restart your development server."),process.exit()},context:e});S().watch("./.env",{persistent:!0}).on("change",(()=>t.newChange()))}({context:e}),function({context:e}){const t=new L({fn:async()=>{const{lowdefyVersion:t}=await R(e);t!==e.lowdefyVersion&&(e.print.warn("Lowdefy version changed. You should restart your development server."),process.exit())},context:e});S().watch("./lowdefy.yaml",{persistent:!0}).on("change",(()=>t.newChange()))}({context:e}),e.print.log("Starting Lowdefy development server.");const a=n.get("port");n.listen(a,(function(){e.print.info(`Development server listening on port ${a}`)})),k()(`http://localhost:${a}`),await e.sendTelemetry({data:{type:"startup"}})}))),n().command("init").description("Initialize a Lowdefy project.").usage("[options]").action(Z((async function({context:e}){const t=s().resolve("./lowdefy.yaml");if(l().existsSync(t))throw new Error('Cannot initialize a Lowdefy project, a "lowdefy.yaml" file already exists');e.print.log("Initializing Lowdefy project"),await(0,x.writeFile)({filePath:t,content:U}),e.print.log("Created 'lowdefy.yaml'."),await(0,x.writeFile)({filePath:s().resolve("./.gitignore"),content:".lowdefy/**\n.env"}),e.print.log("Created '.gitignore'."),await e.sendTelemetry(),e.print.succeed("Project initialized.")}))),n().parse(process.argv)}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,o),i.exports}o.m=e,o.c=t,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{o.S={};var e={},t={};o.I=(r,n)=>{n||(n=[]);var i=t[r];if(i||(i=t[r]={}),!(n.indexOf(i)>=0)){if(n.push(i),e[r])return e[r];o.o(o.S,r)||(o.S[r]={}),o.S[r];var a=[];return e[r]=a.length?Promise.all(a).then((()=>e[r]=1)):1}}})();var r=o(153),n=exports;for(var i in r)n[i]=r[i];r.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2022 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
|
+
*/ import { readFile } from '@lowdefy/node-utils';
|
|
17
|
+
import { Command } from 'commander';
|
|
18
|
+
import build from './commands/build/build.js';
|
|
19
|
+
import dev from './commands/dev/dev.js';
|
|
20
|
+
import init from './commands/init/init.js';
|
|
21
|
+
import start from './commands/start/start.js';
|
|
22
|
+
import runCommand from './utils/runCommand.js';
|
|
23
|
+
const packageJson = JSON.parse(await readFile(new URL('../package.json', import.meta.url).pathname));
|
|
24
|
+
const { description , version: cliVersion } = packageJson;
|
|
25
|
+
const program = new Command();
|
|
26
|
+
program.name('lowdefy').description(description).version(cliVersion, '-v, --version');
|
|
27
|
+
program.command('build').description('Build a Lowdefy production app.').usage(`[options]`).option('--config-directory <config-directory>', 'Change config directory. Default is the current working directory.').option('--disable-telemetry', 'Disable telemetry.').option('--output-directory <output-directory>', 'Change the directory to which build artifacts are saved. Default is "<config-directory>/.lowdefy".').option('--package-manager <package-manager>', 'The package manager to use. Options are "npm" or "yarn".').option('--ref-resolver <ref-resolver-function-path>', 'Path to a JavaScript file containing a _ref resolver function to be used as the app default _ref resolver.').option('--server-directory <server-directory>', 'Change the server directory. Default is "<config-directory>/.lowdefy/server".').action(runCommand({
|
|
28
|
+
cliVersion,
|
|
29
|
+
handler: build
|
|
30
|
+
}));
|
|
31
|
+
program.command('dev').description('Start a Lowdefy development server.').usage(`[options]`).option('--config-directory <config-directory>', 'Change config directory. Default is the current working directory.').option('--disable-telemetry', 'Disable telemetry.').option('--package-manager <package-manager>', 'The package manager to use. Options are "npm" or "yarn".').option('--port <port>', 'Change the port the development server is hosted at. Default is 3000.').option('--ref-resolver <ref-resolver-function-path>', 'Path to a JavaScript file containing a _ref resolver function to be used as the app default _ref resolver.').option('--watch <paths...>', 'A list of paths to files or directories that should be watched for changes. Globs are supported. Specify each path to watch separated by spaces.').option('--watch-ignore <paths...>', 'A list of paths to files or directories that should be ignored by the file watcher. Globs are supported. Specify each path to watch separated by spaces.').option('--dev-directory <dev-directory>', 'Change the development server directory. Default is "<config-directory>/.lowdefy/dev".').action(runCommand({
|
|
32
|
+
cliVersion,
|
|
33
|
+
handler: dev
|
|
34
|
+
}));
|
|
35
|
+
program.command('init').description('Initialize a Lowdefy project.').usage(`[options]`).action(runCommand({
|
|
36
|
+
cliVersion,
|
|
37
|
+
handler: init
|
|
38
|
+
}));
|
|
39
|
+
program.command('start').description('Start a Lowdefy production app.').usage(`[options]`).option('--config-directory <config-directory>', 'Change config directory. Default is the current working directory.').option('--disable-telemetry', 'Disable telemetry.').option('--output-directory <output-directory>', 'Change the directory to which build artifacts are saved. Default is "<config-directory>/.lowdefy".').option('--package-manager <package-manager>', 'The package manager to use. Options are "npm" or "yarn".').option('--port <port>', 'Change the port the server is hosted at. Default is 3000.').option('--server-directory <server-directory>', 'Change the server directory. Default is "<config-directory>/.lowdefy/server".').action(runCommand({
|
|
40
|
+
cliVersion,
|
|
41
|
+
handler: start
|
|
42
|
+
}));
|
|
43
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ let BatchChanges = class BatchChanges {
|
|
16
|
+
newChange(...args) {
|
|
17
|
+
this.args.push(args);
|
|
18
|
+
this.delay = this.minDelay;
|
|
19
|
+
this._startTimer();
|
|
20
|
+
}
|
|
21
|
+
_startTimer() {
|
|
22
|
+
if (this.timer) {
|
|
23
|
+
clearTimeout(this.timer);
|
|
24
|
+
}
|
|
25
|
+
if (this.running) {
|
|
26
|
+
this.repeat = true;
|
|
27
|
+
} else {
|
|
28
|
+
this.timer = setTimeout(this._call, this.delay);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async _call() {
|
|
32
|
+
this.running = true;
|
|
33
|
+
try {
|
|
34
|
+
const args = this.args;
|
|
35
|
+
this.args = [];
|
|
36
|
+
await this.fn(args);
|
|
37
|
+
this.running = false;
|
|
38
|
+
if (this.repeat) {
|
|
39
|
+
this.repeat = false;
|
|
40
|
+
this._call();
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
this.running = false;
|
|
44
|
+
this.context.print.error(error.message);
|
|
45
|
+
this.delay *= 2;
|
|
46
|
+
this.context.print.warn(`Retrying in ${this.delay / 1000}s.`);
|
|
47
|
+
this._startTimer();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
constructor({ fn , context , minDelay }){
|
|
51
|
+
this._call = this._call.bind(this);
|
|
52
|
+
this.args = [];
|
|
53
|
+
this.context = context;
|
|
54
|
+
this.delay = minDelay || 500;
|
|
55
|
+
this.fn = fn;
|
|
56
|
+
this.minDelay = minDelay || 500;
|
|
57
|
+
this.repeat = false;
|
|
58
|
+
this.running = false;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export default BatchChanges;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import path from 'path';
|
|
16
|
+
import { readFile, writeFile } from '@lowdefy/node-utils';
|
|
17
|
+
async function addCustomPluginsAsDeps({ context , directory }) {
|
|
18
|
+
const packageJsonPath = path.join(directory, 'package.json');
|
|
19
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath));
|
|
20
|
+
const devDependencies = packageJson.devDependencies;
|
|
21
|
+
Object.values(context.plugins).forEach((plugin)=>{
|
|
22
|
+
devDependencies[plugin.name] = plugin.version;
|
|
23
|
+
});
|
|
24
|
+
// Sort dependencies
|
|
25
|
+
packageJson.devDependencies = {};
|
|
26
|
+
Object.keys(devDependencies).sort().forEach((name)=>{
|
|
27
|
+
packageJson.devDependencies[name] = devDependencies[name];
|
|
28
|
+
});
|
|
29
|
+
const newPackageJsonContent = JSON.stringify(packageJson, null, 2).concat('\n');
|
|
30
|
+
await writeFile(packageJsonPath, newPackageJsonContent);
|
|
31
|
+
}
|
|
32
|
+
export default addCustomPluginsAsDeps;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import axios from 'axios';
|
|
16
|
+
async function checkForUpdatedVersions({ cliVersion , lowdefyVersion , print }) {
|
|
17
|
+
if (isExperimentalVersion(cliVersion) || isExperimentalVersion(lowdefyVersion)) {
|
|
18
|
+
print.warn(`
|
|
19
|
+
---------------------------------------------------
|
|
20
|
+
You are using an experimental version of Lowdefy.
|
|
21
|
+
Features may change at any time.
|
|
22
|
+
---------------------------------------------------`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const registryUrl = 'https://registry.npmjs.org/lowdefy';
|
|
26
|
+
try {
|
|
27
|
+
const packageInfo = await axios.get(registryUrl);
|
|
28
|
+
const latestVersion = packageInfo.data['dist-tags'].latest;
|
|
29
|
+
if (cliVersion !== latestVersion) {
|
|
30
|
+
print.warn(`
|
|
31
|
+
-------------------------------------------------------------
|
|
32
|
+
You are not using the latest version of the Lowdefy CLI.
|
|
33
|
+
Please update to version ${latestVersion}.
|
|
34
|
+
To always use the latest version, run 'npx lowdefy@latest'.
|
|
35
|
+
-------------------------------------------------------------`);
|
|
36
|
+
}
|
|
37
|
+
if (lowdefyVersion && lowdefyVersion !== latestVersion) {
|
|
38
|
+
print.warn(`
|
|
39
|
+
-------------------------------------------------------------
|
|
40
|
+
Your app is not using the latest Lowdefy version, ${lowdefyVersion}.
|
|
41
|
+
Please update your app to version ${latestVersion}.
|
|
42
|
+
View the changelog here:
|
|
43
|
+
https://github.com/lowdefy/lowdefy/blob/main/CHANGELOG.md
|
|
44
|
+
-------------------------------------------------------------`);
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
print.warn('Failed to check for latest Lowdefy version.');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function isExperimentalVersion(version) {
|
|
51
|
+
return version.includes('alpha') || version.includes('beta') || version.includes('rc');
|
|
52
|
+
}
|
|
53
|
+
export default checkForUpdatedVersions;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import path from 'path';
|
|
16
|
+
import fs from 'fs';
|
|
17
|
+
import { copyDirectory } from '@lowdefy/node-utils';
|
|
18
|
+
async function copyPluginsFolder({ context , directory }) {
|
|
19
|
+
if (context.directories.config === directory) return;
|
|
20
|
+
if (!fs.existsSync(path.resolve(context.directories.config, 'plugins'))) return;
|
|
21
|
+
await copyDirectory(path.resolve(context.directories.config, 'plugins'), path.resolve(directory, 'plugins'));
|
|
22
|
+
}
|
|
23
|
+
export default copyPluginsFolder;
|