@oozou/velocity 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +32 -25
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -177,7 +177,7 @@ var requireProjectId = async (cmd, env) => {
|
|
|
177
177
|
const projectId = await resolveProjectId(cmd, env);
|
|
178
178
|
if (!projectId) {
|
|
179
179
|
throw new Error(
|
|
180
|
-
"No project selected. Pass --project <id> or run `velocity
|
|
180
|
+
"No project selected. Pass --project <slug-or-id> or run `velocity projects use <slug>`."
|
|
181
181
|
);
|
|
182
182
|
}
|
|
183
183
|
return projectId;
|
|
@@ -570,19 +570,19 @@ var registerWhoamiCommand = (program2) => {
|
|
|
570
570
|
});
|
|
571
571
|
};
|
|
572
572
|
|
|
573
|
-
// src/commands/
|
|
573
|
+
// src/commands/projects.ts
|
|
574
574
|
var formatProjectList = (rows) => {
|
|
575
575
|
if (rows.length === 0) return "No projects.\n";
|
|
576
576
|
const widths = {
|
|
577
|
-
|
|
577
|
+
slug: Math.max(4, ...rows.map((r) => (r.slug ?? "\u2014").length)),
|
|
578
578
|
name: Math.max(4, ...rows.map((r) => r.name.length))
|
|
579
579
|
};
|
|
580
580
|
const lines = [
|
|
581
|
-
`${"
|
|
581
|
+
`${"slug".padEnd(widths.slug)} ${"name".padEnd(widths.name)} client`
|
|
582
582
|
];
|
|
583
583
|
for (const r of rows) {
|
|
584
584
|
lines.push(
|
|
585
|
-
`${r.
|
|
585
|
+
`${(r.slug ?? "\u2014").padEnd(widths.slug)} ${r.name.padEnd(widths.name)} ${r.client?.name ?? ""}`
|
|
586
586
|
);
|
|
587
587
|
}
|
|
588
588
|
return lines.join("\n") + "\n";
|
|
@@ -599,21 +599,28 @@ var runGet = async (cmd, id) => {
|
|
|
599
599
|
const projectId = id ?? await readActiveProject(envName);
|
|
600
600
|
if (!projectId) {
|
|
601
601
|
throw new Error(
|
|
602
|
-
"No project id. Pass `velocity
|
|
602
|
+
"No project id. Pass `velocity projects get <id>` or run `velocity projects use <id>`."
|
|
603
603
|
);
|
|
604
604
|
}
|
|
605
605
|
const project = await fromAuth(auth).get(`/api/v1/projects/${projectId}`);
|
|
606
606
|
writeResult(cmd, project);
|
|
607
607
|
};
|
|
608
|
-
var runUse2 = async (cmd,
|
|
608
|
+
var runUse2 = async (cmd, slugOrId) => {
|
|
609
609
|
const auth = await requireAuth(cmd);
|
|
610
|
-
await fromAuth(auth).get(
|
|
610
|
+
const project = await fromAuth(auth).get(
|
|
611
|
+
`/api/v1/projects/${slugOrId}`
|
|
612
|
+
);
|
|
611
613
|
const envName = await resolveEnvName(cmd);
|
|
612
|
-
await writeActiveProject(envName,
|
|
614
|
+
await writeActiveProject(envName, project._id);
|
|
613
615
|
writeResult(
|
|
614
616
|
cmd,
|
|
615
|
-
{
|
|
616
|
-
|
|
617
|
+
{
|
|
618
|
+
projectId: project._id,
|
|
619
|
+
slug: project.slug,
|
|
620
|
+
name: project.name,
|
|
621
|
+
env: envName
|
|
622
|
+
},
|
|
623
|
+
(v) => `Active project set to "${v.name}" (${v.slug ?? v.projectId}) for env ${v.env}.
|
|
617
624
|
`
|
|
618
625
|
);
|
|
619
626
|
};
|
|
@@ -624,7 +631,7 @@ var runCurrent2 = async (cmd) => {
|
|
|
624
631
|
cmd,
|
|
625
632
|
{ env: envName, projectId },
|
|
626
633
|
(v) => v.projectId ? `Active project: ${v.projectId} (env: ${v.env})
|
|
627
|
-
` : `No active project for env "${v.env}". Run \`velocity
|
|
634
|
+
` : `No active project for env "${v.env}". Run \`velocity projects use <id>\`.
|
|
628
635
|
`
|
|
629
636
|
);
|
|
630
637
|
};
|
|
@@ -638,37 +645,37 @@ var runReset2 = async (cmd) => {
|
|
|
638
645
|
`
|
|
639
646
|
);
|
|
640
647
|
};
|
|
641
|
-
var
|
|
642
|
-
const
|
|
643
|
-
|
|
648
|
+
var registerProjectsCommands = (program2) => {
|
|
649
|
+
const projects = program2.command("projects").description("Project listing and active-project selection");
|
|
650
|
+
projects.command("list").description("List accessible projects").action(async function() {
|
|
644
651
|
try {
|
|
645
652
|
await runList2(this);
|
|
646
653
|
} catch (err) {
|
|
647
654
|
exitWithError(err, this);
|
|
648
655
|
}
|
|
649
656
|
});
|
|
650
|
-
|
|
657
|
+
projects.command("get [id]").description("Show project details (defaults to the active project)").action(async function(id) {
|
|
651
658
|
try {
|
|
652
659
|
await runGet(this, id);
|
|
653
660
|
} catch (err) {
|
|
654
661
|
exitWithError(err, this);
|
|
655
662
|
}
|
|
656
663
|
});
|
|
657
|
-
|
|
664
|
+
projects.command("use <slugOrId>").description("Set the active project for the current env (slug or id)").action(async function(id) {
|
|
658
665
|
try {
|
|
659
666
|
await runUse2(this, id);
|
|
660
667
|
} catch (err) {
|
|
661
668
|
exitWithError(err, this);
|
|
662
669
|
}
|
|
663
670
|
});
|
|
664
|
-
|
|
671
|
+
projects.command("current").description("Show the active project for the current env").action(async function() {
|
|
665
672
|
try {
|
|
666
673
|
await runCurrent2(this);
|
|
667
674
|
} catch (err) {
|
|
668
675
|
exitWithError(err, this);
|
|
669
676
|
}
|
|
670
677
|
});
|
|
671
|
-
|
|
678
|
+
projects.command("reset").description("Clear the active project for the current env").action(async function() {
|
|
672
679
|
try {
|
|
673
680
|
await runReset2(this);
|
|
674
681
|
} catch (err) {
|
|
@@ -1287,7 +1294,7 @@ The Velocity CLI is a REST client over /api/v1/* with two output modes:
|
|
|
1287
1294
|
Most commands need a projectId. Resolution:
|
|
1288
1295
|
1. \`--project <id>\` flag
|
|
1289
1296
|
2. \`VELOCITY_PROJECT\` env var
|
|
1290
|
-
3. The active-project file (\`velocity
|
|
1297
|
+
3. The active-project file (\`velocity projects use <slug>\`)
|
|
1291
1298
|
|
|
1292
1299
|
## Command tree
|
|
1293
1300
|
|
|
@@ -1296,9 +1303,9 @@ auth login | logout | status
|
|
|
1296
1303
|
env list | current | use <name> | reset
|
|
1297
1304
|
whoami
|
|
1298
1305
|
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1306
|
+
projects list
|
|
1307
|
+
projects get [slug-or-id]
|
|
1308
|
+
projects use <slug-or-id> | current | reset
|
|
1302
1309
|
|
|
1303
1310
|
stories list
|
|
1304
1311
|
stories get <number>
|
|
@@ -1359,13 +1366,13 @@ var registerAgentHelpCommand = (program2) => {
|
|
|
1359
1366
|
};
|
|
1360
1367
|
|
|
1361
1368
|
// src/index.ts
|
|
1362
|
-
var VERSION = "0.1.
|
|
1369
|
+
var VERSION = "0.1.1";
|
|
1363
1370
|
var program = new Command();
|
|
1364
1371
|
program.name("velocity").description("CLI for Velocity").version(VERSION).option("--json", "force JSON output regardless of TTY", false).option("--human", "force human output regardless of TTY", false).option("--env <name>", "Target a named env (production, local)").option("--api-base <url>", "Override the Velocity API base URL").option("--project <id>", "Target a specific project for this invocation");
|
|
1365
1372
|
registerAuthCommands(program);
|
|
1366
1373
|
registerEnvCommands(program);
|
|
1367
1374
|
registerWhoamiCommand(program);
|
|
1368
|
-
|
|
1375
|
+
registerProjectsCommands(program);
|
|
1369
1376
|
registerStoriesCommands(program);
|
|
1370
1377
|
registerSprintsCommands(program);
|
|
1371
1378
|
registerReleasesCommands(program);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oozou/velocity",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Velocity CLI — browser-based auth + REST client for the Velocity project management API.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"homepage": "https://velocity.oozou.com",
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
"LICENSE"
|
|
30
30
|
],
|
|
31
31
|
"publishConfig": {
|
|
32
|
-
"access": "public"
|
|
33
|
-
"provenance": true
|
|
32
|
+
"access": "public"
|
|
34
33
|
},
|
|
35
34
|
"scripts": {
|
|
36
35
|
"dev": "tsup --watch",
|