lowdefy 4.0.0-alpha.6 → 4.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/build/build.js +27 -10
- package/dist/commands/dev/dev.js +21 -6
- package/dist/commands/dev/runDevServer.js +9 -4
- package/dist/commands/init/init.js +6 -12
- package/dist/commands/init/lowdefyFile.js +2 -2
- package/dist/commands/start/runStart.js +8 -3
- package/dist/commands/start/start.js +3 -2
- package/dist/index.js +20 -19
- package/dist/utils/BatchChanges.js +1 -1
- package/dist/utils/addCustomPluginsAsDeps.js +32 -0
- package/dist/utils/checkForUpdatedVersions.js +1 -1
- package/dist/utils/copyPluginsFolder.js +23 -0
- package/dist/utils/{print.js → createPrint.js} +1 -1
- package/dist/utils/errorHandler.js +2 -2
- package/dist/utils/fetchNpmTarball.js +1 -1
- package/dist/utils/findOpenPort.js +1 -1
- package/dist/utils/getCliJson.js +6 -9
- package/dist/utils/getDirectories.js +6 -6
- package/dist/utils/getLowdefyYaml.js +11 -7
- package/dist/utils/getOptions.js +1 -1
- package/dist/utils/getPackageManager.js +1 -1
- package/dist/utils/getSendTelemetry.js +1 -1
- package/dist/{commands/dev → utils}/getServer.js +15 -12
- package/dist/{commands/build → utils}/installServer.js +3 -3
- package/dist/utils/runCommand.js +23 -24
- package/dist/{commands/build → utils}/runLowdefyBuild.js +5 -4
- package/dist/{commands/build → utils}/runNextBuild.js +3 -3
- package/dist/utils/startUp.js +5 -4
- package/package.json +13 -12
- package/dist/commands/build/getServer.js +0 -42
- package/dist/commands/dev/installServer.js +0 -43
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,26 +12,43 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
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';
|
|
19
21
|
async function build({ context }) {
|
|
20
22
|
context.print.info('Starting build.');
|
|
23
|
+
const directory = context.directories.server;
|
|
21
24
|
await getServer({
|
|
22
|
-
context
|
|
25
|
+
context,
|
|
26
|
+
packageName: '@lowdefy/server',
|
|
27
|
+
directory
|
|
28
|
+
});
|
|
29
|
+
await copyPluginsFolder({
|
|
30
|
+
context,
|
|
31
|
+
directory
|
|
32
|
+
});
|
|
33
|
+
await addCustomPluginsAsDeps({
|
|
34
|
+
context,
|
|
35
|
+
directory
|
|
23
36
|
});
|
|
24
37
|
await installServer({
|
|
25
|
-
context
|
|
38
|
+
context,
|
|
39
|
+
directory
|
|
26
40
|
});
|
|
27
41
|
await runLowdefyBuild({
|
|
28
|
-
context
|
|
42
|
+
context,
|
|
43
|
+
directory
|
|
29
44
|
});
|
|
30
45
|
await installServer({
|
|
31
|
-
context
|
|
46
|
+
context,
|
|
47
|
+
directory
|
|
32
48
|
});
|
|
33
49
|
await runNextBuild({
|
|
34
|
-
context
|
|
50
|
+
context,
|
|
51
|
+
directory
|
|
35
52
|
});
|
|
36
53
|
await context.sendTelemetry({
|
|
37
54
|
sendTypes: true
|
package/dist/commands/dev/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,20 +12,35 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import
|
|
16
|
-
import
|
|
15
|
+
*/ import addCustomPluginsAsDeps from '../../utils/addCustomPluginsAsDeps.js';
|
|
16
|
+
import copyPluginsFolder from '../../utils/copyPluginsFolder.js';
|
|
17
|
+
import installServer from '../../utils/installServer.js';
|
|
17
18
|
import runDevServer from './runDevServer.js';
|
|
19
|
+
import getServer from '../../utils/getServer.js';
|
|
18
20
|
async function dev({ context }) {
|
|
21
|
+
const directory = context.directories.dev;
|
|
19
22
|
context.print.info('Starting development server.');
|
|
20
23
|
await getServer({
|
|
21
|
-
context
|
|
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
|
|
22
35
|
});
|
|
23
36
|
await installServer({
|
|
24
|
-
context
|
|
37
|
+
context,
|
|
38
|
+
directory
|
|
25
39
|
});
|
|
26
40
|
context.sendTelemetry();
|
|
27
41
|
await runDevServer({
|
|
28
|
-
context
|
|
42
|
+
context,
|
|
43
|
+
directory
|
|
29
44
|
});
|
|
30
45
|
}
|
|
31
46
|
export default dev;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
-
async function runDevServer({ context }) {
|
|
16
|
+
async function runDevServer({ context , directory }) {
|
|
17
17
|
await spawnProcess({
|
|
18
18
|
logger: context.print,
|
|
19
19
|
args: [
|
|
@@ -22,10 +22,15 @@ async function runDevServer({ context }) {
|
|
|
22
22
|
],
|
|
23
23
|
command: context.packageManager,
|
|
24
24
|
processOptions: {
|
|
25
|
-
cwd:
|
|
25
|
+
cwd: directory,
|
|
26
26
|
env: {
|
|
27
27
|
...process.env,
|
|
28
|
-
|
|
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
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
silent: false
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -23,18 +23,12 @@ async function init({ context }) {
|
|
|
23
23
|
throw new Error('Cannot initialize a Lowdefy project, a "lowdefy.yaml" file already exists');
|
|
24
24
|
}
|
|
25
25
|
context.print.log(`Initializing Lowdefy project`);
|
|
26
|
-
await writeFile({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
version: context.cliVersion
|
|
30
|
-
})
|
|
31
|
-
});
|
|
26
|
+
await writeFile(lowdefyFilePath, lowdefyFile({
|
|
27
|
+
version: context.cliVersion
|
|
28
|
+
}));
|
|
32
29
|
context.print.log(`Created 'lowdefy.yaml'.`);
|
|
33
|
-
await writeFile(
|
|
34
|
-
|
|
35
|
-
content: `.lowdefy/**
|
|
36
|
-
.env`
|
|
37
|
-
});
|
|
30
|
+
await writeFile(path.resolve('./.gitignore'), `.lowdefy/**
|
|
31
|
+
.env`);
|
|
38
32
|
context.print.log(`Created '.gitignore'.`);
|
|
39
33
|
await context.sendTelemetry();
|
|
40
34
|
context.print.succeed(`Project initialized.`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -36,7 +36,7 @@ pages:
|
|
|
36
36
|
title: Welcome to your Lowdefy app
|
|
37
37
|
subTitle: We are excited to see what you are going to build
|
|
38
38
|
icon:
|
|
39
|
-
name:
|
|
39
|
+
name: AiOutlineHeart
|
|
40
40
|
color: '#f00'
|
|
41
41
|
areas:
|
|
42
42
|
extra:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
-
async function runStart({ context }) {
|
|
16
|
+
async function runStart({ context , directory }) {
|
|
17
17
|
context.print.spin(`Running "${context.packageManager} run start".`);
|
|
18
18
|
await spawnProcess({
|
|
19
19
|
logger: context.print,
|
|
@@ -23,7 +23,12 @@ async function runStart({ context }) {
|
|
|
23
23
|
],
|
|
24
24
|
command: context.packageManager,
|
|
25
25
|
processOptions: {
|
|
26
|
-
cwd:
|
|
26
|
+
cwd: directory,
|
|
27
|
+
env: {
|
|
28
|
+
...process.env,
|
|
29
|
+
LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
|
|
30
|
+
PORT: context.options.port
|
|
31
|
+
}
|
|
27
32
|
},
|
|
28
33
|
silent: false
|
|
29
34
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -20,7 +20,8 @@ async function build({ context }) {
|
|
|
20
20
|
sendTypes: true
|
|
21
21
|
});
|
|
22
22
|
await runStart({
|
|
23
|
-
context
|
|
23
|
+
context,
|
|
24
|
+
directory: context.directories.server
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
export default build;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*
|
|
3
|
-
Copyright 2020-
|
|
3
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
4
4
|
|
|
5
5
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
you may not use this file except in compliance with the License.
|
|
@@ -14,29 +14,30 @@
|
|
|
14
14
|
See the License for the specific language governing permissions and
|
|
15
15
|
limitations under the License.
|
|
16
16
|
*/ import { readFile } from '@lowdefy/node-utils';
|
|
17
|
-
import
|
|
17
|
+
import { Command } from 'commander';
|
|
18
18
|
import build from './commands/build/build.js';
|
|
19
19
|
import dev from './commands/dev/dev.js';
|
|
20
20
|
import init from './commands/init/init.js';
|
|
21
21
|
import start from './commands/start/start.js';
|
|
22
22
|
import runCommand from './utils/runCommand.js';
|
|
23
23
|
const packageJson = JSON.parse(await readFile(new URL('../package.json', import.meta.url).pathname));
|
|
24
|
-
const { description , version } = packageJson;
|
|
25
|
-
program
|
|
26
|
-
program.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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.')
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})(dev));
|
|
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
|
+
}));
|
|
36
35
|
program.command('init').description('Initialize a Lowdefy project.').usage(`[options]`).action(runCommand({
|
|
37
|
-
cliVersion
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
}));
|
|
42
43
|
program.parse(process.argv);
|
|
@@ -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,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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import axios from 'axios';
|
|
16
|
-
import createPrint from './
|
|
16
|
+
import createPrint from './createPrint.js';
|
|
17
17
|
async function logError({ error , context ={} }) {
|
|
18
18
|
try {
|
|
19
19
|
await axios.request({
|
package/dist/utils/getCliJson.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -15,17 +15,14 @@
|
|
|
15
15
|
*/ import path from 'path';
|
|
16
16
|
import { readFile, writeFile } from '@lowdefy/node-utils';
|
|
17
17
|
import { v4 as uuid } from 'uuid';
|
|
18
|
-
async function getCliJson({
|
|
19
|
-
const filePath = path.resolve(
|
|
18
|
+
async function getCliJson({ configDirectory }) {
|
|
19
|
+
const filePath = path.resolve(configDirectory, './.lowdefy/cli.json');
|
|
20
20
|
const cliJson = await readFile(filePath);
|
|
21
21
|
if (!cliJson) {
|
|
22
22
|
const appId = uuid();
|
|
23
|
-
await writeFile({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
appId
|
|
27
|
-
}, null, 2)
|
|
28
|
-
});
|
|
23
|
+
await writeFile(filePath, JSON.stringify({
|
|
24
|
+
appId
|
|
25
|
+
}, null, 2));
|
|
29
26
|
return {
|
|
30
27
|
appId
|
|
31
28
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,19 +13,19 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import path from 'path';
|
|
16
|
-
function getDirectories({
|
|
16
|
+
function getDirectories({ configDirectory , options }) {
|
|
17
17
|
let dotLowdefy;
|
|
18
18
|
if (options.outputDirectory) {
|
|
19
19
|
dotLowdefy = path.resolve(options.outputDirectory);
|
|
20
20
|
} else {
|
|
21
|
-
dotLowdefy = path.resolve(
|
|
21
|
+
dotLowdefy = path.resolve(configDirectory, '.lowdefy');
|
|
22
22
|
}
|
|
23
23
|
return {
|
|
24
|
-
|
|
24
|
+
config: configDirectory,
|
|
25
25
|
build: path.join(dotLowdefy, 'server', 'build'),
|
|
26
26
|
dotLowdefy,
|
|
27
|
-
server: path.join(dotLowdefy, 'server'),
|
|
28
|
-
|
|
27
|
+
server: options.serverDirectory ? path.resolve(options.serverDirectory) : path.join(dotLowdefy, 'server'),
|
|
28
|
+
dev: options.devDirectory ? path.resolve(options.devDirectory) : path.join(dotLowdefy, 'dev')
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
export default getDirectories;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
*/ import path from 'path';
|
|
16
16
|
import { get, type } from '@lowdefy/helpers';
|
|
17
17
|
import { readFile } from '@lowdefy/node-utils';
|
|
18
|
-
import YAML from '
|
|
19
|
-
async function getLowdefyYaml({
|
|
20
|
-
let lowdefyYaml = await readFile(path.
|
|
18
|
+
import YAML from 'yaml';
|
|
19
|
+
async function getLowdefyYaml({ configDirectory , command }) {
|
|
20
|
+
let lowdefyYaml = await readFile(path.join(configDirectory, 'lowdefy.yaml'));
|
|
21
21
|
if (!lowdefyYaml) {
|
|
22
|
-
lowdefyYaml = await readFile(path.
|
|
22
|
+
lowdefyYaml = await readFile(path.join(configDirectory, 'lowdefy.yml'));
|
|
23
23
|
}
|
|
24
24
|
if (!lowdefyYaml) {
|
|
25
25
|
if (![
|
|
26
26
|
'init'
|
|
27
27
|
].includes(command)) {
|
|
28
|
-
throw new Error(`Could not find "lowdefy.yaml" file in specified
|
|
28
|
+
throw new Error(`Could not find "lowdefy.yaml" file in specified config directory ${configDirectory}.`);
|
|
29
29
|
}
|
|
30
30
|
return {
|
|
31
31
|
cliConfig: {}
|
|
@@ -33,7 +33,7 @@ async function getLowdefyYaml({ baseDirectory , command }) {
|
|
|
33
33
|
}
|
|
34
34
|
let lowdefy;
|
|
35
35
|
try {
|
|
36
|
-
lowdefy = YAML.
|
|
36
|
+
lowdefy = YAML.parse(lowdefyYaml);
|
|
37
37
|
} catch (error) {
|
|
38
38
|
throw new Error(`Could not parse "lowdefy.yaml" file. Received error ${error.message}.`);
|
|
39
39
|
}
|
|
@@ -43,10 +43,14 @@ async function getLowdefyYaml({ baseDirectory , command }) {
|
|
|
43
43
|
if (!type.isString(lowdefy.lowdefy)) {
|
|
44
44
|
throw new Error(`Version number specified in "lowdefy.yaml" file should be a string. Received ${JSON.stringify(lowdefy.lowdefy)}.`);
|
|
45
45
|
}
|
|
46
|
+
// TODO: Validate plugins
|
|
46
47
|
return {
|
|
47
48
|
lowdefyVersion: lowdefy.lowdefy,
|
|
48
49
|
cliConfig: get(lowdefy, 'cli', {
|
|
49
50
|
default: {}
|
|
51
|
+
}),
|
|
52
|
+
plugins: get(lowdefy, 'plugins', {
|
|
53
|
+
default: []
|
|
50
54
|
})
|
|
51
55
|
};
|
|
52
56
|
}
|
package/dist/utils/getOptions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -15,28 +15,31 @@
|
|
|
15
15
|
*/ import fs from 'fs';
|
|
16
16
|
import path from 'path';
|
|
17
17
|
import { cleanDirectory, readFile } from '@lowdefy/node-utils';
|
|
18
|
-
import fetchNpmTarball from '
|
|
19
|
-
async function getServer({ context }) {
|
|
18
|
+
import fetchNpmTarball from './fetchNpmTarball.js';
|
|
19
|
+
async function getServer({ context , packageName , directory }) {
|
|
20
|
+
if (context.lowdefyVersion === 'local') {
|
|
21
|
+
context.print.warn(`Running local ${packageName}.`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
20
24
|
let fetchServer = false;
|
|
21
|
-
const serverExists = fs.existsSync(path.join(
|
|
25
|
+
const serverExists = fs.existsSync(path.join(directory, 'package.json'));
|
|
22
26
|
if (!serverExists) fetchServer = true;
|
|
23
27
|
if (serverExists) {
|
|
24
|
-
const serverPackageConfig = JSON.parse(await readFile(path.join(
|
|
28
|
+
const serverPackageConfig = JSON.parse(await readFile(path.join(directory, 'package.json')));
|
|
25
29
|
if (serverPackageConfig.version !== context.lowdefyVersion) {
|
|
26
30
|
fetchServer = true;
|
|
27
|
-
context.print.warn(`Removing
|
|
28
|
-
await cleanDirectory(
|
|
31
|
+
context.print.warn(`Removing ${packageName} with version ${serverPackageConfig.version}`);
|
|
32
|
+
await cleanDirectory(directory);
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
if (fetchServer) {
|
|
32
|
-
context.print.spin(
|
|
36
|
+
context.print.spin(`Fetching ${packageName} from npm.`);
|
|
33
37
|
await fetchNpmTarball({
|
|
34
|
-
packageName
|
|
38
|
+
packageName,
|
|
35
39
|
version: context.lowdefyVersion,
|
|
36
|
-
directory:
|
|
40
|
+
directory: directory
|
|
37
41
|
});
|
|
38
|
-
context.print.log(
|
|
39
|
-
return;
|
|
42
|
+
context.print.log(`Fetched ${packageName} from npm.`);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
export default getServer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -22,7 +22,7 @@ const args = {
|
|
|
22
22
|
'install'
|
|
23
23
|
]
|
|
24
24
|
};
|
|
25
|
-
async function installServer({ context }) {
|
|
25
|
+
async function installServer({ context , directory }) {
|
|
26
26
|
context.print.spin(`Running ${context.packageManager} install.`);
|
|
27
27
|
try {
|
|
28
28
|
await spawnProcess({
|
|
@@ -30,7 +30,7 @@ async function installServer({ context }) {
|
|
|
30
30
|
command: context.packageManager,
|
|
31
31
|
args: args[context.packageManager],
|
|
32
32
|
processOptions: {
|
|
33
|
-
cwd:
|
|
33
|
+
cwd: directory
|
|
34
34
|
},
|
|
35
35
|
silent: false
|
|
36
36
|
});
|
package/dist/utils/runCommand.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,29 +14,28 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import errorHandler from './errorHandler.js';
|
|
16
16
|
import startUp from './startUp.js';
|
|
17
|
-
const runCommand = ({ cliVersion })=>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
17
|
+
const runCommand = ({ cliVersion , handler })=>{
|
|
18
|
+
async function run(options, command) {
|
|
19
|
+
const context = {
|
|
20
|
+
cliVersion
|
|
21
|
+
};
|
|
22
|
+
try {
|
|
23
|
+
await startUp({
|
|
24
|
+
context,
|
|
25
|
+
options,
|
|
26
|
+
command
|
|
27
|
+
});
|
|
28
|
+
const res = await handler({
|
|
29
|
+
context
|
|
30
|
+
});
|
|
31
|
+
return res;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
await errorHandler({
|
|
34
|
+
context,
|
|
35
|
+
error
|
|
36
|
+
});
|
|
38
37
|
}
|
|
39
|
-
return run;
|
|
40
38
|
}
|
|
41
|
-
;
|
|
39
|
+
return run;
|
|
40
|
+
};
|
|
42
41
|
export default runCommand;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
-
async function runLowdefyBuild({ context }) {
|
|
16
|
+
async function runLowdefyBuild({ context , directory }) {
|
|
17
17
|
context.print.log('Running Lowdefy build.');
|
|
18
18
|
try {
|
|
19
19
|
await spawnProcess({
|
|
@@ -24,11 +24,12 @@ async function runLowdefyBuild({ context }) {
|
|
|
24
24
|
'build:lowdefy'
|
|
25
25
|
],
|
|
26
26
|
processOptions: {
|
|
27
|
-
cwd:
|
|
27
|
+
cwd: directory,
|
|
28
28
|
env: {
|
|
29
29
|
...process.env,
|
|
30
|
+
LOWDEFY_BUILD_REF_RESOLVER: context.options.refResolver,
|
|
30
31
|
LOWDEFY_DIRECTORY_BUILD: context.directories.build,
|
|
31
|
-
LOWDEFY_DIRECTORY_CONFIG: context.directories.
|
|
32
|
+
LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
|
|
32
33
|
LOWDEFY_DIRECTORY_SERVER: context.directories.server
|
|
33
34
|
}
|
|
34
35
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { spawnProcess } from '@lowdefy/node-utils';
|
|
16
|
-
async function runNextBuild({ context }) {
|
|
16
|
+
async function runNextBuild({ context , directory }) {
|
|
17
17
|
context.print.log('Running Next build.');
|
|
18
18
|
try {
|
|
19
19
|
await spawnProcess({
|
|
@@ -24,7 +24,7 @@ async function runNextBuild({ context }) {
|
|
|
24
24
|
'build:next'
|
|
25
25
|
],
|
|
26
26
|
processOptions: {
|
|
27
|
-
cwd:
|
|
27
|
+
cwd: directory
|
|
28
28
|
},
|
|
29
29
|
silent: false
|
|
30
30
|
});
|
package/dist/utils/startUp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -21,15 +21,16 @@ import getLowdefyYaml from './getLowdefyYaml.js';
|
|
|
21
21
|
import getOptions from './getOptions.js';
|
|
22
22
|
import getPackageManager from './getPackageManager.js';
|
|
23
23
|
import getSendTelemetry from './getSendTelemetry.js';
|
|
24
|
-
import createPrint from './
|
|
24
|
+
import createPrint from './createPrint.js';
|
|
25
25
|
async function startUp({ context , options ={} , command }) {
|
|
26
26
|
context.command = command.name();
|
|
27
27
|
context.commandLineOptions = options;
|
|
28
28
|
context.print = createPrint();
|
|
29
|
-
context.
|
|
30
|
-
const { cliConfig , lowdefyVersion } = await getLowdefyYaml(context);
|
|
29
|
+
context.configDirectory = path.resolve(options.configDirectory || process.cwd());
|
|
30
|
+
const { cliConfig , lowdefyVersion , plugins } = await getLowdefyYaml(context);
|
|
31
31
|
context.cliConfig = cliConfig;
|
|
32
32
|
context.lowdefyVersion = lowdefyVersion;
|
|
33
|
+
context.plugins = plugins;
|
|
33
34
|
const { appId } = await getCliJson(context);
|
|
34
35
|
context.appId = appId;
|
|
35
36
|
context.options = getOptions(context);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lowdefy",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.9",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy CLI",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -37,28 +37,29 @@
|
|
|
37
37
|
"start": "yarn node ./dist/index.js",
|
|
38
38
|
"prepare": "yarn build",
|
|
39
39
|
"swc": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start",
|
|
40
|
-
"test": "FORCE_COLOR=3
|
|
40
|
+
"test": "FORCE_COLOR=3 yarn node --experimental-vm-modules $(yarn bin jest)"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
44
|
-
"@lowdefy/node-utils": "4.0.0-alpha.
|
|
45
|
-
"axios": "0.
|
|
43
|
+
"@lowdefy/helpers": "4.0.0-alpha.9",
|
|
44
|
+
"@lowdefy/node-utils": "4.0.0-alpha.9",
|
|
45
|
+
"axios": "0.25.0",
|
|
46
46
|
"chalk": "4.1.2",
|
|
47
|
-
"commander": "
|
|
47
|
+
"commander": "9.0.0",
|
|
48
48
|
"decompress": "4.2.1",
|
|
49
49
|
"decompress-targz": "4.1.1",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
50
|
+
"ora": "5.4.1",
|
|
51
|
+
"uuid": "8.3.2",
|
|
52
|
+
"yaml": "2.0.0-10"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
+
"@jest/globals": "27.5.1",
|
|
55
56
|
"@swc/cli": "0.1.55",
|
|
56
|
-
"@swc/core": "1.2.
|
|
57
|
+
"@swc/core": "1.2.135",
|
|
57
58
|
"@swc/jest": "0.2.17",
|
|
58
|
-
"jest": "27.
|
|
59
|
+
"jest": "27.5.1"
|
|
59
60
|
},
|
|
60
61
|
"publishConfig": {
|
|
61
62
|
"access": "public"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
|
|
64
65
|
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/ 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;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/ 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;
|