Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI

on:
pull_request:
branches:
- main
- next
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: npm ci
- run: npm run test
- run: npm run build

- uses: oven-sh/setup-bun@v2
- run: bun run build:binary

integration:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: npm ci
- run: npm run build
- run: npm run test:integration
env:
TIGRIS_STORAGE_ACCESS_KEY_ID: ${{ secrets.TIGRIS_STORAGE_ACCESS_KEY_ID }}
TIGRIS_STORAGE_SECRET_ACCESS_KEY: ${{ secrets.TIGRIS_STORAGE_SECRET_ACCESS_KEY }}
25 changes: 0 additions & 25 deletions .github/workflows/pr.yaml

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ jobs:
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm run test
- run: npm run test:all
env:
TIGRIS_STORAGE_ACCESS_KEY_ID: ${{ secrets.TIGRIS_STORAGE_ACCESS_KEY_ID }}
TIGRIS_STORAGE_SECRET_ACCESS_KEY: ${{ secrets.TIGRIS_STORAGE_SECRET_ACCESS_KEY }}
- run: npm run publint
- run: npm audit signatures

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"lint:fix": "eslint src --fix",
"format": "prettier --write \"src/**/*.ts\"",
"format:check": "prettier --check \"src/**/*.ts\"",
"test": "vitest run",
"test": "vitest run test/utils test/cli-core.test.ts test/specs-completeness.test.ts",
"test:watch": "vitest",
"test:unit": "vitest run test/utils",
"test:all": "vitest run",
"test:integration": "vitest run test/cli.test.ts",
"publint": "publint",
"updatedocs": "tsx scripts/update-docs.ts",
Expand Down
1 change: 1 addition & 0 deletions src/cli-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ export function createProgram(config: CLIConfig): CommanderCommand {

const program = new CommanderCommand();
program.name(specs.name).description(specs.description).version(version);
program.option('-y, --yes', 'Skip all confirmation prompts');

registerCommands(config, program, specs.commands);

Expand Down
13 changes: 13 additions & 0 deletions src/lib/access-keys/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ function normalizeToArray<T>(value: T | T[] | undefined): T[] {
export default async function assign(options: Record<string, unknown>) {
printStart(context);

const json = getOption<boolean>(options, ['json']);
const format = json
? 'json'
: getOption<string>(options, ['format', 'f', 'F'], 'table');

const id = getOption<string>(options, ['id']);
const admin = getOption<boolean>(options, ['admin']);
const revokeRoles = getOption<boolean>(options, [
Expand Down Expand Up @@ -83,6 +88,10 @@ export default async function assign(options: Record<string, unknown>) {
process.exit(1);
}

if (format === 'json') {
console.log(JSON.stringify({ action: 'revoked', id }));
}

printSuccess(context);
return;
}
Expand Down Expand Up @@ -149,5 +158,9 @@ export default async function assign(options: Record<string, unknown>) {
process.exit(1);
}

if (format === 'json') {
console.log(JSON.stringify({ action: 'assigned', id, assignments }));
}

printSuccess(context);
}
30 changes: 23 additions & 7 deletions src/lib/access-keys/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const context = msg('access-keys', 'create');
export default async function create(options: Record<string, unknown>) {
printStart(context);

const json = getOption<boolean>(options, ['json']);
const format = json
? 'json'
: getOption<string>(options, ['format', 'f', 'F'], 'table');

const name = getOption<string>(options, ['name']);

if (!name) {
Expand Down Expand Up @@ -58,13 +63,24 @@ export default async function create(options: Record<string, unknown>) {
process.exit(1);
}

console.log(` Name: ${data.name}`);
console.log(` Access Key ID: ${data.id}`);
console.log(` Secret Access Key: ${data.secret}`);
console.log('');
console.log(
' Save these credentials securely. The secret will not be shown again.'
);
if (format === 'json') {
console.log(
JSON.stringify({
action: 'created',
name: data.name,
id: data.id,
secret: data.secret,
})
);
} else {
console.log(` Name: ${data.name}`);
console.log(` Access Key ID: ${data.id}`);
console.log(` Secret Access Key: ${data.secret}`);
console.log('');
console.log(
' Save these credentials securely. The secret will not be shown again.'
);
}

printSuccess(context);
}
20 changes: 20 additions & 0 deletions src/lib/access-keys/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ import {
printFailure,
msg,
} from '../../utils/messages.js';
import { requireInteractive, confirm } from '../../utils/interactive.js';

const context = msg('access-keys', 'delete');

export default async function remove(options: Record<string, unknown>) {
printStart(context);

const json = getOption<boolean>(options, ['json']);
const format = json
? 'json'
: getOption<string>(options, ['format', 'f', 'F'], 'table');

const id = getOption<string>(options, ['id']);
const force = getOption<boolean>(options, ['force', 'yes', 'y']);

if (!id) {
printFailure(context, 'Access key ID is required');
Expand All @@ -41,6 +48,15 @@ export default async function remove(options: Record<string, unknown>) {
process.exit(1);
}

if (!force) {
requireInteractive('Use --yes to skip confirmation');
const confirmed = await confirm(`Delete access key '${id}'?`);
if (!confirmed) {
console.log('Aborted');
return;
}
}

const accessToken = await authClient.getAccessToken();
const selectedOrg = getSelectedOrganization();
const tigrisConfig = getTigrisConfig();
Expand All @@ -58,5 +74,9 @@ export default async function remove(options: Record<string, unknown>) {
process.exit(1);
}

if (format === 'json') {
console.log(JSON.stringify({ action: 'deleted', id }));
}

printSuccess(context);
}
31 changes: 20 additions & 11 deletions src/lib/access-keys/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const context = msg('access-keys', 'get');
export default async function get(options: Record<string, unknown>) {
printStart(context);

const json = getOption<boolean>(options, ['json']);
const format = json
? 'json'
: getOption<string>(options, ['format', 'f', 'F'], 'table');

const id = getOption<string>(options, ['id']);

if (!id) {
Expand Down Expand Up @@ -58,19 +63,23 @@ export default async function get(options: Record<string, unknown>) {
process.exit(1);
}

console.log(` Name: ${data.name}`);
console.log(` ID: ${data.id}`);
console.log(` Status: ${data.status}`);
console.log(` Created: ${data.createdAt}`);
console.log(` Organization: ${data.organizationId}`);
if (format === 'json') {
console.log(JSON.stringify(data));
} else {
console.log(` Name: ${data.name}`);
console.log(` ID: ${data.id}`);
console.log(` Status: ${data.status}`);
console.log(` Created: ${data.createdAt}`);
console.log(` Organization: ${data.organizationId}`);

if (data.roles && data.roles.length > 0) {
console.log(` Roles:`);
for (const role of data.roles) {
console.log(` - ${role.bucket}: ${role.role}`);
if (data.roles && data.roles.length > 0) {
console.log(` Roles:`);
for (const role of data.roles) {
console.log(` - ${role.bucket}: ${role.role}`);
}
} else {
console.log(` Roles: None`);
}
} else {
console.log(` Roles: None`);
}

printSuccess(context);
Expand Down
10 changes: 8 additions & 2 deletions src/lib/access-keys/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { formatOutput } from '../../utils/format.js';
import { getOption } from '../../utils/options.js';
import { getLoginMethod } from '../../auth/s3-client.js';
import { getAuthClient } from '../../auth/client.js';
import { getSelectedOrganization } from '../../auth/storage.js';
Expand All @@ -14,9 +15,14 @@ import {

const context = msg('access-keys', 'list');

export default async function list() {
export default async function list(options: Record<string, unknown>) {
printStart(context);

const json = getOption<boolean>(options, ['json']);
const format = json
? 'json'
: getOption<string>(options, ['format', 'f', 'F'], 'table');

const loginMethod = await getLoginMethod();

if (loginMethod !== 'oauth') {
Expand Down Expand Up @@ -64,7 +70,7 @@ export default async function list() {
created: key.createdAt,
}));

const output = formatOutput(keys, 'table', 'keys', 'key', [
const output = formatOutput(keys, format!, 'keys', 'key', [
{ key: 'name', header: 'Name' },
{ key: 'id', header: 'ID' },
{ key: 'status', header: 'Status' },
Expand Down
14 changes: 14 additions & 0 deletions src/lib/buckets/create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getOption } from '../../utils/options';
import enquirer from 'enquirer';
import { requireInteractive } from '../../utils/interactive.js';
import { getArgumentSpec, buildPromptChoices } from '../../utils/specs.js';
import { StorageClass, createBucket } from '@tigrisdata/storage';
import { getStorageConfig } from '../../auth/s3-client';
Expand All @@ -19,6 +20,11 @@ const context = msg('buckets', 'create');
export default async function create(options: Record<string, unknown>) {
printStart(context);

const json = getOption<boolean>(options, ['json']);
const format = json
? 'json'
: getOption<string>(options, ['format', 'f', 'F'], 'table');

let name = getOption<string>(options, ['name']);
const isPublic = getOption<boolean>(options, ['public']);
let access = isPublic
Expand Down Expand Up @@ -65,6 +71,8 @@ export default async function create(options: Record<string, unknown>) {
let parsedLocations: BucketLocations | undefined;

if (interactive) {
requireInteractive('Provide --name to skip interactive mode');

const accessSpec = getArgumentSpec('buckets', 'access', 'create');
const accessChoices = buildPromptChoices(accessSpec!);
const accessDefault = accessChoices?.findIndex(
Expand Down Expand Up @@ -151,5 +159,11 @@ export default async function create(options: Record<string, unknown>) {
process.exit(1);
}

if (format === 'json') {
console.log(
JSON.stringify({ action: 'created', name, ...(forkOf ? { forkOf } : {}) })
);
}

printSuccess(context, { name });
}
Loading
Loading