Langsung ke konten
Skillpedia
Pemrograman umum8.1k ยท #12591

webiny-v5-to-v6-migration

Fungsinya

Skill ini menunjukkan cara AI Anda memindahkan kode dari gaya plugin Webiny yang lama ke desain berbasis fitur yang berlaku sekarang. Skill ini untuk developer yang meningkatkan proyek v5 ke v6.

Kapan dipakai

  • โœ“Saat Anda memigrasikan plugin v5 ke fitur v6.
  • โœ“Saat sebuah context plugin lama harus menjadi layanan yang diinjeksi.
  • โœ“Saat langganan event v5 perlu diubah menjadi event handler v6.

Link skill

https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/v5-to-v6-migration/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/v5-to-v6-migration/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit โ†’

Contoh permintaan ke AI

โ€œUbah context plugin v5 yang menyediakan layanan terjemahan ini menjadi layanan v6 yang diinjeksi.โ€

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill ini memberikan pola berdampingan dari v5 dan v6, misalnya mengubah context plugin menjadi abstraksi dengan implementasinya, dan mengubah langganan event menjadi event handler.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

v5 โ†’ v6 Migration Patterns

Overview

v6 replaces v5's plugin-based architecture with feature-based DI. The key shifts:

v5 Concept v6 Equivalent
ContextPlugin createAbstraction + createImplementation (Service)
Plugin array createFeature + container.register()
context.myService DI injection via constructor
onEntryAfterCreate.subscribe() EventHandler feature
new GraphQLSchemaPlugin() GraphQLSchemaFactory.createImplementation()

Pattern 1: Context Plugin โ†’ DI Service

v5

new ContextPlugin(async context => {
  context.lingotekService = {
    translate: async (docId, locale) => {
      /* ... */
    },
    getStatus: async docId => {
      /* ... */
    },
    deleteProject: async projectId => {
      /* ... */
    }
  };
});

v6

// features/lingotekService/abstractions.ts
import { createAbstraction } from "webiny/api";

export interface ILingotekService {
  translate(docId: string, locale: string): Promise<Result<void, Error>>;
  getStatus(docId: string): Promise<Result<TranslationStatus, Error>>;
  deleteProject(projectId: string): Promise<Result<void, Error>>;
}

export const LingotekService = createAbstraction<ILingotekService>("MyExt/LingotekService");

export namespace LingotekService {
  export type Interface = ILingotekService;
}

// features/lingotekService/LingotekService.ts
class LingotekServiceImpl implements LingotekService.Interface {
  constructor(private buildParams: BuildParams.Interface) {}

  async translate(docId: string, locale: string) {
    /* ... */
  }
  async getStatus(docId: string) {
    /* ... */
  }
  async deleteProject(projectId: string) {
    /* ... */
  }
}

export default LingotekService.createImplementation({
  implementation: LingotekServiceImpl,
  dependencies: [BuildParams]
});

// features/lingotekService/feature.ts
export const LingotekServiceFeature = createFeature({
  name: "LingotekService",
  register(container) {
    container.register(LingotekServiceImpl).inSingletonScope();
  }
});

Key difference: v5 attaches to context object. v6 uses DI โ€” consumers declare the service as a constructor dependency.


Pattern 2: Event Subscription โ†’ EventHandler Feature

v5

context.cms.onEntryAfterCreate.subscribe(async params => {
  if (params.model.modelId !== "myModel") return;
  await doSomething(params.entry);
});

v6

// features/syncOnCreate/EntryAfterCreateHandler.ts
import { EntryAfterCreateEventHandler } from "webiny/api/cms/entry";
import { LingotekService } from "../lingotekService/abstractions.js";
import { MY_MODEL_ID } from "~/shared/constants.js";

class SyncOnCreateHandler implements EntryAfterCreateEventHandler.Interface {
  constructor(private lingotekService: LingotekService.Interface) {}

  async handle(event: EntryAfterCreateEventHandler.Event) {
    const { entry, model } = event.payload;
    if (model.modelId !== MY_MODEL_ID) return;
    await this.lingotekService.translate(entry.entryId, "en");
  }
}

export default EntryAfterCreateEventHandler.createImplementation({
  implementation: SyncOnCreateHandler,
  dependencies: [LingotekService]
});

// features/syncOnCreate/feature.ts
export const SyncOnCreateFeature = createFeature({
  name: "SyncOnCreate",
  register(container) {
    container.register(SyncOnCreateHandler);
  }
});

Key differences:

  • Feature directory is named by business capability (syncOnCreate), not by event name
  • Handler is a thin orchestrator โ€” business logic lives in the injected service
  • Must filter by model.modelId โ€” handler fires for ALL models

Pattern 3: Plugin Array โ†’ Feature Registration

v5

export default () => [
    new GraphQLSchemaPlugin({ ... }),
    new ContextPlugin(async ctx => { ... }),
    myModelPlugin,
    eventSubscriptionPlugin
];

v6

// api/Extension.ts
import { createFeature } from "webiny/api";

export const Extension = createFeature({
  name: "MyExtension",
  register(container) {
    container.register(MyModel);
    container.register(MyGraphQLSchema);
    SyncOnCreateFeature.register(container);
 
Pertanyaan umum

Apa yang menggantikan context plugin?

Sebuah abstraksi dengan implementasinya, yang diinjeksi melalui dependency injection.

Apa yang menggantikan GraphQL schema plugin?

Sebuah implementasi GraphQL schema factory, menurut tabel dalam skill.

Apakah ini hanya untuk agen AI?

Skill ini ditulis untuk agen AI yang melakukan migrasi, tetapi orang juga bisa mengikuti pola yang sama.

Detail

Deskripsi asli dari pembuat

Migration patterns for converting v5 Webiny code to v6 architecture. Use this skill when migrating existing v5 plugins to v6 features, converting context plugins to DI services, adapting v5 event subscriptions to v6 EventHandlers, or understanding how v5 patterns translate to v6. Targeted at AI agents performing migrations.

repo: webiny/webiny-js

Popularitas

Bintang GitHub
8.1k
Peringkat
#12591
Lisensi
โ€”
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • โ€ฆ

Skill lain dari repositori ini

Skill serupa