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
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ permissions:
contents: read

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

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- run: npm ci
- run: npm run lint

build:
strategy:
fail-fast: false
Expand Down
35 changes: 35 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/2.5.9/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"includes": ["**", "!!**/dist", "!!tsconfig.json", "!!package-lock.json"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"preset": "recommended"
}
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
22 changes: 12 additions & 10 deletions build-bundle.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const esbuild = require('esbuild');

esbuild.build({
entryPoints: ['hello.ts'],
bundle: true,
outfile: 'dist/bundled/bundle.js',
platform: 'node',
target: 'node24',
format: 'cjs',
sourcemap: true,
minify: true,
}).catch(() => process.exit(1));
esbuild
.build({
entryPoints: ['hello.ts'],
bundle: true,
outfile: 'dist/bundled/bundle.js',
platform: 'node',
target: 'node24',
format: 'cjs',
sourcemap: true,
minify: true,
})
.catch(() => process.exit(1));
22 changes: 15 additions & 7 deletions build-sea.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { execSync } = require('child_process');
const fs = require('fs');
const { execSync } = require('node:child_process');
const fs = require('node:fs');

// Ensure the bundle exists
if (!fs.existsSync('./dist/bundled/bundle.js')) {
Expand All @@ -14,10 +14,14 @@ fs.mkdirSync('dist', { recursive: true });
console.log('Building SEA binary (node --build-sea)...');
try {
execSync('node --build-sea sea-config.json', { stdio: 'inherit' });
} catch (error) {
} catch {
console.error('\nFailed to build the SEA binary.');
console.error(`node --build-sea requires Node.js 25.5+ — you are running ${process.version}.`);
console.error('As of this writing it only ships on the Node 26 "Current" release line (not yet backported to the 24 LTS line). Switch with: nvm install 26 && nvm use 26');
console.error(
`node --build-sea requires Node.js 25.5+ — you are running ${process.version}.`,
);
console.error(
'As of this writing it only ships on the Node 26 "Current" release line (not yet backported to the 24 LTS line). Switch with: nvm install 26 && nvm use 26',
);
process.exit(1);
}

Expand All @@ -43,8 +47,12 @@ if (process.platform === 'darwin') {
process.exit(1);
}
} else if (process.platform === 'win32') {
console.log(`On Windows, sign ${outputPath} yourself if you need a trusted binary:`);
console.log(
`On Windows, sign ${outputPath} yourself if you need a trusted binary:`,
);
console.log(` signtool sign /fd SHA256 ${outputPath}`);
}

console.log(`SEA binary creation complete! The executable is ready: ./${outputPath}`);
console.log(
`SEA binary creation complete! The executable is ready: ./${outputPath}`,
);
6 changes: 3 additions & 3 deletions hello.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from 'commander';
import { Greeter } from './lib/greeter';
import { sayHello } from './lib/greeter';

const program = new Command();

Expand All @@ -8,7 +8,7 @@ program
.description('A simple greeting command')
.argument('<name>', 'name to greet')
.action((name: string) => {
Greeter.sayHello(name);
sayHello(name);
});

program.parse();
program.parse();
8 changes: 4 additions & 4 deletions lib/greeter.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { Greeter } from './greeter';
import { test } from 'node:test';
import { sayHello } from './greeter';

test('sayHello prints a greeting with the given name', () => {
const lines: string[] = [];
const originalLog = console.log;
console.log = (line: string) => lines.push(line);

try {
Greeter.sayHello('World');
sayHello('World');
} finally {
console.log = originalLog;
}
Expand All @@ -23,7 +23,7 @@ test('sayHello reflects the name back verbatim', () => {
console.log = (line: string) => lines.push(line);

try {
Greeter.sayHello('Node 26');
sayHello('Node 26');
} finally {
console.log = originalLog;
}
Expand Down
9 changes: 3 additions & 6 deletions lib/greeter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Utility class for greeting functionality
export class Greeter {
static sayHello(name: string): void {
console.log(`Hello, ${name}!`);
}
}
export function sayHello(name: string): void {
console.log(`Hello, ${name}!`);
}
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.

13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@
"build:js": "tsc",
"build:bundle": "node build-bundle.js",
"build:sea": "node build-sea.js",
"build:all": "npm run clean && npm run build:js && npm run build:bundle && npm run build:sea"
"build:all": "npm run clean && npm run build:js && npm run build:bundle && npm run build:sea",
"lint": "biome check .",
"format": "biome check --write ."
},
"keywords": ["node", "sea", "single-executable-application", "typescript", "esbuild"],
"keywords": [
"node",
"sea",
"single-executable-application",
"typescript",
"esbuild"
],
"author": "Hamdi LAADHARI",
"license": "ISC",
"type": "commonjs",
Expand All @@ -28,6 +36,7 @@
"node": ">=26.0.0"
},
"devDependencies": {
"@biomejs/biome": "^2.5.9",
"@types/node": "^24.13.3",
"commander": "^15.0.0",
"esbuild": "^0.28.2",
Expand Down
Loading