lowdefy 4.0.0-alpha.7 → 4.0.0-alpha.8
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 +25 -9
- package/dist/commands/dev/dev.js +18 -4
- package/dist/commands/dev/runDevServer.js +2 -2
- package/dist/commands/start/runStart.js +2 -2
- package/dist/commands/start/start.js +2 -1
- package/dist/utils/addCustomPluginsAsDeps.js +32 -0
- package/dist/utils/copyPluginsFolder.js +23 -0
- package/dist/utils/getLowdefyYaml.js +6 -2
- package/dist/utils/getServer.js +8 -8
- package/dist/{commands/dev → utils}/installServer.js +2 -2
- package/dist/{commands/build → utils}/runLowdefyBuild.js +2 -2
- package/dist/{commands/build → utils}/runNextBuild.js +2 -2
- package/dist/utils/startUp.js +2 -1
- package/package.json +4 -4
- package/dist/commands/build/installServer.js +0 -43
|
@@ -12,27 +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
25
|
context,
|
|
23
|
-
packageName: '@lowdefy/server'
|
|
26
|
+
packageName: '@lowdefy/server',
|
|
27
|
+
directory
|
|
28
|
+
});
|
|
29
|
+
await copyPluginsFolder({
|
|
30
|
+
context,
|
|
31
|
+
directory
|
|
32
|
+
});
|
|
33
|
+
await addCustomPluginsAsDeps({
|
|
34
|
+
context,
|
|
35
|
+
directory
|
|
24
36
|
});
|
|
25
37
|
await installServer({
|
|
26
|
-
context
|
|
38
|
+
context,
|
|
39
|
+
directory
|
|
27
40
|
});
|
|
28
41
|
await runLowdefyBuild({
|
|
29
|
-
context
|
|
42
|
+
context,
|
|
43
|
+
directory
|
|
30
44
|
});
|
|
31
45
|
await installServer({
|
|
32
|
-
context
|
|
46
|
+
context,
|
|
47
|
+
directory
|
|
33
48
|
});
|
|
34
49
|
await runNextBuild({
|
|
35
|
-
context
|
|
50
|
+
context,
|
|
51
|
+
directory
|
|
36
52
|
});
|
|
37
53
|
await context.sendTelemetry({
|
|
38
54
|
sendTypes: true
|
package/dist/commands/dev/dev.js
CHANGED
|
@@ -12,21 +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
|
|
15
|
+
*/ import addCustomPluginsAsDeps from '../../utils/addCustomPluginsAsDeps.js';
|
|
16
|
+
import copyPluginsFolder from '../../utils/copyPluginsFolder.js';
|
|
17
|
+
import installServer from '../../utils/installServer.js';
|
|
16
18
|
import runDevServer from './runDevServer.js';
|
|
17
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
24
|
context,
|
|
22
|
-
packageName: '@lowdefy/server-dev'
|
|
25
|
+
packageName: '@lowdefy/server-dev',
|
|
26
|
+
directory
|
|
27
|
+
});
|
|
28
|
+
await copyPluginsFolder({
|
|
29
|
+
context,
|
|
30
|
+
directory
|
|
31
|
+
});
|
|
32
|
+
await addCustomPluginsAsDeps({
|
|
33
|
+
context,
|
|
34
|
+
directory
|
|
23
35
|
});
|
|
24
36
|
await installServer({
|
|
25
|
-
context
|
|
37
|
+
context,
|
|
38
|
+
directory
|
|
26
39
|
});
|
|
27
40
|
context.sendTelemetry();
|
|
28
41
|
await runDevServer({
|
|
29
|
-
context
|
|
42
|
+
context,
|
|
43
|
+
directory
|
|
30
44
|
});
|
|
31
45
|
}
|
|
32
46
|
export default dev;
|
|
@@ -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,7 +22,7 @@ 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,
|
|
@@ -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,7 @@ async function runStart({ context }) {
|
|
|
23
23
|
],
|
|
24
24
|
command: context.packageManager,
|
|
25
25
|
processOptions: {
|
|
26
|
-
cwd:
|
|
26
|
+
cwd: directory,
|
|
27
27
|
env: {
|
|
28
28
|
...process.env,
|
|
29
29
|
LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { 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-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 { 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;
|
|
@@ -17,9 +17,9 @@ import { get, type } from '@lowdefy/helpers';
|
|
|
17
17
|
import { readFile } from '@lowdefy/node-utils';
|
|
18
18
|
import YAML from 'yaml';
|
|
19
19
|
async function getLowdefyYaml({ configDirectory , command }) {
|
|
20
|
-
let lowdefyYaml = await readFile(path.
|
|
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 (![
|
|
@@ -43,10 +43,14 @@ async function getLowdefyYaml({ configDirectory , 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/getServer.js
CHANGED
|
@@ -16,30 +16,30 @@
|
|
|
16
16
|
import path from 'path';
|
|
17
17
|
import { cleanDirectory, readFile } from '@lowdefy/node-utils';
|
|
18
18
|
import fetchNpmTarball from './fetchNpmTarball.js';
|
|
19
|
-
async function getServer({ context , packageName }) {
|
|
19
|
+
async function getServer({ context , packageName , directory }) {
|
|
20
20
|
if (context.lowdefyVersion === 'local') {
|
|
21
21
|
context.print.warn(`Running local ${packageName}.`);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
let fetchServer = false;
|
|
25
|
-
const serverExists = fs.existsSync(path.join(
|
|
25
|
+
const serverExists = fs.existsSync(path.join(directory, 'package.json'));
|
|
26
26
|
if (!serverExists) fetchServer = true;
|
|
27
27
|
if (serverExists) {
|
|
28
|
-
const serverPackageConfig = JSON.parse(await readFile(path.join(
|
|
28
|
+
const serverPackageConfig = JSON.parse(await readFile(path.join(directory, 'package.json')));
|
|
29
29
|
if (serverPackageConfig.version !== context.lowdefyVersion) {
|
|
30
30
|
fetchServer = true;
|
|
31
|
-
context.print.warn(`Removing
|
|
32
|
-
await cleanDirectory(
|
|
31
|
+
context.print.warn(`Removing ${packageName} with version ${serverPackageConfig.version}`);
|
|
32
|
+
await cleanDirectory(directory);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
if (fetchServer) {
|
|
36
|
-
context.print.spin(
|
|
36
|
+
context.print.spin(`Fetching ${packageName} from npm.`);
|
|
37
37
|
await fetchNpmTarball({
|
|
38
38
|
packageName,
|
|
39
39
|
version: context.lowdefyVersion,
|
|
40
|
-
directory:
|
|
40
|
+
directory: directory
|
|
41
41
|
});
|
|
42
|
-
context.print.log(
|
|
42
|
+
context.print.log(`Fetched ${packageName} from npm.`);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
export default getServer;
|
|
@@ -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
|
});
|
|
@@ -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,7 +24,7 @@ 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
30
|
LOWDEFY_BUILD_REF_RESOLVER: context.options.refResolver,
|
|
@@ -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
|
@@ -27,9 +27,10 @@ async function startUp({ context , options ={} , command }) {
|
|
|
27
27
|
context.commandLineOptions = options;
|
|
28
28
|
context.print = createPrint();
|
|
29
29
|
context.configDirectory = path.resolve(options.configDirectory || process.cwd());
|
|
30
|
-
const { cliConfig , lowdefyVersion } = await getLowdefyYaml(context);
|
|
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.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy CLI",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
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.
|
|
43
|
+
"@lowdefy/helpers": "4.0.0-alpha.8",
|
|
44
|
+
"@lowdefy/node-utils": "4.0.0-alpha.8",
|
|
45
45
|
"axios": "0.25.0",
|
|
46
46
|
"chalk": "4.1.2",
|
|
47
47
|
"commander": "9.0.0",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "9d56b83cf45e868afe3a1eeba750fe826eb74c8c"
|
|
65
65
|
}
|
|
@@ -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.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;
|