2
0
mirror of https://github.com/lowdefy/lowdefy.git synced 2025-04-24 16:00:53 +08:00

fix(cli): Fix CLI dev server command.

This commit is contained in:
Sam Tolmay 2022-01-20 13:03:22 +02:00
parent b8c1d58ea8
commit 49f6c208ec
No known key found for this signature in database
GPG Key ID: D004126FCD1A6DF0
5 changed files with 52 additions and 1 deletions
packages/cli/src

@ -15,11 +15,13 @@
*/
import getServer from './getServer.js';
import installServer from './installServer.js';
import runDevServer from './runDevServer.js';
async function dev({ context }) {
context.print.info('Starting development server.');
await getServer({ context });
await installServer({ context });
context.sendTelemetry();
await runDevServer({ context });
}

@ -0,0 +1,43 @@
/*
Copyright 2020-2021 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { spawnProcess } from '@lowdefy/node-utils';
const args = {
npm: ['install', '--legacy-peer-deps'],
yarn: ['install'],
};
async function installServer({ context }) {
context.print.spin(`Running ${context.packageManager} install.`);
try {
await spawnProcess({
logger: context.print,
command: context.packageManager, // npm or yarn
args: args[context.packageManager],
processOptions: {
cwd: context.directories.devServer,
},
silent: false,
});
} catch (error) {
console.log(error);
throw new Error(`${context.packageManager} install failed.`);
}
context.print.log(`${context.packageManager} install successful.`);
}
export default installServer;

@ -16,6 +16,8 @@
import runStart from './runStart.js';
// TODO: Handle "spawn yarn ENOENT" error if no built server exists.
async function build({ context }) {
context.print.info('Starting server.');
context.sendTelemetry({ sendTypes: true });

@ -63,6 +63,10 @@ program
'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:
.option('--port <port>', 'Change the port the server is hosted at. Default is 3000.')
// TODO:

@ -28,7 +28,7 @@ function getDirectories({ baseDirectory, options }) {
build: path.join(dotLowdefy, 'server', 'build'),
dotLowdefy,
server: path.join(dotLowdefy, 'server'),
serverDev: path.join(dotLowdefy, 'server-dev'),
devServer: path.join(dotLowdefy, 'dev'),
};
}