Comments (4)
I like (1). It's not exposed now, but it's definitely something we could do. It might even be worth it to break it into its own project and make it a dependency of tfx-cli. Thanks.
from tfs-cli.
One complication - there's a proposal on the table to port this to core CLR (C#) and we are maintaining tfx "api" and compat via the cmd line args. So consumers shouldn't notice the internal impl. If we did this, it would be a problem.
what we could do is move the cred provider/storage stuff over to classes in vso-node-api. would that work?
from tfs-cli.
bryan, i do like the idea of splitting off the credential store, but i wanted to also let you know that since i posted that, I came up with a method that allows me to pull out the information like so:
var fs = require('fs');
var userhome = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
var cred = fs.readFileSync(userhome + '/.tfx/http__gitsourceserver8080_tfs_Netaphor/.allusers').toString().split(':')
var id=cred[1];
var pw=cred[2];
Then we can issue a curl command straight from node:
var exec = require('child_process').exec;
var postbody = JSON.stringify({
query:
"SELECT [System.Id] FROM WorkItemLinks WHERE ([Source].[System.TeamProject] = @project AND [Source].[System.Id] = 2308) And ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward') ORDER BY [System.Id], [Microsoft.VSTS.Common.BacklogPriority] mode(Recursive)"
});
var crypto = require('crypto');
var tempfilename = 'postdata_'+crypto.randomBytes(4).readUInt32LE(0)+'.json';
fs.writeFileSync(tempfilename, postbody);
var curl_command = 'curl -u ' + id + ':' + pw + ' -X POST -H "Content-Type: application/json" -d @' + tempfilename + ' http://gitsourceserver:8080/tfs/Netaphor/SiteAudit/_apis/wit/wiql?api-version=1.0';
var child = exec(curl_command, function(err, stdout, stderr) {
fs.unlinkSync(tempfilename);
if (err) {
console.log('Error: ' + stderr);
} else {
console.log('Output is: ' + stdout);
}
});
So you're wondering why would we use curl and exec from Node when Node is a perfectly proper client to make REST calls. The reason is because we wanted our node client code to have a somewhat uniform interface, since we will also shell out to call tfx like so:
var exec = require('child_process').exec;
var tfx_command = `tfx workitem query --project SiteAudit --json --query "select [Microsoft.VSTS.Common.BacklogPriority], [System.State], [System.IterationPath], [System.WorkItemType], [System.Title], [System.Tags] from WorkItems where [System.State] <> 'Done' and [System.State] <> 'Removed' and [System.AssignedTo] = @me order by [Microsoft.VSTS.Common.BacklogPriority]"`;
var child = exec(tfx_command, function(err, stdout, stderr) {
if (err) {
console.log('Error: ' + stderr);
} else {
// console.log('Output is: ' + stdout);
var o = JSON.parse(stdout);
console.log('count: ' + o.length);
for (var i = 0; i < o.length; i++) {
console.log(' id: ' + o[i].id);
console.log(' WorkItemType: ' + o[i].fields['System.WorkItemType']);
console.log(' IterationPath: ' + o[i].fields['System.IterationPath']);
console.log(' Title: ' + o[i].fields['System.Title']);
console.log(' State: ' + o[i].fields['System.State']);
console.log(' Microsoft.VSTS.Common.BacklogPriority: ' + o[i].fields['Microsoft.VSTS.Common.BacklogPriority']);
console.log();
}
}
});
from tfs-cli.
What would be nice is to have a way to a command called "direct" or "rest" or something, where one can specify enough parameters to make a REST call. This way, when TFS has new APIs, they are immediately usable from this tool.
The user of tfx.cmd need to specify:
- get or post
- api end point. they don't have to specify the version or project/collection
- standard parameters to specify project/colleciton
- Right now, I'd say just assume "?version=1.0" is always appended.
So why not use REST directly? Because this tool provides:
- cred store
- uniform API for project/collection
- uniform output format support.
from tfs-cli.
Related Issues (20)
- fix high severity vulnerability from async HOT 2
- Uploading of Azure DevOps Extensions fails with timeout HOT 2
- Wrong mime type for `fsevents.node` HOT 7
- tfx command line publish issue for Azure DevOps Server 2022 RC1 HOT 4
- tfx build tasks create does not work anymore HOT 3
- tfx cannot handle TLS certificate issued by corp certificate authority HOT 4
- tfx command line publish issue for Azure DevOps Server 2022 RC1 HOT 1
- "Unexpected token import" for Azure DevOps custom task HOT 2
- tfx not found after installing 0.13.0 HOT 4
- Tfx 0.14 reports to be 0.13 HOT 1
- "A token is invalid" When Trying to Upload an Extension HOT 3
- ccccccucjednglchvdevjcerjtvhguhrcltvkrvilfve
- This repo is missing important files HOT 1
- Add documentation for `tfx extension init` HOT 1
- Fix repo and npm name mistmatch. HOT 2
- Pack an extension with binary executables for Mac/Linux using tar insteda of zip? HOT 1
- tfx extension publish not working for ADO cloud HOT 2
- Publish fails for service principal HOT 5
- 'tfx extension publish' not using cached PAT HOT 1
- tfx build tasks upload gives error no task.json in specified directory[49m At C:\Users\pkuijper\AppData\Roaming\npm\tfx.ps1:24 char:5 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tfs-cli.