@adonis-agora/media
Version:
Media-library for AdonisJS — owner collections (MIME whitelist, single-file replace, ordering), image conversions (eager/lazy), pluggable content transformers (HLS video via mediabunny, metadata probe, image blur-up placeholder), and column attachments, a
43 lines • 2.6 kB
JavaScript
import { stubsRoot } from './stubs/main.js';
/**
* `node ace configure @adonis-agora/media` — auto-wires the package:
*
* 1. registers the media service provider in `adonisrc.ts`;
* 2. registers the dashboard provider — the management console SPA ships embedded in this package
* (its built assets are copied in at `pnpm build` time), so this alone is enough to get it; no
* separate `@adonis-agora/media-dashboard` install is required;
* 3. publishes `config/media.ts` and `config/media_dashboard.ts`;
* 4. registers the `@adonis-agora/media/commands` barrel (`media:publish-migration`, …);
* 5. publishes the Lucid migrations for the optional `lucid` store and the resumable (TUS) session
* store (run `node ace migration:run`; delete either if you only use the in-memory equivalents).
*
* With `--topology=tenant`, `config/media.ts` is the one-line tenant form instead and no migration
* is published (a tenant keeps no media of its own).
*
* Requires `@adonisjs/drive` to be installed and configured first (`node ace add @adonisjs/drive`).
*/
export async function configure(command) {
const codemods = await command.createCodemods();
await codemods.updateRcFile((rcFile) => {
rcFile.addProvider('@adonis-agora/media/media_provider');
rcFile.addProvider('@adonis-agora/media/dashboard_provider');
// `media:publish-migration`, `media:tenancy:backfill`.
rcFile.addCommand('@adonis-agora/media/commands');
});
const stubs = stubsRoot();
// `--topology=tenant`: an app whose media lives on a control plane, in the one-line form (url,
// token and partition come from @adonis-agora/authkit-client). A tenant has no store, uploads or
// tenancy of its own, so the migrations below do not apply to it.
if (command.parsedFlags?.topology === 'tenant') {
await codemods.makeUsingStub(stubs, 'config/media_tenant.stub', {});
await codemods.makeUsingStub(stubs, 'config/media_dashboard.stub', {});
return;
}
await codemods.makeUsingStub(stubs, 'config/media.stub', {});
await codemods.makeUsingStub(stubs, 'config/media_dashboard.stub', {});
await codemods.makeUsingStub(stubs, 'database/migrations/create_media_table.stub', {});
await codemods.makeUsingStub(stubs, 'database/migrations/create_media_upload_sessions_table.stub', {});
// The nullable `tenant_id` columns organizations-as-tenants uses (unused while tenancy is off).
await codemods.makeUsingStub(stubs, 'database/migrations/add_media_tenant_id.stub', {});
}
//# sourceMappingURL=configure.js.map