-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
41 lines (34 loc) · 1.12 KB
/
Copy pathcli.js
File metadata and controls
41 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env node
import 'dotenv/config';
const [,, apiName, ...args] = process.argv;
if (!apiName) {
console.error('Usage: adoCli <apiName> <args>');
process.exit(1);
}
const apiMap = {
createPbi: './apis/createPbi.js',
createTask: './apis/createTask.js',
createTaskFromTemplate: './apis/createTaskFromTemplate.js',
getTeams: './apis/getTeams.js',
getRepositories: './apis/getRepositories.js',
createPullRequest: './apis/createPullRequest.js',
deleteNugetPackageVersionsByDateRange: './apis/deleteNugetPackageVersionsByDateRange.js',
listNugetPackages: './apis/listNugetPackages.js',
listArtifactsFeeds: './apis/listArtifactsFeeds.js',
};
async function runApi(apiName, args) {
try {
const apiPath = apiMap[apiName];
if (!apiPath) {
console.error(`Unknown API: ${apiName}`);
process.exit(1);
}
const { default: apiFunction } = await import(apiPath);
const result = await apiFunction(...args);
console.log('Operation completed successfully');
} catch (error) {
console.error('Error during operation:', error.message);
process.exit(1);
}
}
runApi(apiName, args);