lowdefy 3.23.2 → 4.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/build/build.js +41 -0
- package/dist/commands/build/getServer.js +42 -0
- package/dist/commands/build/installServer.js +43 -0
- package/dist/commands/build/runLowdefyBuild.js +42 -0
- package/dist/commands/build/runNextBuild.js +36 -0
- package/dist/commands/dev/dev.js +31 -0
- package/dist/commands/dev/getServer.js +42 -0
- package/dist/commands/dev/installServer.js +43 -0
- package/dist/commands/dev/runDevServer.js +34 -0
- package/dist/commands/init/init.js +42 -0
- package/dist/commands/init/lowdefyFile.js +67 -0
- package/dist/commands/start/runStart.js +31 -0
- package/dist/commands/start/start.js +26 -0
- package/dist/index.js +41 -1
- package/dist/utils/BatchChanges.js +61 -0
- package/dist/utils/checkForUpdatedVersions.js +53 -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 +35 -0
- package/dist/utils/getDirectories.js +31 -0
- package/dist/utils/getLowdefyYaml.js +53 -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/print.js +73 -0
- package/dist/utils/runCommand.js +42 -0
- package/dist/utils/startUp.js +47 -0
- package/package.json +19 -45
- 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,41 @@
|
|
|
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
|
+
*/ import getServer from './getServer.js';
|
|
16
|
+
import installServer from './installServer.js';
|
|
17
|
+
import runLowdefyBuild from './runLowdefyBuild.js';
|
|
18
|
+
import runNextBuild from './runNextBuild.js';
|
|
19
|
+
async function build({ context }) {
|
|
20
|
+
context.print.info('Starting build.');
|
|
21
|
+
await getServer({
|
|
22
|
+
context
|
|
23
|
+
});
|
|
24
|
+
await installServer({
|
|
25
|
+
context
|
|
26
|
+
});
|
|
27
|
+
await runLowdefyBuild({
|
|
28
|
+
context
|
|
29
|
+
});
|
|
30
|
+
await installServer({
|
|
31
|
+
context
|
|
32
|
+
});
|
|
33
|
+
await runNextBuild({
|
|
34
|
+
context
|
|
35
|
+
});
|
|
36
|
+
await context.sendTelemetry({
|
|
37
|
+
sendTypes: true
|
|
38
|
+
});
|
|
39
|
+
context.print.succeed(`Build successful.`);
|
|
40
|
+
}
|
|
41
|
+
export default build;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
*/ import fs from 'fs';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
import { cleanDirectory, readFile } from '@lowdefy/node-utils';
|
|
18
|
+
import fetchNpmTarball from '../../utils/fetchNpmTarball.js';
|
|
19
|
+
async function getServer({ context }) {
|
|
20
|
+
let fetchServer = false;
|
|
21
|
+
const serverExists = fs.existsSync(path.join(context.directories.server, 'package.json'));
|
|
22
|
+
if (!serverExists) fetchServer = true;
|
|
23
|
+
if (serverExists) {
|
|
24
|
+
const serverPackageConfig = JSON.parse(await readFile(path.join(context.directories.server, 'package.json')));
|
|
25
|
+
if (serverPackageConfig.version !== context.lowdefyVersion) {
|
|
26
|
+
fetchServer = true;
|
|
27
|
+
context.print.warn(`Removing @lowdefy/server with version ${serverPackageConfig.version}`);
|
|
28
|
+
await cleanDirectory(context.directories.server);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (fetchServer) {
|
|
32
|
+
context.print.spin('Fetching @lowdefy/server from npm.');
|
|
33
|
+
await fetchNpmTarball({
|
|
34
|
+
packageName: '@lowdefy/server',
|
|
35
|
+
version: context.lowdefyVersion,
|
|
36
|
+
directory: context.directories.server
|
|
37
|
+
});
|
|
38
|
+
context.print.log('Fetched @lowdefy/server from npm.');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export default getServer;
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
+
const args = {
|
|
17
|
+
npm: [
|
|
18
|
+
'install',
|
|
19
|
+
'--legacy-peer-deps'
|
|
20
|
+
],
|
|
21
|
+
yarn: [
|
|
22
|
+
'install'
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
async function installServer({ context }) {
|
|
26
|
+
context.print.spin(`Running ${context.packageManager} install.`);
|
|
27
|
+
try {
|
|
28
|
+
await spawnProcess({
|
|
29
|
+
logger: context.print,
|
|
30
|
+
command: context.packageManager,
|
|
31
|
+
args: args[context.packageManager],
|
|
32
|
+
processOptions: {
|
|
33
|
+
cwd: context.directories.server
|
|
34
|
+
},
|
|
35
|
+
silent: false
|
|
36
|
+
});
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.log(error);
|
|
39
|
+
throw new Error(`${context.packageManager} install failed.`);
|
|
40
|
+
}
|
|
41
|
+
context.print.log(`${context.packageManager} install successful.`);
|
|
42
|
+
}
|
|
43
|
+
export default installServer;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
+
async function runLowdefyBuild({ context }) {
|
|
17
|
+
context.print.log('Running Lowdefy build.');
|
|
18
|
+
try {
|
|
19
|
+
await spawnProcess({
|
|
20
|
+
logger: context.print,
|
|
21
|
+
command: context.packageManager,
|
|
22
|
+
args: [
|
|
23
|
+
'run',
|
|
24
|
+
'build:lowdefy'
|
|
25
|
+
],
|
|
26
|
+
processOptions: {
|
|
27
|
+
cwd: context.directories.server,
|
|
28
|
+
env: {
|
|
29
|
+
...process.env,
|
|
30
|
+
LOWDEFY_DIRECTORY_BUILD: context.directories.build,
|
|
31
|
+
LOWDEFY_DIRECTORY_CONFIG: context.directories.base,
|
|
32
|
+
LOWDEFY_DIRECTORY_SERVER: context.directories.server
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
silent: false
|
|
36
|
+
});
|
|
37
|
+
} catch (error) {
|
|
38
|
+
throw new Error('Lowdefy build failed.');
|
|
39
|
+
}
|
|
40
|
+
context.print.log('Lowdefy build successful.');
|
|
41
|
+
}
|
|
42
|
+
export default runLowdefyBuild;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
+
async function runNextBuild({ context }) {
|
|
17
|
+
context.print.log('Running Next build.');
|
|
18
|
+
try {
|
|
19
|
+
await spawnProcess({
|
|
20
|
+
logger: context.print,
|
|
21
|
+
command: context.packageManager,
|
|
22
|
+
args: [
|
|
23
|
+
'run',
|
|
24
|
+
'build:next'
|
|
25
|
+
],
|
|
26
|
+
processOptions: {
|
|
27
|
+
cwd: context.directories.server
|
|
28
|
+
},
|
|
29
|
+
silent: false
|
|
30
|
+
});
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw new Error('Next build failed.');
|
|
33
|
+
}
|
|
34
|
+
context.print.log('Next build successful.');
|
|
35
|
+
}
|
|
36
|
+
export default runNextBuild;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import getServer from './getServer.js';
|
|
16
|
+
import installServer from './installServer.js';
|
|
17
|
+
import runDevServer from './runDevServer.js';
|
|
18
|
+
async function dev({ context }) {
|
|
19
|
+
context.print.info('Starting development server.');
|
|
20
|
+
await getServer({
|
|
21
|
+
context
|
|
22
|
+
});
|
|
23
|
+
await installServer({
|
|
24
|
+
context
|
|
25
|
+
});
|
|
26
|
+
context.sendTelemetry();
|
|
27
|
+
await runDevServer({
|
|
28
|
+
context
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export default dev;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
*/ import fs from 'fs';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
import { cleanDirectory, readFile } from '@lowdefy/node-utils';
|
|
18
|
+
import fetchNpmTarball from '../../utils/fetchNpmTarball.js';
|
|
19
|
+
async function getServer({ context }) {
|
|
20
|
+
let fetchServer = false;
|
|
21
|
+
const serverExists = fs.existsSync(path.join(context.directories.devServer, 'package.json'));
|
|
22
|
+
if (!serverExists) fetchServer = true;
|
|
23
|
+
if (serverExists) {
|
|
24
|
+
const serverPackageConfig = JSON.parse(await readFile(path.join(context.directories.devServer, 'package.json')));
|
|
25
|
+
if (serverPackageConfig.version !== context.lowdefyVersion) {
|
|
26
|
+
fetchServer = true;
|
|
27
|
+
context.print.warn(`Removing @lowdefy/server-dev with version ${serverPackageConfig.version}`);
|
|
28
|
+
await cleanDirectory(context.directories.devServer);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (fetchServer) {
|
|
32
|
+
context.print.spin('Fetching @lowdefy/server-dev from npm.');
|
|
33
|
+
await fetchNpmTarball({
|
|
34
|
+
packageName: '@lowdefy/server-dev',
|
|
35
|
+
version: context.lowdefyVersion,
|
|
36
|
+
directory: context.directories.devServer
|
|
37
|
+
});
|
|
38
|
+
context.print.log('Fetched @lowdefy/server-dev from npm.');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export default getServer;
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
+
const args = {
|
|
17
|
+
npm: [
|
|
18
|
+
'install',
|
|
19
|
+
'--legacy-peer-deps'
|
|
20
|
+
],
|
|
21
|
+
yarn: [
|
|
22
|
+
'install'
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
async function installServer({ context }) {
|
|
26
|
+
context.print.spin(`Running ${context.packageManager} install.`);
|
|
27
|
+
try {
|
|
28
|
+
await spawnProcess({
|
|
29
|
+
logger: context.print,
|
|
30
|
+
command: context.packageManager,
|
|
31
|
+
args: args[context.packageManager],
|
|
32
|
+
processOptions: {
|
|
33
|
+
cwd: context.directories.devServer
|
|
34
|
+
},
|
|
35
|
+
silent: false
|
|
36
|
+
});
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.log(error);
|
|
39
|
+
throw new Error(`${context.packageManager} install failed.`);
|
|
40
|
+
}
|
|
41
|
+
context.print.log(`${context.packageManager} install successful.`);
|
|
42
|
+
}
|
|
43
|
+
export default installServer;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
+
async function runDevServer({ context }) {
|
|
17
|
+
await spawnProcess({
|
|
18
|
+
logger: context.print,
|
|
19
|
+
args: [
|
|
20
|
+
'run',
|
|
21
|
+
'start'
|
|
22
|
+
],
|
|
23
|
+
command: context.packageManager,
|
|
24
|
+
processOptions: {
|
|
25
|
+
cwd: context.directories.devServer,
|
|
26
|
+
env: {
|
|
27
|
+
...process.env,
|
|
28
|
+
LOWDEFY_DIRECTORY_CONFIG: context.directories.base
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
silent: false
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export default runDevServer;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
*/ 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({
|
|
27
|
+
filePath: lowdefyFilePath,
|
|
28
|
+
content: lowdefyFile({
|
|
29
|
+
version: context.cliVersion
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
context.print.log(`Created 'lowdefy.yaml'.`);
|
|
33
|
+
await writeFile({
|
|
34
|
+
filePath: path.resolve('./.gitignore'),
|
|
35
|
+
content: `.lowdefy/**
|
|
36
|
+
.env`
|
|
37
|
+
});
|
|
38
|
+
context.print.log(`Created '.gitignore'.`);
|
|
39
|
+
await context.sendTelemetry();
|
|
40
|
+
context.print.succeed(`Project initialized.`);
|
|
41
|
+
}
|
|
42
|
+
export default init;
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
*/ 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: HeartTwoTone
|
|
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,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
+
async function runStart({ context }) {
|
|
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: context.directories.server
|
|
27
|
+
},
|
|
28
|
+
silent: false
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export default runStart;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ 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
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export default build;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,42 @@
|
|
|
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-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
|
+
*/ import { readFile } from '@lowdefy/node-utils';
|
|
17
|
+
import program 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 } = packageJson;
|
|
25
|
+
program.name('lowdefy').description(description).version(version, '-v, --version');
|
|
26
|
+
program.command('build').description('Build a Lowdefy production app.').usage(`[options]`).option('--base-directory <base-directory>', 'Change base 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 "<base-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.').action(runCommand({
|
|
27
|
+
cliVersion: version
|
|
28
|
+
})(build));
|
|
29
|
+
program.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('--disable-telemetry', 'Disable telemetry.').option('--package-manager <package-manager>', 'The package manager to use. Options are "npm" or "yarn".')// TODO:
|
|
30
|
+
.option('--port <port>', 'Change the port the server is hosted at. Default is 3000.')// TODO:
|
|
31
|
+
.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.')// TODO:
|
|
32
|
+
.option('--watch <paths...>', 'A list of paths to files or directories that should be watched for changes.')// TODO:
|
|
33
|
+
.option('--watch-ignore <paths...>', 'A list of paths to files or directories that should be ignored by the file watcher. Globs are supported.').action(runCommand({
|
|
34
|
+
cliVersion: version
|
|
35
|
+
})(dev));
|
|
36
|
+
program.command('init').description('Initialize a Lowdefy project.').usage(`[options]`).action(runCommand({
|
|
37
|
+
cliVersion: version
|
|
38
|
+
})(init));
|
|
39
|
+
program.command('start').description('Start a Lowdefy production app.').usage(`[options]`).option('--base-directory <base-directory>', 'Change base 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 "<base-directory>/.lowdefy".').option('--package-manager <package-manager>', 'The package manager to use. Options are "npm" or "yarn".').action(runCommand({
|
|
40
|
+
cliVersion: version
|
|
41
|
+
})(start));
|
|
42
|
+
program.parse(process.argv);
|