@rbacbee-lib/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # @rbacbee-lib/cli
2
+
3
+ CLI for local setup, migrations and diagnostics.
4
+
5
+ ```bash
6
+ rbac doctor
7
+ rbac migrate --connection postgresql://rbac:rbac@localhost:5432/rbac
8
+ ```
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { Command } from "commander";
5
+ import { createPostgresRbacStore } from "@rbacbee-lib/postgres";
6
+ var program = new Command();
7
+ program.name("rbac").description("RBACBee-lib CLI").version("0.1.0");
8
+ program.command("doctor").description("Print environment diagnostics").action(() => {
9
+ console.log("RBAC CLI is ready");
10
+ console.log(`Node: ${process.version}`);
11
+ console.log(`Platform: ${process.platform}`);
12
+ });
13
+ program.command("migrate").description("Apply the RBAC Postgres schema").requiredOption("-c, --connection <url>", "Postgres connection string").action(async (options) => {
14
+ const store = createPostgresRbacStore({ connectionString: options.connection });
15
+ try {
16
+ await store.migrate();
17
+ console.log("RBAC Postgres schema applied");
18
+ } finally {
19
+ await store.close();
20
+ }
21
+ });
22
+ program.command("init").description("Print a minimal NestJS RBAC module configuration").action(() => {
23
+ console.log(`RbacModule.forRoot({
24
+ identity: { strategy: 'jwt', userIdPath: 'user.sub', tenantIdPath: 'user.tenantId' },
25
+ accessRepository,
26
+ cacheTtlMs: 30_000
27
+ });`);
28
+ });
29
+ program.parseAsync(process.argv).catch((error) => {
30
+ const message = error instanceof Error ? error.message : "Unknown CLI error";
31
+ console.error(message);
32
+ process.exitCode = 1;
33
+ });
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { createPostgresRbacStore } from '@rbacbee-lib/postgres';\n\nconst program = new Command();\n\nprogram.name('rbac').description('RBACBee-lib CLI').version('0.1.0');\n\nprogram\n .command('doctor')\n .description('Print environment diagnostics')\n .action(() => {\n console.log('RBAC CLI is ready');\n console.log(`Node: ${process.version}`);\n console.log(`Platform: ${process.platform}`);\n });\n\nprogram\n .command('migrate')\n .description('Apply the RBAC Postgres schema')\n .requiredOption('-c, --connection <url>', 'Postgres connection string')\n .action(async (options: { connection: string }) => {\n const store = createPostgresRbacStore({ connectionString: options.connection });\n\n try {\n await store.migrate();\n console.log('RBAC Postgres schema applied');\n } finally {\n await store.close();\n }\n });\n\nprogram\n .command('init')\n .description('Print a minimal NestJS RBAC module configuration')\n .action(() => {\n console.log(`RbacModule.forRoot({\n identity: { strategy: 'jwt', userIdPath: 'user.sub', tenantIdPath: 'user.tenantId' },\n accessRepository,\n cacheTtlMs: 30_000\n});`);\n });\n\nprogram.parseAsync(process.argv).catch((error: unknown) => {\n const message = error instanceof Error ? error.message : 'Unknown CLI error';\n console.error(message);\n process.exitCode = 1;\n});\n"],"mappings":";;;AACA,SAAS,eAAe;AACxB,SAAS,+BAA+B;AAExC,IAAM,UAAU,IAAI,QAAQ;AAE5B,QAAQ,KAAK,MAAM,EAAE,YAAY,iBAAiB,EAAE,QAAQ,OAAO;AAEnE,QACG,QAAQ,QAAQ,EAChB,YAAY,+BAA+B,EAC3C,OAAO,MAAM;AACZ,UAAQ,IAAI,mBAAmB;AAC/B,UAAQ,IAAI,SAAS,QAAQ,OAAO,EAAE;AACtC,UAAQ,IAAI,aAAa,QAAQ,QAAQ,EAAE;AAC7C,CAAC;AAEH,QACG,QAAQ,SAAS,EACjB,YAAY,gCAAgC,EAC5C,eAAe,0BAA0B,4BAA4B,EACrE,OAAO,OAAO,YAAoC;AACjD,QAAM,QAAQ,wBAAwB,EAAE,kBAAkB,QAAQ,WAAW,CAAC;AAE9E,MAAI;AACF,UAAM,MAAM,QAAQ;AACpB,YAAQ,IAAI,8BAA8B;AAAA,EAC5C,UAAE;AACA,UAAM,MAAM,MAAM;AAAA,EACpB;AACF,CAAC;AAEH,QACG,QAAQ,MAAM,EACd,YAAY,kDAAkD,EAC9D,OAAO,MAAM;AACZ,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA,IAIZ;AACF,CAAC;AAEH,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,UAAmB;AACzD,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,UAAQ,MAAM,OAAO;AACrB,UAAQ,WAAW;AACrB,CAAC;","names":[]}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@rbacbee-lib/cli",
3
+ "version": "0.1.0",
4
+ "description": "CLI for RBAC setup, migrations and diagnostics.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "rbac": "./dist/index.js"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsup src/index.ts --format esm --dts --sourcemap --clean --external @rbacbee-lib/postgres --external commander",
24
+ "dev": "tsup src/index.ts --format esm --dts --sourcemap --watch --external @rbacbee-lib/postgres --external commander",
25
+ "test": "vitest run --passWithNoTests",
26
+ "test:watch": "vitest",
27
+ "lint": "eslint src --max-warnings=0",
28
+ "typecheck": "tsc --noEmit",
29
+ "clean": "rimraf dist coverage",
30
+ "rbac": "node dist/index.js"
31
+ },
32
+ "dependencies": {
33
+ "@rbacbee-lib/postgres": "workspace:^",
34
+ "commander": "^14.0.0"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ }
39
+ }