Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
ask-node committed Feb 28, 2020
2 parents 0ae9693 + 4d035a2 commit 0036a14
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 1,121 deletions.
10 changes: 5 additions & 5 deletions lib/clients/aws-client/aws-util.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const aws = require('aws-sdk');
const fs = require('fs');
const fs = require('fs-extra');
const os = require('os');
const path = require('path');
const jsonUtility = require('@src/utils/json-utility');
const R = require('ramda');

const CONSTANT = require('@src/utils/constants');

module.exports = {
Expand All @@ -23,9 +24,8 @@ function getAWSProfile(askProfile) {
return CONSTANT.PLACEHOLDER.ENVIRONMENT_VAR.AWS_CREDENTIALS;
}
}
const awsCredentials = path.join(os.homedir(), '.ask', 'cli_config');
const propertyPathForAWSProfile = ['profiles', askProfile, 'aws_profile'];
return jsonUtility.getProperty(awsCredentials, propertyPathForAWSProfile);
const askConfig = fs.readJSONSync(path.join(os.homedir(), '.ask', 'cli_config'));
return R.view(R.lensPath(['profiles', askProfile, 'aws_profile']), askConfig);
}

// We face the same issue as mentioned in https://github.com/aws/aws-sdk-js/issues/2181
Expand Down
2 changes: 1 addition & 1 deletion lib/clients/smapi-client/resources/skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ module.exports = (smapiHandle) => {
function listIspForSkill(skillId, stage, queryParams, callback) {
const queryObject = R.clone(queryParams);
if (queryObject && !queryObject.maxResults) {
queryObject.maxResults = CONSTANTS.ISP.NUMBERS.DEFAULT_ISP_MAX_RESULTS;
queryObject.maxResults = CONSTANTS.SMAPI.DEFAULT_MAX_RESULT_PER_PAGE;
}
const url = `skills/${skillId}/stages/${stage}/${ISP_URL_BASE}`;
smapiHandle(
Expand Down
12 changes: 5 additions & 7 deletions lib/commands/api/account-linking/set-account-linking/helper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require('fs');

const stringUtility = require('@src/utils/string-utils');
const tools = require('@src/utils/tools');

const ui = require('./ui');

Expand Down Expand Up @@ -49,19 +48,18 @@ function prepareAccountLinkingPayload(smapiClient, skillId, stage, filePath, cal
}

function getManifest(smapiClient, skillId, stage, callback) {
smapiClient.skill.manifest.getManifest(skillId, stage, (getManifestErr, data) => {
smapiClient.skill.manifest.getManifest(skillId, stage, (getManifestErr, response) => {
if (getManifestErr) {
return callback(getManifestErr);
}
if (data.statusCode === 303) {
if (response.statusCode === 303) {
return callback('[Warn]: The get-manifest request is not ready. Please try again later.');
}

const response = tools.convertDataToJsonObject(data.body);
if (data.statusCode < 300) {
callback(null, response);
if (response.statusCode < 300) {
callback(null, response.body);
} else {
callback(response, null);
callback(response.body, null);
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SetAccountLinkingCommand extends AbstractCommand {
Messenger.getInstance().error(error);
cb(error);
} else {
Messenger.getInstance().info(jsonView.toString(response.body));
Messenger.getInstance().info('Account linking information updated successfully.');
cb();
}
});
Expand Down
13 changes: 5 additions & 8 deletions lib/commands/api/catalog/upload-catalog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const SmapiClient = require('@src/clients/smapi-client');
const S3Client = require('@src/clients/aws-client/s3-client');
const optionModel = require('@src/commands/option-model');
const profileHelper = require('@src/utils/profile-helper');
const tools = require('@src/utils/tools');

const helper = require('./helper');

Expand Down Expand Up @@ -54,23 +53,21 @@ function _multiPartUploadCatalog(catalogId, filePath, smapiClient, callback) {
}

helper._confirmOrOverwritePartSize(totalSize, calculatedPartSize, calculatedPartsNumber, (partSize, partsNumber) => {
smapiClient.catalog.createCatalogUpload(catalogId, partsNumber, (createCatalogUploadError, data) => {
smapiClient.catalog.createCatalogUpload(catalogId, partsNumber, (createCatalogUploadError, createResponse) => {
if (createCatalogUploadError) {
callback(createCatalogUploadError);
return;
}
const createResponse = tools.convertDataToJsonObject(data.body);
if (!createResponse) {
if (!createResponse.body) {
return process.nextTick(() => {
callback('[Error]: The response from create-catalog-upload should not be empty.');
});
}
if (!createResponse.id || !createResponse.presignedUploadParts) {
const uploadId = createResponse.body.id;
if (!uploadId || !createResponse.body.presignedUploadParts) {
return callback('[Error]: The response of create-catalog-upload is not valid.');
}

const uploadId = createResponse.id;
const uploadPartsMap = helper._transformUploadArrayToMap(createResponse.presignedUploadParts);
const uploadPartsMap = helper._transformUploadArrayToMap(createResponse.body.presignedUploadParts);
if (!uploadPartsMap) {
return callback('[Error]: The response from create-catalog-upload is empty.');
}
Expand Down
10 changes: 1 addition & 9 deletions lib/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const DEFAULT_LIST_MAX_RESULT = 50;

module.exports.METRICS = {
ENDPOINT: '', // TODO add the official endpoint when we have it
NEW_USER_LENGTH_DAYS: 3
Expand Down Expand Up @@ -38,12 +36,6 @@ module.exports.SKILL = {
}
};

module.exports.ISP = {
NUMBERS: {
DEFAULT_ISP_MAX_RESULTS: 50
}
};

module.exports.CONFIGURATION = {
JSON_DISPLAY_INDENT: 2,
OPN_BROWSER_DELAY: 1000,
Expand Down Expand Up @@ -271,7 +263,7 @@ module.exports.SMAPI = {
GET_TASK: 'get-task',
SEARCH_TASK: 'search-task'
},
DEFAULT_MAX_RESULT_PER_PAGE: DEFAULT_LIST_MAX_RESULT
DEFAULT_MAX_RESULT_PER_PAGE: 50
};

module.exports.HTTP_REQUEST = {
Expand Down
40 changes: 0 additions & 40 deletions lib/utils/json-read.js

This file was deleted.

110 changes: 0 additions & 110 deletions lib/utils/json-utility.js

This file was deleted.

Loading

0 comments on commit 0036a14

Please sign in to comment.