Skip to content

Commit

Permalink
Merge pull request #236 from LambdaTest/dev
Browse files Browse the repository at this point in the history
3.0.12
  • Loading branch information
asad9711 authored Mar 24, 2023
2 parents d0d8aba + 33d1935 commit b70b681
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 23 deletions.
27 changes: 16 additions & 11 deletions commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const { config } = require('yargs');
const constants = require('./utils/constants.js')

function create_file(file_path, content) {
fs.writeFile(file_path, content, function (err) {
fs.writeFileSync(file_path, content, function (err) {
if (err) throw err;
console.log('Saved at ',file_path);
});
}
};

function create_ltconfig_file(args) {
let cv=9.6
Expand Down Expand Up @@ -47,14 +47,6 @@ function create_ltconfig_file(args) {
}
};

function create_base_reporter_config_file(args) {
let config = require('./utils/default_reporter_config.js')
let content = JSON.stringify(config, null, 3);
if (args._.length == 1) {
create_file(constants.LT_BASE_REPORTER_CONFIG_FILE_NAME, content)
}
};

function create_custom_support_file(args){
const pathToFile = path.join(__dirname, "default_custom_support_file.js");
const pathToNewDestination = constants.LT_BASE_CUSTOM_SUPPORT_FILE_NAME;
Expand All @@ -68,7 +60,16 @@ function create_custom_support_file(args){
});
}

module.exports = function (args) {
function create_base_reporter_config_file(args) {
let config = require('./utils/default_reporter_config.js')
let content = JSON.stringify(config, null, 3);

if (args._.length == 1) {
create_file(constants.LT_BASE_REPORTER_CONFIG_FILE_NAME, content)
}
};

function init_implementation(args){
create_ltconfig_file(args);
create_base_reporter_config_file(args);
if ("cv" in args){
Expand All @@ -77,3 +78,7 @@ module.exports = function (args) {
}
}
};
module.exports = {
create_base_reporter_config_file:create_base_reporter_config_file,
init_implementation:init_implementation,
};
4 changes: 2 additions & 2 deletions commands/utils/batch/batcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ function get_spec_files(files, exclude_files) {
remaining_files.push(matched_files[i]);
}
if (!fs.existsSync(matched_files[i])) {
reject("Spec files are not present");
reject("Error! Spec files are not present");
}
}
if (remaining_files.length == 0) {
reject("Spec files are not present");
reject("Error! Spec files are not present");
}
resolve(remaining_files);
});
Expand Down
1 change: 1 addition & 0 deletions commands/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
REPORT_URL:
"https://api-envi-dev.lambdatestinternal.com/automation/api/v1/cypress/artefacts/test/",
},

stage: {
INTEGRATION_BASE_URL: "https://stage-api.lambdatestinternal.com/liis",
BUILD_BASE_URL:
Expand Down
4 changes: 2 additions & 2 deletions commands/utils/default_reporter_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ module.exports = {
"overwrite": true,
"html": true,
"json": true
}
};
}
}
9 changes: 9 additions & 0 deletions commands/utils/set_args.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const constants = require("./constants.js");
var init_commands = require("./../init.js");

const fs = require("fs");
const path = require("path");
const process = require("process");
Expand Down Expand Up @@ -237,6 +239,13 @@ function sync_args_from_cmd(args) {
console.log(
"Warning !! Value of reporter_config_file parameter missing. Proceeding with default reporter config"
);
// make sure that the default file exists on user system. If not, place it. There is a possibility that
// user may have deleted it from her system/or not ran init command.
if (!fs.existsSync(lt_config["run_settings"]["reporter_config_file"])) {
console.log("!! Warning, Creating the default reporter config file");
init_commands.create_base_reporter_config_file(args);

}
lt_config["run_settings"]["reporter_config_file"] =
constants.LT_BASE_REPORTER_CONFIG_FILE_NAME;
}
Expand Down
6 changes: 3 additions & 3 deletions commands/utils/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const semverCompare = require("semver/functions/compare");

const constants = require("./constants.js");
module.exports = validate_config = function (lt_config, validation_configs) {
console.log("validating config");
console.log("Validating lambdatest config");
return new Promise(function (resolve, reject) {
//validate auth keys are present
if (
Expand Down Expand Up @@ -251,9 +251,9 @@ module.exports = validate_config = function (lt_config, validation_configs) {
);
}
}
} catch {
} catch(e) {
console.log(
"reporter_config_file could not be parsed, please provide a valid json in Reporter Config"
"reporter_config_file could not be parsed, please provide a valid json in Reporter Config - ", e
);
reject("Error!! Reporter JSON File does not have correct json");
}
Expand Down
6 changes: 2 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/usr/bin/env node

const { init } = require("./commands/init");

const argv = require("yargs")
.usage("Usage: $0 <command> [options]")
.command(
"init",
"create an intial config file",
"create an initial config file",
function (yargs) {
return yargs
.option("cv", {
Expand All @@ -21,7 +19,7 @@ const argv = require("yargs")
});
},
function (argv) {
require("./commands/init")(argv);
require("./commands/init").init_implementation(argv);
}
)
.command(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lambdatest-cypress-cli",
"version": "3.0.11",
"version": "3.0.12",
"description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.",
"homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli",
"author": "LambdaTest <[email protected]>",
Expand Down

0 comments on commit b70b681

Please sign in to comment.