orizu 0.1.1 → 0.1.2
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 +17 -10
- package/package.json +1 -1
- package/src/index.ts +18 -10
package/dist/index.js
CHANGED
|
@@ -24,6 +24,9 @@ function getArg(name) {
|
|
|
24
24
|
}
|
|
25
25
|
return cliArgs[index + 1];
|
|
26
26
|
}
|
|
27
|
+
function normalizeSlugInput(slug) {
|
|
28
|
+
return slug.trim().toLowerCase();
|
|
29
|
+
}
|
|
27
30
|
function isInteractiveTerminal() {
|
|
28
31
|
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
29
32
|
}
|
|
@@ -124,7 +127,8 @@ async function fetchTeams() {
|
|
|
124
127
|
return data.teams;
|
|
125
128
|
}
|
|
126
129
|
async function fetchProjects(teamSlug) {
|
|
127
|
-
const
|
|
130
|
+
const normalizedTeamSlug = teamSlug ? normalizeSlugInput(teamSlug) : undefined;
|
|
131
|
+
const query = normalizedTeamSlug ? `?teamSlug=${encodeURIComponent(normalizedTeamSlug)}` : '';
|
|
128
132
|
const response = await authedFetch(`/api/cli/projects${query}`);
|
|
129
133
|
if (!response.ok) {
|
|
130
134
|
throw new Error(`Failed to fetch projects: ${await response.text()}`);
|
|
@@ -180,7 +184,7 @@ async function resolveProjectSlug(projectArg) {
|
|
|
180
184
|
if (segments.length !== 2 || !segments[0] || !segments[1]) {
|
|
181
185
|
throw new Error('Project must be in format teamSlug/projectSlug');
|
|
182
186
|
}
|
|
183
|
-
const [teamSlug, projectSlug] = segments;
|
|
187
|
+
const [teamSlug, projectSlug] = segments.map(normalizeSlugInput);
|
|
184
188
|
const matchedTeam = teams.find(team => team.slug === teamSlug);
|
|
185
189
|
if (!matchedTeam) {
|
|
186
190
|
console.error(`Team '${teamSlug}' not found in your accessible teams.`);
|
|
@@ -189,14 +193,14 @@ async function resolveProjectSlug(projectArg) {
|
|
|
189
193
|
const selectedProject = await promptSelect(`Select a project in ${selectedTeam.slug}`, projects, project => `${project.name} (${project.teamSlug}/${project.slug})`);
|
|
190
194
|
return `${selectedProject.teamSlug}/${selectedProject.slug}`;
|
|
191
195
|
}
|
|
192
|
-
const projects = await fetchProjects(
|
|
196
|
+
const projects = await fetchProjects(matchedTeam.slug);
|
|
193
197
|
const matchedProject = projects.find(project => project.slug === projectSlug);
|
|
194
198
|
if (!matchedProject) {
|
|
195
|
-
console.error(`Project '${projectSlug}' not found in team '${
|
|
196
|
-
const selectedProject = await promptSelect(`Select a project in ${
|
|
199
|
+
console.error(`Project '${projectSlug}' not found in team '${matchedTeam.slug}'.`);
|
|
200
|
+
const selectedProject = await promptSelect(`Select a project in ${matchedTeam.slug}`, projects, project => `${project.name} (${project.teamSlug}/${project.slug})`);
|
|
197
201
|
return `${selectedProject.teamSlug}/${selectedProject.slug}`;
|
|
198
202
|
}
|
|
199
|
-
return `${
|
|
203
|
+
return `${matchedTeam.slug}/${matchedProject.slug}`;
|
|
200
204
|
}
|
|
201
205
|
async function selectTaskIdInteractively() {
|
|
202
206
|
const team = await promptSelect('Select a team', await fetchTeams(), item => `${item.name} (${item.slug})`, { forcePrompt: true });
|
|
@@ -460,7 +464,7 @@ async function listTeams() {
|
|
|
460
464
|
}
|
|
461
465
|
async function resolveTeamSlug(teamSlugArg) {
|
|
462
466
|
if (teamSlugArg) {
|
|
463
|
-
return teamSlugArg;
|
|
467
|
+
return normalizeSlugInput(teamSlugArg);
|
|
464
468
|
}
|
|
465
469
|
const team = await promptSelect('Select a team', await fetchTeams(), item => `${item.name} (${item.slug})`, { forcePrompt: true });
|
|
466
470
|
return team.slug;
|
|
@@ -491,12 +495,14 @@ async function createTeam() {
|
|
|
491
495
|
console.log(`Created team: ${data.team.name} (${data.team.slug})`);
|
|
492
496
|
}
|
|
493
497
|
async function listProjects() {
|
|
494
|
-
const
|
|
498
|
+
const teamSlugArg = getArg('--team');
|
|
499
|
+
const teamSlug = teamSlugArg ? normalizeSlugInput(teamSlugArg) : null;
|
|
495
500
|
printProjects(await fetchProjects(teamSlug || undefined));
|
|
496
501
|
}
|
|
497
502
|
async function createProject() {
|
|
498
503
|
const name = getArg('--name');
|
|
499
|
-
|
|
504
|
+
const teamSlugArg = getArg('--team');
|
|
505
|
+
let teamSlug = teamSlugArg ? normalizeSlugInput(teamSlugArg) : null;
|
|
500
506
|
if (!name) {
|
|
501
507
|
throw new Error('Usage: orizu projects create --name <name> [--team <teamSlug>]');
|
|
502
508
|
}
|
|
@@ -885,7 +891,8 @@ async function removeTeamMember() {
|
|
|
885
891
|
console.log(`Removed team member ${member.email}`);
|
|
886
892
|
}
|
|
887
893
|
async function changeTeamMemberRole() {
|
|
888
|
-
const
|
|
894
|
+
const teamSlugArg = getArg('--team');
|
|
895
|
+
const teamSlug = teamSlugArg ? normalizeSlugInput(teamSlugArg) : null;
|
|
889
896
|
const email = getArg('--email');
|
|
890
897
|
const role = getArg('--role');
|
|
891
898
|
if (!teamSlug || !email || !role) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -134,6 +134,10 @@ function getArg(name: string): string | null {
|
|
|
134
134
|
return cliArgs[index + 1]
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
function normalizeSlugInput(slug: string): string {
|
|
138
|
+
return slug.trim().toLowerCase()
|
|
139
|
+
}
|
|
140
|
+
|
|
137
141
|
function isInteractiveTerminal() {
|
|
138
142
|
return Boolean(process.stdin.isTTY && process.stdout.isTTY)
|
|
139
143
|
}
|
|
@@ -264,7 +268,8 @@ async function fetchTeams(): Promise<Team[]> {
|
|
|
264
268
|
}
|
|
265
269
|
|
|
266
270
|
async function fetchProjects(teamSlug?: string): Promise<Project[]> {
|
|
267
|
-
const
|
|
271
|
+
const normalizedTeamSlug = teamSlug ? normalizeSlugInput(teamSlug) : undefined
|
|
272
|
+
const query = normalizedTeamSlug ? `?teamSlug=${encodeURIComponent(normalizedTeamSlug)}` : ''
|
|
268
273
|
const response = await authedFetch(`/api/cli/projects${query}`)
|
|
269
274
|
if (!response.ok) {
|
|
270
275
|
throw new Error(`Failed to fetch projects: ${await response.text()}`)
|
|
@@ -345,7 +350,7 @@ async function resolveProjectSlug(projectArg: string | null): Promise<string> {
|
|
|
345
350
|
if (segments.length !== 2 || !segments[0] || !segments[1]) {
|
|
346
351
|
throw new Error('Project must be in format teamSlug/projectSlug')
|
|
347
352
|
}
|
|
348
|
-
const [teamSlug, projectSlug] = segments
|
|
353
|
+
const [teamSlug, projectSlug] = segments.map(normalizeSlugInput)
|
|
349
354
|
|
|
350
355
|
const matchedTeam = teams.find(team => team.slug === teamSlug)
|
|
351
356
|
if (!matchedTeam) {
|
|
@@ -366,13 +371,13 @@ async function resolveProjectSlug(projectArg: string | null): Promise<string> {
|
|
|
366
371
|
return `${selectedProject.teamSlug}/${selectedProject.slug}`
|
|
367
372
|
}
|
|
368
373
|
|
|
369
|
-
const projects = await fetchProjects(
|
|
374
|
+
const projects = await fetchProjects(matchedTeam.slug)
|
|
370
375
|
const matchedProject = projects.find(project => project.slug === projectSlug)
|
|
371
376
|
|
|
372
377
|
if (!matchedProject) {
|
|
373
|
-
console.error(`Project '${projectSlug}' not found in team '${
|
|
378
|
+
console.error(`Project '${projectSlug}' not found in team '${matchedTeam.slug}'.`)
|
|
374
379
|
const selectedProject = await promptSelect(
|
|
375
|
-
`Select a project in ${
|
|
380
|
+
`Select a project in ${matchedTeam.slug}`,
|
|
376
381
|
projects,
|
|
377
382
|
project => `${project.name} (${project.teamSlug}/${project.slug})`
|
|
378
383
|
)
|
|
@@ -380,7 +385,7 @@ async function resolveProjectSlug(projectArg: string | null): Promise<string> {
|
|
|
380
385
|
return `${selectedProject.teamSlug}/${selectedProject.slug}`
|
|
381
386
|
}
|
|
382
387
|
|
|
383
|
-
return `${
|
|
388
|
+
return `${matchedTeam.slug}/${matchedProject.slug}`
|
|
384
389
|
}
|
|
385
390
|
|
|
386
391
|
async function selectTaskIdInteractively(): Promise<string> {
|
|
@@ -757,7 +762,7 @@ async function listTeams() {
|
|
|
757
762
|
|
|
758
763
|
async function resolveTeamSlug(teamSlugArg: string | null): Promise<string> {
|
|
759
764
|
if (teamSlugArg) {
|
|
760
|
-
return teamSlugArg
|
|
765
|
+
return normalizeSlugInput(teamSlugArg)
|
|
761
766
|
}
|
|
762
767
|
|
|
763
768
|
const team = await promptSelect(
|
|
@@ -801,13 +806,15 @@ async function createTeam() {
|
|
|
801
806
|
}
|
|
802
807
|
|
|
803
808
|
async function listProjects() {
|
|
804
|
-
const
|
|
809
|
+
const teamSlugArg = getArg('--team')
|
|
810
|
+
const teamSlug = teamSlugArg ? normalizeSlugInput(teamSlugArg) : null
|
|
805
811
|
printProjects(await fetchProjects(teamSlug || undefined))
|
|
806
812
|
}
|
|
807
813
|
|
|
808
814
|
async function createProject() {
|
|
809
815
|
const name = getArg('--name')
|
|
810
|
-
|
|
816
|
+
const teamSlugArg = getArg('--team')
|
|
817
|
+
let teamSlug = teamSlugArg ? normalizeSlugInput(teamSlugArg) : null
|
|
811
818
|
|
|
812
819
|
if (!name) {
|
|
813
820
|
throw new Error('Usage: orizu projects create --name <name> [--team <teamSlug>]')
|
|
@@ -1320,7 +1327,8 @@ async function removeTeamMember() {
|
|
|
1320
1327
|
}
|
|
1321
1328
|
|
|
1322
1329
|
async function changeTeamMemberRole() {
|
|
1323
|
-
const
|
|
1330
|
+
const teamSlugArg = getArg('--team')
|
|
1331
|
+
const teamSlug = teamSlugArg ? normalizeSlugInput(teamSlugArg) : null
|
|
1324
1332
|
const email = getArg('--email')
|
|
1325
1333
|
const role = getArg('--role')
|
|
1326
1334
|
if (!teamSlug || !email || !role) {
|