samuelstroschein / rule-with-api-call

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

inlang plugin-template

Note

Change the following things if you use this template:

  1. Name your repository "inlang-plugin-{name}".
  2. Change the introduction paragraph to describe your plugin.
  3. Create a release on GitHub so users can import a specific version of your plugin.
  4. Update the Usage section.
  5. Open a PR to https://github.com/inlang/awesome-inlang

This is a template for creating a new plugin for inlang.

Plugins allow the customization of inlang's behavior by, for example, defining how resources should be parsed and serialized. Read more about using plugins on the documentation site. This template has been set up to provide out of the box:

  • TypeScript
  • Testing (the example)
  • Bundling

Usage

Plugins can be imported directly from GitHub releases via jsDelivr.

// filename: inlang.config.js

export async function defineConfig(env){
  const plugin = await env.$import(
    "https://cdn.jsdelivr.net/gh/{username}/{repository-name}@{version}/dist/index.js"
  ) 
}

The dist directory is used to distribute the plugin directly via CDN like jsDelivr. Using a CDN works because the inlang config uses dynamic imports to import plugins. Read the jsDelivr documentation on importing from GitHub.

For additional usage information, take a look at example.

Developing

Run the following commands in your terminal (node and npm must be installed):

  1. npm install
  2. npm run dev

npm run dev will start the development environment which automatically compiles the src/index.ts files to JavaScript (dist/index.js), runs tests defined in *.test.ts files and watches changes.

Publishing

  1. Run npm run build to generate a build.
  2. Commit the new build.
  3. Create a new release on GitHub that uses Semantic Versioning (SemVer). Take a look at inlang-plugin-json for example releases.

About

License:MIT License


Languages

Language:TypeScript 92.7%Language:JavaScript 6.4%Language:Shell 0.9%