From 05e35ab98e42164a25aa538d3943667ec2d85c8a Mon Sep 17 00:00:00 2001 From: Nikhil Kumar Date: Fri, 28 Feb 2020 06:32:18 +0530 Subject: [PATCH 1/4] Create README.md --- codegens/nodejs-superagent/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 codegens/nodejs-superagent/README.md diff --git a/codegens/nodejs-superagent/README.md b/codegens/nodejs-superagent/README.md new file mode 100644 index 000000000..d1afc6f6a --- /dev/null +++ b/codegens/nodejs-superagent/README.md @@ -0,0 +1,7 @@ +# codegen-nodejs-superagent + +> Converts Postman-SDK Request into code snippet for NodeJS-superagent. + + +#### Prerequisites +To run the module, ensure that you have NodeJS with superagent as a dependency. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager. From 8b81c13de263b257594c097c07b8e3d75a032a41 Mon Sep 17 00:00:00 2001 From: Nikhil Kumar Date: Sat, 29 Feb 2020 21:45:49 +0530 Subject: [PATCH 2/4] Boilerplate commit for Nodejs(Superagent) Codegen --- codegens/nodejs-superagent/.gitignore | 41 ++ codegens/nodejs-superagent/.npmignore | 76 +++ codegens/nodejs-superagent/README.md | 43 +- codegens/nodejs-superagent/index.js | 1 + codegens/nodejs-superagent/lib/index.js | 9 + codegens/nodejs-superagent/lib/lodash.js | 455 ++++++++++++++++++ .../nodejs-superagent/npm-shrinkwrap.json | 5 + codegens/nodejs-superagent/npm/test-lint.js | 59 +++ codegens/nodejs-superagent/npm/test-newman.js | 59 +++ codegens/nodejs-superagent/npm/test.js | 19 + codegens/nodejs-superagent/package.json | 33 ++ .../test/newman/newman.test.js | 23 + 12 files changed, 819 insertions(+), 4 deletions(-) create mode 100644 codegens/nodejs-superagent/.gitignore create mode 100644 codegens/nodejs-superagent/.npmignore create mode 100644 codegens/nodejs-superagent/index.js create mode 100644 codegens/nodejs-superagent/lib/index.js create mode 100644 codegens/nodejs-superagent/lib/lodash.js create mode 100644 codegens/nodejs-superagent/npm-shrinkwrap.json create mode 100644 codegens/nodejs-superagent/npm/test-lint.js create mode 100644 codegens/nodejs-superagent/npm/test-newman.js create mode 100644 codegens/nodejs-superagent/npm/test.js create mode 100644 codegens/nodejs-superagent/package.json create mode 100644 codegens/nodejs-superagent/test/newman/newman.test.js diff --git a/codegens/nodejs-superagent/.gitignore b/codegens/nodejs-superagent/.gitignore new file mode 100644 index 000000000..2c7c686e6 --- /dev/null +++ b/codegens/nodejs-superagent/.gitignore @@ -0,0 +1,41 @@ +.DS_Store +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Coverage directory used by tools like istanbul +.coverage + +# node-waf configuration +.lock-wscript + + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +out/ diff --git a/codegens/nodejs-superagent/.npmignore b/codegens/nodejs-superagent/.npmignore new file mode 100644 index 000000000..79ad2ba5f --- /dev/null +++ b/codegens/nodejs-superagent/.npmignore @@ -0,0 +1,76 @@ +### NPM Specific: Disregard recursive project files +### =============================================== +/.editorconfig +/.gitmodules +/test + +### Borrowed from .gitignore +### ======================== + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Prevent IDE stuff +.idea +.vscode +*.sublime-* + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +.coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +snippet.swift + +out/ diff --git a/codegens/nodejs-superagent/README.md b/codegens/nodejs-superagent/README.md index d1afc6f6a..fe1706bc4 100644 --- a/codegens/nodejs-superagent/README.md +++ b/codegens/nodejs-superagent/README.md @@ -1,7 +1,42 @@ -# codegen-nodejs-superagent - -> Converts Postman-SDK Request into code snippet for NodeJS-superagent. +> Converts Postman-SDK Request into code snippet for Nodejs(Superagent). #### Prerequisites -To run the module, ensure that you have NodeJS with superagent as a dependency. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager. +To run Code-Gen, ensure that you have NodeJS >= v8. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager. + +## Using the Module +The module will expose an object which will have property `convert` which is the function for converting the Postman-SDK request to swift code snippet. + +### convert function +Convert function takes three parameters + +* `request` - Postman-SDK Request Object + +* `options` - options is an object which hsa following properties + * `indentType` - String denoting type of indentation for code snippet. eg: 'Space', 'Tab' + * `indentCount` - The number of indentation characters to add per code level + * `trimRequestBody` - Whether or not request body fields should be trimmed + +* `callback` - callback function with first parameter as error and second parameter as string for code snippet + +##### Example: +```js +var request = new sdk.Request('www.google.com'), //using postman sdk to create request + options = { + indentCount: 3, + indentType: 'Space', + requestTimeout: 200, + trimRequestBody: true + }; +convert(request, options, function(error, snippet) { + if (error) { + // handle error + } + // handle snippet +}); +``` +### Guidelines for using generated snippet + +* Since Postman-SDK Request object doesn't provide complete path of the file, it needs to be manually inserted in case of uploading a file. + +* This module doesn't support cookies. diff --git a/codegens/nodejs-superagent/index.js b/codegens/nodejs-superagent/index.js new file mode 100644 index 000000000..bb0a047c4 --- /dev/null +++ b/codegens/nodejs-superagent/index.js @@ -0,0 +1 @@ +module.exports = require('./lib'); diff --git a/codegens/nodejs-superagent/lib/index.js b/codegens/nodejs-superagent/lib/index.js new file mode 100644 index 000000000..0b39c25e7 --- /dev/null +++ b/codegens/nodejs-superagent/lib/index.js @@ -0,0 +1,9 @@ +module.exports = { + convert: function (request, options) { + // Use request object and options object to generate code snippet. + // return (String) snippet + }, + getOptions: function () { + // Return an array of options supported by this codegen. + } +}; diff --git a/codegens/nodejs-superagent/lib/lodash.js b/codegens/nodejs-superagent/lib/lodash.js new file mode 100644 index 000000000..5be147afd --- /dev/null +++ b/codegens/nodejs-superagent/lib/lodash.js @@ -0,0 +1,455 @@ +/* istanbul ignore next */ +module.exports = { + + /** + * Checks if `value` is an empty object, array or string. + * + * Objects are considered empty if they have no own enumerable string keyed + * properties. + * + * Values such as strings, arrays are considered empty if they have a `length` of `0`. + * + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * isEmpty(null) + * // => true + * + * isEmpty(true) + * // => true + * + * isEmpty(1) + * // => true + * + * isEmpty([1, 2, 3]) + * // => false + * + * isEmpty('abc') + * // => false + * + * isEmpty({ 'a': 1 }) + * // => false + */ + isEmpty: function (value) { + // eslint-disable-next-line lodash/prefer-is-nil + if (value === null || value === undefined) { + return true; + } + if (Array.isArray(value) || typeof value === 'string' || typeof value.splice === 'function') { + return !value.length; + } + + for (const key in value) { + if (Object.prototype.hasOwnProperty.call(value, key)) { + return false; + } + } + return true; + }, + + /** + * Checks if `value` is `undefined`. + * + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. + * @example + * + * isUndefined(void 0) + * // => true + * + * isUndefined(null) + * // => false + */ + isUndefined: function (value) { + return value === undefined; + }, + + /** + * Checks if `func` is classified as a `Function` object. + * + * @param {*} func The value to check. + * @returns {boolean} Returns `true` if `func` is a function, else `false`. + * @example + * + * isFunction(self.isEmpty) + * // => true + * + * isFunction(/abc/) + * // => false + */ + isFunction: function (func) { + return typeof func === 'function'; + }, + + /** + * Converts the first character of `string` to upper case and the remaining + * to lower case. + * + * @param {string} [string=''] The string to capitalize. + * @returns {string} Returns the capitalized string. + * @example + * + * capitalize('FRED') + * // => 'Fred' + * + * capitalize('john') + * // => 'John' + */ + + capitalize: function (string) { + return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); + }, + + /** + * Reduces `array` to a value which is the accumulated result of running + * each element in `array` thru `iteratee`, where each successive + * invocation is supplied the return value of the previous. If `accumulator` + * is not given, the first element of `array` is used as the initial + * value. The iteratee is invoked with four arguments: + * (accumulator, value, index|key, array). + * + * @param {Array} array The Array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @returns {*} Returns the accumulated value. + * @example + * + * reduce([1, 2], (sum, n) => sum + n, 0) + * // => 3 + * + */ + reduce: function (array, iteratee, accumulator) { + return array.reduce(iteratee, accumulator); + }, + + /** + * Iterates over elements of `array`, returning an array of all elements + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index, array). + * + * @param {Array} array The array to iterate over. + * @param {Function|object} predicate The function/object invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @example + * + * const users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false } + * ] + * + * filter(users, ({ active }) => active) + * // => object for ['barney'] + */ + filter: function (array, predicate) { + if (typeof predicate === 'function') { + return array.filter(predicate); + } + var key = Object.keys(predicate), + val = predicate[key], + res = []; + array.forEach(function (item) { + if (item[key] && item[key] === val) { + res.push(item); + } + }); + return res; + }, + + /** + * The opposite of `filter` this method returns the elements of `array` + * that `predicate` does **not** return truthy for. + * + * @param {Array} array collection to iterate over. + * @param {String} predicate The String that needs to have truthy value, invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @example + * + * const users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false } + * ] + * + * reject(users, 'active') + * // => object for ['fred'] + */ + reject: function (array, predicate) { + var res = []; + array.forEach((object) => { + if (!object[predicate]) { + res.push(object); + } + }); + return res; + }, + + /** + * Creates an array of values by running each element of `array` thru `iteratee`. + * The iteratee is invoked with three arguments: (value, index, array). + * + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + * @example + * + * function square(n) { + * return n * n + * } + * + * map([4, 8], square) + * // => [16, 64] + */ + map: function (array, iteratee) { + return array.map(iteratee); + }, + + /** + * Iterates over elements of `collection` and invokes `iteratee` for each element. + * The iteratee is invoked with three arguments: (value, index|key, collection). + * + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @example + * + * forEach([1, 2], value => console.log(value)) + * // => Logs `1` then `2`. + * + * forEach({ 'a': 1, 'b': 2 }, (value, key) => console.log(key)) + * // => Logs 'a' then 'b' + */ + + forEach: function (collection, iteratee) { + if (collection === null) { + return null; + } + + if (Array.isArray(collection)) { + return collection.forEach(iteratee); + } + const iterable = Object(collection), + props = Object.keys(collection); + var index = -1, + key, i; + + for (i = 0; i < props.length; i++) { + key = props[++index]; + iteratee(iterable[key], key, iterable); + } + return collection; + }, + + /** + * Checks if `value` is in `collection`. If `collection` is a string, it's + * checked for a substring of `value`, otherwise it checks if the `value` is present + * as a key in a `collection` object. + * + * @param {Array|Object|string} collection The collection to inspect. + * @param {*} value The value to search for. + * @returns {boolean} Returns `true` if `value` is found, else `false`. + * @example + * + * _.includes([1, 2, 3], 1); + * // => true + * + * _.includes({ 'a': 1, 'b': 2 }, 1); + * // => true + * + * _.includes('abcd', 'bc'); + * // => true + */ + includes: function (collection, value) { + if (Array.isArray(collection) || typeof collection === 'string') { + return collection.includes(value); + } + for (var key in collection) { + if (collection.hasOwnProperty(key)) { + if (collection[key] === value) { + return true; + } + } + } + return false; + }, + + /** + * Gets the size of `collection` by returning its length for array and strings. + * For objects it returns the number of enumerable string keyed + * properties. + * + * @param {Array|Object|string} collection The collection to inspect. + * @returns {number} Returns the collection size. + * @example + * + * size([1, 2, 3]) + * // => 3 + * + * size({ 'a': 1, 'b': 2 }) + * // => 2 + * + * size('pebbles') + * // => 7 + */ + size: function (collection) { + // eslint-disable-next-line lodash/prefer-is-nil + if (collection === null || collection === undefined) { + return 0; + } + if (Array.isArray(collection) || typeof collection === 'string') { + return collection.length; + } + + return Object.keys(collection).length; + }, + + /** + * Converts all elements in `array` into a string separated by `separator`. + * + * @param {Array} array The array to convert. + * @param {string} [separator=','] The element separator. + * @returns {string} Returns the joined string. + * @example + * + * _.join(['a', 'b', 'c'], '~'); + * // => 'a~b~c' + */ + join: function (array, separator) { + if (array === null) { + return ''; + } + return array.join(separator); + }, + + /** + * Removes trailing whitespace or specified characters from `string`. + * + * @param {string} [string=''] The string to trim. + * @param {string} [chars=whitespace] The characters to trim. + * @returns {string} Returns the trimmed string. + * @example + * + * trimEnd(' abc ') + * // => ' abc' + * + * trimEnd('-_-abc-_-', '_-') + * // => '-_-abc' + */ + trimEnd: function (string, chars) { + if (!string) { + return ''; + } + if (string && !chars) { + return string.replace(/\s*$/, ''); + } + chars += '$'; + return string.replace(new RegExp(chars, 'g'), ''); + }, + + /** + * Returns the index of the first + * element `predicate` returns truthy for. + * + * @param {Array} array The array to inspect. + * @param {Object} predicate The exact object to be searched for in the array. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * _.findIndex(users, {'active' : false}); + * // => 0 + * + */ + findIndex: function (array, predicate) { + var length = array === null ? 0 : array.length, + index = -1, + keys = Object.keys(predicate), + found, i; + if (!length) { + return -1; + } + for (i = 0; i < array.length; i++) { + found = true; + // eslint-disable-next-line no-loop-func + keys.forEach((key) => { + if (!(array[i][key] && array[i][key] === predicate[key])) { + found = false; + } + }); + if (found) { + index = i; + break; + } + } + return index; + }, + + /** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @param {Object} object The object to query. + * @param {string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * const object = { a: {b : 'c'} } + * + * + * get(object, 'a.b.c', 'default') + * // => 'default' + * + * get(object, 'a.b', 'default') + * // => 'c' + */ + get: function (object, path, defaultValue) { + if (object === null) { + return undefined; + } + var arr = path.split('.'), + res = object, + i; + for (i = 0; i < arr.length; i++) { + res = res[arr[i]]; + if (res === undefined) { + return defaultValue; + } + } + return res; + }, + + /** + * Checks if `predicate` returns truthy for **all** elements of `array`. + * Iteration is stopped once `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index, array). + * + * @param {Array} array The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + * @example + * + * every([true, 1, null, 'yes'], Boolean) + * // => false + */ + every: function (array, predicate) { + var index = -1, + length = array === null ? 0 : array.length; + + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } + } + return true; + } + +}; diff --git a/codegens/nodejs-superagent/npm-shrinkwrap.json b/codegens/nodejs-superagent/npm-shrinkwrap.json new file mode 100644 index 000000000..b4071b255 --- /dev/null +++ b/codegens/nodejs-superagent/npm-shrinkwrap.json @@ -0,0 +1,5 @@ +{ + "name": "", + "version": "0.0.1", + "lockfileVersion": 1 +} diff --git a/codegens/nodejs-superagent/npm/test-lint.js b/codegens/nodejs-superagent/npm/test-lint.js new file mode 100644 index 000000000..59ae3a010 --- /dev/null +++ b/codegens/nodejs-superagent/npm/test-lint.js @@ -0,0 +1,59 @@ +#!/usr/bin/env node +require('shelljs/global'); + +var chalk = require('chalk'), + async = require('async'), + ESLintCLIEngine = require('eslint').CLIEngine, + + /** + * The list of source code files / directories to be linted. + * + * @type {Array} + */ + LINT_SOURCE_DIRS = [ + './lib', + './bin', + './test', + './examples/*.js', + './npm/*.js', + './index.js' + ]; + +module.exports = function (exit) { + // banner line + console.info(chalk.yellow.bold('\nLinting files using eslint...')); + + async.waterfall([ + + /** + * Instantiates an ESLint CLI engine and runs it in the scope defined within LINT_SOURCE_DIRS. + * + * @param {Function} next - The callback function whose invocation marks the end of the lint test run. + * @returns {*} + */ + function (next) { + next(null, (new ESLintCLIEngine()).executeOnFiles(LINT_SOURCE_DIRS)); + }, + + /** + * Processes a test report from the Lint test runner, and displays meaningful results. + * + * @param {Object} report - The overall test report for the current lint test. + * @param {Object} report.results - The set of test results for the current lint run. + * @param {Function} next - The callback whose invocation marks the completion of the post run tasks. + * @returns {*} + */ + function (report, next) { + var errorReport = ESLintCLIEngine.getErrorResults(report.results); + // log the result to CLI + console.info(ESLintCLIEngine.getFormatter()(report.results)); + // log the success of the parser if it has no errors + (errorReport && !errorReport.length) && console.info(chalk.green('eslint ok!')); + // ensure that the exit code is non zero in case there was an error + next(Number(errorReport && errorReport.length) || 0); + } + ], exit); +}; + +// ensure we run this script exports if this is a direct stdin.tty run +!module.parent && module.exports(exit); diff --git a/codegens/nodejs-superagent/npm/test-newman.js b/codegens/nodejs-superagent/npm/test-newman.js new file mode 100644 index 000000000..b24727822 --- /dev/null +++ b/codegens/nodejs-superagent/npm/test-newman.js @@ -0,0 +1,59 @@ +#!/usr/bin/env node +/* eslint-env node, es6 */ +// --------------------------------------------------------------------------------------------------------------------- +// This script is intended to execute all unit tests. +// --------------------------------------------------------------------------------------------------------------------- + +require('shelljs/global'); + +// set directories and files for test and coverage report +var path = require('path'), + + NYC = require('nyc'), + chalk = require('chalk'), + recursive = require('recursive-readdir'), + + COV_REPORT_PATH = '.coverage', + SPEC_SOURCE_DIR = path.join(__dirname, '..', 'test', 'newman'); + +module.exports = function (exit) { + // banner line + console.info(chalk.yellow.bold('Running newman tests using mocha on node...')); + + test('-d', COV_REPORT_PATH) && rm('-rf', COV_REPORT_PATH); + mkdir('-p', COV_REPORT_PATH); + + var Mocha = require('mocha'), + nyc = new NYC({ + reportDir: COV_REPORT_PATH, + tempDirectory: COV_REPORT_PATH, + reporter: ['text', 'lcov', 'text-summary'], + exclude: ['config', 'test'], + hookRunInContext: true, + hookRunInThisContext: true + }); + + nyc.wrap(); + // add all spec files to mocha + recursive(SPEC_SOURCE_DIR, function (err, files) { + if (err) { console.error(err); return exit(1); } + + var mocha = new Mocha({ timeout: 1000 * 60 }); + + files.filter(function (file) { // extract all test files + return (file.substr(-8) === '.test.js'); + }).forEach(mocha.addFile.bind(mocha)); + + mocha.run(function (runError) { + runError && console.error(runError.stack || runError); + + nyc.reset(); + nyc.writeCoverageFile(); + nyc.report(); + exit(runError ? 1 : 0); + }); + }); +}; + +// ensure we run this script exports if this is a direct stdin.tty run +!module.parent && module.exports(exit); diff --git a/codegens/nodejs-superagent/npm/test.js b/codegens/nodejs-superagent/npm/test.js new file mode 100644 index 000000000..ee0be8b7d --- /dev/null +++ b/codegens/nodejs-superagent/npm/test.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node +var chalk = require('chalk'), + exit = require('shelljs').exit, + prettyms = require('pretty-ms'), + startedAt = Date.now(), + name = require('../package.json').name; + +require('async').series([ + require('./test-lint'), + require('./test-newman') + // Add a separate folder for every new suite of tests + // require('./test-unit') + // require('./test-browser') + // require('./test-integration') +], function (code) { + // eslint-disable-next-line max-len + console.info(chalk[code ? 'red' : 'green'](`\n${name}: duration ${prettyms(Date.now() - startedAt)}\n${name}: ${code ? 'not ok' : 'ok'}!`)); + exit(code && (typeof code === 'number' ? code : 1) || 0); +}); diff --git a/codegens/nodejs-superagent/package.json b/codegens/nodejs-superagent/package.json new file mode 100644 index 000000000..7206ae93f --- /dev/null +++ b/codegens/nodejs-superagent/package.json @@ -0,0 +1,33 @@ +{ + "name": "@postman/codegen-nodejs-superagent", + "version": "0.0.1", + "description": "Converts Postman SDK Requests to NodeJS(Superagent) code snippet", + "main": "index.js", + "com_postman_plugin": { + "type": "code_generator", + "lang": "nodejs", + "variant": "Superagent", + "syntax_mode": "javascript" + }, + "directories": { + "lib": "lib", + "test": "test" + }, + "scripts": { + "test": "node npm/test.js", + "test-lint": "node npm/test-lint.js", + "test-newman": "node npm/test-newman.js" + }, + "repository": { + "type": "git", + "url": "" + }, + "author": "$AUTHOR_NAME", + "license": "Apache-2.0", + "homepage": "https://github.com/postmanlabs/code-generators/tree/master/codegens/nodejs-superagent", + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=8" + } +} diff --git a/codegens/nodejs-superagent/test/newman/newman.test.js b/codegens/nodejs-superagent/test/newman/newman.test.js new file mode 100644 index 000000000..c765bedd0 --- /dev/null +++ b/codegens/nodejs-superagent/test/newman/newman.test.js @@ -0,0 +1,23 @@ +var runNewmanTest = require('../../../../test/codegen/newman/newmanTestUtil').runNewmanTest, + convert = require('../../index').convert; + + +describe('Nodejs(Superagent) Converter', function () { + describe('convert for different request types', function () { + var options = { + indentType: 'Space', + indentCount: 4 + }, + testConfig = { + // filename along with the appropriate version of the file. This file will be used to run the snippet. + fileName: '', + // Run script required to run the generated code snippet + runScript: '', + // Compile script required to compile the code snippet + compileScript: '', + // Array of name of collections for which newman tests has to be skipped. + skipCollections: [] + }; + runNewmanTest(convert, options, testConfig); + }); +}); From b2de5d7e227d576ca6e54ec34b0ca45835dc7ef2 Mon Sep 17 00:00:00 2001 From: Nikhil Kumar Date: Sun, 1 Mar 2020 04:17:07 +0530 Subject: [PATCH 3/4] Added Superagent to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 471261795..e6034c170 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ List of supported code generators: | NodeJs | Native | | NodeJs | Request | | NodeJs | Unirest | +| NodeJs | Superagent | | Objective-C| NSURLSession| | OCaml | Cohttp | |PHP | cURL | From 4747aec34c12bd3f2a92790e8d652e2259dcde17 Mon Sep 17 00:00:00 2001 From: Nikhil Kumar Date: Mon, 2 Mar 2020 07:50:20 +0530 Subject: [PATCH 4/4] Added author name as Postman Labs --- codegens/nodejs-superagent/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegens/nodejs-superagent/package.json b/codegens/nodejs-superagent/package.json index 7206ae93f..33b20cffb 100644 --- a/codegens/nodejs-superagent/package.json +++ b/codegens/nodejs-superagent/package.json @@ -22,7 +22,7 @@ "type": "git", "url": "" }, - "author": "$AUTHOR_NAME", + "author": "Postman Labs ", "license": "Apache-2.0", "homepage": "https://github.com/postmanlabs/code-generators/tree/master/codegens/nodejs-superagent", "dependencies": {},