Permissions Roles, permissions, and policies for NetPress
NetPressv0.1.7 Permissionsv0.2.3 Docsv0.2.2
Overview Installation Policies Auth Guard
Getting Started

Publishing Assets

The package ships a publisher that integrates with NetPress's vendor:publish artisan command. It is intentionally modelled after Laravel's --tag convention so you can publish assets selectively.

Publishing Everything

npm run artisan -- vendor:publish --provider=NetpressPermissionsServiceProvider

This writes four files into your application:

  • config/permissions.js
  • database/migrations/<timestamp>_create_permission_tables.js
  • app/Providers/PermissionsServiceProvider.js
  • appends a registration into bootstrap/providers.js

If you have more than one database connection configured, the publisher prompts you to choose which connection should own the permissions tables. The generated migration and config are customised for that choice.

Publishing By Tag

Use tags to publish a single concern:

npm run artisan -- vendor:publish --tag=config --provider=NetpressPermissionsServiceProvider
npm run artisan -- vendor:publish --tag=migrations --provider=NetpressPermissionsServiceProvider
npm run artisan -- vendor:publish --tag=provider --provider=NetpressPermissionsServiceProvider

The supported tags are:

  • config or permissions
  • migrations or migration
  • provider or providers
  • permissions / netpress-permissions — publishes all three

Behaviour When Files Exist

By default the publisher skips existing files so re-running the command is safe. Pass --force to overwrite.

npm run artisan -- vendor:publish --provider=NetpressPermissionsServiceProvider --force

Mongo Connections

When you pick a Mongo connection the generated migration emits:

await createPermissionTables(schema.connection('mongo'), permissionsConfig);

The schema primitives in NetPress translate this into Mongo collection creation automatically, so the same createPermissionTables helper covers both SQL and Mongo back ends.

Calling The Publisher Programmatically

import { publishPermissionsPackage } from '@admicaa/netpress-permissions';

await publishPermissionsPackage({
  appRoot: process.cwd(),
  connectionName: 'mongo',
  connectionDescriptor: { name: 'mongo', rawDriver: 'mongo' },
  tag: 'migrations',
  force: true,
});

This is the same code path the artisan command uses, which makes it easy to wire your own CLI or scripted installers.