Skip to content

Commit c88faf5

Browse files
committed
fix: upgrade devDependencies and migrate to eslint 10 flat config
- Upgrade eslint 8.31 → 10.1 with new flat config (eslint.config.js) - Upgrade @vercel/ncc 0.36 → 0.38.4 - Replace eslint-config-airbnb-base + eslint-plugin-import with @eslint/js + @stylistic/eslint-plugin - Remove stale overrides in package.json (word-wrap, semver) - Remove obsolete eslint-disable comments from source files - Add { cause } to rethrown error in rsyncCli.js - Add .gitignore and CLAUDE.md - Resolves all 3 npm audit vulnerabilities (flatted, minimatch, js-yaml)
1 parent d346ae8 commit c88faf5

11 files changed

Lines changed: 888 additions & 2634 deletions

File tree

.eslintrc.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ node_modules/
2020
# IDE
2121
.idea
2222
.vscode
23+
24+
# AI
25+
.claude/settings.local.json

CLAUDE.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
GitHub Action for deploying files via rsync over SSH, with optional remote script execution before/after deployment. Published as `easingthemes/ssh-deploy` on the GitHub Marketplace.
8+
9+
## Commands
10+
11+
- **Build (lint + bundle):** `npm run build`
12+
- **Lint only:** `npm run lint`
13+
- **Lint with autofix:** `npm run lint:fix`
14+
- **No unit test suite** — testing is done via e2e workflows in CI (Docker-based SSH server, see `.github/workflows/e2e.yml`)
15+
16+
The build step runs ESLint then bundles `src/index.js` into `dist/index.js` using `@vercel/ncc`. The `dist/index.js` is the actual entrypoint executed by GitHub Actions (defined in `action.yml`).
17+
18+
## Architecture
19+
20+
The action runs as a single Node.js 24 process with this execution flow:
21+
22+
1. **`src/inputs.js`** — Reads all config from environment variables (both `INPUT_*` and bare names). Converts `SNAKE_CASE` input names to `camelCase`. Splits multi-value inputs: `SOURCE` and `ARGS` on spaces, `EXCLUDE` and `SSH_CMD_ARGS` on commas. Prepends `GITHUB_WORKSPACE` to source paths. Exports a single `inputs` object used by all other modules.
23+
24+
2. **`src/index.js`** — Orchestration entry point. Pipeline: validate inputs → write SSH key → optionally update known_hosts → run SCRIPT_BEFORE → rsync → run SCRIPT_AFTER.
25+
26+
3. **`src/sshKey.js`** — Writes the SSH private key to `~/.ssh/<deploy_key_name>` with mode `0400`. Creates `known_hosts` file. Uses `ssh-keyscan` to add the remote host when before/after scripts are configured.
27+
28+
4. **`src/rsyncCli.js`** — Validates rsync is installed (auto-installs via apt-get if missing). Uses the local `src/rsync.js` module (child_process.spawn) to execute the rsync transfer.
29+
30+
5. **`src/remoteCmd.js`** — Writes script content to a temporary `.sh` file in the workspace, executes it on the remote host via `ssh ... 'bash -s' < script.sh`, then deletes the local script file. Passes `RSYNC_STDOUT` env var to after-scripts.
31+
32+
6. **`src/helpers.js`** — File I/O utilities (`writeToFile`, `deleteFile`), input validation, and `snakeToCamel` converter.
33+
34+
## Key Conventions
35+
36+
- **CommonJS modules** — the project uses `require`/`module.exports`, not ES modules.
37+
- **ESLint 10 flat config** (`eslint.config.js`) — uses `@eslint/js` recommended + `@stylistic/eslint-plugin` for formatting. Notable rules: no trailing commas, `console` is allowed.
38+
- **Semantic release** on `main` branch via `.releaserc` — use conventional commit messages (`fix:`, `feat:`, etc.). npm publish is disabled; releases are git tags + changelog only.
39+
- **`dist/index.js` must be committed** — it's the bundled action entrypoint. Run `npm run build` and commit the updated dist after any source changes.
40+
- **Inputs are environment variables**, not `@actions/core` — the action reads directly from `process.env` rather than using the GitHub Actions toolkit.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const js = require('@eslint/js');
2+
const stylistic = require('@stylistic/eslint-plugin');
3+
const globals = require('globals');
4+
5+
module.exports = [
6+
js.configs.recommended,
7+
{
8+
plugins: {
9+
'@stylistic': stylistic
10+
},
11+
languageOptions: {
12+
ecmaVersion: 2020,
13+
sourceType: 'commonjs',
14+
globals: {
15+
...globals.node,
16+
...globals.commonjs,
17+
...globals.es2020,
18+
Atomics: 'readonly',
19+
SharedArrayBuffer: 'readonly'
20+
}
21+
},
22+
rules: {
23+
// Stylistic rules (migrated from airbnb-base)
24+
'@stylistic/comma-dangle': ['error', 'never'],
25+
'@stylistic/indent': ['error', 2, { SwitchCase: 1 }],
26+
'@stylistic/semi': ['error', 'always'],
27+
'@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
28+
'@stylistic/arrow-parens': ['error', 'always'],
29+
'@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
30+
'@stylistic/comma-spacing': ['error', { before: false, after: true }],
31+
'@stylistic/key-spacing': ['error', { beforeColon: false, afterColon: true }],
32+
'@stylistic/keyword-spacing': ['error', { before: true, after: true }],
33+
'@stylistic/eol-last': ['error', 'always'],
34+
'@stylistic/no-trailing-spaces': 'error',
35+
'@stylistic/space-before-blocks': 'error',
36+
'@stylistic/space-infix-ops': 'error',
37+
'@stylistic/arrow-spacing': ['error', { before: true, after: true }],
38+
39+
// JS rules (migrated from airbnb-base)
40+
'no-console': 'off',
41+
'no-var': 'error',
42+
'prefer-const': 'error',
43+
'prefer-arrow-callback': 'error',
44+
'prefer-template': 'error',
45+
'object-shorthand': ['error', 'always'],
46+
'no-shadow': 'error',
47+
'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
48+
'camelcase': ['error', { properties: 'never' }],
49+
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }]
50+
}
51+
}
52+
];

0 commit comments

Comments
 (0)