Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
848c9a1
Improve README to include MCP server section
mattheworiordan Apr 14, 2025
e898955
Update package to ensure consistent oclif versions
mattheworiordan Apr 14, 2025
ee9dbfc
cli: Add did you mean functionality
mattheworiordan Apr 14, 2025
a71894d
lint fixes (auto fix)
mattheworiordan Apr 15, 2025
49fb771
Upgrade eslint and fix compatibility issues
mattheworiordan Apr 15, 2025
f5bed00
Reduce strictness of linter + add mocha support
mattheworiordan Apr 15, 2025
6a63a1e
eslint: Fix process exit issues
mattheworiordan Apr 15, 2025
9c7deaf
lint: Fix terminal server linting issues
mattheworiordan Apr 15, 2025
dc0e831
lint: Auto fix issues
mattheworiordan Apr 15, 2025
f89d2c4
lint: Various fixes
mattheworiordan Apr 15, 2025
c04f4ec
lint: Various fixes
mattheworiordan Apr 15, 2025
9490eae
Fix unicorn/no-array-push-push linting errors in help.ts
mattheworiordan Apr 15, 2025
84e8919
Fix process.exit() linting errors by using oclif's this.exit() method
mattheworiordan Apr 15, 2025
c561885
Fix unused variable and import warnings in spaces commands
mattheworiordan Apr 15, 2025
4a599eb
lint: Various small fixes
mattheworiordan Apr 15, 2025
27eb6eb
lint: Upgrade to v9 linting format and standardise linting
mattheworiordan Apr 16, 2025
2bb9f38
lint: Fix Unused Variables & Imports (@typescript-eslint/no-unused-vars)
mattheworiordan Apr 16, 2025
a6f4908
lint: Configuration & setup fixes
mattheworiordan Apr 16, 2025
1de3062
lint: High-Impact/Specific Errors and Unused Variables (@typescript-e…
mattheworiordan Apr 16, 2025
f1a0edb
lint: Fix remaining 4 errors
mattheworiordan Apr 17, 2025
8480e27
lint: Fix remaining MCP lint warnings
mattheworiordan Apr 17, 2025
46579ad
lint chore: remove unused vars/imports in src/commands
mattheworiordan Apr 17, 2025
d99d80e
lint chore: Remove unused imports
mattheworiordan Apr 17, 2025
75f285f
lint chore: Remove unused vars/imports
mattheworiordan Apr 17, 2025
272ddf4
lint chore: Replace any types
mattheworiordan Apr 17, 2025
1d58e34
lint chore: resolve no-unused-vars warnings
mattheworiordan Apr 17, 2025
3bc7f6f
lint chore: Resolve no-explicit-any warnings
mattheworiordan Apr 17, 2025
2ebb574
line chore: Address further any assignments
mattheworiordan Apr 17, 2025
9ad7ad0
lint chore: Remove use of any
mattheworiordan Apr 17, 2025
fb982e5
Support test runs with Github Actions
mattheworiordan Apr 17, 2025
5efa0ea
lint: Explicitly enforce indentation of two spaces
mattheworiordan Apr 17, 2025
db893b7
lint chore: FIx Markdown
mattheworiordan Apr 17, 2025
84a49cf
lint: Address coderabbit feedback
mattheworiordan Apr 18, 2025
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
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run Tests

on:
push:
# Trigger on pushes to any branch
branches: [ '**' ]
pull_request:
# Trigger on pull requests targeting any branch
branches: [ '**' ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/action-setup@v3
with:
version: 10 # Use pnpm version 10

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x' # Use Node.js 22.x
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run tests
run: pnpm test
5 changes: 4 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
"@oclif/prettier-config"
{
"extends": "@oclif/prettier-config",
"tabWidth": 2
}
512 changes: 269 additions & 243 deletions README.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion bin/dev.js → bin/development.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning

import {execute} from '@oclif/core'

Expand Down
134 changes: 134 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import globals from 'globals';
// import tseslint from 'typescript-eslint'; // No longer need the combined import
import tsParser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import eslintPluginN from 'eslint-plugin-n';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslint from '@eslint/js'; // Import base eslint config
// import mochaGlobals from 'eslint-plugin-mocha/lib/configs/globals.js'; // Import mocha globals
import eslintPluginMocha from 'eslint-plugin-mocha'; // Import the plugin

export default [
{
// Globally ignores files
ignores: [
'**/dist/**',
'**/lib/**',
'**/node_modules/**',
'**/coverage/**',
'*.config.js',
'examples/web-cli/vite.config.ts',
'oclif.manifest.json',
'**/tmp/**',
'**/.nyc_output/**',
'**/tsconfig.tsbuildinfo',
'**/*.d.ts',
'node_modules/xterm/**',
'packages/react-web-cli/dist/index.js',
'packages/react-web-cli/dist/index.mjs',
'bin/' // Added from .eslintrc.cjs
], // Updated to match all ignorePatterns from .eslintrc.json
},
{
// Base configuration for all JS/TS files
files: ['**/*.{js,mjs,cjs,ts}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.node, // Use Node.js globals
// Add NodeJS global for scripts that might need it (though prefer importing types)
NodeJS: 'readonly',
},
},
plugins: {
n: eslintPluginN,
unicorn: eslintPluginUnicorn,
},
rules: {
// Base ESLint recommended rules
...eslint.configs.recommended.rules,
// Node plugin recommended rules
...eslintPluginN.configs['flat/recommended-module'].rules,
// Unicorn plugin recommended rules
...eslintPluginUnicorn.configs.recommended.rules,
// Disable noisy stylistic rules for now
'unicorn/no-null': 'off',
'unicorn/no-array-for-each': 'off',
'unicorn/no-for-loop': 'off',
'unicorn/prefer-string-raw': 'off',
'unicorn/no-object-as-default-parameter': 'off',
'unicorn/import-style': 'off',
'unicorn/prefer-ternary': 'off',
// Rules from .eslintrc.json
'unicorn/no-process-exit': 'off',
'n/no-process-exit': 'off',
'n/no-unsupported-features/node-builtins': 'off'
},
},
{
// Configuration specific to TypeScript files
files: ['**/*.ts'],
plugins: {
'@typescript-eslint': tsPlugin, // Use the imported plugin object
},
languageOptions: {
parser: tsParser, // Use the imported parser object
parserOptions: {
project: './tsconfig.eslint.json',
},
},
rules: {
// Use rules from the imported plugin object
...tsPlugin.configs.recommended.rules,
// Your custom rules from .eslintrc.json
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
// Add other TS specific rules or overrides here
'unicorn/prefer-module': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/numeric-separators-style': 'off',
},
},
{
// Configuration for React Web CLI package
files: ['packages/react-web-cli/**/*'],
languageOptions: {
globals: {
...globals.browser,
},
},
rules: {
'unicorn/prefer-module': 'off',
},
},
{
// Configuration specific to test files
files: ['test/**/*.test.ts'],
plugins: {
mocha: eslintPluginMocha,
},
languageOptions: {
globals: {
...globals.mocha,
describe: 'readonly',
it: 'readonly',
before: 'readonly',
after: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
},
},
rules: {
// Apply recommended mocha rules which include globals
...eslintPluginMocha.configs.recommended.rules,
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'mocha/no-exclusive-tests': 'error',
'mocha/no-skipped-tests': 'warn'
}
},
// Prettier config must be last
eslintConfigPrettier,
];
16 changes: 14 additions & 2 deletions examples/web-cli/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import globals from 'globals'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
ignores: [
'dist/**',
'**/dist/**',
'node_modules/**',
'**/*.d.ts',
'src/vite-env.d.ts',
'vite.config.ts'
]
},
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
project: null // Disable project references
}
},
plugins: {
'react-hooks': reactHooks,
Expand Down
15 changes: 8 additions & 7 deletions examples/web-cli/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState, useEffect, useCallback } from 'react'
import { AblyCliTerminal } from '@ably/react-web-cli'
import { useCallback, useEffect, useState } from 'react'

import './App.css'

// Default WebSocket URL assuming the terminal-server is run locally from the repo root
Expand All @@ -10,17 +11,17 @@ const envApiKey = import.meta.env.VITE_ABLY_API_KEY;
const envAccessToken = import.meta.env.VITE_ABLY_ACCESS_TOKEN;

// Check if initial credentials were provided via env
const hasInitialCredentials = !!(envApiKey && envAccessToken);
const hasInitialCredentials = Boolean(envApiKey && envAccessToken);

function App() {
const [connectionStatus, setConnectionStatus] = useState<'connecting' | 'connected' | 'disconnected' | 'error'>('disconnected');
const [connectionStatus, setConnectionStatus] = useState<'connected' | 'connecting' | 'disconnected' | 'error'>('disconnected');
const [apiKey, setApiKey] = useState<string | undefined>(envApiKey);
const [accessToken, setAccessToken] = useState<string | undefined>(envAccessToken);

// Remove state vars that cause remounting issues
const [shouldConnect, setShouldConnect] = useState<boolean>(hasInitialCredentials);

const handleConnectionChange = useCallback((status: 'connecting' | 'connected' | 'disconnected' | 'error') => {
const handleConnectionChange = useCallback((status: 'connected' | 'connecting' | 'disconnected' | 'error') => {
console.log('Connection Status:', status);
setConnectionStatus(status);
}, []);
Expand Down Expand Up @@ -52,19 +53,19 @@ function App() {
<div className="Terminal-container">
{shouldConnect && apiKey && accessToken && (
<AblyCliTerminal
websocketUrl={DEFAULT_WEBSOCKET_URL}
ablyApiKey={apiKey}
ablyAccessToken={accessToken}
ablyApiKey={apiKey}
onConnectionStatusChange={handleConnectionChange}
onSessionEnd={handleSessionEnd}
renderRestartButton={(onRestart) => (
<button
onClick={onRestart}
className="Restart-button"
onClick={onRestart}
>
Restart Terminal
</button>
)}
websocketUrl={DEFAULT_WEBSOCKET_URL}
/>
)}
</div>
Expand Down
3 changes: 2 additions & 1 deletion examples/web-cli/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom/client'

import App from './App.tsx'
import './index.css'

ReactDOM.createRoot(document.getElementById('root')!).render(
ReactDOM.createRoot(document.querySelector('#root')!).render(
<App />
)
2 changes: 1 addition & 1 deletion examples/web-cli/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'

// https://vitejs.dev/config/
Expand Down
40 changes: 29 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"scripts": {
"build": "rm -rf dist && rm -f tsconfig.tsbuildinfo && tsc",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"postpack": "rm -f oclif.manifest.json",
"posttest": "npm run lint",
"prepack": "npm run build && ([ -f node_modules/.bin/oclif ] && node_modules/.bin/oclif manifest && node_modules/.bin/oclif readme || echo 'Skipping oclif commands in production')",
"prepare": "npm run build && npm run prepack",
"posttest": "pnpm run lint",
"prepack": "pnpm run build && ([ -f node_modules/.bin/oclif ] && node_modules/.bin/oclif manifest && node_modules/.bin/oclif readme || echo 'Skipping oclif commands in production')",
"prepare": "pnpm run build && pnpm run prepack",
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif readme && git add README.md",
"cli": "bin/run.js",
Expand All @@ -38,7 +39,7 @@
],
"hooks": {
"init": "./dist/src/hooks/init/alias-command",
"command_not_found": "./dist/src/hooks/command_not_found/alias-command"
"command_not_found": "./dist/src/hooks/command_not_found/did-you-mean"
},
"hidden": [
"aliases"
Expand All @@ -48,6 +49,7 @@
"dependencies": {
"@ably/chat": "^0.5.1",
"@ably/spaces": "^0.4.0",
"@inquirer/prompts": "^5.1.3",
"@modelcontextprotocol/sdk": "^1.8.0",
"@oclif/core": "^4.2.10",
"@types/react": "^18.3.20",
Expand All @@ -58,6 +60,7 @@
"chalk": "5",
"cli-table3": "^0.6.5",
"color-json": "^3.0.5",
"fast-levenshtein": "^3.0.0",
"inquirer": "^9.2.16",
"jsonwebtoken": "^9.0.2",
"node-fetch": "^3.3.2",
Expand All @@ -70,32 +73,47 @@
"zod": "^3.24.2"
},
"devDependencies": {
"@eslint/js": "^9.21.0",
"@oclif/test": "^2.5.5",
"@types/chai": "^4.3.11",
"@types/dockerode": "^3.3.29",
"@types/fast-levenshtein": "^0.0.4",
"@types/inquirer": "^9.0.7",
"@types/jsonwebtoken": "^9.0.7",
"@types/mocha": "^10.0.6",
"@types/mocha": "^10.0.10",
"@types/node": "^20.10.0",
"@types/node-fetch": "^2.6.12",
"@types/sinon": "^17.0.3",
"@types/ws": "^8.5.11",
"@typescript-eslint/eslint-plugin": "^8.30.1",
"@typescript-eslint/parser": "^8.30.1",
"chai": "^4.4.1",
"dockerode": "^4.0.2",
"eslint": "^8.54.0",
"eslint": "^9.24.0",
"eslint-config-oclif": "^6.0.44",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-mocha": "^10.5.0",
"eslint-plugin-n": "^17.17.0",
"eslint-plugin-prettier": "^5.2.6",
"eslint-plugin-unicorn": "^58.0.0",
"globals": "^15.15.0",
"mocha": "^11",
"oclif": "^4.17.42",
"oclif": "^4.2.10",
"prettier": "^3.5.3",
"shx": "^0.4",
"sinon": "^18.0.0",
"strip-ansi": "^7.1.0",
"ts-node": "^10.9.2",
"typescript": "^5.8.2"
},
"engines": {
"node": ">=18.0.0"
},
"files": [
"/bin",
"/dist",
"/example/web-cli",
"/oclif.manifest.json"
"bin",
"dist",
"example/web-cli",
"oclif.manifest.json"
],
"repository": {
"type": "git",
Expand Down
Loading