@cplace/cli
Advanced tools
Comparing version 0.10.0 to 0.11.0
@@ -96,5 +96,7 @@ #!/usr/bin/env node | ||
e2e [--baseUrl <baseUrl>] [--browser <browser>] [--plugins <plugins>] [--timeout <timeout>] [--headless] | ||
e2e [--baseUrl <baseUrl>] [--context <context>] [--tenantId <context>] [--browser <browser>] [--plugins <plugins>] [--timeout <timeout>] [--headless] | ||
--baseUrl to configure where to run the tests against (default: localhost) | ||
--baseUrl to configure where to run the tests against (default: 'http://localhost:8083') | ||
--context to define in which context cplace is running (default: '/intern/tricia/') | ||
--tenantId to define against which tenant the tests are run (default: '' single tenant mode) | ||
--browser to specify which browser to use (default: Chrome) | ||
@@ -101,0 +103,0 @@ --plugins to specify a comma separated list of plugins to run tests for (default: all plugins in the current repository) |
export declare class ConfigTemplate { | ||
private readonly template; | ||
constructor(e2eFolder: string, browser: string, baseUrl: string, timeout: number, headless: boolean); | ||
constructor(mainRepoDir: string, e2eFolder: string, browser: string, baseUrl: string, timeout: number, headless: boolean); | ||
getTemplate(): string; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class ConfigTemplate { | ||
constructor(e2eFolder, browser, baseUrl, timeout, headless) { | ||
constructor(mainRepoDir, e2eFolder, browser, baseUrl, timeout, headless) { | ||
let capabilities = ''; | ||
@@ -29,7 +29,7 @@ if (headless) { | ||
var config = require('${e2eFolder}/tsconfig.json'); | ||
require('tsconfig-paths').register({ | ||
require('${mainRepoDir}/node_modules/tsconfig-paths').register({ | ||
baseUrl: '${e2eFolder}', | ||
paths: config.compilerOptions.paths || [] | ||
}); | ||
require('ts-node').register({ | ||
require('${mainRepoDir}/node_modules/ts-node').register({ | ||
files: true, | ||
@@ -36,0 +36,0 @@ project: '${e2eFolder}/tsconfig.json' |
@@ -7,2 +7,4 @@ /** | ||
private static readonly PARAMETER_BASE_URL; | ||
private static readonly PARAMETER_CONTEXT; | ||
private static readonly PARAMETER_TENANTID; | ||
private static readonly PARAMETER_PLUGINS; | ||
@@ -13,8 +15,12 @@ private static readonly PARAMETER_BROWSER; | ||
private static readonly DEFAULT_BASE_URL; | ||
private static readonly DEFAULT_CONTEXT; | ||
private static readonly DEFAULT_BROWSER; | ||
private static readonly DEFAULT_TIMEOUT; | ||
private workingDir; | ||
private mainRepoDir; | ||
private pluginsToBeTested; | ||
private baseUrl; | ||
private context; | ||
private tenantId; | ||
private browser; | ||
private workingDir; | ||
private timeout; | ||
@@ -21,0 +27,0 @@ private headless; |
@@ -8,2 +8,3 @@ "use strict"; | ||
const fs = require("fs"); | ||
const util_1 = require("../../util"); | ||
class E2E { | ||
@@ -15,2 +16,7 @@ constructor() { | ||
this.workingDir = process.cwd(); | ||
this.mainRepoDir = util_1.getPathToMainRepo(this.workingDir); | ||
if (!this.mainRepoDir) { | ||
console.error(`Could not determine path to main repo!`); | ||
return false; | ||
} | ||
const plugins = params[E2E.PARAMETER_PLUGINS]; | ||
@@ -28,5 +34,11 @@ if (typeof plugins === 'string' && plugins.length > 0) { | ||
console.log('Running E2E tests for: ', this.pluginsToBeTested.join(', ')); | ||
// NOTE: The slashes of baseUrl and context need to match the | ||
// specifications required by the cplace base system. Also see the E2EENV | ||
// comments in main. | ||
const baseUrl = params[E2E.PARAMETER_BASE_URL]; | ||
if (typeof baseUrl === 'string' && baseUrl.length > 0) { | ||
this.baseUrl = baseUrl; | ||
if (this.baseUrl.endsWith('/')) { | ||
this.baseUrl = this.baseUrl.substr(0, this.baseUrl.length - 1); | ||
} | ||
} | ||
@@ -36,2 +48,22 @@ else { | ||
} | ||
const context = params[E2E.PARAMETER_CONTEXT]; | ||
if (typeof context === 'string' && context.length > 0) { | ||
this.context = context; | ||
if (!this.context.startsWith('/')) { | ||
this.context = '/' + this.context; | ||
} | ||
if (!this.context.endsWith('/')) { | ||
this.context += '/'; | ||
} | ||
} | ||
else { | ||
this.context = E2E.DEFAULT_CONTEXT; | ||
} | ||
const tenantId = params[E2E.PARAMETER_TENANTID]; | ||
if (typeof tenantId === 'string' && tenantId.length > 0) { | ||
this.tenantId = tenantId; | ||
} | ||
else { | ||
this.tenantId = ''; | ||
} | ||
const browser = params[E2E.PARAMETER_BROWSER]; | ||
@@ -57,2 +89,3 @@ if (typeof browser === 'string' && browser.length > 0) { | ||
this.headless = false; | ||
console.error(`! Headless disabled - only available for Chrome execution`); | ||
} | ||
@@ -70,4 +103,10 @@ this.testRunner = new TestRunner_1.TestRunner(this.pluginsToBeTested, this.workingDir); | ||
} | ||
const wdioGenerator = new WdioConfigGenerator_1.WdioConfigGenerator(this.pluginsToBeTested, this.baseUrl, this.browser, this.timeout, this.workingDir, this.headless); | ||
const context = { | ||
baseUrl: this.baseUrl, | ||
context: this.context, | ||
tenantId: this.tenantId | ||
}; | ||
const wdioGenerator = new WdioConfigGenerator_1.WdioConfigGenerator(this.workingDir, this.mainRepoDir, this.pluginsToBeTested, this.browser, context, this.timeout, this.headless); | ||
console.log('Generating WDIO configuration files...'); | ||
wdioGenerator.generateE2EEnv(); | ||
wdioGenerator.generateWdioConfig(); | ||
@@ -97,2 +136,4 @@ console.log('Starting test runner...'); | ||
E2E.PARAMETER_BASE_URL = 'baseUrl'; | ||
E2E.PARAMETER_CONTEXT = 'context'; | ||
E2E.PARAMETER_TENANTID = 'tenantId'; | ||
E2E.PARAMETER_PLUGINS = 'plugins'; | ||
@@ -103,3 +144,4 @@ E2E.PARAMETER_BROWSER = 'browser'; | ||
// Default | ||
E2E.DEFAULT_BASE_URL = 'http://localhost:8083/'; | ||
E2E.DEFAULT_BASE_URL = 'http://localhost:8083'; | ||
E2E.DEFAULT_CONTEXT = '/intern/tricia/'; | ||
E2E.DEFAULT_BROWSER = 'chrome'; | ||
@@ -106,0 +148,0 @@ E2E.DEFAULT_TIMEOUT = 30000; |
@@ -0,12 +1,16 @@ | ||
import { IE2EContext } from './E2EEnvTemplate'; | ||
export declare class WdioConfigGenerator { | ||
static readonly WDIO_CONF_NAME: string; | ||
private readonly baseUrl; | ||
static readonly E2E_ENV_NAME: string; | ||
private readonly workingDir; | ||
private readonly mainDir; | ||
private readonly context; | ||
private readonly plugins; | ||
private readonly browser; | ||
private readonly timeout; | ||
private readonly workingDir; | ||
private readonly headless; | ||
constructor(plugins: string[], baseUrl: string, browser: string, timeout: number, workingDir: string, headless: boolean); | ||
constructor(workingDir: string, mainDir: string, plugins: string[], browser: string, context: IE2EContext, timeout: number, headless: boolean); | ||
private static pathToE2EFolder; | ||
generateE2EEnv(): void; | ||
generateWdioConfig(): void; | ||
private pathToE2EFolder; | ||
} |
@@ -6,25 +6,33 @@ "use strict"; | ||
const fs = require("fs"); | ||
const E2EEnvTemplate_1 = require("./E2EEnvTemplate"); | ||
class WdioConfigGenerator { | ||
constructor(plugins, baseUrl, browser, timeout, workingDir, headless) { | ||
constructor(workingDir, mainDir, plugins, browser, context, timeout, headless) { | ||
this.workingDir = workingDir; | ||
this.mainDir = mainDir; | ||
this.browser = browser; | ||
this.plugins = plugins; | ||
this.baseUrl = baseUrl; | ||
this.context = context; | ||
this.timeout = timeout; | ||
this.workingDir = workingDir; | ||
this.headless = headless; | ||
} | ||
static pathToE2EFolder(pluginName, baseDir) { | ||
const e2ePath = path.join(baseDir, pluginName, 'assets', 'e2e'); | ||
return e2ePath.replace(/\\/g, '/'); // For Windows | ||
} | ||
generateE2EEnv() { | ||
const e2eFolder = WdioConfigGenerator.pathToE2EFolder('cf.cplace.platform', this.mainDir); | ||
const e2eEnv = new E2EEnvTemplate_1.E2EEnvTemplate(this.context); | ||
fs.writeFileSync(path.join(e2eFolder, 'lib', 'config', WdioConfigGenerator.E2E_ENV_NAME), e2eEnv.getTemplate(), { encoding: 'utf8' }); | ||
} | ||
generateWdioConfig() { | ||
this.plugins.forEach((plugin) => { | ||
const e2eFolder = this.pathToE2EFolder(plugin); | ||
const config = new ConfigTemplate_1.ConfigTemplate(e2eFolder, this.browser, this.baseUrl, this.timeout, this.headless); | ||
const e2eFolder = WdioConfigGenerator.pathToE2EFolder(plugin, this.workingDir); | ||
const config = new ConfigTemplate_1.ConfigTemplate(this.mainDir, e2eFolder, this.browser, this.context.baseUrl, this.timeout, this.headless); | ||
fs.writeFileSync(path.join(e2eFolder, WdioConfigGenerator.WDIO_CONF_NAME), config.getTemplate(), { encoding: 'utf8' }); | ||
}); | ||
} | ||
pathToE2EFolder(pluginName) { | ||
const e2ePath = path.join(this.workingDir, pluginName, 'assets', 'e2e'); | ||
return e2ePath.replace(/\\/g, '/'); // For Windows | ||
} | ||
} | ||
WdioConfigGenerator.WDIO_CONF_NAME = 'wdio.conf.js'; | ||
WdioConfigGenerator.E2E_ENV_NAME = 'e2e.ts'; | ||
exports.WdioConfigGenerator = WdioConfigGenerator; | ||
//# sourceMappingURL=WdioConfigGenerator.js.map |
@@ -6,1 +6,2 @@ /** | ||
export declare function makeSingleLine(text: string): string; | ||
export declare function getPathToMainRepo(workingDir?: string): string | null; |
@@ -6,2 +6,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
function enforceNewline(text) { | ||
@@ -17,2 +19,19 @@ return text.replace(/\r\n?/g, '\n'); | ||
exports.makeSingleLine = makeSingleLine; | ||
function getPathToMainRepo(workingDir = '') { | ||
if (!workingDir) { | ||
workingDir = process.cwd(); | ||
} | ||
workingDir = path.resolve(workingDir); | ||
if (path.basename(workingDir) === 'main') { | ||
return workingDir; | ||
} | ||
const expectedMain = path.resolve(workingDir, '..', 'main'); | ||
if (!fs.existsSync(expectedMain)) { | ||
return null; | ||
} | ||
else { | ||
return expectedMain; | ||
} | ||
} | ||
exports.getPathToMainRepo = getPathToMainRepo; | ||
//# sourceMappingURL=util.js.map |
{ | ||
"name": "@cplace/cli", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
275870
141
3858
11