mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-03-19 15:01:06 +08:00
fix(cli): Define build directory on context.
This commit is contained in:
parent
d225ab2422
commit
51bc05f835
@ -18,12 +18,13 @@ import path from 'path';
|
||||
|
||||
function getDirectories({ configDirectory, options }) {
|
||||
const dotLowdefy = path.resolve(configDirectory, '.lowdefy');
|
||||
|
||||
const server = options.serverDirectory
|
||||
? path.resolve(options.serverDirectory)
|
||||
: path.join(dotLowdefy, 'server');
|
||||
return {
|
||||
config: configDirectory,
|
||||
server: options.serverDirectory
|
||||
? path.resolve(options.serverDirectory)
|
||||
: path.join(dotLowdefy, 'server'),
|
||||
build: path.join(server, 'build'),
|
||||
server,
|
||||
dev: options.devDirectory ? path.resolve(options.devDirectory) : path.join(dotLowdefy, 'dev'),
|
||||
};
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ test('default directories', () => {
|
||||
});
|
||||
|
||||
expect(directories).toEqual({
|
||||
build: '/test/config/.lowdefy/server/build',
|
||||
config: '/test/config',
|
||||
dev: '/test/config/.lowdefy/dev',
|
||||
server: '/test/config/.lowdefy/server',
|
||||
@ -38,6 +39,7 @@ test('specify serverDirectory in options', () => {
|
||||
});
|
||||
|
||||
expect(directories).toEqual({
|
||||
build: '/test/server/build',
|
||||
config: '/test/config',
|
||||
dev: '/test/config/.lowdefy/dev',
|
||||
server: '/test/server',
|
||||
@ -53,6 +55,7 @@ test('specify devDirectory in options', () => {
|
||||
});
|
||||
|
||||
expect(directories).toEqual({
|
||||
build: '/test/config/.lowdefy/server/build',
|
||||
config: '/test/config',
|
||||
dev: '/test/dev',
|
||||
server: '/test/config/.lowdefy/server',
|
||||
|
@ -58,7 +58,6 @@ test('startUp, options empty', async () => {
|
||||
build: path.resolve(process.cwd(), './.lowdefy/server/build'),
|
||||
config: path.resolve(process.cwd()),
|
||||
dev: path.resolve(process.cwd(), './.lowdefy/dev'),
|
||||
dotLowdefy: path.resolve(process.cwd(), './.lowdefy'),
|
||||
server: path.resolve(process.cwd(), './.lowdefy/server'),
|
||||
},
|
||||
lowdefyVersion: 'lowdefyVersion',
|
||||
@ -106,7 +105,6 @@ test('startUp, options undefined', async () => {
|
||||
build: path.resolve(process.cwd(), './.lowdefy/server/build'),
|
||||
config: path.resolve(process.cwd()),
|
||||
dev: path.resolve(process.cwd(), './.lowdefy/dev'),
|
||||
dotLowdefy: path.resolve(process.cwd(), './.lowdefy'),
|
||||
server: path.resolve(process.cwd(), './.lowdefy/server'),
|
||||
},
|
||||
lowdefyVersion: 'lowdefyVersion',
|
||||
@ -153,7 +151,6 @@ test('startUp, options configDirectory', async () => {
|
||||
build: path.resolve(process.cwd(), './configDirectory/.lowdefy/server/build'),
|
||||
config: path.resolve(process.cwd(), './configDirectory'),
|
||||
dev: path.resolve(process.cwd(), './configDirectory/.lowdefy/dev'),
|
||||
dotLowdefy: path.resolve(process.cwd(), './configDirectory/.lowdefy'),
|
||||
server: path.resolve(process.cwd(), './configDirectory/.lowdefy/server'),
|
||||
},
|
||||
lowdefyVersion: 'lowdefyVersion',
|
||||
@ -168,79 +165,6 @@ test('startUp, options configDirectory', async () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('startUp, options outputDirectory', async () => {
|
||||
const startUp = (await import('./startUp.js')).default;
|
||||
const context = { cliVersion: 'cliVersion' };
|
||||
await startUp({ context, options: { outputDirectory: './outputDirectory' }, command });
|
||||
const print = context.print;
|
||||
expect(context).toEqual({
|
||||
appId: 'appId',
|
||||
configDirectory: path.resolve(process.cwd()),
|
||||
cliConfig: { cliConfig: true },
|
||||
cliVersion: 'cliVersion',
|
||||
command: 'test',
|
||||
commandLineOptions: { outputDirectory: './outputDirectory' },
|
||||
directories: {
|
||||
build: path.resolve(process.cwd(), './outputDirectory/server/build'),
|
||||
config: path.resolve(process.cwd()),
|
||||
dev: path.resolve(process.cwd(), './outputDirectory/dev'),
|
||||
dotLowdefy: path.resolve(process.cwd(), './outputDirectory'),
|
||||
server: path.resolve(process.cwd(), './outputDirectory/server'),
|
||||
},
|
||||
lowdefyVersion: 'lowdefyVersion',
|
||||
options: {
|
||||
cliConfig: true,
|
||||
outputDirectory: './outputDirectory',
|
||||
},
|
||||
packageManager: 'yarn',
|
||||
packageManagerCmd: process.platform === 'win32' ? 'yarn.cmd' : 'yarn',
|
||||
print,
|
||||
sendTelemetry: 'sendTelemetry',
|
||||
});
|
||||
});
|
||||
|
||||
test('startUp, options configDirectory and outputDirectory', async () => {
|
||||
const startUp = (await import('./startUp.js')).default;
|
||||
const context = { cliVersion: 'cliVersion' };
|
||||
await startUp({
|
||||
context,
|
||||
options: {
|
||||
configDirectory: './configDirectory',
|
||||
outputDirectory: './outputDirectory',
|
||||
},
|
||||
command,
|
||||
});
|
||||
const print = context.print;
|
||||
expect(context).toEqual({
|
||||
appId: 'appId',
|
||||
configDirectory: path.resolve(process.cwd(), 'configDirectory'),
|
||||
cliConfig: { cliConfig: true },
|
||||
cliVersion: 'cliVersion',
|
||||
command: 'test',
|
||||
commandLineOptions: {
|
||||
configDirectory: './configDirectory',
|
||||
outputDirectory: './outputDirectory',
|
||||
},
|
||||
directories: {
|
||||
build: path.resolve(process.cwd(), './outputDirectory/server/build'),
|
||||
config: path.resolve(process.cwd(), './configDirectory'),
|
||||
dev: path.resolve(process.cwd(), './outputDirectory/dev'),
|
||||
dotLowdefy: path.resolve(process.cwd(), './outputDirectory'),
|
||||
server: path.resolve(process.cwd(), './outputDirectory/server'),
|
||||
},
|
||||
lowdefyVersion: 'lowdefyVersion',
|
||||
options: {
|
||||
configDirectory: './configDirectory',
|
||||
cliConfig: true,
|
||||
outputDirectory: './outputDirectory',
|
||||
},
|
||||
packageManager: 'yarn',
|
||||
packageManagerCmd: process.platform === 'win32' ? 'yarn.cmd' : 'yarn',
|
||||
print,
|
||||
sendTelemetry: 'sendTelemetry',
|
||||
});
|
||||
});
|
||||
|
||||
test('startUp, no lowdefyVersion returned', async () => {
|
||||
const startUp = (await import('./startUp.js')).default;
|
||||
const checkForUpdatedVersions = (await import('./checkForUpdatedVersions.js')).default;
|
||||
@ -260,7 +184,6 @@ test('startUp, no lowdefyVersion returned', async () => {
|
||||
build: path.resolve(process.cwd(), './.lowdefy/server/build'),
|
||||
config: path.resolve(process.cwd()),
|
||||
dev: path.resolve(process.cwd(), './.lowdefy/dev'),
|
||||
dotLowdefy: path.resolve(process.cwd(), './.lowdefy'),
|
||||
server: path.resolve(process.cwd(), './.lowdefy/server'),
|
||||
},
|
||||
lowdefyVersion: undefined,
|
||||
|
Loading…
x
Reference in New Issue
Block a user