postman-code-generators
Advanced tools
Comparing version 1.11.0-beta.0 to 1.11.0-beta.1
let utils = require('./util'), | ||
_ = require('./lodash'), | ||
{ Url } = require('postman-collection/lib/collection/url'); | ||
sdk = require('postman-collection'); | ||
@@ -36,3 +36,3 @@ /** | ||
url = Url.parse(request.url.toString()); | ||
url = sdk.Url.parse(request.url.toString()); | ||
host = url.host ? url.host.join('.') : ''; | ||
@@ -39,0 +39,0 @@ host += url.port ? ':' + url.port : ''; |
@@ -24,3 +24,3 @@ { | ||
"dependencies": { | ||
"postman-collection": "^4.4.0" | ||
"postman-collection": "3.6.8" | ||
}, | ||
@@ -27,0 +27,0 @@ "scripts": { |
var expect = require('chai').expect, | ||
{ Request } = require('postman-collection/lib/collection/request'), | ||
sdk = require('postman-collection'), | ||
sanitize = require('../../lib/util').sanitize, | ||
@@ -18,3 +18,3 @@ parseBody = require('../../lib/parseRequest').parseBody, | ||
it('should return a Tab indented snippet ', function () { | ||
request = new Request(mainCollection.item[0].request); | ||
request = new sdk.Request(mainCollection.item[0].request); | ||
options = { | ||
@@ -39,3 +39,3 @@ indentType: 'Tab', | ||
it('should return snippet with timeout property when timeout is set to non zero', function () { | ||
request = new Request(mainCollection.item[0].request); | ||
request = new sdk.Request(mainCollection.item[0].request); | ||
options = { | ||
@@ -55,3 +55,3 @@ requestTimeout: 1000 | ||
it('should use JSON.parse if the content-type is application/vnd.api+json', function () { | ||
request = new Request({ | ||
request = new sdk.Request({ | ||
'method': 'POST', | ||
@@ -92,3 +92,3 @@ 'header': [ | ||
'0 for no follow redirect', function () { | ||
const request = new Request(mainCollection.item[0].request); | ||
const request = new sdk.Request(mainCollection.item[0].request); | ||
options = { | ||
@@ -109,3 +109,3 @@ followRedirect: false | ||
'0 for no follow redirect from request settings', function () { | ||
const request = new Request(mainCollection.item[0].request), | ||
const request = new sdk.Request(mainCollection.item[0].request), | ||
options = {}; | ||
@@ -129,3 +129,3 @@ | ||
'follow redirect is true from request settings', function () { | ||
const request = new Request(mainCollection.item[0].request), | ||
const request = new sdk.Request(mainCollection.item[0].request), | ||
options = {}; | ||
@@ -154,3 +154,3 @@ | ||
}; | ||
request = new Request(reqObject); | ||
request = new sdk.Request(reqObject); | ||
convert(request, options, function (error, snippet) { | ||
@@ -167,3 +167,3 @@ if (error) { | ||
it('should not fail for a random body mode', function () { | ||
request = new Request(mainCollection.item[2].request); | ||
request = new sdk.Request(mainCollection.item[2].request); | ||
request.body.mode = 'random'; | ||
@@ -184,3 +184,3 @@ request.body[request.body.mode] = {}; | ||
it('should generate snippet for file body mode', function () { | ||
request = new Request({ | ||
request = new sdk.Request({ | ||
'url': 'https://echo.getpostman.com/post', | ||
@@ -210,3 +210,3 @@ 'method': 'POST', | ||
it('should add content type if formdata field contains a content-type', function () { | ||
request = new Request({ | ||
request = new sdk.Request({ | ||
'method': 'POST', | ||
@@ -265,3 +265,3 @@ 'body': { | ||
*/ | ||
request = new Request(mainCollection.item[0].request); | ||
request = new sdk.Request(mainCollection.item[0].request); | ||
options = {}; | ||
@@ -287,3 +287,3 @@ convert(request, options, function (error, snippet) { | ||
'is set to non zero', function () { | ||
request = new Request(mainCollection.item[0].request); | ||
request = new sdk.Request(mainCollection.item[0].request); | ||
options = { | ||
@@ -306,3 +306,3 @@ requestTimeout: 1000 | ||
'is set to non zero and followRedirect as false', function () { | ||
request = new Request(mainCollection.item[0].request); | ||
request = new sdk.Request(mainCollection.item[0].request); | ||
options = { | ||
@@ -327,3 +327,3 @@ requestTimeout: 1000, | ||
it('should not require unused fs', function () { | ||
request = new Request({ | ||
request = new sdk.Request({ | ||
'url': 'https://postman-echo.com/get', | ||
@@ -346,3 +346,3 @@ 'method': 'GET', | ||
it('should add fs for form-data file upload', function () { | ||
request = new Request({ | ||
request = new sdk.Request({ | ||
'url': 'https://postman-echo.com/post', | ||
@@ -371,3 +371,3 @@ 'method': 'POST', | ||
it('should trim header keys and not trim header values', function () { | ||
var request = new Request({ | ||
var request = new sdk.Request({ | ||
'method': 'GET', | ||
@@ -399,3 +399,3 @@ 'header': [ | ||
it('should include JSON.stringify in the snippet for raw json bodies', function () { | ||
var request = new Request({ | ||
var request = new sdk.Request({ | ||
'method': 'POST', | ||
@@ -434,3 +434,3 @@ 'header': [ | ||
it('should generate snippets for no files in form data', function () { | ||
var request = new Request({ | ||
var request = new sdk.Request({ | ||
'method': 'POST', | ||
@@ -484,3 +484,3 @@ 'header': [], | ||
it('should return snippet with maxBodyLength property as "Infinity"', function () { | ||
request = new Request(mainCollection.item[0].request); | ||
request = new sdk.Request(mainCollection.item[0].request); | ||
options = { | ||
@@ -500,3 +500,3 @@ requestTimeout: 1000 | ||
it('should return snippet with promise based code when async_await is disabled', function () { | ||
const request = new Request(mainCollection.item[0].request); | ||
const request = new sdk.Request(mainCollection.item[0].request); | ||
@@ -515,3 +515,3 @@ convert(request, {}, function (error, snippet) { | ||
it('should return snippet with async/await based code when option is enabled', function () { | ||
const request = new Request(mainCollection.item[0].request); | ||
const request = new sdk.Request(mainCollection.item[0].request); | ||
@@ -518,0 +518,0 @@ convert(request, { asyncAwaitEnabled: true }, function (error, snippet) { |
const _ = require('./lodash'), | ||
{ Url } = require('postman-collection/lib/collection/url'), | ||
sdk = require('postman-collection'), | ||
sanitizeOptions = require('./util').sanitizeOptions, | ||
@@ -135,3 +135,3 @@ sanitize = require('./util').sanitize, | ||
url = Url.parse(request.url.toString()); | ||
url = sdk.Url.parse(request.url.toString()); | ||
host = url.host ? url.host.join('.') : ''; | ||
@@ -138,0 +138,0 @@ path = url.path ? '/' + url.path.join('/') : '/'; |
var _ = require('./lodash'), | ||
{ Url } = require('postman-collection/lib/collection/url'), | ||
sdk = require('postman-collection'), | ||
sanitize = require('./util/sanitize').sanitize, | ||
@@ -116,3 +116,3 @@ sanitizeOptions = require('./util/sanitize').sanitizeOptions, | ||
url = Url.parse(request.url.toString()); | ||
url = sdk.Url.parse(request.url.toString()); | ||
host = url.host ? url.host.join('.') : ''; | ||
@@ -119,0 +119,0 @@ path = url.path ? '/' + url.path.join('/') : '/'; |
const expect = require('chai').expect, | ||
{ Request } = require('postman-collection/lib/collection/request'), | ||
sdk = require('postman-collection'), | ||
convert = require('../../lib/index').convert; | ||
@@ -12,3 +12,3 @@ | ||
it('should set no redirect policy when followRedirect is set to false', function () { | ||
const request = new Request({ | ||
const request = new sdk.Request({ | ||
'method': 'GET', | ||
@@ -39,3 +39,3 @@ 'header': [], | ||
it('should set read timeout when requestTimeout is set to non zero value', function () { | ||
const request = new Request({ | ||
const request = new sdk.Request({ | ||
'method': 'GET', | ||
@@ -67,3 +67,3 @@ 'header': [], | ||
['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS', 'CONNECT', 'PATH', 'TRACE'].forEach(function (method) { | ||
const request = new Request({ | ||
const request = new sdk.Request({ | ||
'method': method, | ||
@@ -96,3 +96,3 @@ 'header': [], | ||
['PROPFIND', 'PURGE', 'LOCK', 'UNLOCK', 'LINK', 'UNLINK', 'COPY'].forEach(function (method) { | ||
const request = new Request({ | ||
const request = new sdk.Request({ | ||
'method': method, | ||
@@ -99,0 +99,0 @@ 'header': [], |
@@ -1,2 +0,2 @@ | ||
const { Request } = require('postman-collection/lib/collection/request'), | ||
const sdk = require('postman-collection'), | ||
labelList = require('./assets/languageLabels.json'), | ||
@@ -89,3 +89,3 @@ languageMap = require('./assets/languages.js'); | ||
if (!Request.isRequest(request)) { | ||
if (!sdk.Request.isRequest(request)) { | ||
return callback('Codegen~convert: Invalid request'); | ||
@@ -92,0 +92,0 @@ } |
var shell = require('shelljs'), | ||
path = require('path'), | ||
async = require('async'), | ||
{ detect } = require('detect-package-manager'), | ||
pm, | ||
PRODUCTION_FLAG = '', | ||
@@ -11,9 +13,2 @@ getSubfolders, | ||
if (args[2] && args[2] === 'dev') { | ||
console.log('Dev flag detected running npm install'); | ||
} | ||
else { | ||
PRODUCTION_FLAG = '--no-audit --production'; | ||
} | ||
getSubfolders = (folder) => { | ||
@@ -27,2 +22,16 @@ return fs.readdirSync(folder) | ||
function (next) { | ||
detect().then((res) => { | ||
pm = res; | ||
console.log('Detected package manager: ' + pm); | ||
return next(); | ||
}); | ||
}, | ||
function (next) { | ||
if (args[2] && args[2] === 'dev') { | ||
console.log('Dev flag detected running ' + pm + ' install'); | ||
} | ||
else { | ||
PRODUCTION_FLAG = '--no-audit --production'; | ||
} | ||
console.log('Running pre-package script'); | ||
@@ -47,7 +56,7 @@ var prepackagePath = path.resolve(__dirname, 'pre-package.js'), | ||
console.log(codegen.name + ': npm install ' + PRODUCTION_FLAG); | ||
commandOut = shell.exec('npm install ' + PRODUCTION_FLAG, { silent: true }); | ||
console.log(codegen.name + ': ' + pm + ' install ' + PRODUCTION_FLAG); | ||
commandOut = shell.exec(pm + ' install ' + PRODUCTION_FLAG, { silent: true }); | ||
if (commandOut.code !== 0) { | ||
console.error('Failed to run npm install on codegen ' + codegen.name + ', here is the error:'); | ||
console.error('Failed to run ' + pm + ' install on codegen ' + codegen.name + ', here is the error:'); | ||
return next(commandOut.stderr); | ||
@@ -54,0 +63,0 @@ } |
{ | ||
"name": "postman-code-generators", | ||
"version": "1.11.0-beta.0", | ||
"version": "1.11.0-beta.1", | ||
"description": "Generates code snippets for a postman collection", | ||
@@ -29,5 +29,6 @@ "main": "index.js", | ||
"async": "3.2.2", | ||
"detect-package-manager": "3.0.2", | ||
"lodash": "4.17.21", | ||
"path": "0.12.7", | ||
"postman-collection": "^4.4.0", | ||
"postman-collection": "4.0.0", | ||
"shelljs": "0.8.5" | ||
@@ -34,0 +35,0 @@ }, |
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
1716701
44896
6
+ Addeddetect-package-manager@3.0.2
+ Addedcross-spawn@7.0.3(transitive)
+ Addeddetect-package-manager@3.0.2(transitive)
+ Addedexeca@5.1.1(transitive)
+ Addedfaker@5.5.3(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhuman-signals@2.1.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedlru-cache@6.0.0(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmime-db@1.48.0(transitive)
+ Addedmime-types@2.1.31(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedpostman-collection@4.0.0(transitive)
+ Addedpostman-url-encoder@3.0.1(transitive)
+ Addedsemver@7.3.5(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addedwhich@2.0.2(transitive)
+ Addedyallist@4.0.0(transitive)
- Removed@faker-js/faker@5.5.3(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedpostman-collection@4.5.0(transitive)
- Removedpostman-url-encoder@3.0.5(transitive)
- Removedsemver@7.6.3(transitive)
Updatedpostman-collection@4.0.0