0.0.50 • Published 9 months ago

@subjektifylabs/subjektify-codegen v0.0.50

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

@subjektifylabs/subjektify-codegen

NPM Version

subjektify-codegen is a core package of the Subjektify toolkit, designed to facilitate code generation from the Subjekt model. This package provides tools and utilities to generate client, server, and smart contract code from Subjekt model files, ensuring a seamless and efficient development workflow.

Features

  • Code Generation: Generate client, server, and smart contract code from Subjekt model files (.subjekt or JSON).
  • Customizable Output: Support for various output formats and customization options to fit your project's needs.
  • Integration with Build Tools: Easily integrates with common build tools and CI/CD pipelines to automate the code generation process.

Installation

subjektify-codegen is already included in the subjektify package.

Tasks

npx subjektify codegen

Environment Extensions

The plugin adds a model object to the Subjektify Runtime Environment, containing both the AST model and the semantic model for the Subjekt files configured.

Usage

subjektify-codegen is configurable from the subjektify.config.(js|ts). Here’s a basic example of how to use subjektify-codegen to generate code from a Subjekt model:

import { SubjektifyConfig, CodeGenTarget, CodeGenLanguage } from "subjektify";

const config: SubjektifyConfig = {
  namespace: "my.namespace",
  version: "0.1.0",
  license: "MIT",
  codegen: [
    {
      target: CodeGenTarget.Client,
      language: CodeGenLanguage.TypeScript,
      outputDirectory: "generated/client",
    },
    {
      target: CodeGenTarget.Server,
      language: CodeGenLanguage.TypeScript,
      outputDirectory: "generated/server",
    },
    {
      target: CodeGenTarget.Contract,
      language: CodeGenLanguage.Solidity,
      outputDirectory: "generated/contracts",
    },
  ],
};

export default config;

How it Works

  1. Configuration Parsing: The code generation process begins by reading the subjektify.config.(js|ts) file to determine the specified code generation targets and settings.
  2. Model Loading: The Subjekt model is loaded and parsed from the configured sources.
  3. Code Generation: Based on the target and language specified in the configuration, the appropriate code generation strategy is applied:
    • Client Code: Generates client-side code (e.g., TypeScript or JavaScript).
    • Server Code: Generates server-side code (e.g., TypeScript or JavaScript with frameworks like Express).
    • Smart Contract Code: Generates smart contract code (e.g., Solidity).
  4. Output: The generated code is written to the specified outputDirectory, organized by target and language.
0.0.43

9 months ago

0.0.44

9 months ago

0.0.45

9 months ago

0.0.46

9 months ago

0.0.47

9 months ago

0.0.50

9 months ago

0.0.48

9 months ago

0.0.49

9 months ago

0.0.42

9 months ago

0.0.41

9 months ago

0.0.40

9 months ago

0.0.39

9 months ago

0.0.38

10 months ago

0.0.37

10 months ago

0.0.35

11 months ago

0.0.34

11 months ago

0.0.33

11 months ago

0.0.32

11 months ago

0.0.31

11 months ago

0.0.30

11 months ago

0.0.29

11 months ago

0.0.27

12 months ago

0.0.26

12 months ago

0.0.25

12 months ago

0.0.24

12 months ago

0.0.23

12 months ago

0.0.22

12 months ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago