@voidwalkers/void-cli
Advanced tools
Comparing version 0.1.11 to 0.1.12
{ | ||
"name": "@voidwalkers/void-cli", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "CLI for Void Walkers Void", | ||
@@ -5,0 +5,0 @@ "main": "./src/app.js", |
@@ -105,7 +105,7 @@ import fs from 'node:fs'; | ||
const commandUser = new Command('user'); | ||
const commandUsers = new Command('users'); | ||
commandUser.description('Manage users'); | ||
commandUsers.description('Manage users'); | ||
commandUser.command('create') | ||
commandUsers.command('create') | ||
.description('Create a new user') | ||
@@ -154,7 +154,27 @@ .argument('[email]', 'User email') | ||
const commandProject = new Command('project'); | ||
commandUsers.command('list') | ||
.description('List users') | ||
.action(async () => { | ||
const globalConfig = loadGlobalConfig(); | ||
commandProject.description('Manage projects'); | ||
if (!globalConfig.admin?.secret) { | ||
console.log('Admin not logged in. Use "void-cli admin login"'); | ||
commandProject.command('create') | ||
return; | ||
} | ||
const {data} = await axios.get(`${BASE_URL_API}/api/users`, { | ||
headers: { | ||
Authorization: `Bearer ${globalConfig.admin.secret}` | ||
} | ||
}); | ||
console.log(`User list:\n\n${data.items.map(item => `${item.id} ${item.email}`).join('\n')}`); | ||
}); | ||
const commandProjects = new Command('projects'); | ||
commandProjects.description('Manage projects'); | ||
commandProjects.command('create') | ||
.description('Create a new project') | ||
@@ -213,5 +233,26 @@ .argument('<slug>', 'Project slug (short name)') | ||
command.addCommand(commandProject); | ||
command.addCommand(commandUser); | ||
commandProjects.command('list') | ||
.description('List user projects') | ||
.requiredOption('-u, --user <id>', 'User ID') | ||
.action(async ({user: userId}) => { | ||
const globalConfig = loadGlobalConfig(); | ||
if (!globalConfig.admin?.secret) { | ||
console.log('Admin not logged in. Use "void-cli admin login"'); | ||
return; | ||
} | ||
const {data} = await axios.get(`${BASE_URL_API}/api/users/${userId}/projects`, { | ||
headers: { | ||
Authorization: `Bearer ${globalConfig.admin.secret}` | ||
} | ||
}); | ||
console.log(`Project list:\n\n${data.items.map(item => `${item.id} ${item.slug}`).join('\n')}`); | ||
}); | ||
command.addCommand(commandProjects); | ||
command.addCommand(commandUsers); | ||
export default command; |
@@ -47,12 +47,2 @@ import {Argument, Command} from 'commander'; | ||
/* | ||
{ | ||
"project": { | ||
"slug": "test", | ||
"tokenPrivate": "4nAoKC98OOGKC8ybRbl1aEshtgmDzvxNC3PSRbSLYG3/oPKdj/mdjsRBB4EGkjvtkBo9hYnNibnX6Bt25f3Hzw==", | ||
"tokenPublic": "6jAAVSlT2FT8UJinFZtBNXGDhjQQXGtt19i4dCB2SqDebIpIssATq41e81sEMk26ppN+RBoQ6ODiKY7vge608w==" | ||
} | ||
} | ||
*/ | ||
export default command; |
@@ -24,3 +24,3 @@ import fs from 'node:fs'; | ||
await axios.post(`${BASE_URL_API}/api/projects/${projectSlug}/buckets`, { | ||
const {data} = await axios.post(`${BASE_URL_API}/api/projects/${projectSlug}/buckets`, { | ||
name: bucketName, | ||
@@ -41,7 +41,17 @@ type: bucketType | ||
storage.buckets.push({ | ||
const bucket = { | ||
name: bucketName, | ||
type: bucketType | ||
}); | ||
}; | ||
if (data?.item?.access_rules) { | ||
bucket.accessRules = data.item.access_rules.reduce((acc, rule) => { | ||
acc[rule.operation_type] = {rule: rule.rule}; | ||
return acc; | ||
}, {}); | ||
} | ||
storage.buckets.push(bucket); | ||
return { | ||
@@ -48,0 +58,0 @@ ...c, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43072
1186