rbac-shield 0.1.15 → 0.2.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 CHANGED
@@ -391,7 +391,7 @@ Structural component for conditional rendering.
391
391
 
392
392
  ### Hooks
393
393
 
394
- #### `useRBAC()` (formerly `useRBAC`)
394
+ #### `useRBAC()`
395
395
 
396
396
  Access raw state and actions.
397
397
 
package/bin/init.js CHANGED
@@ -9,13 +9,18 @@ const {
9
9
  isTypeScriptProject,
10
10
  ensureDirectory,
11
11
  fileExists,
12
- showNextSteps
12
+ showNextSteps,
13
+ detectPackageManager
13
14
  } = require('./utils');
14
15
 
15
16
  async function init() {
16
17
  console.log(chalk.cyan.bold('\nšŸ” RBAC Shield - Interactive Setup'));
17
18
  console.log(chalk.cyan('━'.repeat(40)) + '\n');
18
19
 
20
+ // Detect package manager
21
+ const pm = detectPackageManager();
22
+ console.log(chalk.blue(`ℹ Using package manager: ${pm}`));
23
+
19
24
  // Detect project type
20
25
  const framework = detectFramework();
21
26
  const hasTypeScript = isTypeScriptProject();
@@ -142,11 +147,12 @@ async function init() {
142
147
  if (!isInstalled) {
143
148
  console.log(chalk.blue('šŸ“¦ Installing rbac-shield...'));
144
149
  try {
145
- execSync('npm install rbac-shield@latest', { stdio: 'inherit' });
150
+ const installCmd = pm === 'npm' ? 'npm install' : pm === 'yarn' ? 'yarn add' : pm === 'pnpm' ? 'pnpm add' : 'bun add';
151
+ execSync(`${installCmd} rbac-shield@latest`, { stdio: 'inherit' });
146
152
  console.log(chalk.green('āœ“ rbac-shield installed\n'));
147
153
  } catch (error) {
148
154
  console.error(chalk.red('āœ– Failed to install rbac-shield'));
149
- console.error(chalk.yellow('Please install manually: npm install rbac-shield'));
155
+ console.error(chalk.yellow(`Please install manually: ${pm} add rbac-shield`));
150
156
  process.exit(1);
151
157
  }
152
158
  }
@@ -180,7 +186,7 @@ async function init() {
180
186
  console.log(chalk.green('āœ“ Setup complete!\n'));
181
187
 
182
188
  // Show next steps
183
- showNextSteps(framework, language);
189
+ showNextSteps(framework, language, pm);
184
190
  }
185
191
 
186
192
  module.exports = init;
package/bin/utils.js CHANGED
@@ -40,7 +40,25 @@ function fileExists(filePath) {
40
40
  return fs.existsSync(filePath);
41
41
  }
42
42
 
43
- function showNextSteps(framework, language) {
43
+ function detectPackageManager() {
44
+ const userAgent = process.env.npm_config_user_agent;
45
+
46
+ if (userAgent) {
47
+ if (userAgent.startsWith('yarn')) return 'yarn';
48
+ if (userAgent.startsWith('pnpm')) return 'pnpm';
49
+ if (userAgent.startsWith('bun')) return 'bun';
50
+ if (userAgent.startsWith('npm')) return 'npm';
51
+ }
52
+
53
+ // Fallback to lock files
54
+ if (fs.existsSync(path.join(process.cwd(), 'yarn.lock'))) return 'yarn';
55
+ if (fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'))) return 'pnpm';
56
+ if (fs.existsSync(path.join(process.cwd(), 'bun.lockb'))) return 'bun';
57
+
58
+ return 'npm';
59
+ }
60
+
61
+ function showNextSteps(framework, language, packageManager = 'npm') {
44
62
  const ext = language === 'typescript' ? 'ts' : 'js';
45
63
  const importExt = language === 'typescript' ? 'tsx' : 'jsx';
46
64
 
@@ -64,10 +82,10 @@ function showNextSteps(framework, language) {
64
82
  console.log(chalk.white('2. Initialize permissions (create a component):\n'));
65
83
  console.log(chalk.gray(` 'use client';
66
84
  import { useEffect } from 'react';
67
- import { useStore } from '@/lib/rbac';
85
+ import { useRBAC } from '@/lib/rbac';
68
86
 
69
87
  export function PermissionLoader({ children }) {
70
- const { setAuth, switchTenant } = useStore();
88
+ const { setAuth, switchTenant } = useRBAC();
71
89
 
72
90
  useEffect(() => {
73
91
  // Fetch from your API
@@ -113,5 +131,7 @@ module.exports = {
113
131
  isTypeScriptProject,
114
132
  ensureDirectory,
115
133
  fileExists,
116
- showNextSteps
134
+ showNextSteps,
135
+ detectPackageManager
117
136
  };
137
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rbac-shield",
3
- "version": "0.1.15",
3
+ "version": "0.2.0",
4
4
  "description": "A production-ready, type-safe Role-Based Access Control (RBAC) system for Next.js applications with multi-tenant support",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",