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.jsdatabase/migrations/<timestamp>_create_permission_tables.jsapp/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:
configorpermissionsmigrationsormigrationproviderorproviderspermissions/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.