mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Add mainModulePath and globalModules CLI flags.
This commit is contained in:
@@ -3,8 +3,6 @@ import { Loader } from 'componentsjs';
|
||||
import { CliRunner } from '../../../src/init/CliRunner';
|
||||
import type { Initializer } from '../../../src/init/Initializer';
|
||||
|
||||
const mainModulePath = path.join(__dirname, '../../../');
|
||||
|
||||
const initializer: jest.Mocked<Initializer> = {
|
||||
handleSafe: jest.fn(),
|
||||
} as any;
|
||||
@@ -19,6 +17,7 @@ jest.mock('componentsjs', (): any => ({
|
||||
Loader: jest.fn((): Loader => loader),
|
||||
}));
|
||||
|
||||
jest.spyOn(process, 'cwd').mockReturnValue('/var/cwd');
|
||||
const write = jest.spyOn(process.stderr, 'write').mockImplementation(jest.fn());
|
||||
const exit = jest.spyOn(process, 'exit').mockImplementation(jest.fn() as any);
|
||||
|
||||
@@ -34,7 +33,9 @@ describe('CliRunner', (): void => {
|
||||
await initializer.handleSafe();
|
||||
|
||||
expect(Loader).toHaveBeenCalledTimes(1);
|
||||
expect(Loader).toHaveBeenCalledWith({ mainModulePath });
|
||||
expect(Loader).toHaveBeenCalledWith({
|
||||
mainModulePath: path.join(__dirname, '../../../'),
|
||||
});
|
||||
expect(loader.instantiateFromUrl).toHaveBeenCalledTimes(1);
|
||||
expect(loader.instantiateFromUrl).toHaveBeenCalledWith(
|
||||
'urn:solid-server:default:Initializer',
|
||||
@@ -61,29 +62,36 @@ describe('CliRunner', (): void => {
|
||||
new CliRunner().run({
|
||||
argv: [
|
||||
'node', 'script',
|
||||
'-p', '4000',
|
||||
'-b', 'http://pod.example/',
|
||||
'-c', 'myconfig.json',
|
||||
'-f', '/root',
|
||||
'-s', 'http://localhost:5000/sparql',
|
||||
'-g',
|
||||
'-l', 'debug',
|
||||
'-m', 'module/path',
|
||||
'-p', '4000',
|
||||
'-s', 'http://localhost:5000/sparql',
|
||||
'-t', 'templates',
|
||||
],
|
||||
});
|
||||
await initializer.handleSafe();
|
||||
|
||||
expect(Loader).toHaveBeenCalledTimes(1);
|
||||
expect(Loader).toHaveBeenCalledWith({
|
||||
mainModulePath: '/var/cwd/module/path',
|
||||
scanGlobal: true,
|
||||
});
|
||||
expect(loader.instantiateFromUrl).toHaveBeenCalledWith(
|
||||
'urn:solid-server:default:Initializer',
|
||||
path.join(process.cwd(), 'myconfig.json'),
|
||||
'/var/cwd/myconfig.json',
|
||||
undefined,
|
||||
{
|
||||
variables: {
|
||||
'urn:solid-server:default:variable:port': 4000,
|
||||
'urn:solid-server:default:variable:baseUrl': 'http://pod.example/',
|
||||
'urn:solid-server:default:variable:rootFilePath': '/root',
|
||||
'urn:solid-server:default:variable:sparqlEndpoint': 'http://localhost:5000/sparql',
|
||||
'urn:solid-server:default:variable:loggingLevel': 'debug',
|
||||
'urn:solid-server:default:variable:podTemplateFolder': 'templates',
|
||||
'urn:solid-server:default:variable:port': 4000,
|
||||
'urn:solid-server:default:variable:rootFilePath': '/root',
|
||||
'urn:solid-server:default:variable:sparqlEndpoint': 'http://localhost:5000/sparql',
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -93,29 +101,36 @@ describe('CliRunner', (): void => {
|
||||
new CliRunner().run({
|
||||
argv: [
|
||||
'node', 'script',
|
||||
'--port', '4000',
|
||||
'--baseUrl', 'http://pod.example/',
|
||||
'--config', 'myconfig.json',
|
||||
'--globalModules',
|
||||
'--loggingLevel', 'debug',
|
||||
'--mainModulePath', 'module/path',
|
||||
'--podTemplateFolder', 'templates',
|
||||
'--port', '4000',
|
||||
'--rootFilePath', '/root',
|
||||
'--sparqlEndpoint', 'http://localhost:5000/sparql',
|
||||
'--loggingLevel', 'debug',
|
||||
'--podTemplateFolder', 'templates',
|
||||
],
|
||||
});
|
||||
await initializer.handleSafe();
|
||||
|
||||
expect(Loader).toHaveBeenCalledTimes(1);
|
||||
expect(Loader).toHaveBeenCalledWith({
|
||||
mainModulePath: '/var/cwd/module/path',
|
||||
scanGlobal: true,
|
||||
});
|
||||
expect(loader.instantiateFromUrl).toHaveBeenCalledWith(
|
||||
'urn:solid-server:default:Initializer',
|
||||
path.join(process.cwd(), 'myconfig.json'),
|
||||
'/var/cwd/myconfig.json',
|
||||
undefined,
|
||||
{
|
||||
variables: {
|
||||
'urn:solid-server:default:variable:port': 4000,
|
||||
'urn:solid-server:default:variable:baseUrl': 'http://pod.example/',
|
||||
'urn:solid-server:default:variable:rootFilePath': '/root',
|
||||
'urn:solid-server:default:variable:sparqlEndpoint': 'http://localhost:5000/sparql',
|
||||
'urn:solid-server:default:variable:loggingLevel': 'debug',
|
||||
'urn:solid-server:default:variable:podTemplateFolder': 'templates',
|
||||
'urn:solid-server:default:variable:port': 4000,
|
||||
'urn:solid-server:default:variable:rootFilePath': '/root',
|
||||
'urn:solid-server:default:variable:sparqlEndpoint': 'http://localhost:5000/sparql',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user