mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-03-19 15:01:06 +08:00
fix(cli): Change additional base dir references to config.
This commit is contained in:
parent
f5fad82a9d
commit
e20cfdfdcb
@ -28,7 +28,7 @@ async function runLowdefyBuild({ context }) {
|
||||
env: {
|
||||
...process.env,
|
||||
LOWDEFY_DIRECTORY_BUILD: context.directories.build,
|
||||
LOWDEFY_DIRECTORY_CONFIG: context.directories.base,
|
||||
LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
|
||||
LOWDEFY_DIRECTORY_SERVER: context.directories.server,
|
||||
},
|
||||
},
|
||||
|
@ -26,7 +26,7 @@ async function runDevServer({ context }) {
|
||||
cwd: context.directories.devServer,
|
||||
env: {
|
||||
...process.env,
|
||||
LOWDEFY_DIRECTORY_CONFIG: context.directories.base,
|
||||
LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
|
||||
},
|
||||
},
|
||||
silent: false,
|
||||
|
@ -37,7 +37,7 @@ program
|
||||
.usage(`[options]`)
|
||||
.option(
|
||||
'--config-directory <config-directory>',
|
||||
'Change base directory. Default is the current working directory.'
|
||||
'Change config directory. Default is the current working directory.'
|
||||
)
|
||||
.option('--disable-telemetry', 'Disable telemetry.')
|
||||
.option(
|
||||
@ -60,7 +60,7 @@ program
|
||||
.usage(`[options]`)
|
||||
.option(
|
||||
'--config-directory <config-directory>',
|
||||
'Change base directory. Default is the current working directory.'
|
||||
'Change config directory. Default is the current working directory.'
|
||||
)
|
||||
.option('--disable-telemetry', 'Disable telemetry.')
|
||||
.option(
|
||||
@ -98,7 +98,7 @@ program
|
||||
.usage(`[options]`)
|
||||
.option(
|
||||
'--config-directory <config-directory>',
|
||||
'Change base directory. Default is the current working directory.'
|
||||
'Change config directory. Default is the current working directory.'
|
||||
)
|
||||
.option('--disable-telemetry', 'Disable telemetry.')
|
||||
.option(
|
||||
|
@ -24,7 +24,7 @@ function getDirectories({ configDirectory, options }) {
|
||||
dotLowdefy = path.resolve(configDirectory, '.lowdefy');
|
||||
}
|
||||
return {
|
||||
base: configDirectory,
|
||||
config: configDirectory,
|
||||
build: path.join(dotLowdefy, 'server', 'build'),
|
||||
dotLowdefy,
|
||||
server: path.join(dotLowdefy, 'server'),
|
||||
|
@ -18,22 +18,22 @@ import getDirectories from './getDirectories.js';
|
||||
|
||||
test('default directories', () => {
|
||||
const { cacheDirectory, buildDirectory } = getDirectories({
|
||||
configDirectory: '/test/base',
|
||||
configDirectory: '/test/config',
|
||||
options: {},
|
||||
});
|
||||
|
||||
expect(cacheDirectory).toEqual('/test/base/.lowdefy/.cache');
|
||||
expect(buildDirectory).toEqual('/test/base/.lowdefy/build');
|
||||
expect(cacheDirectory).toEqual('/test/config/.lowdefy/.cache');
|
||||
expect(buildDirectory).toEqual('/test/config/.lowdefy/build');
|
||||
});
|
||||
|
||||
test('specify outputDirectory in options', () => {
|
||||
const { cacheDirectory, buildDirectory } = getDirectories({
|
||||
configDirectory: '/test/base',
|
||||
configDirectory: '/test/config',
|
||||
options: {
|
||||
outputDirectory: '/test/build',
|
||||
},
|
||||
});
|
||||
|
||||
expect(cacheDirectory).toEqual('/test/base/.lowdefy/.cache');
|
||||
expect(cacheDirectory).toEqual('/test/config/.lowdefy/.cache');
|
||||
expect(buildDirectory).toEqual('/test/build');
|
||||
});
|
||||
|
@ -27,7 +27,7 @@ async function getLowdefyYaml({ configDirectory, command }) {
|
||||
if (!lowdefyYaml) {
|
||||
if (!['init'].includes(command)) {
|
||||
throw new Error(
|
||||
`Could not find "lowdefy.yaml" file in specified base directory ${configDirectory}.`
|
||||
`Could not find "lowdefy.yaml" file in specified config directory ${configDirectory}.`
|
||||
);
|
||||
}
|
||||
return { cliConfig: {} };
|
||||
|
@ -46,9 +46,9 @@ test('get version from yaml file', async () => {
|
||||
expect(config).toEqual({ lowdefyVersion: '1.0.0', cliConfig: {} });
|
||||
});
|
||||
|
||||
test('get version from yaml file, base dir specified', async () => {
|
||||
test('get version from yaml file, config dir specified', async () => {
|
||||
readFile.mockImplementation((filePath) => {
|
||||
if (filePath === path.resolve(process.cwd(), 'baseDir/lowdefy.yaml')) {
|
||||
if (filePath === path.resolve(process.cwd(), 'configDir/lowdefy.yaml')) {
|
||||
return `
|
||||
lowdefy: 1.0.0
|
||||
`;
|
||||
@ -56,7 +56,7 @@ test('get version from yaml file, base dir specified', async () => {
|
||||
return null;
|
||||
});
|
||||
const config = await getLowdefyYaml({
|
||||
configDirectory: path.resolve(process.cwd(), './baseDir'),
|
||||
configDirectory: path.resolve(process.cwd(), './configDir'),
|
||||
});
|
||||
expect(config).toEqual({ lowdefyVersion: '1.0.0', cliConfig: {} });
|
||||
});
|
||||
@ -74,15 +74,15 @@ test('could not find lowdefy.yaml in cwd', async () => {
|
||||
`;
|
||||
});
|
||||
await expect(getLowdefyYaml({ configDirectory })).rejects.toThrow(
|
||||
'Could not find "lowdefy.yaml" file in specified base directory'
|
||||
'Could not find "lowdefy.yaml" file in specified config directory'
|
||||
);
|
||||
});
|
||||
|
||||
test('could not find lowdefy.yaml in base dir', async () => {
|
||||
test('could not find lowdefy.yaml in config dir', async () => {
|
||||
readFile.mockImplementation((filePath) => {
|
||||
if (
|
||||
filePath === path.resolve(process.cwd(), 'baseDir/lowdefy.yaml') ||
|
||||
filePath === path.resolve(process.cwd(), 'baseDir/lowdefy.yml')
|
||||
filePath === path.resolve(process.cwd(), 'configDir/lowdefy.yaml') ||
|
||||
filePath === path.resolve(process.cwd(), 'configDir/lowdefy.yml')
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
@ -91,8 +91,8 @@ test('could not find lowdefy.yaml in base dir', async () => {
|
||||
`;
|
||||
});
|
||||
await expect(
|
||||
getLowdefyYaml({ configDirectory: path.resolve(process.cwd(), './baseDir') })
|
||||
).rejects.toThrow('Could not find "lowdefy.yaml" file in specified base directory');
|
||||
getLowdefyYaml({ configDirectory: path.resolve(process.cwd(), './configDir') })
|
||||
).rejects.toThrow('Could not find "lowdefy.yaml" file in specified config directory');
|
||||
});
|
||||
|
||||
test('lowdefy.yaml is invalid yaml', async () => {
|
||||
@ -175,7 +175,7 @@ test('get cliConfig', async () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('could not find lowdefy.yaml in base dir, command is "init" or "clean-cache"', async () => {
|
||||
test('could not find lowdefy.yaml in config dir, command is "init" or "clean-cache"', async () => {
|
||||
readFile.mockImplementation(() => null);
|
||||
let config = await getLowdefyYaml({ command: 'init', configDirectory });
|
||||
expect(config).toEqual({
|
||||
|
@ -58,7 +58,7 @@ _ref:
|
||||
|
||||
The `build` command runs a Lowdefy build. The options are:
|
||||
|
||||
- `--config-directory <config-directory>`: Change base directory. The default is the current working directory.
|
||||
- `--config-directory <config-directory>`: Change config directory. The default is the current working directory.
|
||||
- `--blocks-server-url <blocks-server-url>`: The URL from where Lowdefy blocks will be served. See below for more information.
|
||||
- `--disable-telemetry`: Disable telemetry.
|
||||
- `--output-directory <output-directory>`: Change the directory to which build artifacts are saved. The default is `<config-directory>/.lowdefy/build`.
|
||||
@ -69,7 +69,7 @@ _ref:
|
||||
|
||||
We recommend setting the build command to `npx lowdefy@latest build-netlify`. The Netlify publish directory should be set to `.lowdefy/publish`, and the functions directory set to `.lowdefy/functions`.
|
||||
|
||||
- `--config-directory <config-directory>`: Change base directory. The default is the current working directory (The base directory should rather be configured in the Netlify build settings).
|
||||
- `--config-directory <config-directory>`: Change config directory. The default is the current working directory (The confg directory should rather be configured in the Netlify build settings).
|
||||
- `--blocks-server-url <blocks-server-url>`: The URL from where Lowdefy blocks will be served. See below for more information.
|
||||
- `--disable-telemetry`: Disable telemetry.
|
||||
- `--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.
|
||||
@ -78,14 +78,14 @@ _ref:
|
||||
|
||||
The Lowdefy CLI caches block metadata, and build and server scripts in the `.lowdefy/cache` directory. These cached files can be removed using the `clean-cache` command.
|
||||
|
||||
- `--config-directory <config-directory>`: Change base directory. The default is the current working directory.
|
||||
- `--config-directory <config-directory>`: Change config directory. The default is the current working directory.
|
||||
- `--disable-telemetry`: Disable telemetry.
|
||||
|
||||
## dev
|
||||
|
||||
The `dev` command starts a Lowdefy development server, running locally. It can be accessed in a browser at [http://localhost:3000](http://localhost:3000). The CLI watches the file system, and rebuilds the app and reloads served pages every time a change is made to any of the files in the project directory.
|
||||
|
||||
- `--config-directory <config-directory>`: Change base directory. The default is the current working directory.
|
||||
- `--config-directory <config-directory>`: Change config directory. The default is the current working directory.
|
||||
- `--blocks-server-url <blocks-server-url>`: The URL from where Lowdefy blocks will be served. See below for more information.
|
||||
- `--disable-telemetry`: Disable telemetry.
|
||||
- `--port <port>`: Change the port the server is hosted at. The default is `3000`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user