Skip to content

Commit c337d44

Browse files
committed
Merge branch 'master' into deploy
2 parents de131c2 + 16ec8a2 commit c337d44

File tree

11 files changed

+643
-419
lines changed

11 files changed

+643
-419
lines changed

bin/commands/info.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ module.exports = function info(args) {
1010
let bsConfigPath = utils.getConfigPath(args.cf);
1111

1212
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
13+
utils.setDefaults(bsConfig, args);
14+
1315
// accept the username from command line if provided
1416
utils.setUsername(bsConfig, args);
1517

@@ -30,7 +32,7 @@ module.exports = function info(args) {
3032
password: bsConfig.auth.access_key,
3133
},
3234
headers: {
33-
"User-Agent": utils.getUserAgent(),
35+
'User-Agent': utils.getUserAgent(),
3436
},
3537
};
3638

@@ -55,7 +57,7 @@ module.exports = function info(args) {
5557

5658
if (resp.statusCode == 299) {
5759
messageType = Constants.messageTypes.INFO;
58-
errorCode = "api_deprecated";
60+
errorCode = 'api_deprecated';
5961

6062
if (build) {
6163
message = build.message;
@@ -66,14 +68,14 @@ module.exports = function info(args) {
6668
}
6769
} else if (resp.statusCode != 200) {
6870
messageType = Constants.messageTypes.ERROR;
69-
errorCode = "api_failed_build_info";
71+
errorCode = 'api_failed_build_info';
7072

7173
if (build) {
7274
message = `${
7375
Constants.userMessages.BUILD_INFO_FAILED
7476
} with error: \n${JSON.stringify(build, null, 2)}`;
7577
logger.error(message);
76-
if (build.message === "Unauthorized") errorCode = "api_auth_failed";
78+
if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
7779
} else {
7880
message = Constants.userMessages.BUILD_INFO_FAILED;
7981
logger.error(message);
@@ -89,7 +91,7 @@ module.exports = function info(args) {
8991
}
9092
}
9193
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode);
92-
})
94+
});
9395
}).catch(function (err) {
9496
logger.error(err);
9597
utils.setUsageReportingFlag(null, args.disableUsageReporting);

bin/commands/runs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module.exports = function run(args) {
1717
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
1818
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
1919

20+
utils.setDefaults(bsConfig, args);
21+
2022
// accept the username from command line or env variable if provided
2123
utils.setUsername(bsConfig, args);
2224

bin/commands/stop.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ module.exports = function stop(args) {
1010
let bsConfigPath = utils.getConfigPath(args.cf);
1111

1212
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
13+
utils.setDefaults(bsConfig, args);
14+
1315
// accept the username from command line if provided
1416
utils.setUsername(bsConfig, args);
1517

@@ -30,7 +32,7 @@ module.exports = function stop(args) {
3032
password: bsConfig.auth.access_key,
3133
},
3234
headers: {
33-
"User-Agent": utils.getUserAgent(),
35+
'User-Agent': utils.getUserAgent(),
3436
},
3537
};
3638

@@ -46,16 +48,16 @@ module.exports = function stop(args) {
4648

4749
logger.info(message);
4850
} else {
49-
let build = null
51+
let build = null;
5052
try {
51-
build = JSON.parse(body)
53+
build = JSON.parse(body);
5254
} catch (error) {
53-
build = null
55+
build = null;
5456
}
5557

5658
if (resp.statusCode == 299) {
5759
messageType = Constants.messageTypes.INFO;
58-
errorCode = "api_deprecated";
60+
errorCode = 'api_deprecated';
5961

6062
if (build) {
6163
message = build.message;
@@ -66,14 +68,14 @@ module.exports = function stop(args) {
6668
}
6769
} else if (resp.statusCode != 200) {
6870
messageType = Constants.messageTypes.ERROR;
69-
errorCode = "api_failed_build_stop";
71+
errorCode = 'api_failed_build_stop';
7072

7173
if (build) {
7274
message = `${
7375
Constants.userMessages.BUILD_STOP_FAILED
7476
} with error: \n${JSON.stringify(build, null, 2)}`;
7577
logger.error(message);
76-
if (build.message === "Unauthorized") errorCode = "api_auth_failed";
78+
if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
7779
} else {
7880
message = Constants.userMessages.BUILD_STOP_FAILED;
7981
logger.error(message);
@@ -85,7 +87,7 @@ module.exports = function stop(args) {
8587
}
8688
}
8789
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode);
88-
})
90+
});
8991
}).catch(function (err) {
9092
logger.error(err);
9193
utils.setUsageReportingFlag(null, args.disableUsageReporting);

bin/helpers/archiver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles) => {
4242
let ignoreFiles = getFilesToIgnore(runSettings, excludeFiles);
4343

4444
Constants.allowedFileTypes.forEach(fileType => {
45-
archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ignoreFiles });
45+
archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ignoreFiles, dot:true });
4646
});
4747

4848
let packageJSON = {};

bin/helpers/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ const messageTypes = {
8787
NULL: null
8888
}
8989

90-
const allowedFileTypes = ['js', 'json', 'txt', 'ts', 'feature', 'features', 'pdf', 'jpg', 'jpeg', 'png', 'zip'];
90+
const allowedFileTypes = ['js', 'json', 'txt', 'ts', 'feature', 'features', 'pdf', 'jpg', 'jpeg', 'png', 'zip', 'npmrc'];
9191

92-
const filesToIgnoreWhileUploading = ['node_modules/**', 'package-lock.json', 'package.json', 'browserstack-package.json', 'tests.zip', 'cypress.json']
92+
const filesToIgnoreWhileUploading = ['**/node_modules/**', 'node_modules/**', 'package-lock.json', 'package.json', 'browserstack-package.json', 'tests.zip', 'cypress.json']
9393

9494
module.exports = Object.freeze({
9595
userMessages,

bin/helpers/utils.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ exports.setParallels = (bsConfig, args) => {
115115
}
116116
};
117117

118+
exports.setDefaults = (bsConfig, args) => {
119+
// setting setDefaultAuthHash to {} if not present and set via env variables or via args.
120+
if (this.isUndefined(bsConfig['auth']) && (!this.isUndefined(args.username) || !this.isUndefined(process.env.BROWSERSTACK_USERNAME))) {
121+
bsConfig['auth'] = {};
122+
}
123+
124+
// setting npm_dependencies to {} if not present
125+
if (bsConfig.run_settings && this.isUndefined(bsConfig.run_settings.npm_dependencies)) {
126+
bsConfig.run_settings.npm_dependencies = {}
127+
}
128+
}
129+
118130
exports.setUsername = (bsConfig, args) => {
119131
if (!this.isUndefined(args.username)) {
120132
bsConfig["auth"]["username"] = args.username;
@@ -270,8 +282,8 @@ exports.isCypressProjDirValid = (cypressProjDir, integrationFoldDir) => {
270282
integrationFolderDir = path.resolve(path.join(cypressProjDir, integrationFoldDir));
271283
}
272284
if (integrationFolderDir === cypressDir) return true;
273-
let parentTokens = cypressDir.split("/").filter((i) => i.length);
274-
let childTokens = integrationFolderDir.split("/").filter((i) => i.length);
285+
let parentTokens = cypressDir.split(path.sep).filter((i) => i.length);
286+
let childTokens = integrationFolderDir.split(path.sep).filter((i) => i.length);
275287
return parentTokens.every((t, i) => childTokens[i] === t);
276288
};
277289

0 commit comments

Comments
 (0)