Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A code generation framework inspired by JavaScript front-end frameworks

License

NotificationsYou must be signed in to change notification settings

alloy-framework/alloy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Documentation

Alloy is a framework for code generation that borrows concepts from JavaScriptfront-end frameworks like React and Solid to provide highly ergonomic andproductive source code generation. Use JSX syntax or string templates to definesource files and the language elements within them. Alloy helps handle a lot ofthe hard bits like building source text from strings, linking declarations andimporting necessary dependencies, applying naming conventions, formatting, andgenerating syntax for a number of languages.

import*asayfrom"@alloy-js/core";import*astsfrom"@alloy-js/typescript";consthelloWorldRef=ay.refkey();constres=ay.render(<ay.Output><ay.SourceFilepath="readme.md"filetype="markdown">      This is a sample output project.</ay.SourceFile><ts.SourceFilepath="test1.ts"><ts.VarDeclarationexportname="foo"refkey={helloWorldRef}>        "Hello world"</ts.VarDeclaration></ts.SourceFile><ts.SourceFilepath="test2.ts"><ts.VarDeclarationname="v">{helloWorldRef}</ts.VarDeclaration>      console.log(v);</ts.SourceFile></ay.Output>,);console.log(res[2].contents);// import { foo } from "./test2.ts";//// const v = foo;

Or, if you prefer, you can use string templates:

import{refkey,render,code}from"@alloy-js/core";import*asayfrom"@alloy-js/core/stc";import*astsfrom"@alloy-js/typescript/stc";consthelloWorldRef=refkey();constres=render(ay.Output().children(ay.SourceFile({path:"readme.md",filetype:"markdown"}).code`      This is a sample output project.    `,ts.SourceFile({path:"test1.ts"}).children(ts.VarDeclaration({export:true,name:"foo",refkey:helloWorldRef}).code`        "Hello world"      `,),ts.SourceFile({path:"test2.ts"}).code`${ts.VarDeclaration({name:"v"}).children(helloWorldRef)}      console.log(v);    `,),);console.log(res[2].contents);// import { foo } from "./test2.ts";//// const v = foo;

This project is in pre-beta. Expect everything to change. Feedback is especiallyappreciated. The docs are not great but are being worked on.

Dependencies

  • pnpm
  • node 20+

Installation

Use this template to get started.

Alternatively, you can find the latest packages on GitHub by clicking the green checkbox next to the latest commit and clicking "details" next to Continuous Releases. Alloy will be published to NPM in the coming weeks.

Building

Clone the repo, then:

> pnpm install> pnpm build

Supported Languages

  • C#: @alloy-js/csharp
  • Java: @alloy-js/java
  • TypeScript: @alloy-js/typescript

More are coming soon.

About

A code generation framework inspired by JavaScript front-end frameworks

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors17


[8]ページ先頭

©2009-2025 Movatter.jp