Standalone command-line tool for analyzing, testing, and managing ngxsmk-gatekeeper configurations.
npm install -g @ngxsmk-gatekeeper/cliOr use with npx:
npx @ngxsmk-gatekeeper/cli <command>Command-line tool for managing and analyzing ngxsmk-gatekeeper configurations.
npm install -g @ngxsmk-gatekeeper/cliOr use with npx:
npx @ngxsmk-gatekeeper/cli <command>Initialize a new ngxsmk-gatekeeper configuration file.
gatekeeper init
gatekeeper init --force # Overwrite existing config
gatekeeper init --yes # Use defaults without promptsOptions:
-f, --force- Overwrite existing configuration-y, --yes- Skip interactive prompts and use defaults
Creates:
gatekeeper.config.json- Configuration filesrc/middlewares/auth.middleware.ts- Example middleware (optional)
Analyze route protection in your Angular application.
gatekeeper analyze
gatekeeper analyze --path src/app
gatekeeper analyze --format jsonOptions:
-p, --path <path>- Path to routes file or directory (default:src)-f, --format <format>- Output format:tableorjson(default:table)
Output:
- Lists all routes with protection status
- Shows which routes have guards and middleware
- Provides summary statistics
Test middleware chains with sample contexts.
gatekeeper test
gatekeeper test --config gatekeeper.config.json
gatekeeper test --test-file tests/middleware.test.jsonOptions:
-c, --config <path>- Path to gatekeeper config file (default:gatekeeper.config.json)-t, --test-file <path>- Path to test file with test cases
Test Cases:
- Authenticated user
- Unauthenticated user
- User with admin role
- No user context
Export middleware configuration and routes.
gatekeeper export
gatekeeper export --output backup.json
gatekeeper export --format json --include-routesOptions:
-o, --output <path>- Output file path (default:gatekeeper-export.json)-f, --format <format>- Export format:jsonoryaml(default:json)--include-routes- Include route analysis in export
Exports:
- Configuration file
- Middleware files
- Route files (if
--include-routesis specified)
gatekeeper initThis will:
- Create
gatekeeper.config.json - Prompt for configuration options
- Optionally create example middleware file
gatekeeper analyzeOutput:
Route Protection Analysis
Path Guard Middleware File
----------------------------------------------------------------------------------------------------
/dashboard β 2 middleware(s) src/app/app.routes.ts
/profile β 1 middleware(s) src/app/app.routes.ts
/login β none src/app/app.routes.ts
Summary:
Total routes: 3
Protected routes: 2
Routes with middleware: 2
Unprotected routes: 1
gatekeeper testOutput:
Test Results
Test Case Expected Result Status
--------------------------------------------------------------------------------
Authenticated user true true β PASS
Unauthenticated user false false β PASS
User with admin role true true β PASS
No user context false false β PASS
Summary:
Passed: 4
Failed: 0
Total: 4
β All tests passed!
gatekeeper export --include-routesCreates gatekeeper-export.json with:
- Configuration
- Middleware files
- Route files
The gatekeeper.config.json file structure:
{
"middlewares": ["auth"],
"onFail": "/login",
"debug": false
}To build the CLI locally:
cd tools/cli
npm install
npm run buildTo test locally:
node dist/index.js <command>Make sure the CLI is installed globally or use npx:
npx @ngxsmk-gatekeeper/cli <command>The CLI requires TypeScript files to be analyzed. Make sure your project has TypeScript configured.
Specify the correct path:
gatekeeper analyze --path src/appContributions welcome! See the main project contributing guide.