
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@computerwwwizards/di-code-generator
Advanced tools
Code generator for @computerwwwizards/dependency-injection - generates TypeScript boilerplate for DI containers
A minimal, focused code generator written in Zig for creating TypeScript/JavaScript dependency injection boilerplate.
This project provides primitives for string interpolation and name manipulation - the foundational building blocks needed to generate DI registration files and related boilerplate code.
{param} placeholderscamelCasePascalCasesnake_casekebab-caseSCREAMING_SNAKE_CASE# Build the project
zig build
# Run the example
zig build run
# Run all tests
zig build test
Tests are organized by concern:
zig build test
const std = @import("std");
const di_gen = @import("di-code-generator");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
// Template interpolation with case conversion
const result = try di_gen.name_utils.parameterizeName(
allocator,
"register{Name}",
"user_service",
.PascalCase,
);
defer allocator.free(result);
// Result: "registerUserService"
// Case conversions
const snake = try di_gen.name_utils.toSnakeCase(allocator, "HelloWorld");
defer allocator.free(snake);
// Result: "hello_world"
}
zig/di-code-generator/
├── build.zig # Build configuration
├── build.zig.zon # Package metadata
├── src/
│ ├── root.zig # Module exports
│ ├── main.zig # CLI executable
│ ├── interpolation.zig # String interpolation primitives
│ └── name_utils.zig # Name manipulation utilities
└── README.md
interpolation.zig)InterpolationPartUnion type representing either literal text or a parameter placeholder.
parseTemplate(allocator, template) ![]InterpolationPartParse a template string into parts. Template format: "Hello {name}!"
applyParams(allocator, parts, params) ![]u8Apply parameter values to interpolation parts.
concat(allocator, separator, strings) ![]u8Concatenate multiple strings with a separator.
name_utils.zig)toCamelCase(allocator, input) ![]u8toPascalCase(allocator, input) ![]u8toSnakeCase(allocator, input) ![]u8toKebabCase(allocator, input) ![]u8parameterizeName(allocator, pattern, name, case) ![]u8Apply a name to a pattern with automatic case conversion.
pattern: Template string like "register{Name}"name: The name to insertcase: Target naming conventionThis implementation focuses solely on the primitives needed for code generation:
These are the most fundamental operations required to generate any boilerplate code. Higher-level features (file generation, directory structure, etc.) can be built on top of these primitives.
The project uses only Zig's standard library, making it lightweight and easy to integrate.
Tests are separated by concern into different executables, allowing focused testing and faster iteration during development.
See repository root for license information.
This generator is designed to work with @computerwwizards/dependency-injection - a reflection-free IoC container for JavaScript/TypeScript.
This tool is also available as an npm package: @computerwwwizards/di-code-generator
npm install @computerwwwizards/di-code-generator
# or
pnpm add @computerwwwizards/di-code-generator
# Auto-discover config.json in current directory
npx di-code-gen
# Specify config file
npx di-code-gen --config ./services.config.json
# Override output directory
npx di-code-gen --config ./config.json --output ./src/di
Generate a service directly via CLI without a config file. The interface name is automatically inferred from the service name (e.g., userService → IUserService):
# Single service
npx di-code-gen --service userService --output ./src/di
# Multiple services
npx di-code-gen --service userService --service paymentGateway --output ./src/di
# Custom interface name (optional; defaults to I + PascalCase of service name)
npx di-code-gen --service userService:IUserAuthService --output ./src/di
# Combination: CLI services override config
npx di-code-gen --config config.json --service customService --output ./src/di
Auto-inference examples:
userService → IUserServicepaymentGateway → IPaymentGatewayauth_service → IAuthServiceDBConnection → IDbconnectionWhen --service is provided, CLI services take precedence over config file services.
di.config.json:{
"output": "./src/di",
"services": [
{ "name": "userService", "interface": "IUserService" }
]
}
npx di-code-gen --config ./di.config.json
src/di/
userService/
types.ts
registerUserService.ts
types.ts (empty ServicesList with augmentation elsewhere):import { PreProcessDependencyContainerWithUse } from '@computerwwwizards/dependency-injection'
export interface ServicesList {}
export type ContainerCtx = PreProcessDependencyContainerWithUse<ServicesList>
registerUserService.ts includes IUserService, default register() stub, a mock() helper, and augments ServicesList:export interface IUserService {}
export default function register(ctx: ContainerCtx) {
// TODO: register real implementation
}
export function mock(ctx: ContainerCtx) {
// TODO: register mock for tests
}
declare module './types' {
interface ServicesList {
userService: IUserService
}
}
register.mock = mock
ESM:
import { execute } from '@computerwwwizards/di-code-generator'
const exitCode = await execute([
'--config', './my-config.json',
'--output', './src/generated'
])
CommonJS:
const { execute } = require('@computerwwwizards/di-code-generator')
const exitCode = await execute(['--config', './config.json'])
Includes pre-compiled binaries for Linux, macOS, and Windows (x64, arm64).
FAQs
Code generator for @computerwwwizards/dependency-injection - generates TypeScript boilerplate for DI containers
We found that @computerwwwizards/di-code-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.