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
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ concurrency:
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: npm

- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint

test:
name: Test (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
Expand Down
54 changes: 54 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!dist", "!node_modules"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 90,
"bracketSpacing": false
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"noNonNullAssertion": "off"
},
"complexity": {
"useLiteralKeys": "off"
},
"correctness": {
"useExhaustiveDependencies": "off"
},
"suspicious": {
"noArrayIndexKey": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"jsxQuoteStyle": "double",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always"
}
}
}
176 changes: 176 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"dev": "tsup --watch",
"test": "vitest run",
"test:watch": "vitest",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"lint": "biome check .",
"format": "biome check --write ."
},
"keywords": [
"wordpress",
Expand All @@ -37,6 +39,7 @@
"zod": "^4.4.3"
},
"devDependencies": {
"@biomejs/biome": "^2.4.16",
"@sindresorhus/tsconfig": "^8.1.0",
"@types/node": "^25.9.1",
"@types/react": "^19.2.15",
Expand Down
40 changes: 27 additions & 13 deletions src/commands/db/dump.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {useState, useRef} from 'react';
import {Box, Text, useApp} from 'ink';
import path from 'node:path';
import {createGzip} from 'node:zlib';
import StepRunner from '../../components/StepRunner.js';
import {Box, Text, useApp} from 'ink';
import {useRef, useState} from 'react';
import type {Step} from '../../components/StepRunner.js';
import {readProjectConfig} from '../../lib/config.js';
import {getProjectRuntimeDir, getProjectBackupsDir} from '../../lib/paths.js';
import {getMachineHostname} from '../../lib/hostname.js';
import StepRunner from '../../components/StepRunner.js';
import type {BackupRecord} from '../../lib/backup-storage.js';
import {createBackupStorage} from '../../lib/backup-storage.js';
import {encodeBackupId} from '../../lib/backups.js';
import {readProjectConfig} from '../../lib/config.js';
import {getMachineHostname} from '../../lib/hostname.js';
import {getProjectBackupsDir, getProjectRuntimeDir} from '../../lib/paths.js';
import {spawnWpCli} from '../../lib/wpcli.js';
import type {BackupRecord} from '../../lib/backup-storage.js';
import path from 'node:path';

export const description = 'Create a compressed SQL backup of the database';

Expand All @@ -27,7 +27,10 @@ export default function DbDump() {
if (!pc) {
throw new Error('This project is not initialized. Run "kiqr init" first.');
}
const composePath = path.join(getProjectRuntimeDir(pc.project_id), 'compose.yaml');
const composePath = path.join(
getProjectRuntimeDir(pc.project_id),
'compose.yaml',
);
const storage = createBackupStorage(getProjectBackupsDir(pc.project_id));
const createdAt = new Date();
const id = encodeBackupId(createdAt);
Expand All @@ -51,7 +54,9 @@ export default function DbDump() {
if (code === 0) resolve();
else {
const msg = Buffer.concat(stderrChunks).toString().trim();
reject(new Error(`wp db export failed (exit ${code}): ${msg || 'no output'}`));
reject(
new Error(`wp db export failed (exit ${code}): ${msg || 'no output'}`),
);
}
});
}),
Expand All @@ -74,10 +79,19 @@ export default function DbDump() {
/>
{complete && ref.current.record && (
<Box flexDirection="column" marginTop={1}>
<Text bold color="green">Backup created.</Text>
<Text bold color="green">
Backup created.
</Text>
<Text> </Text>
<Text>ID: <Text bold color="cyan">{ref.current.record.id}</Text></Text>
<Text>File: <Text dimColor>{ref.current.record.filename}</Text></Text>
<Text>
ID:{' '}
<Text bold color="cyan">
{ref.current.record.id}
</Text>
</Text>
<Text>
File: <Text dimColor>{ref.current.record.filename}</Text>
</Text>
<Text dimColor>Restore with: kiqr db restore {ref.current.record.id}</Text>
</Box>
)}
Expand Down
15 changes: 12 additions & 3 deletions src/commands/db/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ export default function DbIndex() {
<Text dimColor>Backup and restore the project database</Text>
<Text> </Text>
<Text>Commands:</Text>
<Text> <Text bold>kiqr db dump</Text> Create a compressed SQL backup</Text>
<Text> <Text bold>kiqr db list</Text> List available backups</Text>
<Text> <Text bold>kiqr db restore &lt;id&gt;</Text> Restore from a backup</Text>
<Text>
{' '}
<Text bold>kiqr db dump</Text> Create a compressed SQL backup
</Text>
<Text>
{' '}
<Text bold>kiqr db list</Text> List available backups
</Text>
<Text>
{' '}
<Text bold>kiqr db restore &lt;id&gt;</Text> Restore from a backup
</Text>
</Box>
);
}
Loading
Loading