matt-ball / postman-local Goto Github PK
View Code? Open in Web Editor NEWA client to facilitate local development of scripts for Postman.
License: Apache License 2.0
A client to facilitate local development of scripts for Postman.
License: Apache License 2.0
Clean up sync.js - some duplicate code/possibility for abstraction
Bundling happens on a per request level meaning libraries may be imported multiple times.
Generate test scripts even when there are no scripts in the Postman collection.
Edit requests/responses as well as scripts
I'm getting this error on postman setup
when choosing to include environments when none actually exist in the workspace.
✔ Would you like to include Environment(s)? (y/N) · true
(node:31358) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
at createChoices (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/lib/create-choices.js:2:14)
at continueSetup (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/setup.js:70:32)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:31358) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:31358) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The error appears to be coming from here: https://github.com/matt-ball/postman-cli/blob/0fb32ef68060ac42a0bc77f67ece2dd947c51f94/src/setup.js#L70
When no environments exist, there actually is no data.workspace.environments
field in the API response, so it's sending undefined
to createChoices
.
When running postman sync
from a bootstrapped collection, Browserify can't build the dependency graph if the Postman built-in modules haven't been npm install
'd. Can these either be detected ahead of time and installed or can we optimistically install all built-in libraries from the Postman sandbox on the initial bootstrap?
➜ postman sync
(node:32473) UnhandledPromiseRejectionWarning: Error: Can't walk dependency graph: Cannot find module 'lodash' from '/private/tmp/postman-cli-test/postman/Utilities/Delay Response/test.js'
required by /private/tmp/postman-cli-test/postman/Utilities/Delay Response/test.js
at /usr/local/lib/node_modules/@matt.ball/postman-cli/node_modules/resolve/lib/async.js:115:35
at processDirs (/usr/local/lib/node_modules/@matt.ball/postman-cli/node_modules/resolve/lib/async.js:268:39)
at isdir (/usr/local/lib/node_modules/@matt.ball/postman-cli/node_modules/resolve/lib/async.js:275:32)
at /usr/local/lib/node_modules/@matt.ball/postman-cli/node_modules/resolve/lib/async.js:25:69
at FSReqCallback.oncomplete (fs.js:175:21)
Note: The workaround for this was just doing npm i lodash
and moving forward.
When running postman env against a postman account in which no environments have been defined, postman fails with the following error :
(node:2179) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
at createChoices (/Users/myself/Workspace/postman-cli-sandbox/node_modules/@matt.ball/postman-cli/src/lib/create-choices.js:2:14)
at Command.env (/Users/myself/Workspace/postman-cli-sandbox/node_modules/@matt.ball/postman-cli/src/env.js:12:30)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2179) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2179) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
It would be nice to catch this edge case, log a warning and exit gracefully.
postman-cli version : 0.0.26
node version : v12.16.1
After adding a prerequest.js
to a request directory locally, I received an error on postman sync
.
➜ postman sync
(node:32815) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'findIndex' of undefined
at mapFileToItem (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/sync.js:23:31)
at recurseCollectionForItems (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/lib/recurse-collection.js:34:20)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async recurseCollectionForItems (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/lib/recurse-collection.js:40:7)
at async recurseCollection (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/lib/recurse-collection.js:13:5)
at async Command.sync (/usr/local/lib/node_modules/@matt.ball/postman-cli/src/sync.js:9:22)
The error is here: https://github.com/matt-ball/postman-cli/blob/cdaa51c05ffde6d68e8465df2d6e30d6e4b0b7ab/src/sync.js#L23
In this case, req.event
does not exist and needs to be created.
I have two environment, localhost and heroku. Every time I run pm bootstrap, only localhost environment is getting retrieved in IDE.
Mocks + monitors:
Steps to reproduce :
console.log('bla bla')
in pre-request script and test script pm sync
command (the collection file is created succerspm update
( Postman updated! message displayed)Expected behavior :
Find the change I made on prerequest.js in pre-request script in Postman GUI
Environment :
Windows 10
postman-cli : v7.20.1
node : v10.16.2
npm : 6.9.0
VS Code : 1.43.1
Do not hesitate if you need more details to reproduce/fix the issue
It would be nice if we could make changes in the Postman app and have them sync with the postman-cli'd bootstrapped version. Right now, I think improvements introduced by a solution to #12 could help facilitate that. Three-way merge on conflict is a related big deal, so I'll defer.
Otherwise, we can potentially detect if the Postman-hosted script has been browserify'd and extract the source using a JavaScript parser.
A quick and dirty test seems to show it could work:
const fs = require('fs');
const acorn = require('acorn');
const source = fs.readFileSync('./subject.js').toString('utf8');
const result = acorn.parse(source, { ecmaVersion: 2020 });
const bundledSources = result.body[0].expression.arguments[0].properties;
const scriptSource = bundledSources[bundledSources.length - 1];
const bodyElements = scriptSource.value.elements[0].body.body;
const start = bodyElements[0].start;
const end = bodyElements[bodyElements.length - 1].end;
const body = source.substring(start, end);
console.log(body);
Just not sure if we'd want it to work. 😅
Have a default outline as a reference:
- postmanDir
- Request1
- request.json
- response.json
- test.js
- prerequest.js
Help reduce confusion for new users.
Hi,
tried to setup and experiment with postman-cli.
Here's the error I had:
node:9881) UnhandledPromiseRejectionWarning: TypeError: item.find is not a function
at mapItemToFile (/Users/myself/Workspace/postman-cli-sandbox/node_modules/@matt.ball/postman-cli/src/bootstrap.js:24:105)
at recurseCollectionForItems (/Users/myself/Workspace/postman-cli-sandbox/node_modules/@matt.ball/postman-cli/src/lib/recurse-collection.js:32:20)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I added a little bit of logging. It seems that the item at stake is:
{
name: 'Random cat pictures',
_postman_id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx',
protocolProfileBehavior: { disableBodyPruning: true },
request: {
method: 'GET',
header: [],
url: {
raw: 'https://aws.random.cat/meow',
protocol: 'https',
host: [Array],
path: [Array]
}
},
response: []
}
Its type is: 'request'
I guess the issue is coming from :
const scriptObj = (item.event && item.event.find((el) => el.listen === type)) || (!item.event && item.find((el) => el.listen === type))
But I could not really decipher what we are trying to do, so I did not investigate further.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.